Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/Reseller/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('reseller@kolabnow.com', 'reseller', true) | ->submitLogon('reseller@' . \config('app.domain'), \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 51 Lines • ▼ Show 20 Lines | public function testBonusPenalty(): void | ||||
->waitUntilMissing('.app-loader') | ->waitUntilMissing('.app-loader') | ||||
->with('table', function (Browser $browser) { | ->with('table', function (Browser $browser) { | ||||
$browser->assertElementsCount('tbody tr', 3) | $browser->assertElementsCount('tbody tr', 3) | ||||
->assertMissing('tfoot') | ->assertMissing('tfoot') | ||||
->assertSeeIn('tbody tr:first-child td.description', 'Bonus: Test bonus') | ->assertSeeIn('tbody tr:first-child td.description', 'Bonus: Test bonus') | ||||
->assertSeeIn('tbody tr:first-child td.price', '12,34 CHF'); | ->assertSeeIn('tbody tr:first-child td.price', '12,34 CHF'); | ||||
if (!$browser->isPhone()) { | if (!$browser->isPhone()) { | ||||
$browser->assertSeeIn('tbody tr:first-child td.email', 'reseller@kolabnow.com'); | $browser->assertSeeIn('tbody tr:first-child td.email', 'reseller@' . \config('app.domain')); | ||||
} | } | ||||
}); | }); | ||||
$this->assertSame(1234, $john->wallets()->first()->balance); | $this->assertSame(1234, $john->wallets()->first()->balance); | ||||
// Test penalty | // Test penalty | ||||
$browser->click('@user-finances #button-penalty') | $browser->click('@user-finances #button-penalty') | ||||
// Test dialog content, and closing it with Cancel button | // Test dialog content, and closing it with Cancel button | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |