Skip to content

Commit aba1b29

Browse files
committed
Add a test that wont work due to auth issues currently
1 parent a44b4c4 commit aba1b29

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

tests/Browser/Pages/BasePage.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ abstract class BasePage extends Page
1111
*/
1212
public static function siteElements()
1313
{
14-
return [];
14+
return [
15+
'@@success' => '.alert.success[role="alert"]',
16+
];
1517
}
1618
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Pterodactyl\Tests\Browser\Pages\Dashboard;
4+
5+
use Pterodactyl\Tests\Browser\Pages\BasePage;
6+
7+
class AccountPage extends BasePage
8+
{
9+
/**
10+
* @return string
11+
*/
12+
public function url()
13+
{
14+
return '/account';
15+
}
16+
17+
/**
18+
* @return array
19+
*/
20+
public function elements()
21+
{
22+
return array_merge(parent::elements(), [
23+
'@email' => '#update-email-container #grid-email',
24+
'@password' => '#update-email-container #grid-password',
25+
'@submit' => '#update-email-container button[type="submit"]',
26+
]);
27+
}
28+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace Pterodactyl\Tests\Browser\Processes\Dashboard;
4+
5+
use Pterodactyl\Models\User;
6+
use Illuminate\Support\Facades\Hash;
7+
use Pterodactyl\Tests\Browser\BrowserTestCase;
8+
use Pterodactyl\Tests\Browser\PterodactylBrowser;
9+
use Pterodactyl\Tests\Browser\Pages\Dashboard\AccountPage;
10+
11+
class AccountEmailProcessTest extends BrowserTestCase
12+
{
13+
/**
14+
* @var \Pterodactyl\Models\User
15+
*/
16+
private $user;
17+
18+
/**
19+
* Setup a user for the test process to use.
20+
*/
21+
public function setUp()
22+
{
23+
parent::setUp();
24+
25+
$this->user = factory(User::class)->create([
26+
'password' => Hash::make('Password123'),
27+
]);
28+
}
29+
30+
public function testEmailCanBeChanged()
31+
{
32+
$this->browse(function (PterodactylBrowser $browser) {
33+
$browser->loginAs($this->user)
34+
->visit(new AccountPage)
35+
->assertValue('@email', $this->user->email)
36+
->type('@email', 'new.email@example.com')
37+
->type('@password', 'Password123')
38+
->click('@submit')
39+
->waitFor('@@success')
40+
->assertSeeIn('@@success', trans('dashboard/account.email.updated'))
41+
->assertValue('@email', 'new.email@example.com');
42+
43+
$this->assertDatabaseHas('users', ['id' => $this->user->id, 'email' => 'new.email@example.com']);
44+
});
45+
}
46+
}

0 commit comments

Comments
 (0)