Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UsersTest.php
Show All 36 Lines | public function setUp(): 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(); | ||||
Entitlement::where('cost', '>=', 5000)->delete(); | |||||
$wallet = $john->wallets()->first(); | $wallet = $john->wallets()->first(); | ||||
$wallet->discount()->dissociate(); | $wallet->discount()->dissociate(); | ||||
$wallet->save(); | $wallet->save(); | ||||
$this->clearBetaEntitlements(); | $this->clearBetaEntitlements(); | ||||
$this->clearMeetEntitlements(); | $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(); | ||||
Entitlement::where('cost', '>=', 5000)->delete(); | |||||
$wallet = $john->wallets()->first(); | $wallet = $john->wallets()->first(); | ||||
$wallet->discount()->dissociate(); | $wallet->discount()->dissociate(); | ||||
$wallet->save(); | $wallet->save(); | ||||
$this->clearBetaEntitlements(); | $this->clearBetaEntitlements(); | ||||
$this->clearMeetEntitlements(); | $this->clearMeetEntitlements(); | ||||
▲ Show 20 Lines • Show All 468 Lines • ▼ Show 20 Lines | public function testDiscountedPrices(): void | ||||
// SKUs on user edit page | // SKUs on user edit page | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit('/logout') | $browser->visit('/logout') | ||||
->on(new Home()) | ->on(new Home()) | ||||
->submitLogon('john@kolab.org', 'simple123', true) | ->submitLogon('john@kolab.org', 'simple123', true) | ||||
->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') // joe@kolab.org | ||||
->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', 6) | ->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', '22,05 CHF/month¹') | ||||
// groupware SKU | // groupware SKU | ||||
->assertSeeIn('tbody tr:nth-child(3) td.price', '4,99 CHF/month¹') | ->assertSeeIn('tbody tr:nth-child(3) td.price', '4,99 CHF/month¹') | ||||
// ActiveSync SKU | // ActiveSync SKU | ||||
->assertSeeIn('tbody tr:nth-child(4) td.price', '0,90 CHF/month¹') | ->assertSeeIn('tbody tr:nth-child(4) td.price', '0,90 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 9 Lines | public function testDiscountedPrices(): void | ||||
$browser->whenAvailable('@packages', function (Browser $browser) { | $browser->whenAvailable('@packages', function (Browser $browser) { | ||||
$browser->assertElementsCount('tbody tr', 2) | $browser->assertElementsCount('tbody tr', 2) | ||||
->assertSeeIn('tbody tr:nth-child(1) .price', '8,99 CHF/month¹') // Groupware | ->assertSeeIn('tbody tr:nth-child(1) .price', '8,99 CHF/month¹') // Groupware | ||||
->assertSeeIn('tbody tr:nth-child(2) .price', '3,99 CHF/month¹'); // Lite | ->assertSeeIn('tbody tr:nth-child(2) .price', '3,99 CHF/month¹'); // Lite | ||||
}) | }) | ||||
->assertSeeIn('@packages table + .hint', '¹ applied discount: 10% - Test voucher'); | ->assertSeeIn('@packages table + .hint', '¹ applied discount: 10% - Test voucher'); | ||||
}); | }); | ||||
}); | }); | ||||
// Test using entitlement cost instead of the SKU cost | |||||
$this->browse(function (Browser $browser) use ($wallet) { | |||||
$joe = User::where('email', 'joe@kolab.org')->first(); | |||||
$beta_sku = Sku::where('title', 'beta')->first(); | |||||
$storage_sku = Sku::where('title', 'storage')->first(); | |||||
// Add an extra storage and beta entitlement with different prices | |||||
Entitlement::create([ | |||||
'wallet_id' => $wallet->id, | |||||
'sku_id' => $beta_sku->id, | |||||
'cost' => 5010, | |||||
'entitleable_id' => $joe->id, | |||||
'entitleable_type' => User::class | |||||
]); | |||||
Entitlement::create([ | |||||
'wallet_id' => $wallet->id, | |||||
'sku_id' => $storage_sku->id, | |||||
'cost' => 5000, | |||||
'entitleable_id' => $joe->id, | |||||
'entitleable_type' => User::class | |||||
]); | |||||
$browser->visit('/user/' . $joe->id) | |||||
->on(new UserInfo()) | |||||
->with('@form', function (Browser $browser) { | |||||
$browser->whenAvailable('@skus', function (Browser $browser) { | |||||
$quota_input = new QuotaInput('tbody tr:nth-child(2) .range-input'); | |||||
$browser->waitFor('tbody tr') | |||||
// Beta SKU | |||||
->assertSeeIn('tbody tr:nth-child(7) td.price', '45,09 CHF/month¹') | |||||
// Storage SKU | |||||
->assertSeeIn('tr:nth-child(2) td.price', '45,00 CHF/month¹') | |||||
->with($quota_input, function (Browser $browser) { | |||||
$browser->setQuotaValue(4); | |||||
}) | |||||
->assertSeeIn('tr:nth-child(2) td.price', '45,22 CHF/month¹') | |||||
->with($quota_input, function (Browser $browser) { | |||||
$browser->setQuotaValue(2); | |||||
}) | |||||
->assertSeeIn('tr:nth-child(2) td.price', '0,00 CHF/month¹'); | |||||
}) | |||||
->assertSeeIn('@skus table + .hint', '¹ applied discount: 10% - Test voucher'); | |||||
}); | |||||
}); | |||||
} | } | ||||
/** | /** | ||||
* Test beta entitlements | * Test beta entitlements | ||||
* | * | ||||
* @depends testList | * @depends testList | ||||
*/ | */ | ||||
public function testBetaEntitlements(): void | public function testBetaEntitlements(): void | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |