From 542c87d929e621dd07c8405001938325d5840f5e Mon Sep 17 00:00:00 2001 From: mihir Date: Tue, 17 Nov 2026 14:11:34 +0530 Subject: [PATCH] test: stabilize partner order retries in CI 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. --- test/partner-orders.ui.test.tsx | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/test/partner-orders.ui.test.tsx b/test/partner-orders.ui.test.tsx index 80ab813..1366509 100644 --- a/test/partner-orders.ui.test.tsx +++ b/test/partner-orders.ui.test.tsx @@ -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");