Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/WalletTest.php
Show All 32 Lines | class WalletTest extends TestCaseDusk | ||||
*/ | */ | ||||
public function tearDown(): void | public function tearDown(): void | ||||
{ | { | ||||
$this->deleteTestUser('wallets-controller@kolabnow.com'); | $this->deleteTestUser('wallets-controller@kolabnow.com'); | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
Wallet::where('user_id', $john->id)->update(['balance' => 0]); | Wallet::where('user_id', $john->id)->update(['balance' => 0]); | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test wallet page (unauthenticated) | * Test wallet page (unauthenticated) | ||||
*/ | */ | ||||
public function testWalletUnauth(): void | public function testWalletUnauth(): void | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | public function testHistory(): void | ||||
->click('@links .link-wallet') | ->click('@links .link-wallet') | ||||
->on(new WalletPage()) | ->on(new WalletPage()) | ||||
->assertSeeIn('@nav #tab-history', 'History') | ->assertSeeIn('@nav #tab-history', 'History') | ||||
->click('@nav #tab-history') | ->click('@nav #tab-history') | ||||
->with('@history-tab', function (Browser $browser) use ($pages) { | ->with('@history-tab', function (Browser $browser) use ($pages) { | ||||
$browser->waitUntilMissing('.app-loader') | $browser->waitUntilMissing('.app-loader') | ||||
->assertElementsCount('table tbody tr', 10) | ->assertElementsCount('table tbody tr', 10) | ||||
->assertMissing('table td.email') | ->assertMissing('table td.email') | ||||
->assertSeeIn('#transactions-loader button', 'Load more'); | ->assertSeeIn('.more-loader button', 'Load more'); | ||||
foreach ($pages[0] as $idx => $transaction) { | foreach ($pages[0] as $idx => $transaction) { | ||||
$selector = 'table tbody tr:nth-child(' . ($idx + 1) . ')'; | $selector = 'table tbody tr:nth-child(' . ($idx + 1) . ')'; | ||||
$priceStyle = $transaction->type == Transaction::WALLET_AWARD ? 'text-success' : 'text-danger'; | $priceStyle = $transaction->type == Transaction::WALLET_AWARD ? 'text-success' : 'text-danger'; | ||||
$browser->assertSeeIn("$selector td.description", $transaction->shortDescription()) | $browser->assertSeeIn("$selector td.description", $transaction->shortDescription()) | ||||
->assertMissing("$selector td.selection button") | ->assertMissing("$selector td.selection button") | ||||
->assertVisible("$selector td.price.{$priceStyle}"); | ->assertVisible("$selector td.price.{$priceStyle}"); | ||||
// TODO: Test more transaction details | // TODO: Test more transaction details | ||||
} | } | ||||
// Load the next page | // Load the next page | ||||
$browser->click('#transactions-loader button') | $browser->click('.more-loader button') | ||||
->waitUntilMissing('.app-loader') | ->waitUntilMissing('.app-loader') | ||||
->assertElementsCount('table tbody tr', 12) | ->assertElementsCount('table tbody tr', 12) | ||||
->assertMissing('#transactions-loader button'); | ->assertMissing('.more-loader button'); | ||||
$debitEntry = null; | $debitEntry = null; | ||||
foreach ($pages[1] as $idx => $transaction) { | foreach ($pages[1] as $idx => $transaction) { | ||||
$selector = 'table tbody tr:nth-child(' . ($idx + 1 + 10) . ')'; | $selector = 'table tbody tr:nth-child(' . ($idx + 1 + 10) . ')'; | ||||
$priceStyle = $transaction->type == Transaction::WALLET_CREDIT ? 'text-success' : 'text-danger'; | $priceStyle = $transaction->type == Transaction::WALLET_CREDIT ? 'text-success' : 'text-danger'; | ||||
$browser->assertSeeIn("$selector td.description", $transaction->shortDescription()); | $browser->assertSeeIn("$selector td.description", $transaction->shortDescription()); | ||||
if ($transaction->type == Transaction::WALLET_DEBIT) { | if ($transaction->type == Transaction::WALLET_DEBIT) { | ||||
Show All 31 Lines |