From 660c85aa9799b422e2951bc9633ba0a9f85c4cc7 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Wed, 26 Oct 2022 21:04:32 -0400 Subject: [PATCH] Wip --- tests/Browser/LoginTest.php | 36 ++++++++++++++++++++++++++ tests/Browser/Pages/Login.php | 39 +++++++++++++++++++++++++++++ tests/Traits/DatabaseMigrations.php | 22 ++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 tests/Browser/LoginTest.php create mode 100644 tests/Browser/Pages/Login.php create mode 100644 tests/Traits/DatabaseMigrations.php diff --git a/tests/Browser/LoginTest.php b/tests/Browser/LoginTest.php new file mode 100644 index 000000000..058478df1 --- /dev/null +++ b/tests/Browser/LoginTest.php @@ -0,0 +1,36 @@ +create([ + 'email' => $login, + 'password' => Hash::make($pass), + ]); + + $this->browse(function (Browser $browser) use ($login, $pass) { + $browser->visit(new Login())->loginToPanel($browser, $login, $pass); + }); + } +} diff --git a/tests/Browser/Pages/Login.php b/tests/Browser/Pages/Login.php new file mode 100644 index 000000000..a49027662 --- /dev/null +++ b/tests/Browser/Pages/Login.php @@ -0,0 +1,39 @@ +assertPathIs($this->url()); + } + + public function loginToPanel(Browser $browser, $username, $password) + { + $browser->type('username', $username); + $browser->script("document.querySelector('input[name=username]').value = '$username'"); + $browser->type('password', $password); + + $browser->clickAndWaitForReload('button[type=submit]', 2); + } +} diff --git a/tests/Traits/DatabaseMigrations.php b/tests/Traits/DatabaseMigrations.php new file mode 100644 index 000000000..c0e6c3eaf --- /dev/null +++ b/tests/Traits/DatabaseMigrations.php @@ -0,0 +1,22 @@ +artisan('migrate:fresh', $this->migrateFreshUsing()); + + $this->app[Kernel::class]->setArtisan(null); + } +}