Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/Admin/UserFinancesTest.php
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | public function testFinances(): void | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$jack = $this->getTestUser('jack@kolab.org'); | $jack = $this->getTestUser('jack@kolab.org'); | ||||
$wallet = $jack->wallets()->first(); | $wallet = $jack->wallets()->first(); | ||||
$wallet->transactions()->delete(); | $wallet->transactions()->delete(); | ||||
$wallet->setSetting('stripe_id', 'abc'); | $wallet->setSetting('stripe_id', 'abc'); | ||||
$page = new UserPage($jack->id); | $page = new UserPage($jack->id); | ||||
$browser->visit(new Home()) | $browser->visit(new Home()) | ||||
->submitLogon('jeroen@jeroen.jeroen', 'jeroen', true) | ->submitLogon('jeroen@jeroen.jeroen', \App\Utils::generatePassphrase(), true) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->visit($page) | ->visit($page) | ||||
->on($page) | ->on($page) | ||||
->assertSeeIn('@nav #tab-finances', 'Finances') | ->assertSeeIn('@nav #tab-finances', 'Finances') | ||||
->with('@user-finances', function (Browser $browser) { | ->with('@user-finances', function (Browser $browser) { | ||||
$browser->waitUntilMissing('.app-loader') | $browser->waitUntilMissing('.app-loader') | ||||
->assertSeeIn('.card-title:first-child', 'Account balance') | ->assertSeeIn('.card-title:first-child', 'Account balance') | ||||
->assertSeeIn('.card-title:first-child .text-success', '0,00 CHF') | ->assertSeeIn('.card-title:first-child .text-success', '0,00 CHF') | ||||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | public function testWalletDiscount(): void | ||||
$browser->click('@body select') | $browser->click('@body select') | ||||
->click('@body select option:nth-child(2)') | ->click('@body select option:nth-child(2)') | ||||
->click('@button-action'); | ->click('@button-action'); | ||||
}) | }) | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User wallet updated successfully.') | ->assertToast(Toast::TYPE_SUCCESS, 'User wallet updated successfully.') | ||||
->assertSeeIn('#discount span', '10% - Test voucher') | ->assertSeeIn('#discount span', '10% - Test voucher') | ||||
->click('@nav #tab-subscriptions') | ->click('@nav #tab-subscriptions') | ||||
->with('@user-subscriptions', function (Browser $browser) { | ->with('@user-subscriptions', function (Browser $browser) { | ||||
$browser->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '3,99 CHF/month¹') | $browser->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '4,50 CHF/month¹') | ||||
->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '0,00 CHF/month¹') | ->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '0,00 CHF/month¹') | ||||
->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '4,99 CHF/month¹') | ->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '4,41 CHF/month¹') | ||||
->assertSeeIn('table + .hint', '¹ applied discount: 10% - Test voucher'); | ->assertSeeIn('table + .hint', '¹ applied discount: 10% - Test voucher'); | ||||
}) | }) | ||||
// Change back to 'none' | // Change back to 'none' | ||||
->click('@nav #tab-finances') | ->click('@nav #tab-finances') | ||||
->click('@user-finances #discount button') | ->click('@user-finances #discount button') | ||||
->with(new Dialog('#discount-dialog'), function (Browser $browser) { | ->with(new Dialog('#discount-dialog'), function (Browser $browser) { | ||||
$browser->click('@body select') | $browser->click('@body select') | ||||
->click('@body select option:nth-child(1)') | ->click('@body select option:nth-child(1)') | ||||
->click('@button-action'); | ->click('@button-action'); | ||||
}) | }) | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User wallet updated successfully.') | ->assertToast(Toast::TYPE_SUCCESS, 'User wallet updated successfully.') | ||||
->assertSeeIn('#discount span', 'none') | ->assertSeeIn('#discount span', 'none') | ||||
->click('@nav #tab-subscriptions') | ->click('@nav #tab-subscriptions') | ||||
->with('@user-subscriptions', function (Browser $browser) { | ->with('@user-subscriptions', function (Browser $browser) { | ||||
$browser->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '4,44 CHF/month') | $browser->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '5,00 CHF/month') | ||||
->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '0,00 CHF/month') | ->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '0,00 CHF/month') | ||||
->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '5,55 CHF/month') | ->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '4,90 CHF/month') | ||||
->assertMissing('table + .hint'); | ->assertMissing('table + .hint'); | ||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test awarding/penalizing a wallet | * Test awarding/penalizing a wallet | ||||
* | * | ||||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |