test: stabilize partner order retries in CI
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Set fixture field values directly to avoid per-keystroke scheduling delays. Verify the original request before exercising retry and keep the exact payload and idempotency-key replay assertions.
This commit is contained in:
parent
770b8e0727
commit
542c87d929
|
|
@ -1,5 +1,5 @@
|
|||
import { type ReactNode } from "react";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { ThemeProvider } from "@mui/material/styles";
|
||||
|
|
@ -97,14 +97,21 @@ test("conversion retries the same accepted quote, reference, note, and key after
|
|||
|
||||
const user = userEvent.setup();
|
||||
await user.click(screen.getByRole("button", { name: "Test login" }));
|
||||
await user.type(await screen.findByRole("textbox", { name: /Partner reference/ }), order.partnerReference);
|
||||
await user.type(screen.getByRole("textbox", { name: /Order note/ }), order.note);
|
||||
fireEvent.change(await screen.findByRole("textbox", { name: /Partner reference/ }), {
|
||||
target: { value: order.partnerReference },
|
||||
});
|
||||
fireEvent.change(screen.getByRole("textbox", { name: /Order note/ }), {
|
||||
target: { value: order.note },
|
||||
});
|
||||
await user.click(screen.getByRole("button", { name: "Record partner order" }));
|
||||
expect(attempts).toEqual([{
|
||||
quoteId, partnerReference: order.partnerReference, note: order.note, idempotencyKey: expect.any(String),
|
||||
}]);
|
||||
|
||||
await user.click(await screen.findByRole("button", { name: "Retry partner order" }));
|
||||
await screen.findByRole("button", { name: "Cancel partner order" });
|
||||
|
||||
expect(location.pathname).toBe(`${route}/${orderId}`);
|
||||
expect(attempts[0]).toEqual({ quoteId, partnerReference: order.partnerReference, note: order.note, idempotencyKey: expect.any(String) });
|
||||
expect(attempts).toEqual([attempts[0], attempts[0]]);
|
||||
});
|
||||
|
||||
|
|
@ -128,13 +135,14 @@ test("a received partner order can be cancelled and the same cancellation key ca
|
|||
|
||||
const user = userEvent.setup();
|
||||
await user.click(screen.getByRole("button", { name: "Test login" }));
|
||||
await user.type(await screen.findByRole("textbox", { name: /Cancellation reason/ }), reason);
|
||||
fireEvent.change(await screen.findByRole("textbox", { name: /Cancellation reason/ }), { target: { value: reason } });
|
||||
await user.click(screen.getByRole("button", { name: "Cancel partner order" }));
|
||||
expect(attempts).toEqual([{ reason, idempotencyKey: expect.any(String) }]);
|
||||
|
||||
await user.click(await screen.findByRole("button", { name: "Retry cancellation" }));
|
||||
await screen.findByText(new RegExp(reason));
|
||||
|
||||
expect(screen.queryByRole("button", { name: "Cancel partner order" })).toBeNull();
|
||||
expect(attempts[0]).toEqual({ reason, idempotencyKey: expect.any(String) });
|
||||
expect(attempts).toEqual([attempts[0], attempts[0]]);
|
||||
});
|
||||
|
||||
|
|
@ -172,7 +180,9 @@ test("a cancellation blocked by an active receipt keeps the saved order and expl
|
|||
|
||||
const user = userEvent.setup();
|
||||
await user.click(screen.getByRole("button", { name: "Test login" }));
|
||||
await user.type(await screen.findByRole("textbox", { name: /Cancellation reason/ }), "Partner changed the order");
|
||||
fireEvent.change(await screen.findByRole("textbox", { name: /Cancellation reason/ }), {
|
||||
target: { value: "Partner changed the order" },
|
||||
});
|
||||
await user.click(screen.getByRole("button", { name: "Cancel partner order" }));
|
||||
|
||||
await screen.findByText("Reverse active payments before cancelling the order");
|
||||
|
|
|
|||
Loading…
Reference in New Issue