Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UsersTest.php
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | public function setUp(): void | ||||
->where('alias', 'john.test@kolab.org')->delete(); | ->where('alias', 'john.test@kolab.org')->delete(); | ||||
Entitlement::where('entitleable_id', $john->id)->whereIn('cost', [25, 100])->delete(); | Entitlement::where('entitleable_id', $john->id)->whereIn('cost', [25, 100])->delete(); | ||||
$wallet = $john->wallets()->first(); | $wallet = $john->wallets()->first(); | ||||
$wallet->discount()->dissociate(); | $wallet->discount()->dissociate(); | ||||
$wallet->save(); | $wallet->save(); | ||||
$betas = Sku::where('handler_class', 'like', '%\\Beta%')->pluck('id')->all(); | $this->clearBetaEntitlements(); | ||||
Entitlement::whereIn('sku_id', $betas)->delete(); | $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(); | ||||
Entitlement::where('entitleable_id', $john->id)->whereIn('cost', [25, 100])->delete(); | Entitlement::where('entitleable_id', $john->id)->whereIn('cost', [25, 100])->delete(); | ||||
$wallet = $john->wallets()->first(); | $wallet = $john->wallets()->first(); | ||||
$wallet->discount()->dissociate(); | $wallet->discount()->dissociate(); | ||||
$wallet->save(); | $wallet->save(); | ||||
$betas = Sku::where('handler_class', 'like', '%\\Beta%')->pluck('id')->all(); | $this->clearBetaEntitlements(); | ||||
Entitlement::whereIn('sku_id', $betas)->delete(); | $this->clearMeetEntitlements(); | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test user info page (unauthenticated) | * Test user info page (unauthenticated) | ||||
*/ | */ | ||||
public function testInfoUnauth(): void | public function testInfoUnauth(): void | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | public function testInfo(): void | ||||
$alias = UserAlias::where('user_id', $john->id)->where('alias', 'john.test@kolab.org')->first(); | $alias = UserAlias::where('user_id', $john->id)->where('alias', 'john.test@kolab.org')->first(); | ||||
$this->assertTrue(!empty($alias)); | $this->assertTrue(!empty($alias)); | ||||
// Test subscriptions | // Test subscriptions | ||||
$browser->with('@form', function (Browser $browser) { | $browser->with('@form', function (Browser $browser) { | ||||
$browser->assertSeeIn('div.row:nth-child(9) label', 'Subscriptions') | $browser->assertSeeIn('div.row:nth-child(9) label', 'Subscriptions') | ||||
->assertVisible('@skus.row:nth-child(9)') | ->assertVisible('@skus.row:nth-child(9)') | ||||
->with('@skus', function ($browser) { | ->with('@skus', function ($browser) { | ||||
$browser->assertElementsCount('tbody tr', 5) | $browser->assertElementsCount('tbody tr', 6) | ||||
// 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', '4,44 CHF/month') | ->assertSeeIn('tbody tr:nth-child(1) td.price', '4,44 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 11 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 240 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') | ->click('@table tr:nth-child(2) a') | ||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
->with('@form', function (Browser $browser) { | ->with('@form', 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', 5) | ->assertElementsCount('tbody tr', 6) | ||||
// Mailbox SKU | // Mailbox SKU | ||||
->assertSeeIn('tbody tr:nth-child(1) td.price', '3,99 CHF/month¹') | ->assertSeeIn('tbody tr:nth-child(1) td.price', '3,99 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,56 CHF/month¹') | ->assertSeeIn('tr:nth-child(2) td.price', '21,56 CHF/month¹') | ||||
Show All 35 Lines | public function testBetaEntitlements(): void | ||||
$john = User::where('email', 'john@kolab.org')->first(); | $john = User::where('email', 'john@kolab.org')->first(); | ||||
$sku = Sku::where('title', 'beta')->first(); | $sku = Sku::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', 7) | $browser->assertElementsCount('tbody tr', 7) | ||||
// Beta SKU | // Beta/Meet SKU | ||||
->assertSeeIn('tbody tr:nth-child(6) td.name', 'Beta program') | ->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') | ->assertSeeIn('tr:nth-child(6) td.price', '0,00 CHF/month') | ||||
->assertChecked('tbody tr:nth-child(6) td.selection input') | ->assertNotChecked('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', | ||||
'Access to beta program subscriptions' | 'Video conferencing tool' | ||||
) | ) | ||||
// Beta/Meet SKU | // Beta SKU | ||||
->assertSeeIn('tbody tr:nth-child(7) td.name', 'Video chat') | ->assertSeeIn('tbody tr:nth-child(7) td.name', 'Private Beta (invitation only)') | ||||
->assertSeeIn('tr:nth-child(7) td.price', '0,00 CHF/month') | ->assertSeeIn('tbody tr:nth-child(7) td.price', '0,00 CHF/month') | ||||
->assertNotChecked('tbody tr:nth-child(7) td.selection input') | ->assertChecked('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', | ||||
'Video conferencing tool' | 'Access to the private beta program subscriptions' | ||||
) | ) | ||||
/* | |||||
// Check Meet, Uncheck Beta, expect Meet unchecked | // Check Meet, Uncheck Beta, expect Meet unchecked | ||||
->click('#sku-input-meet') | ->click('#sku-input-meet') | ||||
->click('#sku-input-beta') | ->click('#sku-input-beta') | ||||
->assertNotChecked('#sku-input-beta') | ->assertNotChecked('#sku-input-beta') | ||||
->assertNotChecked('#sku-input-meet') | ->assertNotChecked('#sku-input-meet') | ||||
// Click Meet expect an alert | // Click Meet expect an alert | ||||
->click('#sku-input-meet') | ->click('#sku-input-meet') | ||||
->assertDialogOpened('Video chat requires Beta program.') | ->assertDialogOpened('Video chat requires Beta program.') | ||||
->acceptDialog() | ->acceptDialog() | ||||
// Enable Meet and Beta and submit | */ | ||||
->click('#sku-input-beta') | // Enable Meet and submit | ||||
->click('#sku-input-meet'); | ->click('#sku-input-meet'); | ||||
}) | }) | ||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ||||
$expected = ['beta', 'groupware', 'mailbox', 'meet', 'storage', 'storage']; | $expected = ['beta', 'groupware', 'mailbox', 'meet', 'storage', 'storage']; | ||||
$this->assertUserEntitlements($john, $expected); | $this->assertUserEntitlements($john, $expected); | ||||
$browser->visit('/user/' . $john->id) | $browser->visit('/user/' . $john->id) | ||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
->click('#sku-input-beta') | ->click('#sku-input-beta') | ||||
->click('#sku-input-meet') | |||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ||||
$expected = ['groupware', 'mailbox', 'storage', 'storage']; | $expected = ['groupware', 'mailbox', 'storage', 'storage']; | ||||
$this->assertUserEntitlements($john, $expected); | $this->assertUserEntitlements($john, $expected); | ||||
}); | }); | ||||
} | } | ||||
} | } |