Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UsersTest.php
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | public function tearDown(): void | ||||
$this->clearBetaEntitlements(); | $this->clearBetaEntitlements(); | ||||
$this->clearMeetEntitlements(); | $this->clearMeetEntitlements(); | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test user info page (unauthenticated) | * Test user account editing page (not profile page) | ||||
*/ | */ | ||||
public function testInfoUnauth(): void | public function testInfo(): void | ||||
{ | { | ||||
// Test that the page requires authentication | |||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$user = User::where('email', 'john@kolab.org')->first(); | $user = User::where('email', 'john@kolab.org')->first(); | ||||
$browser->visit('/user/' . $user->id)->on(new Home()); | |||||
}); | |||||
} | |||||
/** | |||||
* Test users list page (unauthenticated) | |||||
*/ | |||||
public function testListUnauth(): void | |||||
{ | |||||
// Test that the page requires authentication | // Test that the page requires authentication | ||||
$this->browse(function (Browser $browser) { | $browser->visit('/user/' . $user->id) | ||||
$browser->visit('/users')->on(new Home()); | ->on(new Home()) | ||||
}); | ->submitLogon('john@kolab.org', 'simple123', false) | ||||
} | |||||
/** | |||||
* Test users list page | |||||
*/ | |||||
public function testList(): void | |||||
{ | |||||
// Test that the page requires authentication | |||||
$this->browse(function (Browser $browser) { | |||||
$browser->visit(new Home()) | |||||
->submitLogon('john@kolab.org', 'simple123', true) | |||||
->on(new Dashboard()) | |||||
->assertSeeIn('@links .link-users', 'User accounts') | |||||
->click('@links .link-users') | |||||
->on(new UserList()) | |||||
->whenAvailable('@table', function (Browser $browser) { | |||||
$browser->waitFor('tbody tr') | |||||
->assertElementsCount('tbody tr', 4) | |||||
->assertSeeIn('tbody tr:nth-child(1) a', 'jack@kolab.org') | |||||
->assertSeeIn('tbody tr:nth-child(2) a', 'joe@kolab.org') | |||||
->assertSeeIn('tbody tr:nth-child(3) a', 'john@kolab.org') | |||||
->assertSeeIn('tbody tr:nth-child(4) a', 'ned@kolab.org') | |||||
->assertMissing('tfoot'); | |||||
}); | |||||
}); | |||||
} | |||||
/** | |||||
* Test user account editing page (not profile page) | |||||
* | |||||
* @depends testList | |||||
*/ | |||||
public function testInfo(): void | |||||
{ | |||||
$this->browse(function (Browser $browser) { | |||||
$browser->on(new UserList()) | |||||
->click('@table tr:nth-child(3) a') | |||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
->assertSeeIn('#user-info .card-title', 'User account') | ->assertSeeIn('#user-info .card-title', 'User account') | ||||
->with('@general', function (Browser $browser) { | ->with('@general', function (Browser $browser) { | ||||
// Assert form content | // Assert form content | ||||
$browser->assertSeeIn('div.row:nth-child(1) label', 'Status') | $browser->assertSeeIn('div.row:nth-child(1) label', 'Status') | ||||
->assertSeeIn('div.row:nth-child(1) #status', 'Active') | ->assertSeeIn('div.row:nth-child(1) #status', 'Active') | ||||
->assertFocused('div.row:nth-child(2) input') | ->assertFocused('div.row:nth-child(2) input') | ||||
->assertSeeIn('div.row:nth-child(2) label', 'First Name') | ->assertSeeIn('div.row:nth-child(2) label', 'First Name') | ||||
▲ Show 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | public function testUserSettings(): void | ||||
}); | }); | ||||
$this->assertSame('false', $john->fresh()->getSetting('greylist_enabled')); | $this->assertSame('false', $john->fresh()->getSetting('greylist_enabled')); | ||||
} | } | ||||
/** | /** | ||||
* Test user adding page | * Test user adding page | ||||
* | * | ||||
* @depends testList | * @depends testInfo | ||||
*/ | */ | ||||
public function testNewUser(): void | public function testNewUser(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit(new UserList()) | $browser->visit(new UserList()) | ||||
->assertSeeIn('button.create-user', 'Create user') | ->assertSeeIn('button.create-user', 'Create user') | ||||
->click('button.create-user') | ->click('button.create-user') | ||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
▲ Show 20 Lines • Show All 363 Lines • ▼ Show 20 Lines | public function testCurrency(): void | ||||
}); | }); | ||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test beta entitlements | * Test beta entitlements | ||||
* | * | ||||
* @depends testList | * @depends testInfo | ||||
*/ | */ | ||||
public function testBetaEntitlements(): void | public function testBetaEntitlements(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$john = User::where('email', 'john@kolab.org')->first(); | $john = User::where('email', 'john@kolab.org')->first(); | ||||
$sku = Sku::withEnvTenantContext()->where('title', 'beta')->first(); | $sku = Sku::withEnvTenantContext()->where('title', 'beta')->first(); | ||||
$john->assignSku($sku); | $john->assignSku($sku); | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |