Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/WalletTest.php
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | class WalletTest extends TestCaseDusk | ||||
/** | /** | ||||
* Test wallet "box" on Dashboard | * Test wallet "box" on Dashboard | ||||
*/ | */ | ||||
public function testDashboard(): void | public function testDashboard(): void | ||||
{ | { | ||||
// Test that the page requires authentication | // Test that the page requires authentication | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit(new Home()) | $browser->visit(new Home()) | ||||
->submitLogon('john@kolab.org', 'simple123', true) | ->submitLogon('john@kolab.org', \App\Utils::generatePassphrase(), true) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertSeeIn('@links .link-wallet .name', 'Wallet') | ->assertSeeIn('@links .link-wallet .name', 'Wallet') | ||||
->assertSeeIn('@links .link-wallet .badge', '-12,34 CHF'); | ->assertSeeIn('@links .link-wallet .badge', '-12,34 CHF'); | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test wallet page | * Test wallet page | ||||
Show All 11 Lines | public function testWallet(): void | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test Receipts tab | * Test Receipts tab | ||||
*/ | */ | ||||
public function testReceipts(): void | public function testReceipts(): void | ||||
{ | { | ||||
$user = $this->getTestUser('wallets-controller@kolabnow.com', ['password' => 'simple123']); | $user = $this->getTestUser('wallets-controller@kolabnow.com', ['password' => \App\Utils::generatePassphrase()]); | ||||
$wallet = $user->wallets()->first(); | $wallet = $user->wallets()->first(); | ||||
$wallet->payments()->delete(); | $wallet->payments()->delete(); | ||||
// Log out John and log in the test user | // Log out John and log in the test user | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit('/logout') | $browser->visit('/logout') | ||||
->waitForLocation('/login') | ->waitForLocation('/login') | ||||
->on(new Home()) | ->on(new Home()) | ||||
->submitLogon('wallets-controller@kolabnow.com', 'simple123', true); | ->submitLogon('wallets-controller@kolabnow.com', \App\Utils::generatePassphrase(), true); | ||||
}); | }); | ||||
// Assert Receipts tab content when there's no receipts available | // Assert Receipts tab content when there's no receipts available | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->on(new Dashboard()) | $browser->on(new Dashboard()) | ||||
->click('@links .link-wallet') | ->click('@links .link-wallet') | ||||
->on(new WalletPage()) | ->on(new WalletPage()) | ||||
->assertSeeIn('#wallet .card-title', 'Account balance 0,00 CHF') | ->assertSeeIn('#wallet .card-title', 'Account balance 0,00 CHF') | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | public function testReceipts(): void | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test History tab | * Test History tab | ||||
*/ | */ | ||||
public function testHistory(): void | public function testHistory(): void | ||||
{ | { | ||||
$user = $this->getTestUser('wallets-controller@kolabnow.com', ['password' => 'simple123']); | $user = $this->getTestUser('wallets-controller@kolabnow.com', ['password' => \App\Utils::generatePassphrase()]); | ||||
// Log out John and log in the test user | // Log out John and log in the test user | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit('/logout') | $browser->visit('/logout') | ||||
->waitForLocation('/login') | ->waitForLocation('/login') | ||||
->on(new Home()) | ->on(new Home()) | ||||
->submitLogon('wallets-controller@kolabnow.com', 'simple123', true); | ->submitLogon('wallets-controller@kolabnow.com', \App\Utils::generatePassphrase(), true); | ||||
}); | }); | ||||
$package_kolab = \App\Package::where('title', 'kolab')->first(); | $package_kolab = \App\Package::where('title', 'kolab')->first(); | ||||
$user->assignPackage($package_kolab); | $user->assignPackage($package_kolab); | ||||
$wallet = $user->wallets()->first(); | $wallet = $user->wallets()->first(); | ||||
// Create some sample transactions | // Create some sample transactions | ||||
$transactions = $this->createTestTransactions($wallet); | $transactions = $this->createTestTransactions($wallet); | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | class WalletTest extends TestCaseDusk | ||||
/** | /** | ||||
* Test that non-controller user has no access to wallet | * Test that non-controller user has no access to wallet | ||||
*/ | */ | ||||
public function testAccessDenied(): void | public function testAccessDenied(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit('/logout') | $browser->visit('/logout') | ||||
->on(new Home()) | ->on(new Home()) | ||||
->submitLogon('jack@kolab.org', 'simple123', true) | ->submitLogon('jack@kolab.org', \App\Utils::generatePassphrase(), true) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertMissing('@links .link-wallet') | ->assertMissing('@links .link-wallet') | ||||
->visit('/wallet') | ->visit('/wallet') | ||||
->assertErrorPage(403, "Only account owners can access a wallet."); | ->assertErrorPage(403, "Only account owners can access a wallet."); | ||||
}); | }); | ||||
} | } | ||||
} | } |