From 4c91326edb096124f8f9c7b4ac948f29a21a2c25 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 3 Mar 2025 14:37:29 +0100 Subject: [PATCH] fix, testing: i18n not properly configured --- src/Modal.test.tsx | 2 +- src/__snapshots__/QrCode.test.tsx.snap | 2 +- src/button/ReactionToggleButton.test.tsx | 26 +++++++++---------- src/input/StarRating.test.tsx | 6 +---- src/livekit/useECConnectionState.test.tsx | 2 +- .../RaisedHandIndicator.test.tsx.snap | 6 ++--- src/room/GroupCallView.test.tsx | 2 +- src/room/InviteModal.test.tsx | 2 +- src/room/VideoPreview.test.tsx | 4 +-- src/tile/MediaView.test.tsx | 12 +++------ src/tile/SpotlightTile.test.tsx | 6 ++--- src/vitest.setup.ts | 2 +- 12 files changed, 30 insertions(+), 42 deletions(-) diff --git a/src/Modal.test.tsx b/src/Modal.test.tsx index 6715ae19..74670b6d 100644 --- a/src/Modal.test.tsx +++ b/src/Modal.test.tsx @@ -46,7 +46,7 @@ test("the modal can be closed by clicking the close button", async () => { } const user = userEvent.setup(); const { queryByRole, getByRole } = render(); - await user.click(getByRole("button", { name: "action.close" })); + await user.click(getByRole("button", { name: "Close" })); expect(queryByRole("dialog")).toBeNull(); }); diff --git a/src/__snapshots__/QrCode.test.tsx.snap b/src/__snapshots__/QrCode.test.tsx.snap index d1d444b8..701f427b 100644 --- a/src/__snapshots__/QrCode.test.tsx.snap +++ b/src/__snapshots__/QrCode.test.tsx.snap @@ -5,7 +5,7 @@ exports[`QrCode > renders 1`] = ` class="qrCode bar" > qr_code diff --git a/src/button/ReactionToggleButton.test.tsx b/src/button/ReactionToggleButton.test.tsx index b7571595..90865d25 100644 --- a/src/button/ReactionToggleButton.test.tsx +++ b/src/button/ReactionToggleButton.test.tsx @@ -47,7 +47,7 @@ test("Can open menu", async () => { const { getByLabelText, container } = render( , ); - await user.click(getByLabelText("common.reactions")); + await user.click(getByLabelText("Reactions")); expect(container).toMatchSnapshot(); }); @@ -58,8 +58,8 @@ test("Can raise hand", async () => { const { getByLabelText, container } = render( , ); - await user.click(getByLabelText("common.reactions")); - await user.click(getByLabelText("action.raise_hand")); + await user.click(getByLabelText("Reactions")); + await user.click(getByLabelText("Raise hand")); expect(rtcSession.room.client.sendEvent).toHaveBeenCalledWith( rtcSession.room.roomId, "m.reaction", @@ -92,8 +92,8 @@ test("Can lower hand", async () => { const { getByLabelText, container } = render( , ); - await user.click(getByLabelText("common.reactions")); - await user.click(getByLabelText("action.raise_hand")); + await user.click(getByLabelText("Reactions")); + await user.click(getByLabelText("Raise hand")); act(() => { handRaisedSubject$.next({ [localIdent]: { @@ -103,8 +103,8 @@ test("Can lower hand", async () => { }, }); }); - await user.click(getByLabelText("common.reactions")); - await user.click(getByLabelText("action.lower_hand")); + await user.click(getByLabelText("Reactions")); + await user.click(getByLabelText("Lower hand")); expect(rtcSession.room.client.redactEvent).toHaveBeenCalledWith( rtcSession.room.roomId, reactionEventId, @@ -122,7 +122,7 @@ test("Can react with emoji", async () => { const { getByLabelText, getByText } = render( , ); - await user.click(getByLabelText("common.reactions")); + await user.click(getByLabelText("Reactions")); await user.click(getByText("🐶")); expect(rtcSession.room.client.sendEvent).toHaveBeenCalledWith( rtcSession.room.roomId, @@ -144,8 +144,8 @@ test("Can fully expand emoji picker", async () => { const { getByLabelText, container, getByText } = render( , ); - await user.click(getByLabelText("common.reactions")); - await user.click(getByLabelText("action.show_more")); + await user.click(getByLabelText("Reactions")); + await user.click(getByLabelText("Show more")); expect(container).toMatchSnapshot(); await user.click(getByText("🦗")); expect(rtcSession.room.client.sendEvent).toHaveBeenCalledWith( @@ -168,8 +168,8 @@ test("Can close reaction dialog", async () => { const { getByLabelText, container } = render( , ); - await user.click(getByLabelText("common.reactions")); - await user.click(getByLabelText("action.show_more")); - await user.click(getByLabelText("action.show_less")); + await user.click(getByLabelText("Reactions")); + await user.click(getByLabelText("Show more")); + await user.click(getByLabelText("Show less")); expect(container).toMatchSnapshot(); }); diff --git a/src/input/StarRating.test.tsx b/src/input/StarRating.test.tsx index 3a7956a1..1c3c0ffc 100644 --- a/src/input/StarRating.test.tsx +++ b/src/input/StarRating.test.tsx @@ -20,10 +20,6 @@ test("StarRatingInput is accessible", async () => { ); expect(await axe(container)).toHaveNoViolations(); // Change the rating to 4 stars - await user.click( - ( - await screen.findAllByRole("radio", { name: "star_rating_input_label" }) - )[3], - ); + await user.click(await screen.findByLabelText("4 stars")); expect(onChange).toBeCalledWith(4); }); diff --git a/src/livekit/useECConnectionState.test.tsx b/src/livekit/useECConnectionState.test.tsx index 7194c252..1314ce81 100644 --- a/src/livekit/useECConnectionState.test.tsx +++ b/src/livekit/useECConnectionState.test.tsx @@ -67,6 +67,6 @@ test.each<[string, ConnectionError]>([ , ); await user.click(screen.getByRole("button", { name: "Connect" })); - screen.getByText("error.insufficient_capacity"); + screen.getByText("Insufficient capacity"); }, ); diff --git a/src/reactions/__snapshots__/RaisedHandIndicator.test.tsx.snap b/src/reactions/__snapshots__/RaisedHandIndicator.test.tsx.snap index db3e4b85..ab6fafa3 100644 --- a/src/reactions/__snapshots__/RaisedHandIndicator.test.tsx.snap +++ b/src/reactions/__snapshots__/RaisedHandIndicator.test.tsx.snap @@ -8,7 +8,7 @@ exports[`RaisedHandIndicator > renders a smaller indicator when miniature is spe class="reaction" > ✋ @@ -28,7 +28,7 @@ exports[`RaisedHandIndicator > renders an indicator when a hand has been raised class="reaction reactionLarge" > ✋ @@ -48,7 +48,7 @@ exports[`RaisedHandIndicator > renders an indicator when a hand has been raised class="reaction reactionLarge" > ✋ diff --git a/src/room/GroupCallView.test.tsx b/src/room/GroupCallView.test.tsx index 00d6fa00..0a57d081 100644 --- a/src/room/GroupCallView.test.tsx +++ b/src/room/GroupCallView.test.tsx @@ -199,7 +199,7 @@ test("GroupCallView leaves the session when an error occurs", async () => { const user = userEvent.setup(); const { rtcSession } = createGroupCallView(null); await user.click(screen.getByRole("button", { name: "Panic!" })); - screen.getByText("error.generic"); + screen.getByText("Something went wrong"); expect(leaveRTCSession).toHaveBeenCalledWith( rtcSession, "error", diff --git a/src/room/InviteModal.test.tsx b/src/room/InviteModal.test.tsx index 7008dc3c..bb1a4c2b 100644 --- a/src/room/InviteModal.test.tsx +++ b/src/room/InviteModal.test.tsx @@ -30,6 +30,6 @@ test("InviteModal is accessible", async () => { ); expect(await axe(container)).toHaveNoViolations(); - await user.click(screen.getByRole("button", { name: "action.copy_link" })); + await user.click(screen.getByRole("button", { name: "Copy link" })); expect(onDismiss).toBeCalled(); }); diff --git a/src/room/VideoPreview.test.tsx b/src/room/VideoPreview.test.tsx index 542b73d2..3bbb6ad5 100644 --- a/src/room/VideoPreview.test.tsx +++ b/src/room/VideoPreview.test.tsx @@ -66,8 +66,6 @@ describe("VideoPreview", () => { children={<>} />, ); - expect(queryByRole("status")).toHaveTextContent( - "video_tile.camera_starting", - ); + expect(queryByRole("status")).toHaveTextContent("Video loading..."); }); }); diff --git a/src/tile/MediaView.test.tsx b/src/tile/MediaView.test.tsx index 717cc1c0..79d6f779 100644 --- a/src/tile/MediaView.test.tsx +++ b/src/tile/MediaView.test.tsx @@ -70,16 +70,14 @@ describe("MediaView", () => { , ); expect(screen.getByRole("img", { name: "some name" })).toBeVisible(); - expect(screen.queryAllByText("video_tile.waiting_for_media").length).toBe( - 0, - ); + expect(screen.queryAllByText("Waiting for media...").length).toBe(0); }); it("shows avatar and label for remote user", () => { render( , ); expect(screen.getByRole("img", { name: "some name" })).toBeVisible(); - expect(screen.getByText("video_tile.waiting_for_media")).toBeVisible(); + expect(screen.getByText("Waiting for media...")).toBeVisible(); }); }); @@ -98,9 +96,7 @@ describe("MediaView", () => { , ); expect(await axe(container)).toHaveNoViolations(); - expect( - screen.getByRole("img", { name: "common.unencrypted" }), - ).toBeTruthy(); + expect(screen.getByRole("img", { name: "Not encrypted" })).toBeTruthy(); }); test("is not shown", () => { @@ -110,7 +106,7 @@ describe("MediaView", () => { , ); expect( - screen.queryAllByRole("img", { name: "common.unencrypted" }).length, + screen.queryAllByRole("img", { name: "Not encrypted" }).length, ).toBe(0); }); }); diff --git a/src/tile/SpotlightTile.test.tsx b/src/tile/SpotlightTile.test.tsx index 27d292c7..1f3b7a86 100644 --- a/src/tile/SpotlightTile.test.tsx +++ b/src/tile/SpotlightTile.test.tsx @@ -64,14 +64,12 @@ test("SpotlightTile is accessible", async () => { // Bob should be out of the spotlight, and therefore invisible expect(isInaccessible(screen.getByText("Bob"))).toBe(true); // Now navigate to Bob - await user.click(screen.getByRole("button", { name: "common.next" })); + await user.click(screen.getByRole("button", { name: "Next" })); screen.getByText("Bob"); expect(screen.getByRole("img")).not.toBe(aliceAvatar); expect(isInaccessible(screen.getByText("Alice"))).toBe(true); // Can toggle whether the tile is expanded - await user.click( - screen.getByRole("button", { name: "video_tile.expand" }), - ); + await user.click(screen.getByRole("button", { name: "Expand" })); expect(toggleExpanded).toHaveBeenCalled(); }, ); diff --git a/src/vitest.setup.ts b/src/vitest.setup.ts index f0821c15..b97b78ff 100644 --- a/src/vitest.setup.ts +++ b/src/vitest.setup.ts @@ -30,7 +30,7 @@ i18n // We embed the translations, so that it never needs to fetch resources: { en: { - app: EN, + translation: EN, }, }, interpolation: {