Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/Admin/UserTest.php
Show All 33 Lines | public function setUp(): void | ||||
if ($john->isSuspended()) { | if ($john->isSuspended()) { | ||||
User::where('email', $john->email)->update(['status' => $john->status - User::STATUS_SUSPENDED]); | User::where('email', $john->email)->update(['status' => $john->status - User::STATUS_SUSPENDED]); | ||||
} | } | ||||
$wallet = $john->wallets()->first(); | $wallet = $john->wallets()->first(); | ||||
$wallet->discount()->dissociate(); | $wallet->discount()->dissociate(); | ||||
$wallet->save(); | $wallet->save(); | ||||
Entitlement::where('cost', '>=', 5000)->delete(); | Entitlement::where('cost', '>=', 5000)->delete(); | ||||
$this->deleteTestGroup('group-test@kolab.org'); | |||||
$this->clearMeetEntitlements(); | $this->clearMeetEntitlements(); | ||||
} | } | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function tearDown(): void | public function tearDown(): void | ||||
{ | { | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$john->setSettings([ | $john->setSettings([ | ||||
'phone' => null, | 'phone' => null, | ||||
'external_email' => 'john.doe.external@gmail.com', | 'external_email' => 'john.doe.external@gmail.com', | ||||
]); | ]); | ||||
if ($john->isSuspended()) { | if ($john->isSuspended()) { | ||||
User::where('email', $john->email)->update(['status' => $john->status - User::STATUS_SUSPENDED]); | User::where('email', $john->email)->update(['status' => $john->status - User::STATUS_SUSPENDED]); | ||||
} | } | ||||
$wallet = $john->wallets()->first(); | $wallet = $john->wallets()->first(); | ||||
$wallet->discount()->dissociate(); | $wallet->discount()->dissociate(); | ||||
$wallet->save(); | $wallet->save(); | ||||
Entitlement::where('cost', '>=', 5000)->delete(); | Entitlement::where('cost', '>=', 5000)->delete(); | ||||
$this->deleteTestGroup('group-test@kolab.org'); | |||||
$this->clearMeetEntitlements(); | $this->clearMeetEntitlements(); | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test user info page (unauthenticated) | * Test user info page (unauthenticated) | ||||
*/ | */ | ||||
Show All 38 Lines | public function testUserInfo(): void | ||||
->assertSeeIn('.row:nth-child(6) label', 'External email') | ->assertSeeIn('.row:nth-child(6) label', 'External email') | ||||
->assertMissing('.row:nth-child(6) #external_email a') | ->assertMissing('.row:nth-child(6) #external_email a') | ||||
->assertSeeIn('.row:nth-child(7) label', 'Country') | ->assertSeeIn('.row:nth-child(7) label', 'Country') | ||||
->assertSeeIn('.row:nth-child(7) #country', 'United States'); | ->assertSeeIn('.row:nth-child(7) #country', 'United States'); | ||||
}); | }); | ||||
// Some tabs are loaded in background, wait a second | // Some tabs are loaded in background, wait a second | ||||
$browser->pause(500) | $browser->pause(500) | ||||
->assertElementsCount('@nav a', 5); | ->assertElementsCount('@nav a', 6); | ||||
// Note: Finances tab is tested in UserFinancesTest.php | // Note: Finances tab is tested in UserFinancesTest.php | ||||
$browser->assertSeeIn('@nav #tab-finances', 'Finances'); | $browser->assertSeeIn('@nav #tab-finances', 'Finances'); | ||||
// Assert Aliases tab | // Assert Aliases tab | ||||
$browser->assertSeeIn('@nav #tab-aliases', 'Aliases (1)') | $browser->assertSeeIn('@nav #tab-aliases', 'Aliases (1)') | ||||
->click('@nav #tab-aliases') | ->click('@nav #tab-aliases') | ||||
->whenAvailable('@user-aliases', function (Browser $browser) { | ->whenAvailable('@user-aliases', function (Browser $browser) { | ||||
Show All 27 Lines | public function testUserInfo(): void | ||||
// Assert Users tab | // Assert Users tab | ||||
$browser->assertSeeIn('@nav #tab-users', 'Users (0)') | $browser->assertSeeIn('@nav #tab-users', 'Users (0)') | ||||
->click('@nav #tab-users') | ->click('@nav #tab-users') | ||||
->with('@user-users', function (Browser $browser) { | ->with('@user-users', function (Browser $browser) { | ||||
$browser->assertElementsCount('table tbody tr', 0) | $browser->assertElementsCount('table tbody tr', 0) | ||||
->assertSeeIn('table tfoot tr td', 'There are no users in this account.'); | ->assertSeeIn('table tfoot tr td', 'There are no users in this account.'); | ||||
}); | }); | ||||
// Assert Distribution lists tab | |||||
$browser->assertSeeIn('@nav #tab-distlists', 'Distribution lists (0)') | |||||
->click('@nav #tab-distlists') | |||||
->with('@user-distlists', function (Browser $browser) { | |||||
$browser->assertElementsCount('table tbody tr', 0) | |||||
->assertSeeIn('table tfoot tr td', 'There are no distribution lists in this account.'); | |||||
}); | |||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test user info page (continue) | * Test user info page (continue) | ||||
* | * | ||||
* @depends testUserInfo | * @depends testUserInfo | ||||
*/ | */ | ||||
public function testUserInfo2(): void | public function testUserInfo2(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$page = new UserPage($john->id); | $page = new UserPage($john->id); | ||||
$discount = Discount::where('code', 'TEST')->first(); | $discount = Discount::where('code', 'TEST')->first(); | ||||
$wallet = $john->wallet(); | $wallet = $john->wallet(); | ||||
$wallet->discount()->associate($discount); | $wallet->discount()->associate($discount); | ||||
$wallet->debit(2010); | $wallet->debit(2010); | ||||
$wallet->save(); | $wallet->save(); | ||||
$group = $this->getTestGroup('group-test@kolab.org'); | |||||
$group->assignToWallet($john->wallets->first()); | |||||
// Click the managed-by link on Jack's page | // Click the managed-by link on Jack's page | ||||
$browser->click('@user-info #manager a') | $browser->click('@user-info #manager a') | ||||
->on($page); | ->on($page); | ||||
// Assert main info box content | // Assert main info box content | ||||
$browser->assertSeeIn('@user-info .card-title', $john->email) | $browser->assertSeeIn('@user-info .card-title', $john->email) | ||||
->with('@user-info form', function (Browser $browser) use ($john) { | ->with('@user-info form', function (Browser $browser) use ($john) { | ||||
Show All 18 Lines | public function testUserInfo2(): void | ||||
->assertSeeIn('.row:nth-child(8) label', 'Address') | ->assertSeeIn('.row:nth-child(8) label', 'Address') | ||||
->assertSeeIn('.row:nth-child(8) #billing_address', $john->getSetting('billing_address')) | ->assertSeeIn('.row:nth-child(8) #billing_address', $john->getSetting('billing_address')) | ||||
->assertSeeIn('.row:nth-child(9) label', 'Country') | ->assertSeeIn('.row:nth-child(9) label', 'Country') | ||||
->assertSeeIn('.row:nth-child(9) #country', 'United States'); | ->assertSeeIn('.row:nth-child(9) #country', 'United States'); | ||||
}); | }); | ||||
// Some tabs are loaded in background, wait a second | // Some tabs are loaded in background, wait a second | ||||
$browser->pause(500) | $browser->pause(500) | ||||
->assertElementsCount('@nav a', 5); | ->assertElementsCount('@nav a', 6); | ||||
// Note: Finances tab is tested in UserFinancesTest.php | // Note: Finances tab is tested in UserFinancesTest.php | ||||
$browser->assertSeeIn('@nav #tab-finances', 'Finances'); | $browser->assertSeeIn('@nav #tab-finances', 'Finances'); | ||||
// Assert Aliases tab | // Assert Aliases tab | ||||
$browser->assertSeeIn('@nav #tab-aliases', 'Aliases (1)') | $browser->assertSeeIn('@nav #tab-aliases', 'Aliases (1)') | ||||
->click('@nav #tab-aliases') | ->click('@nav #tab-aliases') | ||||
->whenAvailable('@user-aliases', function (Browser $browser) { | ->whenAvailable('@user-aliases', function (Browser $browser) { | ||||
Show All 22 Lines | public function testUserInfo2(): void | ||||
->click('@nav #tab-domains') | ->click('@nav #tab-domains') | ||||
->with('@user-domains table', function (Browser $browser) { | ->with('@user-domains table', function (Browser $browser) { | ||||
$browser->assertElementsCount('tbody tr', 1) | $browser->assertElementsCount('tbody tr', 1) | ||||
->assertSeeIn('tbody tr:nth-child(1) td:first-child a', 'kolab.org') | ->assertSeeIn('tbody tr:nth-child(1) td:first-child a', 'kolab.org') | ||||
->assertVisible('tbody tr:nth-child(1) td:first-child svg.text-success') | ->assertVisible('tbody tr:nth-child(1) td:first-child svg.text-success') | ||||
->assertMissing('tfoot'); | ->assertMissing('tfoot'); | ||||
}); | }); | ||||
// Assert Distribution lists tab | |||||
$browser->assertSeeIn('@nav #tab-distlists', 'Distribution lists (1)') | |||||
->click('@nav #tab-distlists') | |||||
->with('@user-distlists table', function (Browser $browser) { | |||||
$browser->assertElementsCount('tbody tr', 1) | |||||
->assertSeeIn('tbody tr:nth-child(1) td:first-child a', 'group-test@kolab.org') | |||||
->assertVisible('tbody tr:nth-child(1) td:first-child svg.text-danger') | |||||
->assertMissing('tfoot'); | |||||
}); | |||||
// Assert Users tab | // Assert Users tab | ||||
$browser->assertSeeIn('@nav #tab-users', 'Users (4)') | $browser->assertSeeIn('@nav #tab-users', 'Users (4)') | ||||
->click('@nav #tab-users') | ->click('@nav #tab-users') | ||||
->with('@user-users table', function (Browser $browser) { | ->with('@user-users table', function (Browser $browser) { | ||||
$browser->assertElementsCount('tbody tr', 4) | $browser->assertElementsCount('tbody tr', 4) | ||||
->assertSeeIn('tbody tr:nth-child(1) td:first-child a', 'jack@kolab.org') | ->assertSeeIn('tbody tr:nth-child(1) td:first-child a', 'jack@kolab.org') | ||||
->assertVisible('tbody tr:nth-child(1) td:first-child svg.text-success') | ->assertVisible('tbody tr:nth-child(1) td:first-child svg.text-success') | ||||
->assertSeeIn('tbody tr:nth-child(2) td:first-child a', 'joe@kolab.org') | ->assertSeeIn('tbody tr:nth-child(2) td:first-child a', 'joe@kolab.org') | ||||
Show All 38 Lines | public function testUserInfo2(): void | ||||
$browser->assertSeeIn('@user-info .card-title', $ned->email) | $browser->assertSeeIn('@user-info .card-title', $ned->email) | ||||
->with('@user-info form', function (Browser $browser) use ($ned) { | ->with('@user-info form', function (Browser $browser) use ($ned) { | ||||
$browser->assertSeeIn('.row:nth-child(2) label', 'ID (Created at)') | $browser->assertSeeIn('.row:nth-child(2) label', 'ID (Created at)') | ||||
->assertSeeIn('.row:nth-child(2) #userid', "{$ned->id} ({$ned->created_at})"); | ->assertSeeIn('.row:nth-child(2) #userid', "{$ned->id} ({$ned->created_at})"); | ||||
}); | }); | ||||
// Some tabs are loaded in background, wait a second | // Some tabs are loaded in background, wait a second | ||||
$browser->pause(500) | $browser->pause(500) | ||||
->assertElementsCount('@nav a', 5); | ->assertElementsCount('@nav a', 6); | ||||
// Note: Finances tab is tested in UserFinancesTest.php | // Note: Finances tab is tested in UserFinancesTest.php | ||||
$browser->assertSeeIn('@nav #tab-finances', 'Finances'); | $browser->assertSeeIn('@nav #tab-finances', 'Finances'); | ||||
// Assert Aliases tab | // Assert Aliases tab | ||||
$browser->assertSeeIn('@nav #tab-aliases', 'Aliases (0)') | $browser->assertSeeIn('@nav #tab-aliases', 'Aliases (0)') | ||||
->click('@nav #tab-aliases') | ->click('@nav #tab-aliases') | ||||
->whenAvailable('@user-aliases', function (Browser $browser) { | ->whenAvailable('@user-aliases', function (Browser $browser) { | ||||
Show All 33 Lines | public function testUserInfo2(): void | ||||
// We don't expect John's users here | // We don't expect John's users here | ||||
$browser->assertSeeIn('@nav #tab-users', 'Users (0)') | $browser->assertSeeIn('@nav #tab-users', 'Users (0)') | ||||
->click('@nav #tab-users') | ->click('@nav #tab-users') | ||||
->with('@user-users', function (Browser $browser) { | ->with('@user-users', function (Browser $browser) { | ||||
$browser->assertElementsCount('table tbody tr', 0) | $browser->assertElementsCount('table tbody tr', 0) | ||||
->assertSeeIn('table tfoot tr td', 'There are no users in this account.'); | ->assertSeeIn('table tfoot tr td', 'There are no users in this account.'); | ||||
}); | }); | ||||
// We don't expect John's distribution lists here | |||||
$browser->assertSeeIn('@nav #tab-distlists', 'Distribution lists (0)') | |||||
->click('@nav #tab-distlists') | |||||
->with('@user-distlists', function (Browser $browser) { | |||||
$browser->assertElementsCount('table tbody tr', 0) | |||||
->assertSeeIn('table tfoot tr td', 'There are no distribution lists in this account.'); | |||||
}); | |||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test editing an external email | * Test editing an external email | ||||
* | * | ||||
* @depends testUserInfo2 | * @depends testUserInfo2 | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines |