test: the transfer tooltip, the cancel button and the opened notes row (#437)

Review 25443, point 2: the transfer icon's tooltip goes through t with
its account and direction (X4), LicenseKeyForm's cancel button through
t (X11), and the notes textarea opens under the row whose button was
clicked, read in the Fragment keyed by that row's id (X8).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
le king fu 2026-10-19 21:10:03 -04:00
parent 2389d51b48
commit 0df60f6042
3 changed files with 22 additions and 1 deletions

View file

@ -51,4 +51,8 @@ describe("LicenseKeyForm", () => {
expect(html).toContain('placeholder="t(license.keyPlaceholder)"'); expect(html).toContain('placeholder="t(license.keyPlaceholder)"');
expect(html).toMatch(/<button type="submit"[^>]*>t\(license\.activate\)<\/button>/); expect(html).toMatch(/<button type="submit"[^>]*>t\(license\.activate\)<\/button>/);
}); });
it("names the cancel button through t (#437)", () => {
expect(render(null)).toMatch(/<button type="button"[^>]*>t\(common\.cancel\)<\/button>/);
});
}); });

View file

@ -147,6 +147,10 @@ describe("TransactionTable — texts that go through t (#437)", () => {
const icon = 'aria-label="t(transactions.transferIcon.ariaLabel)"'; const icon = 'aria-label="t(transactions.transferIcon.ariaLabel)"';
expect(count(html, icon)).toBe(1); expect(count(html, icon)).toBe(1);
expect(bodyRows(html)[1]).toContain(icon); expect(bodyRows(html)[1]).toContain(icon);
// Its tooltip, the account and the direction of the link included.
expect(bodyRows(html)[1]).toContain(
'title="t(transactions.transferIcon.tooltip): CELI (t(balance.transfers.direction.in))"',
);
}); });
it("names every row's notes button through t", () => { it("names every row's notes button through t", () => {

View file

@ -9,7 +9,7 @@
// SplitButton (or to a row's notes button), then renders again to read what // SplitButton (or to a row's notes button), then renders again to read what
// opened. // opened.
import { describe, it, expect, vi, beforeEach } from "vitest"; import { describe, it, expect, vi, beforeEach } from "vitest";
import { isValidElement, type ReactElement, type ReactNode } from "react"; import { Fragment, isValidElement, type ReactElement, type ReactNode } from "react";
vi.mock("react", async (orig) => (await import("../../test/hookHarness")).fakeReact(await orig())); vi.mock("react", async (orig) => (await import("../../test/hookHarness")).fakeReact(await orig()));
vi.mock("react-i18next", async () => (await import("../../test/i18nMock")).i18nMock()); vi.mock("react-i18next", async () => (await import("../../test/i18nMock")).i18nMock());
@ -156,4 +156,17 @@ describe("TransactionTable — the notes row (#437)", () => {
expect(areas).toHaveLength(1); expect(areas).toHaveLength(1);
expect(areas[0].props.placeholder).toBe("t(transactions.notes.placeholder)"); expect(areas[0].props.placeholder).toBe("t(transactions.notes.placeholder)");
}); });
it("opens the notes of the row whose button was clicked, under that row", () => {
(notesButtons(render("open"))[1].props.onClick as () => void)();
// Each row and the rows it opens sit in a Fragment keyed by the row's id
// (the unkeyed ones are inside the cells).
const byRow = find(render("open"), Fragment)
.filter((row) => row.key !== null)
.map((row) => [row.key, find(row.props.children, "textarea").length]);
expect(byRow).toEqual([
["1", 0],
["2", 1],
]);
});
}); });