Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UsersTest.php
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | public function setUp(): void | ||||
Entitlement::where('cost', '=', 25)->where('sku_id', $storage_sku->id)->delete(); | Entitlement::where('cost', '=', 25)->where('sku_id', $storage_sku->id)->delete(); | ||||
$wallet = $john->wallets()->first(); | $wallet = $john->wallets()->first(); | ||||
$wallet->discount()->dissociate(); | $wallet->discount()->dissociate(); | ||||
$wallet->currency = 'CHF'; | $wallet->currency = 'CHF'; | ||||
$wallet->save(); | $wallet->save(); | ||||
$this->clearBetaEntitlements(); | $this->clearBetaEntitlements(); | ||||
$this->clearMeetEntitlements(); | |||||
} | } | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function tearDown(): void | public function tearDown(): void | ||||
{ | { | ||||
$this->deleteTestUser('julia.roberts@kolab.org'); | $this->deleteTestUser('julia.roberts@kolab.org'); | ||||
$john = User::where('email', 'john@kolab.org')->first(); | $john = User::where('email', 'john@kolab.org')->first(); | ||||
$john->setSettings($this->profile); | $john->setSettings($this->profile); | ||||
UserAlias::where('user_id', $john->id) | UserAlias::where('user_id', $john->id) | ||||
->where('alias', 'john.test@kolab.org')->delete(); | ->where('alias', 'john.test@kolab.org')->delete(); | ||||
$activesync_sku = Sku::withEnvTenantContext()->where('title', 'activesync')->first(); | $activesync_sku = Sku::withEnvTenantContext()->where('title', 'activesync')->first(); | ||||
$storage_sku = Sku::withEnvTenantContext()->where('title', 'storage')->first(); | $storage_sku = Sku::withEnvTenantContext()->where('title', 'storage')->first(); | ||||
Entitlement::where('entitleable_id', $john->id)->where('sku_id', $activesync_sku->id)->delete(); | Entitlement::where('entitleable_id', $john->id)->where('sku_id', $activesync_sku->id)->delete(); | ||||
Entitlement::where('cost', '>=', 5000)->delete(); | Entitlement::where('cost', '>=', 5000)->delete(); | ||||
Entitlement::where('cost', '=', 25)->where('sku_id', $storage_sku->id)->delete(); | Entitlement::where('cost', '=', 25)->where('sku_id', $storage_sku->id)->delete(); | ||||
$wallet = $john->wallets()->first(); | $wallet = $john->wallets()->first(); | ||||
$wallet->discount()->dissociate(); | $wallet->discount()->dissociate(); | ||||
$wallet->currency = 'CHF'; | |||||
$wallet->save(); | $wallet->save(); | ||||
$this->clearBetaEntitlements(); | $this->clearBetaEntitlements(); | ||||
$this->clearMeetEntitlements(); | |||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test user account editing page (not profile page) | * Test user account editing page (not profile page) | ||||
*/ | */ | ||||
public function testInfo(): void | public function testInfo(): void | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | public function testInfo(): void | ||||
$alias = $john->aliases()->where('alias', 'john.test@kolab.org')->first(); | $alias = $john->aliases()->where('alias', 'john.test@kolab.org')->first(); | ||||
$this->assertTrue(!empty($alias)); | $this->assertTrue(!empty($alias)); | ||||
// Test subscriptions | // Test subscriptions | ||||
$browser->with('@general', function (Browser $browser) { | $browser->with('@general', function (Browser $browser) { | ||||
$browser->assertSeeIn('div.row:nth-child(8) label', 'Subscriptions') | $browser->assertSeeIn('div.row:nth-child(8) label', 'Subscriptions') | ||||
->assertVisible('@skus.row:nth-child(8)') | ->assertVisible('@skus.row:nth-child(8)') | ||||
->with('@skus', function ($browser) { | ->with('@skus', function ($browser) { | ||||
$browser->assertElementsCount('tbody tr', 6) | $browser->assertElementsCount('tbody tr', 5) | ||||
// Mailbox SKU | // Mailbox SKU | ||||
->assertSeeIn('tbody tr:nth-child(1) td.name', 'User Mailbox') | ->assertSeeIn('tbody tr:nth-child(1) td.name', 'User Mailbox') | ||||
->assertSeeIn('tbody tr:nth-child(1) td.price', '5,00 CHF/month') | ->assertSeeIn('tbody tr:nth-child(1) td.price', '5,00 CHF/month') | ||||
->assertChecked('tbody tr:nth-child(1) td.selection input') | ->assertChecked('tbody tr:nth-child(1) td.selection input') | ||||
->assertDisabled('tbody tr:nth-child(1) td.selection input') | ->assertDisabled('tbody tr:nth-child(1) td.selection input') | ||||
->assertTip( | ->assertTip( | ||||
'tbody tr:nth-child(1) td.buttons button', | 'tbody tr:nth-child(1) td.buttons button', | ||||
'Just a mailbox' | 'Just a mailbox' | ||||
Show All 33 Lines | public function testInfo(): void | ||||
->assertSeeIn('tbody tr:nth-child(5) td.name', '2-Factor Authentication') | ->assertSeeIn('tbody tr:nth-child(5) td.name', '2-Factor Authentication') | ||||
->assertSeeIn('tbody tr:nth-child(5) td.price', '0,00 CHF/month') | ->assertSeeIn('tbody tr:nth-child(5) td.price', '0,00 CHF/month') | ||||
->assertNotChecked('tbody tr:nth-child(5) td.selection input') | ->assertNotChecked('tbody tr:nth-child(5) td.selection input') | ||||
->assertEnabled('tbody tr:nth-child(5) td.selection input') | ->assertEnabled('tbody tr:nth-child(5) td.selection input') | ||||
->assertTip( | ->assertTip( | ||||
'tbody tr:nth-child(5) td.buttons button', | 'tbody tr:nth-child(5) td.buttons button', | ||||
'Two factor authentication for webmail and administration panel' | 'Two factor authentication for webmail and administration panel' | ||||
) | ) | ||||
// Meet SKU | |||||
->assertSeeIn('tbody tr:nth-child(6) td.name', 'Voice & Video Conferencing (public beta)') | |||||
->assertSeeIn('tbody tr:nth-child(6) td.price', '0,00 CHF/month') | |||||
->assertNotChecked('tbody tr:nth-child(6) td.selection input') | |||||
->assertEnabled('tbody tr:nth-child(6) td.selection input') | |||||
->assertTip( | |||||
'tbody tr:nth-child(6) td.buttons button', | |||||
'Video conferencing tool' | |||||
) | |||||
->click('tbody tr:nth-child(4) td.selection input'); | ->click('tbody tr:nth-child(4) td.selection input'); | ||||
}) | }) | ||||
->assertMissing('@skus table + .hint') | ->assertMissing('@skus table + .hint') | ||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ||||
}) | }) | ||||
->on(new UserList()) | ->on(new UserList()) | ||||
->click('@table tr:nth-child(3) a') | ->click('@table tr:nth-child(3) a') | ||||
Show All 12 Lines | public function testInfo(): void | ||||
->assertNotChecked('#sku-input-activesync') | ->assertNotChecked('#sku-input-activesync') | ||||
->assertEnabled('#sku-input-activesync') | ->assertEnabled('#sku-input-activesync') | ||||
->assertNotReadonly('#sku-input-activesync') | ->assertNotReadonly('#sku-input-activesync') | ||||
// Check 'activesync', expect an alert | // Check 'activesync', expect an alert | ||||
->click('#sku-input-activesync') | ->click('#sku-input-activesync') | ||||
->assertDialogOpened('Activesync requires Groupware Features.') | ->assertDialogOpened('Activesync requires Groupware Features.') | ||||
->acceptDialog() | ->acceptDialog() | ||||
->assertNotChecked('#sku-input-activesync') | ->assertNotChecked('#sku-input-activesync') | ||||
// Check 'meet', expect an alert | |||||
->click('#sku-input-meet') | |||||
->assertDialogOpened('Voice & Video Conferencing (public beta) requires Groupware Features.') | |||||
->acceptDialog() | |||||
->assertNotChecked('#sku-input-meet') | |||||
// Check '2FA', expect 'activesync' unchecked and readonly | // Check '2FA', expect 'activesync' unchecked and readonly | ||||
->click('#sku-input-2fa') | ->click('#sku-input-2fa') | ||||
->assertChecked('#sku-input-2fa') | ->assertChecked('#sku-input-2fa') | ||||
->assertNotChecked('#sku-input-activesync') | ->assertNotChecked('#sku-input-activesync') | ||||
->assertReadonly('#sku-input-activesync') | ->assertReadonly('#sku-input-activesync') | ||||
// Uncheck '2FA' | // Uncheck '2FA' | ||||
->click('#sku-input-2fa') | ->click('#sku-input-2fa') | ||||
->assertNotChecked('#sku-input-2fa') | ->assertNotChecked('#sku-input-2fa') | ||||
▲ Show 20 Lines • Show All 330 Lines • ▼ Show 20 Lines | public function testDiscountedPrices(): void | ||||
->visit(new UserList()) | ->visit(new UserList()) | ||||
->waitFor('@table tr:nth-child(2)') | ->waitFor('@table tr:nth-child(2)') | ||||
->click('@table tr:nth-child(2) a') // joe@kolab.org | ->click('@table tr:nth-child(2) a') // joe@kolab.org | ||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
->with('@general', function (Browser $browser) { | ->with('@general', function (Browser $browser) { | ||||
$browser->whenAvailable('@skus', function (Browser $browser) { | $browser->whenAvailable('@skus', function (Browser $browser) { | ||||
$quota_input = new QuotaInput('tbody tr:nth-child(2) .range-input'); | $quota_input = new QuotaInput('tbody tr:nth-child(2) .range-input'); | ||||
$browser->waitFor('tbody tr') | $browser->waitFor('tbody tr') | ||||
->assertElementsCount('tbody tr', 6) | ->assertElementsCount('tbody tr', 5) | ||||
// Mailbox SKU | // Mailbox SKU | ||||
->assertSeeIn('tbody tr:nth-child(1) td.price', '4,50 CHF/month¹') | ->assertSeeIn('tbody tr:nth-child(1) td.price', '4,50 CHF/month¹') | ||||
// Storage SKU | // Storage SKU | ||||
->assertSeeIn('tr:nth-child(2) td.price', '0,00 CHF/month¹') | ->assertSeeIn('tr:nth-child(2) td.price', '0,00 CHF/month¹') | ||||
->with($quota_input, function (Browser $browser) { | ->with($quota_input, function (Browser $browser) { | ||||
$browser->setQuotaValue(100); | $browser->setQuotaValue(100); | ||||
}) | }) | ||||
->assertSeeIn('tr:nth-child(2) td.price', '21,37 CHF/month¹') | ->assertSeeIn('tr:nth-child(2) td.price', '21,37 CHF/month¹') | ||||
// groupware SKU | // Groupware SKU | ||||
->assertSeeIn('tbody tr:nth-child(3) td.price', '4,41 CHF/month¹') | ->assertSeeIn('tbody tr:nth-child(3) td.price', '4,41 CHF/month¹') | ||||
// ActiveSync SKU | // ActiveSync SKU | ||||
->assertSeeIn('tbody tr:nth-child(4) td.price', '0,00 CHF/month¹') | ->assertSeeIn('tbody tr:nth-child(4) td.price', '0,00 CHF/month¹') | ||||
// 2FA SKU | // 2FA SKU | ||||
->assertSeeIn('tbody tr:nth-child(5) td.price', '0,00 CHF/month¹'); | ->assertSeeIn('tbody tr:nth-child(5) td.price', '0,00 CHF/month¹'); | ||||
}) | }) | ||||
->assertSeeIn('@skus table + .hint', '¹ applied discount: 10% - Test voucher'); | ->assertSeeIn('@skus table + .hint', '¹ applied discount: 10% - Test voucher'); | ||||
}); | }); | ||||
Show All 38 Lines | public function testDiscountedPrices(): void | ||||
$browser->visit('/user/' . $joe->id) | $browser->visit('/user/' . $joe->id) | ||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
->with('@general', function (Browser $browser) { | ->with('@general', function (Browser $browser) { | ||||
$browser->whenAvailable('@skus', function (Browser $browser) { | $browser->whenAvailable('@skus', function (Browser $browser) { | ||||
$quota_input = new QuotaInput('tbody tr:nth-child(2) .range-input'); | $quota_input = new QuotaInput('tbody tr:nth-child(2) .range-input'); | ||||
$browser->waitFor('tbody tr') | $browser->waitFor('tbody tr') | ||||
// Beta SKU | // Beta SKU | ||||
->assertSeeIn('tbody tr:nth-child(7) td.price', '45,09 CHF/month¹') | ->assertSeeIn('tbody tr:nth-child(6) td.price', '45,09 CHF/month¹') | ||||
// Storage SKU | // Storage SKU | ||||
->assertSeeIn('tr:nth-child(2) td.price', '45,00 CHF/month¹') | ->assertSeeIn('tr:nth-child(2) td.price', '45,00 CHF/month¹') | ||||
->with($quota_input, function (Browser $browser) { | ->with($quota_input, function (Browser $browser) { | ||||
$browser->setQuotaValue(7); | $browser->setQuotaValue(7); | ||||
}) | }) | ||||
->assertSeeIn('tr:nth-child(2) td.price', '45,22 CHF/month¹') | ->assertSeeIn('tr:nth-child(2) td.price', '45,22 CHF/month¹') | ||||
->with($quota_input, function (Browser $browser) { | ->with($quota_input, function (Browser $browser) { | ||||
$browser->setQuotaValue(5); | $browser->setQuotaValue(5); | ||||
Show All 34 Lines | public function testCurrency(): void | ||||
$browser->visit(new UserList()) | $browser->visit(new UserList()) | ||||
->waitFor('@table tr:nth-child(2)') | ->waitFor('@table tr:nth-child(2)') | ||||
->click('@table tr:nth-child(2) a') // joe@kolab.org | ->click('@table tr:nth-child(2) a') // joe@kolab.org | ||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
->with('@general', function (Browser $browser) { | ->with('@general', function (Browser $browser) { | ||||
$browser->whenAvailable('@skus', function (Browser $browser) { | $browser->whenAvailable('@skus', function (Browser $browser) { | ||||
$quota_input = new QuotaInput('tbody tr:nth-child(2) .range-input'); | $quota_input = new QuotaInput('tbody tr:nth-child(2) .range-input'); | ||||
$browser->waitFor('tbody tr') | $browser->waitFor('tbody tr') | ||||
->assertElementsCount('tbody tr', 6) | ->assertElementsCount('tbody tr', 5) | ||||
// Mailbox SKU | // Mailbox SKU | ||||
->assertSeeIn('tbody tr:nth-child(1) td.price', '5,00 €/month') | ->assertSeeIn('tbody tr:nth-child(1) td.price', '5,00 €/month') | ||||
// Storage SKU | // Storage SKU | ||||
->assertSeeIn('tr:nth-child(2) td.price', '0,00 €/month') | ->assertSeeIn('tr:nth-child(2) td.price', '0,00 €/month') | ||||
->with($quota_input, function (Browser $browser) { | ->with($quota_input, function (Browser $browser) { | ||||
$browser->setQuotaValue(100); | $browser->setQuotaValue(100); | ||||
}) | }) | ||||
->assertSeeIn('tr:nth-child(2) td.price', '23,75 €/month'); | ->assertSeeIn('tr:nth-child(2) td.price', '23,75 €/month'); | ||||
Show All 26 Lines | 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); | ||||
$browser->visit('/user/' . $john->id) | $browser->visit('/user/' . $john->id) | ||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
->with('@skus', function ($browser) { | ->with('@skus', function ($browser) { | ||||
$browser->assertElementsCount('tbody tr', 11) | $browser->assertElementsCount('tbody tr', 10) | ||||
// Meet SKU | // Beta SKU | ||||
->assertSeeIn('tbody tr:nth-child(6) td.name', 'Voice & Video Conferencing (public beta)') | ->assertSeeIn('tbody tr:nth-child(6) td.name', 'Private Beta (invitation only)') | ||||
->assertSeeIn('tr:nth-child(6) td.price', '0,00 CHF/month') | ->assertSeeIn('tbody tr:nth-child(6) td.price', '0,00 CHF/month') | ||||
->assertNotChecked('tbody tr:nth-child(6) td.selection input') | ->assertChecked('tbody tr:nth-child(6) td.selection input') | ||||
->assertEnabled('tbody tr:nth-child(6) td.selection input') | ->assertEnabled('tbody tr:nth-child(6) td.selection input') | ||||
->assertTip( | ->assertTip( | ||||
'tbody tr:nth-child(6) td.buttons button', | 'tbody tr:nth-child(6) td.buttons button', | ||||
'Video conferencing tool' | 'Access to the private beta program subscriptions' | ||||
) | ) | ||||
// Beta SKU | // Distlists SKU | ||||
->assertSeeIn('tbody tr:nth-child(7) td.name', 'Private Beta (invitation only)') | ->assertSeeIn('tbody tr:nth-child(7) td.name', 'Distribution lists') | ||||
->assertSeeIn('tbody tr:nth-child(7) td.price', '0,00 CHF/month') | ->assertSeeIn('tr:nth-child(7) td.price', '0,00 CHF/month') | ||||
->assertChecked('tbody tr:nth-child(7) td.selection input') | ->assertNotChecked('tbody tr:nth-child(7) td.selection input') | ||||
->assertEnabled('tbody tr:nth-child(7) td.selection input') | ->assertEnabled('tbody tr:nth-child(7) td.selection input') | ||||
->assertTip( | ->assertTip( | ||||
'tbody tr:nth-child(7) td.buttons button', | 'tbody tr:nth-child(7) td.buttons button', | ||||
'Access to the private beta program subscriptions' | 'Access to mail distribution lists' | ||||
) | ) | ||||
// Distlists SKU | // Resources SKU | ||||
->assertSeeIn('tbody tr:nth-child(8) td.name', 'Distribution lists') | ->assertSeeIn('tbody tr:nth-child(8) td.name', 'Calendaring resources') | ||||
->assertSeeIn('tr:nth-child(8) td.price', '0,00 CHF/month') | ->assertSeeIn('tr:nth-child(8) td.price', '0,00 CHF/month') | ||||
->assertNotChecked('tbody tr:nth-child(8) td.selection input') | ->assertNotChecked('tbody tr:nth-child(8) td.selection input') | ||||
->assertEnabled('tbody tr:nth-child(8) td.selection input') | ->assertEnabled('tbody tr:nth-child(8) td.selection input') | ||||
->assertTip( | ->assertTip( | ||||
'tbody tr:nth-child(8) td.buttons button', | 'tbody tr:nth-child(8) td.buttons button', | ||||
'Access to mail distribution lists' | 'Access to calendaring resources' | ||||
) | ) | ||||
// Resources SKU | // Shared folders SKU | ||||
->assertSeeIn('tbody tr:nth-child(9) td.name', 'Calendaring resources') | ->scrollTo('tbody tr:nth-child(9)')->pause(250) | ||||
->assertSeeIn('tbody tr:nth-child(9) td.name', 'Shared folders') | |||||
->assertSeeIn('tr:nth-child(9) td.price', '0,00 CHF/month') | ->assertSeeIn('tr:nth-child(9) td.price', '0,00 CHF/month') | ||||
->assertNotChecked('tbody tr:nth-child(9) td.selection input') | ->assertNotChecked('tbody tr:nth-child(9) td.selection input') | ||||
->assertEnabled('tbody tr:nth-child(9) td.selection input') | ->assertEnabled('tbody tr:nth-child(9) td.selection input') | ||||
->assertTip( | ->assertTip( | ||||
'tbody tr:nth-child(9) td.buttons button', | 'tbody tr:nth-child(9) td.buttons button', | ||||
'Access to calendaring resources' | 'Access to shared folders' | ||||
) | ) | ||||
// Shared folders SKU | // Files SKU | ||||
->scrollTo('tbody tr:nth-child(10)')->pause(250) | ->scrollTo('tbody tr:nth-child(10)')->pause(250) | ||||
->assertSeeIn('tbody tr:nth-child(10) td.name', 'Shared folders') | ->assertSeeIn('tbody tr:nth-child(10) td.name', 'File storage') | ||||
->assertSeeIn('tr:nth-child(10) td.price', '0,00 CHF/month') | ->assertSeeIn('tr:nth-child(10) td.price', '0,00 CHF/month') | ||||
->assertNotChecked('tbody tr:nth-child(10) td.selection input') | ->assertNotChecked('tbody tr:nth-child(10) td.selection input') | ||||
->assertEnabled('tbody tr:nth-child(10) td.selection input') | ->assertEnabled('tbody tr:nth-child(10) td.selection input') | ||||
->assertTip( | ->assertTip( | ||||
'tbody tr:nth-child(10) td.buttons button', | 'tbody tr:nth-child(10) td.buttons button', | ||||
'Access to shared folders' | |||||
) | |||||
// Files SKU | |||||
->scrollTo('tbody tr:nth-child(11)')->pause(250) | |||||
->assertSeeIn('tbody tr:nth-child(11) td.name', 'File storage') | |||||
->assertSeeIn('tr:nth-child(11) td.price', '0,00 CHF/month') | |||||
->assertNotChecked('tbody tr:nth-child(11) td.selection input') | |||||
->assertEnabled('tbody tr:nth-child(11) td.selection input') | |||||
->assertTip( | |||||
'tbody tr:nth-child(11) td.buttons button', | |||||
'Access to file storage' | 'Access to file storage' | ||||
) | ) | ||||
// Check Distlist, Uncheck Beta, expect Distlist unchecked | // Check Distlist, Uncheck Beta, expect Distlist unchecked | ||||
->click('#sku-input-beta-distlists') | ->click('#sku-input-beta-distlists') | ||||
->click('#sku-input-beta') | ->click('#sku-input-beta') | ||||
->assertNotChecked('#sku-input-beta') | ->assertNotChecked('#sku-input-beta') | ||||
->assertNotChecked('#sku-input-beta-distlists') | ->assertNotChecked('#sku-input-beta-distlists') | ||||
// Click Distlists expect an alert | // Click Distlists expect an alert | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |