22
33namespace Pterodactyl \Tests \Browser \Processes \Authentication ;
44
5- use Pterodactyl \Models \User ;
6- use Illuminate \Support \Facades \Hash ;
75use Facebook \WebDriver \WebDriverKeys ;
86use Pterodactyl \Tests \Browser \BrowserTestCase ;
97use Pterodactyl \Tests \Browser \Pages \LoginPage ;
@@ -20,10 +18,7 @@ protected function setUp()
2018 {
2119 parent ::setUp ();
2220
23- $ this ->user = factory (User::class)->create ([
24- 'email ' => 'test@example.com ' ,
25- 'password ' => Hash::make ('Password123 ' ),
26- ]);
21+ $ this ->user = $ this ->user ();
2722 }
2823
2924 /**
@@ -34,8 +29,8 @@ public function testLoginUsingEmail()
3429 $ this ->browse (function (PterodactylBrowser $ browser ) {
3530 $ browser ->visit (new LoginPage )
3631 ->waitFor ('@username ' )
37- ->type ('@username ' , ' test@example.com ' )
38- ->type ('@password ' , ' Password123 ' )
32+ ->type ('@username ' , $ this -> user -> email )
33+ ->type ('@password ' , self :: $ userPassword )
3934 ->click ('@loginButton ' )
4035 ->waitForReload ()
4136 ->assertPathIs ('/ ' )
@@ -52,7 +47,7 @@ public function testLoginUsingUsername()
5247 $ browser ->visit (new LoginPage )
5348 ->waitFor ('@username ' )
5449 ->type ('@username ' , $ this ->user ->username )
55- ->type ('@password ' , ' Password123 ' )
50+ ->type ('@password ' , self :: $ userPassword )
5651 ->click ('@loginButton ' )
5752 ->waitForReload ()
5853 ->assertPathIs ('/ ' )
@@ -70,15 +65,15 @@ public function testLoginWithErrors()
7065 $ browser ->logout ()
7166 ->visit (new LoginPage ())
7267 ->waitFor ('@username ' )
73- ->type ('@username ' , ' test@example.com ' )
68+ ->type ('@username ' , $ this -> user -> email )
7469 ->type ('@password ' , 'invalid ' )
7570 ->click ('@loginButton ' )
7671 ->waitFor ('.alert.error ' )
7772 ->assertSeeIn ('.alert.error ' , trans ('auth.failed ' ))
78- ->assertValue ('@username ' , ' test@example.com ' )
73+ ->assertValue ('@username ' , $ this -> user -> email )
7974 ->assertValue ('@password ' , '' )
8075 ->assertFocused ('@password ' )
81- ->type ('@password ' , ' Password123 ' )
76+ ->type ('@password ' , self :: $ userPassword )
8277 ->keys ('@password ' , [WebDriverKeys::ENTER ])
8378 ->waitForReload ()
8479 ->assertPathIs ('/ ' )
0 commit comments