Skip to content

Commit da518c1

Browse files
committed
test(a11y): cover icon control labels
1 parent 17f880b commit da518c1

3 files changed

Lines changed: 94 additions & 0 deletions

File tree

src/frontend/src/components/core/appHeaderComponent/__tests__/appHeader.a11y.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,13 @@ describe("AppHeader accessibility", () => {
6969
"aria-label",
7070
);
7171
});
72+
73+
it("should_name_home_logo_button", () => {
74+
renderHeader();
75+
76+
expect(screen.getByTestId("icon-ChevronLeft")).toHaveAttribute(
77+
"aria-label",
78+
"Langflow Logo",
79+
);
80+
});
7281
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { render, screen } from "@testing-library/react";
2+
import type { ReactNode } from "react";
3+
import { AddFolderButton } from "../add-folder-button";
4+
import { UploadFolderButton } from "../upload-folder-button";
5+
6+
jest.mock("react-i18next", () => ({
7+
initReactI18next: {
8+
type: "3rdParty",
9+
init: jest.fn(),
10+
},
11+
useTranslation: () => ({
12+
t: (key: string) => key,
13+
}),
14+
}));
15+
16+
jest.mock("@/components/common/genericIconComponent", () => ({
17+
__esModule: true,
18+
default: ({ name }: { name: string }) => (
19+
<span data-testid={`icon-${name}`} />
20+
),
21+
}));
22+
23+
jest.mock("@/components/common/shadTooltipComponent", () => ({
24+
__esModule: true,
25+
default: ({ children }: { children: ReactNode }) => <>{children}</>,
26+
}));
27+
28+
describe("folder action buttons", () => {
29+
it("names the create project button", () => {
30+
render(
31+
<AddFolderButton onClick={jest.fn()} disabled={false} loading={false} />,
32+
);
33+
34+
expect(
35+
screen.getByRole("button", { name: "folder.createNewProject" }),
36+
).toBeInTheDocument();
37+
});
38+
39+
it("names the upload flow button", () => {
40+
render(<UploadFolderButton onClick={jest.fn()} disabled={false} />);
41+
42+
expect(
43+
screen.getByRole("button", { name: "folder.uploadFlow" }),
44+
).toBeInTheDocument();
45+
});
46+
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { render, screen } from "@testing-library/react";
2+
import type { ReactNode } from "react";
3+
import { ToolbarButton } from "../toolbar-button";
4+
5+
jest.mock("@/components/common/genericIconComponent", () => ({
6+
ForwardedIconComponent: ({ name }: { name: string }) => (
7+
<span data-testid={`icon-${name}`} />
8+
),
9+
}));
10+
11+
jest.mock("@/components/common/shadTooltipComponent", () => ({
12+
__esModule: true,
13+
default: ({ children }: { children: ReactNode }) => <>{children}</>,
14+
}));
15+
16+
jest.mock("../../shortcutDisplay", () => ({
17+
__esModule: true,
18+
default: ({ name }: { name?: string }) => <span>{name}</span>,
19+
}));
20+
21+
describe("ToolbarButton", () => {
22+
it("uses the visible label as its accessible name", () => {
23+
render(<ToolbarButton icon="FileText" label="Docs" onClick={jest.fn()} />);
24+
25+
expect(screen.getByRole("button", { name: "Docs" })).toBeInTheDocument();
26+
});
27+
28+
it("falls back to the shortcut name for icon-only actions", () => {
29+
render(
30+
<ToolbarButton
31+
icon="Snowflake"
32+
shortcut={{ name: "Freeze", shortcut: "F" }}
33+
onClick={jest.fn()}
34+
/>,
35+
);
36+
37+
expect(screen.getByRole("button", { name: "Freeze" })).toBeInTheDocument();
38+
});
39+
});

0 commit comments

Comments
 (0)