Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/PaymentMollieTest.php
Show First 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | public function testAutoPaymentSetup(): void | ||||
->waitFor('#mandate-info') | ->waitFor('#mandate-info') | ||||
->assertSeeIn('#mandate-info p:first-child', $expected) | ->assertSeeIn('#mandate-info p:first-child', $expected) | ||||
->click('@button-cancel'); | ->click('@button-cancel'); | ||||
}); | }); | ||||
}); | }); | ||||
// Test updating auto-payment | // Test updating auto-payment | ||||
$this->browse(function (Browser $browser) use ($user) { | $this->browse(function (Browser $browser) use ($user) { | ||||
$browser->on(new WalletPage()) | $wallet = $user->wallets()->first(); | ||||
$wallet->setSetting('mandate_disabled', 1); | |||||
$browser->refresh() | |||||
->on(new WalletPage()) | |||||
->click('@main button') | ->click('@main button') | ||||
->with(new Dialog('@payment-dialog'), function (Browser $browser) { | ->with(new Dialog('@payment-dialog'), function (Browser $browser) use ($wallet) { | ||||
$browser->assertSeeIn('@body #mandate-info button.btn-primary', 'Change auto-payment') | $browser->waitFor('@body #mandate-info') | ||||
->assertSeeIn( | |||||
'@body #mandate-info p.disabled-mandate', | |||||
'The configured auto-payment has been disabled' | |||||
) | |||||
->assertSeeIn('@body #mandate-info button.btn-primary', 'Change auto-payment') | |||||
->click('@body #mandate-info button.btn-primary') | ->click('@body #mandate-info button.btn-primary') | ||||
->assertSeeIn('@title', 'Update auto-payment') | ->assertSeeIn('@title', 'Update auto-payment') | ||||
->assertSeeIn( | |||||
'@body form p.disabled-mandate', | |||||
'The auto-payment is disabled.' | |||||
) | |||||
->assertValue('@body #mandate_amount', '100') | ->assertValue('@body #mandate_amount', '100') | ||||
->assertValue('@body #mandate_balance', '0') | ->assertValue('@body #mandate_balance', '0') | ||||
->assertSeeIn('@button-cancel', 'Cancel') | ->assertSeeIn('@button-cancel', 'Cancel') | ||||
->assertSeeIn('@button-action', 'Submit') | ->assertSeeIn('@button-action', 'Submit') | ||||
// Test error handling | // Test error handling | ||||
->type('@body #mandate_amount', 'aaa') | ->type('@body #mandate_amount', 'aaa') | ||||
->click('@button-action') | ->click('@button-action') | ||||
->assertToast(Toast::TYPE_ERROR, 'Form validation error') | ->assertToast(Toast::TYPE_ERROR, 'Form validation error') | ||||
->assertVisible('@body #mandate_amount.is-invalid') | ->assertVisible('@body #mandate_amount.is-invalid') | ||||
->assertSeeIn('#mandate_amount + span + .invalid-feedback', 'The amount must be a number.') | ->assertSeeIn('#mandate_amount + span + .invalid-feedback', 'The amount must be a number.') | ||||
// Submit valid data | // Submit valid data | ||||
->type('@body #mandate_amount', '50') | ->type('@body #mandate_amount', '50') | ||||
->click('@button-action'); | ->click('@button-action'); | ||||
}) | }) | ||||
->waitUntilMissing('#payment-dialog') | ->waitUntilMissing('#payment-dialog') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'The auto-payment has been updated.'); | ->assertToast(Toast::TYPE_SUCCESS, 'The auto-payment has been updated.') | ||||
// Open the dialog again and make sure the "disabled" text isn't there | |||||
->click('@main button') | |||||
->with(new Dialog('@payment-dialog'), function (Browser $browser) use ($wallet) { | |||||
$browser->assertMissing('@body #mandate-info p.disabled-mandate') | |||||
->click('@body #mandate-info button.btn-primary') | |||||
->assertMissing('@body form p.disabled-mandate') | |||||
->click('@button-cancel'); | |||||
}); | |||||
}); | }); | ||||
// Test deleting auto-payment | // Test deleting auto-payment | ||||
$this->browse(function (Browser $browser) use ($user) { | $this->browse(function (Browser $browser) use ($user) { | ||||
$browser->on(new WalletPage()) | $browser->on(new WalletPage()) | ||||
->click('@main button') | ->click('@main button') | ||||
->with(new Dialog('@payment-dialog'), function (Browser $browser) { | ->with(new Dialog('@payment-dialog'), function (Browser $browser) { | ||||
$browser->assertSeeIn('@body #mandate-info button.btn-danger', 'Cancel auto-payment') | $browser->assertSeeIn('@body #mandate-info button.btn-danger', 'Cancel auto-payment') | ||||
->click('@body #mandate-info button.btn-danger') | ->click('@body #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.') | ||||
->assertVisible('@body #mandate-form') | ->assertVisible('@body #mandate-form') | ||||
->assertMissing('@body #mandate-info'); | ->assertMissing('@body #mandate-info'); | ||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
} | } |