Merge pull request 'test: stabilize partner order retries in CI' (#27) from fix/partner-order-ci into main
continuous-integration/drone/push Build is failing Details

Reviewed-on: #27
This commit is contained in:
Mihir Motiyani 2026-11-17 14:18:06 +05:30
commit d01de1dfbf
1 changed files with 17 additions and 7 deletions

View File

@ -1,5 +1,5 @@
import { type ReactNode } from "react"; 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 userEvent from "@testing-library/user-event";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ThemeProvider } from "@mui/material/styles"; 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(); const user = userEvent.setup();
await user.click(screen.getByRole("button", { name: "Test login" })); await user.click(screen.getByRole("button", { name: "Test login" }));
await user.type(await screen.findByRole("textbox", { name: /Partner reference/ }), order.partnerReference); fireEvent.change(await screen.findByRole("textbox", { name: /Partner reference/ }), {
await user.type(screen.getByRole("textbox", { name: /Order note/ }), order.note); 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" })); 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 user.click(await screen.findByRole("button", { name: "Retry partner order" }));
await screen.findByRole("button", { name: "Cancel partner order" }); await screen.findByRole("button", { name: "Cancel partner order" });
expect(location.pathname).toBe(`${route}/${orderId}`); 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]]); 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(); const user = userEvent.setup();
await user.click(screen.getByRole("button", { name: "Test login" })); 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" })); 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 user.click(await screen.findByRole("button", { name: "Retry cancellation" }));
await screen.findByText(new RegExp(reason)); await screen.findByText(new RegExp(reason));
expect(screen.queryByRole("button", { name: "Cancel partner order" })).toBeNull(); 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]]); 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(); const user = userEvent.setup();
await user.click(screen.getByRole("button", { name: "Test login" })); 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 user.click(screen.getByRole("button", { name: "Cancel partner order" }));
await screen.findByText("Reverse active payments before cancelling the order"); await screen.findByText("Reverse active payments before cancelling the order");