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(); }); }); });