Skip to content

Commit 790bed4

Browse files
committed
fix: update tests to match accessibility improvements
- Image.test.ts: add interactive={true} prop since Image now only renders as button when interactive - TopBar.test.ts: replace tabindex checks with disabled attribute checks for semantic button elements - TopBar.test.ts: update test name and use click instead of keyboard event (native buttons handle keyboard automatically)
1 parent d34ee81 commit 790bed4

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/ui/PodcastView/TopBar.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ describe("TopBar", () => {
2020

2121
expect(grid.className).toContain("topbar-selected");
2222
expect(episode.className).toContain("topbar-selectable");
23-
expect(episode.getAttribute("tabindex")).toBe("0");
24-
expect(player.getAttribute("tabindex")).toBe("-1");
23+
expect(episode).not.toBeDisabled();
24+
expect(player).toBeDisabled();
2525
expect(player.className).not.toContain("topbar-selectable");
2626
});
2727

@@ -43,7 +43,7 @@ describe("TopBar", () => {
4343
expect(playerButton.className).not.toContain("topbar-selected");
4444
});
4545

46-
test("keeps controls unfocusable when view is unavailable", () => {
46+
test("keeps controls disabled when view is unavailable", () => {
4747
const { getByLabelText } = render(TopBar, {
4848
props: {
4949
viewState: ViewState.PodcastGrid,
@@ -55,12 +55,12 @@ describe("TopBar", () => {
5555
const episodeButton = getByLabelText("Episode list");
5656
const playerButton = getByLabelText("Player");
5757

58-
expect(episodeButton).toHaveAttribute("tabindex", "-1");
59-
expect(playerButton).toHaveAttribute("tabindex", "-1");
58+
expect(episodeButton).toBeDisabled();
59+
expect(playerButton).toBeDisabled();
6060
expect(episodeButton.className).not.toContain("topbar-selectable");
6161
});
6262

63-
test("responds to keyboard activation for player control", async () => {
63+
test("activates player control when clicked", async () => {
6464
const { getByLabelText } = render(TopBar, {
6565
props: {
6666
viewState: ViewState.EpisodeList,
@@ -71,7 +71,7 @@ describe("TopBar", () => {
7171

7272
const playerButton = getByLabelText("Player");
7373

74-
await fireEvent.keyDown(playerButton, { key: "Enter" });
74+
await fireEvent.click(playerButton);
7575

7676
expect(playerButton.className).toContain("topbar-selected");
7777
});

src/ui/common/Image.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const baseProps = {
99
src: "https://example.com/art.jpg",
1010
alt: "Example artwork",
1111
fadeIn: true,
12+
interactive: true,
1213
};
1314

1415
describe("Image component", () => {

0 commit comments

Comments
 (0)