Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UsersTest.php
Show All 10 Lines | |||||
use Tests\Browser\Components\Dialog; | use Tests\Browser\Components\Dialog; | ||||
use Tests\Browser\Components\ListInput; | use Tests\Browser\Components\ListInput; | ||||
use Tests\Browser\Components\QuotaInput; | use Tests\Browser\Components\QuotaInput; | ||||
use Tests\Browser\Components\Toast; | use Tests\Browser\Components\Toast; | ||||
use Tests\Browser\Pages\Dashboard; | use Tests\Browser\Pages\Dashboard; | ||||
use Tests\Browser\Pages\Home; | use Tests\Browser\Pages\Home; | ||||
use Tests\Browser\Pages\UserInfo; | use Tests\Browser\Pages\UserInfo; | ||||
use Tests\Browser\Pages\UserList; | use Tests\Browser\Pages\UserList; | ||||
use Tests\Browser\Pages\Wallet as WalletPage; | |||||
use Tests\TestCaseDusk; | use Tests\TestCaseDusk; | ||||
use Illuminate\Foundation\Testing\DatabaseMigrations; | use Illuminate\Foundation\Testing\DatabaseMigrations; | ||||
class UsersTest extends TestCaseDusk | class UsersTest extends TestCaseDusk | ||||
{ | { | ||||
private $profile = [ | private $profile = [ | ||||
'first_name' => 'John', | 'first_name' => 'John', | ||||
'last_name' => 'Doe', | 'last_name' => 'Doe', | ||||
Show All 18 Lines | public function setUp(): void | ||||
$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(); | $this->clearMeetEntitlements(); | ||||
} | } | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
▲ Show 20 Lines • Show All 614 Lines • ▼ Show 20 Lines | public function testDiscountedPrices(): void | ||||
->assertSeeIn('tr:nth-child(2) td.price', '0,00 CHF/month¹'); | ->assertSeeIn('tr:nth-child(2) td.price', '0,00 CHF/month¹'); | ||||
}) | }) | ||||
->assertSeeIn('@skus table + .hint', '¹ applied discount: 10% - Test voucher'); | ->assertSeeIn('@skus table + .hint', '¹ applied discount: 10% - Test voucher'); | ||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test non-default currency in the UI | |||||
*/ | |||||
public function testCurrency(): void | |||||
{ | |||||
// Add 10% discount | |||||
$john = User::where('email', 'john@kolab.org')->first(); | |||||
$wallet = $john->wallet(); | |||||
$wallet->balance = -1000; | |||||
$wallet->currency = 'EUR'; | |||||
$wallet->save(); | |||||
// On Dashboard and the wallet page | |||||
$this->browse(function (Browser $browser) { | |||||
$browser->visit('/logout') | |||||
->on(new Home()) | |||||
->submitLogon('john@kolab.org', 'simple123', true) | |||||
->on(new Dashboard()) | |||||
->assertSeeIn('@links .link-wallet .badge', '-10,00 €') | |||||
->click('@links .link-wallet') | |||||
->on(new WalletPage()) | |||||
->assertSeeIn('#wallet .card-title', 'Account balance -10,00 €'); | |||||
}); | |||||
// SKUs on user edit page | |||||
$this->browse(function (Browser $browser) { | |||||
$browser->visit(new UserList()) | |||||
->waitFor('@table tr:nth-child(2)') | |||||
->click('@table tr:nth-child(2) a') // joe@kolab.org | |||||
->on(new UserInfo()) | |||||
->with('@general', function (Browser $browser) { | |||||
$browser->whenAvailable('@skus', function (Browser $browser) { | |||||
$quota_input = new QuotaInput('tbody tr:nth-child(2) .range-input'); | |||||
$browser->waitFor('tbody tr') | |||||
->assertElementsCount('tbody tr', 6) | |||||
// Mailbox SKU | |||||
->assertSeeIn('tbody tr:nth-child(1) td.price', '5,00 €/month') | |||||
// Storage SKU | |||||
->assertSeeIn('tr:nth-child(2) td.price', '0,00 €/month') | |||||
->with($quota_input, function (Browser $browser) { | |||||
$browser->setQuotaValue(100); | |||||
}) | |||||
->assertSeeIn('tr:nth-child(2) td.price', '23,75 €/month'); | |||||
}); | |||||
}); | |||||
}); | |||||
// Packages on new user page | |||||
$this->browse(function (Browser $browser) { | |||||
$browser->visit(new UserList()) | |||||
->click('button.create-user') | |||||
->on(new UserInfo()) | |||||
->with('@general', function (Browser $browser) { | |||||
$browser->whenAvailable('@packages', function (Browser $browser) { | |||||
$browser->assertElementsCount('tbody tr', 2) | |||||
->assertSeeIn('tbody tr:nth-child(1) .price', '9,90 €/month') // Groupware | |||||
->assertSeeIn('tbody tr:nth-child(2) .price', '5,00 €/month'); // Lite | |||||
}); | |||||
}); | |||||
}); | |||||
} | |||||
/** | |||||
* Test beta entitlements | * Test beta entitlements | ||||
* | * | ||||
* @depends testList | * @depends testList | ||||
*/ | */ | ||||
public function testBetaEntitlements(): void | 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(); | ||||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |