Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/Admin/UserTest.php
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | class UserTest extends TestCaseDusk | ||||
*/ | */ | ||||
public function testUserInfo(): void | public function testUserInfo(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$jack = $this->getTestUser('jack@kolab.org'); | $jack = $this->getTestUser('jack@kolab.org'); | ||||
$page = new UserPage($jack->id); | $page = new UserPage($jack->id); | ||||
$browser->visit(new Home()) | $browser->visit(new Home()) | ||||
->submitLogon('jeroen@jeroen.jeroen', 'jeroen', true) | ->submitLogon('jeroen@jeroen.jeroen', \App\Utils::generatePassphrase(), true) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->visit($page) | ->visit($page) | ||||
->on($page); | ->on($page); | ||||
// Assert main info box content | // Assert main info box content | ||||
$browser->assertSeeIn('@user-info .card-title', $jack->email) | $browser->assertSeeIn('@user-info .card-title', $jack->email) | ||||
->with('@user-info form', function (Browser $browser) use ($jack) { | ->with('@user-info form', function (Browser $browser) use ($jack) { | ||||
$browser->assertElementsCount('.row', 7) | $browser->assertElementsCount('.row', 7) | ||||
Show All 30 Lines | public function testUserInfo(): void | ||||
}); | }); | ||||
// Assert Subscriptions tab | // Assert Subscriptions tab | ||||
$browser->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (3)') | $browser->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (3)') | ||||
->click('@nav #tab-subscriptions') | ->click('@nav #tab-subscriptions') | ||||
->with('@user-subscriptions', function (Browser $browser) { | ->with('@user-subscriptions', function (Browser $browser) { | ||||
$browser->assertElementsCount('table tbody tr', 3) | $browser->assertElementsCount('table tbody tr', 3) | ||||
->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'User Mailbox') | ->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'User Mailbox') | ||||
->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '4,44 CHF') | ->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '5,00 CHF') | ||||
->assertSeeIn('table tbody tr:nth-child(2) td:first-child', 'Storage Quota 2 GB') | ->assertSeeIn('table tbody tr:nth-child(2) td:first-child', 'Storage Quota 5 GB') | ||||
->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '0,00 CHF') | ->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '0,00 CHF') | ||||
->assertSeeIn('table tbody tr:nth-child(3) td:first-child', 'Groupware Features') | ->assertSeeIn('table tbody tr:nth-child(3) td:first-child', 'Groupware Features') | ||||
->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '5,55 CHF') | ->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '4,90 CHF') | ||||
->assertMissing('table tfoot') | ->assertMissing('table tfoot') | ||||
->assertMissing('#reset2fa'); | ->assertMissing('#reset2fa'); | ||||
}); | }); | ||||
// Assert Domains tab | // Assert Domains tab | ||||
$browser->assertSeeIn('@nav #tab-domains', 'Domains (0)') | $browser->assertSeeIn('@nav #tab-domains', 'Domains (0)') | ||||
->click('@nav #tab-domains') | ->click('@nav #tab-domains') | ||||
->with('@user-domains', function (Browser $browser) { | ->with('@user-domains', function (Browser $browser) { | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | public function testUserInfo2(): void | ||||
}); | }); | ||||
// Assert Subscriptions tab | // Assert Subscriptions tab | ||||
$browser->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (3)') | $browser->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (3)') | ||||
->click('@nav #tab-subscriptions') | ->click('@nav #tab-subscriptions') | ||||
->with('@user-subscriptions', function (Browser $browser) { | ->with('@user-subscriptions', function (Browser $browser) { | ||||
$browser->assertElementsCount('table tbody tr', 3) | $browser->assertElementsCount('table tbody tr', 3) | ||||
->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'User Mailbox') | ->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'User Mailbox') | ||||
->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '3,99 CHF/month¹') | ->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '4,50 CHF/month¹') | ||||
->assertSeeIn('table tbody tr:nth-child(2) td:first-child', 'Storage Quota 2 GB') | ->assertSeeIn('table tbody tr:nth-child(2) td:first-child', 'Storage Quota 5 GB') | ||||
->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '0,00 CHF/month¹') | ->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '0,00 CHF/month¹') | ||||
->assertSeeIn('table tbody tr:nth-child(3) td:first-child', 'Groupware Features') | ->assertSeeIn('table tbody tr:nth-child(3) td:first-child', 'Groupware Features') | ||||
->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '4,99 CHF/month¹') | ->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '4,41 CHF/month¹') | ||||
->assertMissing('table tfoot') | ->assertMissing('table tfoot') | ||||
->assertSeeIn('table + .hint', '¹ applied discount: 10% - Test voucher'); | ->assertSeeIn('table + .hint', '¹ applied discount: 10% - Test voucher'); | ||||
}); | }); | ||||
// Assert Domains tab | // Assert Domains tab | ||||
$browser->assertSeeIn('@nav #tab-domains', 'Domains (1)') | $browser->assertSeeIn('@nav #tab-domains', 'Domains (1)') | ||||
->click('@nav #tab-domains') | ->click('@nav #tab-domains') | ||||
->with('@user-domains table', function (Browser $browser) { | ->with('@user-domains table', function (Browser $browser) { | ||||
Show All 28 Lines | public function testUserInfo2(): void | ||||
->assertVisible('tbody tr:nth-child(4) td:first-child svg.text-success') | ->assertVisible('tbody tr:nth-child(4) td:first-child svg.text-success') | ||||
->assertMissing('tfoot'); | ->assertMissing('tfoot'); | ||||
}); | }); | ||||
}); | }); | ||||
// Now we go to Ned's info page, he's a controller on John's wallet | // Now we go to Ned's info page, he's a controller on John's wallet | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$ned = $this->getTestUser('ned@kolab.org'); | $ned = $this->getTestUser('ned@kolab.org'); | ||||
$beta_sku = Sku::where('title', 'beta')->first(); | $beta_sku = Sku::withEnvTenantContext()->where('title', 'beta')->first(); | ||||
$storage_sku = Sku::where('title', 'storage')->first(); | $storage_sku = Sku::withEnvTenantContext()->where('title', 'storage')->first(); | ||||
$wallet = $ned->wallet(); | $wallet = $ned->wallet(); | ||||
// Add an extra storage and beta entitlement with different prices | // Add an extra storage and beta entitlement with different prices | ||||
Entitlement::create([ | Entitlement::create([ | ||||
'wallet_id' => $wallet->id, | 'wallet_id' => $wallet->id, | ||||
'sku_id' => $beta_sku->id, | 'sku_id' => $beta_sku->id, | ||||
'cost' => 5010, | 'cost' => 5010, | ||||
'entitleable_id' => $ned->id, | 'entitleable_id' => $ned->id, | ||||
Show All 35 Lines | public function testUserInfo2(): void | ||||
}); | }); | ||||
// Assert Subscriptions tab, we expect John's discount here | // Assert Subscriptions tab, we expect John's discount here | ||||
$browser->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (6)') | $browser->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (6)') | ||||
->click('@nav #tab-subscriptions') | ->click('@nav #tab-subscriptions') | ||||
->with('@user-subscriptions', function (Browser $browser) { | ->with('@user-subscriptions', function (Browser $browser) { | ||||
$browser->assertElementsCount('table tbody tr', 6) | $browser->assertElementsCount('table tbody tr', 6) | ||||
->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'User Mailbox') | ->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'User Mailbox') | ||||
->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '3,99 CHF/month¹') | ->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '4,50 CHF/month¹') | ||||
->assertSeeIn('table tbody tr:nth-child(2) td:first-child', 'Storage Quota 3 GB') | ->assertSeeIn('table tbody tr:nth-child(2) td:first-child', 'Storage Quota 6 GB') | ||||
->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '45,00 CHF/month¹') | ->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '45,00 CHF/month¹') | ||||
->assertSeeIn('table tbody tr:nth-child(3) td:first-child', 'Groupware Features') | ->assertSeeIn('table tbody tr:nth-child(3) td:first-child', 'Groupware Features') | ||||
->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '4,99 CHF/month¹') | ->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '4,41 CHF/month¹') | ||||
->assertSeeIn('table tbody tr:nth-child(4) td:first-child', 'Activesync') | ->assertSeeIn('table tbody tr:nth-child(4) td:first-child', 'Activesync') | ||||
->assertSeeIn('table tbody tr:nth-child(4) td:last-child', '0,90 CHF/month¹') | ->assertSeeIn('table tbody tr:nth-child(4) td:last-child', '0,00 CHF/month¹') | ||||
->assertSeeIn('table tbody tr:nth-child(5) td:first-child', '2-Factor Authentication') | ->assertSeeIn('table tbody tr:nth-child(5) td:first-child', '2-Factor Authentication') | ||||
->assertSeeIn('table tbody tr:nth-child(5) td:last-child', '0,00 CHF/month¹') | ->assertSeeIn('table tbody tr:nth-child(5) td:last-child', '0,00 CHF/month¹') | ||||
->assertSeeIn('table tbody tr:nth-child(6) td:first-child', 'Private Beta (invitation only)') | ->assertSeeIn('table tbody tr:nth-child(6) td:first-child', 'Private Beta (invitation only)') | ||||
->assertSeeIn('table tbody tr:nth-child(6) td:last-child', '45,09 CHF/month¹') | ->assertSeeIn('table tbody tr:nth-child(6) td:last-child', '45,09 CHF/month¹') | ||||
->assertMissing('table tfoot') | ->assertMissing('table tfoot') | ||||
->assertSeeIn('table + .hint', '¹ applied discount: 10% - Test voucher') | ->assertSeeIn('table + .hint', '¹ applied discount: 10% - Test voucher') | ||||
->assertSeeIn('#reset2fa', 'Reset 2-Factor Auth'); | ->assertSeeIn('#reset2fa', 'Reset 2-Factor Auth'); | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | class UserTest extends TestCaseDusk | ||||
/** | /** | ||||
* Test resetting 2FA for the user | * Test resetting 2FA for the user | ||||
*/ | */ | ||||
public function testReset2FA(): void | public function testReset2FA(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$this->deleteTestUser('userstest1@kolabnow.com'); | $this->deleteTestUser('userstest1@kolabnow.com'); | ||||
$user = $this->getTestUser('userstest1@kolabnow.com'); | $user = $this->getTestUser('userstest1@kolabnow.com'); | ||||
$sku2fa = Sku::firstOrCreate(['title' => '2fa']); | $sku2fa = Sku::withEnvTenantContext()->where('title', '2fa')->first(); | ||||
$user->assignSku($sku2fa); | $user->assignSku($sku2fa); | ||||
SecondFactor::seed('userstest1@kolabnow.com'); | SecondFactor::seed('userstest1@kolabnow.com'); | ||||
$browser->visit(new UserPage($user->id)) | $browser->visit(new UserPage($user->id)) | ||||
->click('@nav #tab-subscriptions') | ->click('@nav #tab-subscriptions') | ||||
->with('@user-subscriptions', function (Browser $browser) use ($sku2fa) { | ->with('@user-subscriptions', function (Browser $browser) use ($sku2fa) { | ||||
$browser->waitFor('#reset2fa') | $browser->waitFor('#reset2fa') | ||||
->assertVisible('#sku' . $sku2fa->id); | ->assertVisible('#sku' . $sku2fa->id); | ||||
Show All 15 Lines |