Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/PaymentMollieTest.php
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | public function testAutoPaymentSetup(): void | ||||
$browser->visit(new Home()) | $browser->visit(new Home()) | ||||
->submitLogon('payment-test@kolabnow.com', 'simple123', true, ['paymentProvider' => 'mollie']) | ->submitLogon('payment-test@kolabnow.com', 'simple123', true, ['paymentProvider' => 'mollie']) | ||||
->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', 'Add auto-payment') | $browser->assertSeeIn('@title', 'Set up auto-payment') | ||||
->waitFor('#payment-method-selection #creditcard') | ->waitFor('#payment-method-selection #creditcard') | ||||
->assertMissing('#payment-method-selection #paypal') | ->assertMissing('#payment-method-selection #paypal') | ||||
->assertMissing('#payment-method-selection #banktransfer') | ->assertMissing('#payment-method-selection #banktransfer') | ||||
->click('#creditcard'); | ->click('#creditcard'); | ||||
}) | }) | ||||
->with(new Dialog('@payment-dialog'), function (Browser $browser) { | ->with(new Dialog('@payment-dialog'), function (Browser $browser) { | ||||
$browser->assertSeeIn('@title', 'Add auto-payment') | $browser->assertSeeIn('@title', 'Set up auto-payment') | ||||
->assertSeeIn('@body label[for="mandate_amount"]', 'Fill up by') | ->assertSeeIn('@body label[for="mandate_amount"]', 'Fill up by') | ||||
->assertValue('@body #mandate_amount', PaymentProvider::MIN_AMOUNT / 100) | ->assertValue('@body #mandate_amount', PaymentProvider::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 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | public function testAutoPaymentSetup(): void | ||||
}); | }); | ||||
// Test pending and failed mandate | // Test pending and failed mandate | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->on(new WalletPage()) | $browser->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', 'Add auto-payment') | $browser->assertSeeIn('@title', 'Set up auto-payment') | ||||
->waitFor('#payment-method-selection #creditcard') | ->waitFor('#payment-method-selection #creditcard') | ||||
->click('#creditcard'); | ->click('#creditcard'); | ||||
}) | }) | ||||
->with(new Dialog('@payment-dialog'), function (Browser $browser) { | ->with(new Dialog('@payment-dialog'), function (Browser $browser) { | ||||
$browser->assertSeeIn('@title', 'Add auto-payment') | $browser->assertSeeIn('@title', 'Set up auto-payment') | ||||
->assertSeeIn('@button-cancel', 'Cancel') | ->assertSeeIn('@button-cancel', 'Cancel') | ||||
->assertSeeIn('@button-action', 'Continue') | ->assertSeeIn('@button-action', 'Continue') | ||||
// Submit valid data | // Submit valid data | ||||
->type('@body #mandate_amount', '100') | ->type('@body #mandate_amount', '100') | ||||
->type('@body #mandate_balance', '0') | ->type('@body #mandate_balance', '0') | ||||
->click('@button-action'); | ->click('@button-action'); | ||||
}) | }) | ||||
->on(new PaymentMollie()) | ->on(new PaymentMollie()) | ||||
->submitValidCreditCard('open') | ->submitValidCreditCard('open') | ||||
->waitForLocation('/wallet') | ->waitForLocation('/wallet') | ||||
->visit('/wallet?paymentProvider=mollie') | ->visit('/wallet?paymentProvider=mollie') | ||||
->on(new WalletPage()) | ->on(new WalletPage()) | ||||
->assertSeeIn( | ->assertSeeIn( | ||||
'#mandate-info .alert-warning', | '#mandate-info .alert-warning', | ||||
'The setup of the automatic payment is still in progress.' | 'The setup of the automatic payment is still in progress.' | ||||
) | ) | ||||
// Delete the mandate | // Delete the mandate | ||||
->click('#mandate-info * button.btn-danger') | ->click('#mandate-info * button.btn-danger') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'The auto-payment has been removed.') | ->assertToast(Toast::TYPE_SUCCESS, 'The auto-payment has been removed.') | ||||
->assertMissing('@body #mandate-form .alert') | ->assertMissing('@body #mandate-form .alert') | ||||
// Create a new mandate | // Create a new mandate | ||||
->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', 'Add auto-payment') | $browser->assertSeeIn('@title', 'Set up auto-payment') | ||||
->waitFor('#payment-method-selection #creditcard') | ->waitFor('#payment-method-selection #creditcard') | ||||
->click('#creditcard'); | ->click('#creditcard'); | ||||
}) | }) | ||||
->with(new Dialog('@payment-dialog'), function (Browser $browser) { | ->with(new Dialog('@payment-dialog'), function (Browser $browser) { | ||||
$browser->assertSeeIn('@title', 'Add auto-payment') | $browser->assertSeeIn('@title', 'Set up auto-payment') | ||||
->assertSeeIn('@button-cancel', 'Cancel') | ->assertSeeIn('@button-cancel', 'Cancel') | ||||
->assertSeeIn('@button-action', 'Continue') | ->assertSeeIn('@button-action', 'Continue') | ||||
// Submit valid data | // Submit valid data | ||||
->type('@body #mandate_amount', '100') | ->type('@body #mandate_amount', '100') | ||||
->type('@body #mandate_balance', '0') | ->type('@body #mandate_balance', '0') | ||||
->click('@button-action'); | ->click('@button-action'); | ||||
}) | }) | ||||
->on(new PaymentMollie()) | ->on(new PaymentMollie()) | ||||
Show All 17 Lines |