Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UsersTest.php
Show First 20 Lines • Show All 646 Lines • ▼ Show 20 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::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', 8) | ||||
// Beta/Meet SKU | // Meet SKU | ||||
->assertSeeIn('tbody tr:nth-child(6) td.name', 'Voice & Video Conferencing (public beta)') | ->assertSeeIn('tbody tr:nth-child(6) td.name', 'Voice & Video Conferencing (public beta)') | ||||
->assertSeeIn('tr:nth-child(6) td.price', '0,00 CHF/month') | ->assertSeeIn('tr:nth-child(6) td.price', '0,00 CHF/month') | ||||
->assertNotChecked('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', | ||||
'Video conferencing tool' | 'Video conferencing tool' | ||||
) | ) | ||||
// Beta SKU | // Beta SKU | ||||
->assertSeeIn('tbody tr:nth-child(7) td.name', 'Private Beta (invitation only)') | ->assertSeeIn('tbody tr:nth-child(7) td.name', 'Private Beta (invitation only)') | ||||
->assertSeeIn('tbody tr:nth-child(7) td.price', '0,00 CHF/month') | ->assertSeeIn('tbody tr:nth-child(7) td.price', '0,00 CHF/month') | ||||
->assertChecked('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', | ||||
'Access to the private beta program subscriptions' | 'Access to the private beta program subscriptions' | ||||
) | ) | ||||
/* | // Distlist SKU | ||||
// Check Meet, Uncheck Beta, expect Meet unchecked | ->assertSeeIn('tbody tr:nth-child(8) td.name', 'Distribution lists') | ||||
->click('#sku-input-meet') | ->assertSeeIn('tr:nth-child(8) td.price', '0,00 CHF/month') | ||||
->assertNotChecked('tbody tr:nth-child(8) td.selection input') | |||||
->assertEnabled('tbody tr:nth-child(8) td.selection input') | |||||
->assertTip( | |||||
'tbody tr:nth-child(8) td.buttons button', | |||||
'Access to mail distribution lists' | |||||
) | |||||
// Check Distlist, Uncheck Beta, expect Distlist unchecked | |||||
->click('#sku-input-distlist') | |||||
->click('#sku-input-beta') | ->click('#sku-input-beta') | ||||
->assertNotChecked('#sku-input-beta') | ->assertNotChecked('#sku-input-beta') | ||||
->assertNotChecked('#sku-input-meet') | ->assertNotChecked('#sku-input-distlist') | ||||
// Click Meet expect an alert | // Click Distlist expect an alert | ||||
->click('#sku-input-meet') | ->click('#sku-input-distlist') | ||||
->assertDialogOpened('Video chat requires Beta program.') | ->assertDialogOpened('Distribution lists requires Private Beta (invitation only).') | ||||
->acceptDialog() | ->acceptDialog() | ||||
*/ | // Enable Beta and Distlist and submit | ||||
// Enable Meet and submit | ->click('#sku-input-beta') | ||||
->click('#sku-input-meet'); | ->click('#sku-input-distlist'); | ||||
}) | }) | ||||
->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', 'distlist', 'groupware', 'mailbox', '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); | ||||
}); | }); | ||||
// TODO: Test that the Distlist SKU is not available for users that aren't a group account owners | |||||
// TODO: Test that entitlements change has immediate effect on the available items in dashboard | |||||
// i.e. does not require a page reload nor re-login. | |||||
} | } | ||||
} | } |