Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/PaymentStripeTest.php
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | public function testPayment(): void | ||||
->type('@body #amount', '12.34') | ->type('@body #amount', '12.34') | ||||
// Note we use double click to assert it does not create redundant requests | // Note we use double click to assert it does not create redundant requests | ||||
->click('@button-action') | ->click('@button-action') | ||||
->click('@button-action'); | ->click('@button-action'); | ||||
}) | }) | ||||
->on(new PaymentStripe()) | ->on(new PaymentStripe()) | ||||
->assertSeeIn('@title', $user->tenant->title . ' Payment') | ->assertSeeIn('@title', $user->tenant->title . ' Payment') | ||||
->assertSeeIn('@amount', 'CHF 12.34') | ->assertSeeIn('@amount', 'CHF 12.34') | ||||
->assertValue('@email-input', $user->email) | ->assertSeeIn('@email', $user->email) | ||||
->submitValidCreditCard(); | ->submitValidCreditCard(); | ||||
// Now it should redirect back to wallet page and in background | // Now it should redirect back to wallet page and in background | ||||
// use the webhook to update payment status (and balance). | // use the webhook to update payment status (and balance). | ||||
// Looks like in test-mode the webhook is executed before redirect | // Looks like in test-mode the webhook is executed before redirect | ||||
// so we can expect balance updated on the wallet page | // so we can expect balance updated on the wallet page | ||||
Show All 18 Lines | public function testAutoPaymentSetup(): void | ||||
$this->browse(function (Browser $browser) use ($user) { | $this->browse(function (Browser $browser) use ($user) { | ||||
$browser->visit(new Home()) | $browser->visit(new Home()) | ||||
->submitLogon('payment-test@kolabnow.com', 'simple123', true, ['paymentProvider' => 'stripe']) | ->submitLogon('payment-test@kolabnow.com', 'simple123', true, ['paymentProvider' => 'stripe']) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->click('@links .link-wallet') | ->click('@links .link-wallet') | ||||
->on(new WalletPage()) | ->on(new WalletPage()) | ||||
->assertMissing('@body #mandate-form .alert') | ->assertMissing('@body #mandate-form .alert') | ||||
->click('@main #mandate-form button') | ->click('@main #mandate-form button') | ||||
/* | |||||
->with(new Dialog('@payment-dialog'), function (Browser $browser) { | ->with(new Dialog('@payment-dialog'), function (Browser $browser) { | ||||
$browser->assertSeeIn('@title', 'Set up auto-payment') | $browser->assertSeeIn('@title', 'Set up auto-payment') | ||||
->waitFor('#payment-method-selection .link-creditcard') | ->waitFor('#payment-method-selection .link-creditcard') | ||||
->assertMissing('#payment-method-selection .link-paypal') | ->assertMissing('#payment-method-selection .link-paypal') | ||||
->assertMissing('#payment-method-selection .link-banktransfer') | ->assertMissing('#payment-method-selection .link-banktransfer') | ||||
->click('#payment-method-selection .link-creditcard'); | ->click('#payment-method-selection .link-creditcard'); | ||||
}) | }) | ||||
*/ | |||||
->with(new Dialog('@payment-dialog'), function (Browser $browser) { | ->with(new Dialog('@payment-dialog'), function (Browser $browser) { | ||||
$browser->assertSeeIn('@title', 'Set up auto-payment') | $browser->assertSeeIn('@title', 'Set up auto-payment') | ||||
->waitFor('@body #mandate_amount') | |||||
->assertSeeIn('@body label[for="mandate_amount"]', 'Fill up by') | ->assertSeeIn('@body label[for="mandate_amount"]', 'Fill up by') | ||||
->assertValue('@body #mandate_amount', Payment::MIN_AMOUNT / 100) | ->assertValue('@body #mandate_amount', Payment::MIN_AMOUNT / 100) | ||||
->assertSeeIn('@body label[for="mandate_balance"]', 'when account balance is below') // phpcs:ignore | ->assertSeeIn('@body label[for="mandate_balance"]', 'when account balance is below') // phpcs:ignore | ||||
->assertValue('@body #mandate_balance', '0') | ->assertValue('@body #mandate_balance', '0') | ||||
->assertSeeIn('@button-cancel', 'Cancel') | ->assertSeeIn('@button-cancel', 'Cancel') | ||||
->assertSeeIn('@button-action', 'Continue') | ->assertSeeIn('@button-action', 'Continue') | ||||
// Test error handling | // Test error handling | ||||
->type('@body #mandate_amount', 'aaa') | ->type('@body #mandate_amount', 'aaa') | ||||
Show All 17 Lines | */ | ||||
->type('@body #mandate_balance', '0') | ->type('@body #mandate_balance', '0') | ||||
// Note we use double click to assert it does not create redundant requests | // Note we use double click to assert it does not create redundant requests | ||||
->click('@button-action') | ->click('@button-action') | ||||
->click('@button-action'); | ->click('@button-action'); | ||||
}) | }) | ||||
->on(new PaymentStripe()) | ->on(new PaymentStripe()) | ||||
->assertMissing('@title') | ->assertMissing('@title') | ||||
->assertMissing('@amount') | ->assertMissing('@amount') | ||||
->assertValue('@email-input', $user->email) | ->assertSeeIn('@email', $user->email) | ||||
->submitValidCreditCard() | ->submitValidCreditCard() | ||||
->waitForLocation('/wallet', 30) // need more time than default 5 sec. | ->waitForLocation('/wallet', 30) // need more time than default 5 sec. | ||||
->visit('/wallet?paymentProvider=stripe') | ->visit('/wallet?paymentProvider=stripe') | ||||
->waitFor('#mandate-info') | ->waitFor('#mandate-info') | ||||
->assertPresent('#mandate-info p:first-child') | ->assertPresent('#mandate-info p:first-child') | ||||
->assertSeeIn( | ->assertSeeIn( | ||||
'#mandate-info p:first-child', | '#mandate-info p:first-child', | ||||
'Auto-payment is set to fill up your account by 100 CHF ' . | 'Auto-payment is set to fill up your account by 100 CHF ' . | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |