Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/Admin/UserFinancesTest.php
Show All 24 Lines | public function setUp(): void | ||||
parent::setUp(); | parent::setUp(); | ||||
self::useAdminUrl(); | self::useAdminUrl(); | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$wallet = $john->wallets()->first(); | $wallet = $john->wallets()->first(); | ||||
$wallet->discount()->dissociate(); | $wallet->discount()->dissociate(); | ||||
$wallet->balance = 0; | $wallet->balance = 0; | ||||
$wallet->save(); | $wallet->save(); | ||||
$wallet->setSettings(['mollie_id' => null, 'stripe_id' => null]); | |||||
} | } | ||||
/** | /** | ||||
* Test Finances tab (and transactions) | * Test Finances tab (and transactions) | ||||
*/ | */ | ||||
public function testFinances(): void | public function testFinances(): void | ||||
{ | { | ||||
// Assert Jack's Finances tab | // Assert Jack's Finances tab | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$jack = $this->getTestUser('jack@kolab.org'); | $jack = $this->getTestUser('jack@kolab.org'); | ||||
$jack->wallets()->first()->transactions()->delete(); | $wallet = $jack->wallets()->first(); | ||||
$wallet->transactions()->delete(); | |||||
$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', 'jeroen', 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') | ||||
->with('form', function (Browser $browser) { | ->with('form', function (Browser $browser) { | ||||
$payment_provider = ucfirst(\config('services.payment_provider')); | |||||
$browser->assertElementsCount('.row', 2) | $browser->assertElementsCount('.row', 2) | ||||
->assertSeeIn('.row:nth-child(1) label', 'Discount') | ->assertSeeIn('.row:nth-child(1) label', 'Discount') | ||||
->assertSeeIn('.row:nth-child(1) #discount span', 'none') | ->assertSeeIn('.row:nth-child(1) #discount span', 'none') | ||||
->assertSeeIn('.row:nth-child(2) label', $payment_provider . ' ID') | ->assertSeeIn('.row:nth-child(2) label', 'Stripe ID') | ||||
->assertVisible('.row:nth-child(2) a'); | ->assertSeeIn('.row:nth-child(2) a', 'abc'); | ||||
}) | }) | ||||
->assertSeeIn('h2:nth-of-type(2)', 'Transactions') | ->assertSeeIn('h2:nth-of-type(2)', 'Transactions') | ||||
->with('table', function (Browser $browser) { | ->with('table', function (Browser $browser) { | ||||
$browser->assertMissing('tbody') | $browser->assertMissing('tbody') | ||||
->assertSeeIn('tfoot td', "There are no transactions for this account."); | ->assertSeeIn('tfoot td', "There are no transactions for this account."); | ||||
}) | }) | ||||
->assertMissing('table + button'); | ->assertMissing('table + button'); | ||||
}); | }); | ||||
Show All 25 Lines | public function testFinances(): void | ||||
// Click the managed-by link on Jack's page | // Click the managed-by link on Jack's page | ||||
$browser->click('@user-info #manager a') | $browser->click('@user-info #manager a') | ||||
->on($page) | ->on($page) | ||||
->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-danger', '-20,10 CHF') | ->assertSeeIn('.card-title:first-child .text-danger', '-20,10 CHF') | ||||
->with('form', function (Browser $browser) { | ->with('form', function (Browser $browser) { | ||||
$browser->assertElementsCount('.row', 2) | $browser->assertElementsCount('.row', 1) | ||||
->assertSeeIn('.row:nth-child(1) label', 'Discount') | ->assertSeeIn('.row:nth-child(1) label', 'Discount') | ||||
->assertSeeIn('.row:nth-child(1) #discount span', '10% - Test voucher'); | ->assertSeeIn('.row:nth-child(1) #discount span', '10% - Test voucher'); | ||||
}) | }) | ||||
->assertSeeIn('h2:nth-of-type(2)', 'Transactions') | ->assertSeeIn('h2:nth-of-type(2)', 'Transactions') | ||||
->with('table', function (Browser $browser) { | ->with('table', function (Browser $browser) { | ||||
$browser->assertElementsCount('tbody tr', 2) | $browser->assertElementsCount('tbody tr', 2) | ||||
->assertMissing('tfoot') | ->assertMissing('tfoot') | ||||
->assertSeeIn('tbody tr:last-child td.email', 'jeroen@jeroen.jeroen'); | ->assertSeeIn('tbody tr:last-child td.email', 'jeroen@jeroen.jeroen'); | ||||
Show All 9 Lines | public function testFinances(): void | ||||
$browser->click('@nav #tab-users') | $browser->click('@nav #tab-users') | ||||
->click('@user-users tbody tr:nth-child(3) td:first-child a') | ->click('@user-users tbody tr:nth-child(3) td:first-child a') | ||||
->on($page) | ->on($page) | ||||
->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') | ||||
->with('form', function (Browser $browser) { | ->with('form', function (Browser $browser) { | ||||
$browser->assertElementsCount('.row', 2) | $browser->assertElementsCount('.row', 1) | ||||
->assertSeeIn('.row:nth-child(1) label', 'Discount') | ->assertSeeIn('.row:nth-child(1) label', 'Discount') | ||||
->assertSeeIn('.row:nth-child(1) #discount span', 'none'); | ->assertSeeIn('.row:nth-child(1) #discount span', 'none'); | ||||
}) | }) | ||||
->assertSeeIn('h2:nth-of-type(2)', 'Transactions') | ->assertSeeIn('h2:nth-of-type(2)', 'Transactions') | ||||
->with('table', function (Browser $browser) { | ->with('table', function (Browser $browser) { | ||||
$browser->assertMissing('tbody') | $browser->assertMissing('tbody') | ||||
->assertSeeIn('tfoot td', "There are no transactions for this account."); | ->assertSeeIn('tfoot td', "There are no transactions for this account."); | ||||
}) | }) | ||||
▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines |