Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: i18n not properly configured in vitest #3037

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test("the modal can be closed by clicking the close button", async () => {
}
const user = userEvent.setup();
const { queryByRole, getByRole } = render(<ModalFn />);
await user.click(getByRole("button", { name: "action.close" }));
await user.click(getByRole("button", { name: "Close" }));
expect(queryByRole("dialog")).toBeNull();
});

Expand Down
2 changes: 1 addition & 1 deletion src/__snapshots__/QrCode.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`QrCode > renders 1`] = `
class="qrCode bar"
>
<img
alt="qr_code"
alt="QR Code"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHQAAAB0CAYAAABUmhYnAAAAAklEQVR4AewaftIAAALBSURBVO3BQW7kQAwEwSxC//9yro88NSBI4/UQjIg/WGMUa5RijVKsUYo1SrFGKdYoxRqlWKMUa5RijVKsUYo1SrFGKdYoxRrl4qEk/CaVkyR0Kl0STlS6JPwmlSeKNUqxRinWKBcvU3lTEk6S8ITKHSpvSsKbijVKsUYp1igXH5aEO1Q+SaVLQqdyRxLuUPmkYo1SrFGKNcrFl1PpknCShE5lkmKNUqxRijXKxZdLQqdyotIloVP5ZsUapVijFGuUiw9T+UuS8CaVv6RYoxRrlGKNcvGyJPwlSehUuiTckYS/rFijFGuUYo0Sf/DFkvAmlW9WrFGKNUqxRrl4KAknKl0SOpWTJJyodEk4UbkjCXeodEk4UXlTsUYp1ijFGuXiIZUuCXck4USlS0KXhE7lk1TelIRO5YlijVKsUYo1ysXLVLok3KHSJaFT6ZLQJaFTOUnCicodSehUTpLwpmKNUqxRijXKxUNJ6FSeSEKn0iXhROUkCZ3Kb0pCp/KmYo1SrFGKNcrFh6mcJKFT6ZJwotIloVPpVLokdCpdEjqVLgmdyh1J6FSeKNYoxRqlWKPEH3yxJHQqJ0noVO5IwolKl4ROpUtCp/JEsUYp1ijFGuXioST8JpU7ktCpnCShUzlROVHpktCpvKlYoxRrlGKNcvEylTcl4USlS8JJEt6UhBOVTqVLQqfyRLFGKdYoxRrl4sOScIfKEyonSehUTpJwh0qXhN9UrFGKNUqxRrn4ckn4JJU7kvA/FWuUYo1SrFEuvpxKl4QTlS4JncodSehU7kjCm4o1SrFGKdYoFx+m8klJOFE5UemScKJyRxI6lU7lTcUapVijFGuUi5cl4X9SOUnCicoTSThJQqfypmKNUqxRijVK/MEao1ijFGuUYo1SrFGKNUqxRinWKMUapVijFGuUYo1SrFGKNUqxRinWKP8AKoQP/lIBoMIAAAAASUVORK5CYII="
/>
</div>
Expand Down
26 changes: 13 additions & 13 deletions src/button/ReactionToggleButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test("Can open menu", async () => {
const { getByLabelText, container } = render(
<TestComponent vm={vm} rtcSession={rtcSession} />,
);
await user.click(getByLabelText("common.reactions"));
await user.click(getByLabelText("Reactions"));
expect(container).toMatchSnapshot();
});

Expand All @@ -58,8 +58,8 @@ test("Can raise hand", async () => {
const { getByLabelText, container } = render(
<TestComponent vm={vm} rtcSession={rtcSession} />,
);
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",
Expand Down Expand Up @@ -92,8 +92,8 @@ test("Can lower hand", async () => {
const { getByLabelText, container } = render(
<TestComponent vm={vm} rtcSession={rtcSession} />,
);
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]: {
Expand All @@ -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,
Expand All @@ -122,7 +122,7 @@ test("Can react with emoji", async () => {
const { getByLabelText, getByText } = render(
<TestComponent vm={vm} rtcSession={rtcSession} />,
);
await user.click(getByLabelText("common.reactions"));
await user.click(getByLabelText("Reactions"));
await user.click(getByText("🐶"));
expect(rtcSession.room.client.sendEvent).toHaveBeenCalledWith(
rtcSession.room.roomId,
Expand All @@ -144,8 +144,8 @@ test("Can fully expand emoji picker", async () => {
const { getByLabelText, container, getByText } = render(
<TestComponent vm={vm} rtcSession={rtcSession} />,
);
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(
Expand All @@ -168,8 +168,8 @@ test("Can close reaction dialog", async () => {
const { getByLabelText, container } = render(
<TestComponent vm={vm} rtcSession={rtcSession} />,
);
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();
});
6 changes: 1 addition & 5 deletions src/input/StarRating.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
2 changes: 1 addition & 1 deletion src/livekit/useECConnectionState.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ test.each<[string, ConnectionError]>([
</MemoryRouter>,
);
await user.click(screen.getByRole("button", { name: "Connect" }));
screen.getByText("error.insufficient_capacity");
screen.getByText("Insufficient capacity");
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`RaisedHandIndicator > renders a smaller indicator when miniature is spe
class="reaction"
>
<span
aria-label="common.reaction"
aria-label="Reaction"
role="img"
>
Expand All @@ -28,7 +28,7 @@ exports[`RaisedHandIndicator > renders an indicator when a hand has been raised
class="reaction reactionLarge"
>
<span
aria-label="common.reaction"
aria-label="Reaction"
role="img"
>
Expand All @@ -48,7 +48,7 @@ exports[`RaisedHandIndicator > renders an indicator when a hand has been raised
class="reaction reactionLarge"
>
<span
aria-label="common.reaction"
aria-label="Reaction"
role="img"
>
Expand Down
2 changes: 1 addition & 1 deletion src/room/GroupCallView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/room/InviteModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
4 changes: 1 addition & 3 deletions src/room/VideoPreview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ describe("VideoPreview", () => {
children={<></>}
/>,
);
expect(queryByRole("status")).toHaveTextContent(
"video_tile.camera_starting",
);
expect(queryByRole("status")).toHaveTextContent("Video loading...");
});
});
12 changes: 4 additions & 8 deletions src/tile/MediaView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,14 @@ describe("MediaView", () => {
<MediaView {...baseProps} video={undefined} localParticipant={true} />,
);
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(
<MediaView {...baseProps} video={undefined} localParticipant={false} />,
);
expect(screen.getByRole("img", { name: "some name" })).toBeVisible();
expect(screen.getByText("video_tile.waiting_for_media")).toBeVisible();
expect(screen.getByText("Waiting for media...")).toBeVisible();
});
});

Expand All @@ -98,9 +96,7 @@ describe("MediaView", () => {
</TooltipProvider>,
);
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", () => {
Expand All @@ -110,7 +106,7 @@ describe("MediaView", () => {
</TooltipProvider>,
);
expect(
screen.queryAllByRole("img", { name: "common.unencrypted" }).length,
screen.queryAllByRole("img", { name: "Not encrypted" }).length,
).toBe(0);
});
});
Expand Down
6 changes: 2 additions & 4 deletions src/tile/SpotlightTile.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
);
Expand Down
2 changes: 1 addition & 1 deletion src/vitest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ i18n
// We embed the translations, so that it never needs to fetch
resources: {
en: {
app: EN,
translation: EN,
},
},
interpolation: {
Expand Down