From 15126a494c716bc51f8288eae816d5a03a9d123e Mon Sep 17 00:00:00 2001 From: Jagadeeshftw <92681651+Jagadeeshftw@users.noreply.github.com> Date: Sat, 22 Aug 2026 14:32:14 -0700 Subject: [PATCH] test: use semantic settlement table queries --- src/components/SettlementTable.test.tsx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/components/SettlementTable.test.tsx b/src/components/SettlementTable.test.tsx index cfef701..0960acd 100644 --- a/src/components/SettlementTable.test.tsx +++ b/src/components/SettlementTable.test.tsx @@ -67,9 +67,8 @@ describe("SettlementTable sorting", () => { it("shows the amount and fee totals for the visible rows", () => { render(); - const totalRow = document.querySelector("tfoot tr"); - expect(totalRow).not.toBeNull(); - expect(within(totalRow!).getAllByRole("cell").map((cell) => cell.textContent)).toEqual([ + const totalRow = screen.getByRole("row", { name: /Total \(visible rows\)/ }); + expect(within(totalRow).getAllByRole("cell").map((cell) => cell.textContent)).toEqual([ "Total (visible rows)", "600", "6", @@ -261,15 +260,14 @@ describe("SettlementTable mobile layout", () => { render(); const cards = screen.getAllByTestId("settlement-card"); expect(cards).toHaveLength(settlements.length); - settlements.forEach((s) => { - const card = screen - .getByText(`Settlement #${s.id}`) - .closest('[data-testid="settlement-card"]'); + settlements.forEach((s, index) => { + const card = cards[index]; expect(card).toBeInTheDocument(); - expect(within(card!).getByText(s.anchor)).toBeInTheDocument(); - expect(within(card!).getByText(s.asset)).toBeInTheDocument(); - expect(within(card!).getByText(formatAmount(s.amount))).toBeInTheDocument(); - expect(within(card!).getByText(formatAmount(s.fee))).toBeInTheDocument(); + expect(within(card).getByRole("link", { name: `Settlement #${s.id}` })).toBeInTheDocument(); + expect(within(card).getByText(s.anchor)).toBeInTheDocument(); + expect(within(card).getByText(s.asset)).toBeInTheDocument(); + expect(within(card).getByText(formatAmount(s.amount))).toBeInTheDocument(); + expect(within(card).getByText(formatAmount(s.fee))).toBeInTheDocument(); }); }); });