merchant-backoffice

ZZZ: Inactive/Deprecated
Log | Files | Refs | Submodules | README

commit 8003d414e0a2013e0491e8d33801a2c7db27c39b
parent ee6e662d4838f5d0c48d7de589bb1f287ef99807
Author: ms <ms@taler.net>
Date:   Mon, 20 Dec 2021 11:16:40 +0100

bank: test withdrawal abort

Diffstat:
Mpackages/bank/tests/__tests__/homepage.js | 30++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/packages/bank/tests/__tests__/homepage.js b/packages/bank/tests/__tests__/homepage.js @@ -83,6 +83,28 @@ describe("withdraw", () => { await screen.findByText("gave response error", {exact: false}) }) + test("Abort withdrawal", async () => { + let withdrawButton = screen.getByText("Charge Taler wallet"); + fetch.once(JSON.stringify({ + taler_withdraw_uri: "taler://withdraw/foo", + withdrawal_id: "foo" + })); + /** + * After triggering a withdrawal, check if the taler://withdraw URI + * rendered, and confirm if so. Lastly, check that a success message + * appeared on the screen. + */ + fireEvent.click(withdrawButton); + const abortButton = await screen.findByText("abort withdrawal", {exact: false}) + fireEvent.click(abortButton); + expect(fetch).toHaveBeenLastCalledWith( + `http://localhost/demobanks/default/access-api/accounts/${context.username}/withdrawals/foo/abort`, + expect.anything() + ) + await waitFor(() => expect( + screen.queryByText("abort withdrawal", {exact: false})).not.toBeInTheDocument()); + }) + test("Successful withdrawal creation and confirmation", async () => { let withdrawButton = screen.getByText("Charge Taler wallet"); fetch.once(JSON.stringify({ @@ -103,10 +125,7 @@ describe("withdraw", () => { // assume wallet POSTed the payment details. const confirmButton = await screen.findByText("confirm withdrawal", {exact: false}) await waitFor(() => expect( - screen.queryByText( - "charge taler wallet", - {exact: false})).not.toBeInTheDocument() - ); + screen.queryByText("charge taler wallet", {exact: false})).not.toBeInTheDocument()); fetch.once("{}") fireEvent.click(confirmButton); /** @@ -124,6 +143,9 @@ describe("withdraw", () => { "give this address to the taler wallet", {exact: false})).not.toBeInTheDocument() ); + expect(fetch).toHaveBeenLastCalledWith( + `http://localhost/demobanks/default/access-api/accounts/${context.username}/withdrawals/foo/confirm`, + expect.anything()) // success message await screen.findByText("withdrawal confirmed", {exact: false})