Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UserProfileTest.php
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | class UserProfileTest extends TestCaseDusk | ||||
/** | /** | ||||
* Test profile page | * Test profile page | ||||
*/ | */ | ||||
public function testProfile(): void | public function testProfile(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit(new Home()) | $browser->visit(new Home()) | ||||
->submitLogon('john@kolab.org', 'simple123', true) | ->submitLogon('john@kolab.org', \App\Utils::generatePassphrase(), true) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertSeeIn('@links .link-profile', 'Your profile') | ->assertSeeIn('@links .link-profile', 'Your profile') | ||||
->click('@links .link-profile') | ->click('@links .link-profile') | ||||
->on(new UserProfile()) | ->on(new UserProfile()) | ||||
->assertSeeIn('#user-profile .button-delete', 'Delete account') | ->assertSeeIn('#user-profile .button-delete', 'Delete account') | ||||
->whenAvailable('@form', function (Browser $browser) { | ->whenAvailable('@form', function (Browser $browser) { | ||||
$user = User::where('email', 'john@kolab.org')->first(); | $user = User::where('email', 'john@kolab.org')->first(); | ||||
// Assert form content | // Assert form content | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | class UserProfileTest extends TestCaseDusk | ||||
* Test profile of non-controller user | * Test profile of non-controller user | ||||
*/ | */ | ||||
public function testProfileNonController(): void | public function testProfileNonController(): void | ||||
{ | { | ||||
// Test acting as non-controller | // Test acting as non-controller | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit('/logout') | $browser->visit('/logout') | ||||
->visit(new Home()) | ->visit(new Home()) | ||||
->submitLogon('jack@kolab.org', 'simple123', true) | ->submitLogon('jack@kolab.org', \App\Utils::generatePassphrase(), true) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertSeeIn('@links .link-profile', 'Your profile') | ->assertSeeIn('@links .link-profile', 'Your profile') | ||||
->click('@links .link-profile') | ->click('@links .link-profile') | ||||
->on(new UserProfile()) | ->on(new UserProfile()) | ||||
->assertMissing('#user-profile .button-delete') | ->assertMissing('#user-profile .button-delete') | ||||
->whenAvailable('@form', function (Browser $browser) { | ->whenAvailable('@form', function (Browser $browser) { | ||||
// TODO: decide on what fields the non-controller user should be able | // TODO: decide on what fields the non-controller user should be able | ||||
// to see/change | // to see/change | ||||
}); | }); | ||||
// Test that /profile/delete page is not accessible | // Test that /profile/delete page is not accessible | ||||
$browser->visit('/profile/delete') | $browser->visit('/profile/delete') | ||||
->assertErrorPage(403); | ->assertErrorPage(403); | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test profile delete page | * Test profile delete page | ||||
*/ | */ | ||||
public function testProfileDelete(): void | public function testProfileDelete(): void | ||||
{ | { | ||||
$user = $this->getTestUser('profile-delete@kolabnow.com', ['password' => 'simple123']); | $user = $this->getTestUser('profile-delete@kolabnow.com', ['password' => \App\Utils::generatePassphrase()]); | ||||
$this->browse(function (Browser $browser) use ($user) { | $this->browse(function (Browser $browser) use ($user) { | ||||
$browser->visit('/logout') | $browser->visit('/logout') | ||||
->on(new Home()) | ->on(new Home()) | ||||
->submitLogon('profile-delete@kolabnow.com', 'simple123', true) | ->submitLogon('profile-delete@kolabnow.com', \App\Utils::generatePassphrase(), true) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertSeeIn('@links .link-profile', 'Your profile') | ->assertSeeIn('@links .link-profile', 'Your profile') | ||||
->click('@links .link-profile') | ->click('@links .link-profile') | ||||
->on(new UserProfile()) | ->on(new UserProfile()) | ||||
->click('#user-profile .button-delete') | ->click('#user-profile .button-delete') | ||||
->waitForLocation('/profile/delete') | ->waitForLocation('/profile/delete') | ||||
->assertSeeIn('#user-delete .card-title', 'Delete this account?') | ->assertSeeIn('#user-delete .card-title', 'Delete this account?') | ||||
->assertSeeIn('#user-delete .button-cancel', 'Cancel') | ->assertSeeIn('#user-delete .button-cancel', 'Cancel') | ||||
Show All 20 Lines |