From aba1b297c865212285cbfc3907a9ef4c6fc2c9e6 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 14 Jul 2018 22:11:56 -0700 Subject: [PATCH] Add a test that wont work due to auth issues currently --- tests/Browser/Pages/BasePage.php | 4 +- tests/Browser/Pages/Dashboard/AccountPage.php | 28 +++++++++++ .../Dashboard/AccountEmailProcessTest.php | 46 +++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 tests/Browser/Pages/Dashboard/AccountPage.php create mode 100644 tests/Browser/Processes/Dashboard/AccountEmailProcessTest.php diff --git a/tests/Browser/Pages/BasePage.php b/tests/Browser/Pages/BasePage.php index 7d8efb513..075634c40 100644 --- a/tests/Browser/Pages/BasePage.php +++ b/tests/Browser/Pages/BasePage.php @@ -11,6 +11,8 @@ abstract class BasePage extends Page */ public static function siteElements() { - return []; + return [ + '@@success' => '.alert.success[role="alert"]', + ]; } } diff --git a/tests/Browser/Pages/Dashboard/AccountPage.php b/tests/Browser/Pages/Dashboard/AccountPage.php new file mode 100644 index 000000000..ea46791c4 --- /dev/null +++ b/tests/Browser/Pages/Dashboard/AccountPage.php @@ -0,0 +1,28 @@ + '#update-email-container #grid-email', + '@password' => '#update-email-container #grid-password', + '@submit' => '#update-email-container button[type="submit"]', + ]); + } +} diff --git a/tests/Browser/Processes/Dashboard/AccountEmailProcessTest.php b/tests/Browser/Processes/Dashboard/AccountEmailProcessTest.php new file mode 100644 index 000000000..7e249d6cd --- /dev/null +++ b/tests/Browser/Processes/Dashboard/AccountEmailProcessTest.php @@ -0,0 +1,46 @@ +user = factory(User::class)->create([ + 'password' => Hash::make('Password123'), + ]); + } + + public function testEmailCanBeChanged() + { + $this->browse(function (PterodactylBrowser $browser) { + $browser->loginAs($this->user) + ->visit(new AccountPage) + ->assertValue('@email', $this->user->email) + ->type('@email', 'new.email@example.com') + ->type('@password', 'Password123') + ->click('@submit') + ->waitFor('@@success') + ->assertSeeIn('@@success', trans('dashboard/account.email.updated')) + ->assertValue('@email', 'new.email@example.com'); + + $this->assertDatabaseHas('users', ['id' => $this->user->id, 'email' => 'new.email@example.com']); + }); + } +}