Align common_* strings with Element X project in Localazy (#11434)

This commit is contained in:
Michael Telatynski 2023-08-22 18:47:33 +01:00 committed by GitHub
parent 1a49a38f04
commit c40141cc4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
132 changed files with 1491 additions and 1247 deletions

View file

@ -19,11 +19,12 @@ import { act, fireEvent, render } from "@testing-library/react";
import TabbedView, { Tab, TabLocation } from "../../../src/components/structures/TabbedView";
import { NonEmptyArray } from "../../../src/@types/common";
import { _t } from "../../../src/languageHandler";
describe("<TabbedView />", () => {
const generalTab = new Tab("GENERAL", "General", "general", <div>general</div>);
const labsTab = new Tab("LABS", "Labs", "labs", <div>labs</div>);
const securityTab = new Tab("SECURITY", "Security", "security", <div>security</div>);
const securityTab = new Tab("SECURITY", "common|security", "security", <div>security</div>);
const defaultProps = {
tabLocation: TabLocation.LEFT,
tabs: [generalTab, labsTab, securityTab] as NonEmptyArray<Tab<any>>,
@ -55,7 +56,7 @@ describe("<TabbedView />", () => {
it("renders initialTabId tab as active when valid", () => {
const { container } = render(getComponent({ initialTabId: securityTab.id }));
expect(getActiveTab(container)?.textContent).toEqual(securityTab.label);
expect(getActiveTab(container)?.textContent).toEqual(_t(securityTab.label));
expect(getActiveTabBody(container)?.textContent).toEqual("security");
});
@ -66,7 +67,7 @@ describe("<TabbedView />", () => {
fireEvent.click(getByTestId(getTabTestId(securityTab)));
});
expect(getActiveTab(container)?.textContent).toEqual(securityTab.label);
expect(getActiveTab(container)?.textContent).toEqual(_t(securityTab.label));
expect(getActiveTabBody(container)?.textContent).toEqual("security");
});
@ -102,12 +103,12 @@ describe("<TabbedView />", () => {
act(() => {
fireEvent.click(getByTestId(getTabTestId(securityTab)));
});
expect(getActiveTab(container)?.textContent).toEqual(securityTab.label);
expect(getActiveTab(container)?.textContent).toEqual(_t(securityTab.label));
// rerender with new tab location
rerender(getComponent({ tabLocation: TabLocation.TOP }));
// still security tab
expect(getActiveTab(container)?.textContent).toEqual(securityTab.label);
expect(getActiveTab(container)?.textContent).toEqual(_t(securityTab.label));
});
});

View file

@ -28,6 +28,8 @@ import { stubClient } from "../../../test-utils";
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
import DMRoomMap from "../../../../src/utils/DMRoomMap";
import SettingsStore from "../../../../src/settings/SettingsStore";
import { EchoChamber } from "../../../../src/stores/local-echo/EchoChamber";
import { RoomNotifState } from "../../../../src/RoomNotifs";
jest.mock("../../../../src/customisations/helpers/UIComponents", () => ({
shouldShowComponent: jest.fn(),
@ -100,4 +102,15 @@ describe("RoomContextMenu", () => {
expect(screen.getByText("Developer tools")).toBeInTheDocument();
});
});
it("should render notification option for joined rooms", () => {
const chamber = EchoChamber.forRoom(room);
chamber.notificationVolume = RoomNotifState.Mute;
jest.spyOn(room, "getMyMembership").mockReturnValue("join");
renderComponent();
expect(
screen.getByRole("menuitem", { name: "Notifications" }).querySelector(".mx_IconizedContextMenu_sublabel"),
).toHaveTextContent("Mute");
});
});

View file

@ -22,6 +22,7 @@ import encrypt from "matrix-encrypt-attachment";
import { mocked } from "jest-mock";
import fs from "fs";
import path from "path";
import userEvent from "@testing-library/user-event";
import MImageBody from "../../../../src/components/views/messages/MImageBody";
import { RoomPermalinkCreator } from "../../../../src/utils/permalinks/Permalinks";
@ -258,4 +259,29 @@ describe("<MImageBody/>", () => {
// thumbnail with dimensions present
expect(container).toMatchSnapshot();
});
it("should show banner on hover", async () => {
const event = new MatrixEvent({
room_id: "!room:server",
sender: userId,
type: EventType.RoomMessage,
content: {
body: "alt for a test image",
info: {
w: 40,
h: 50,
},
url: "mxc://server/image",
},
});
const { container } = render(
<MImageBody {...props} mxEvent={event} mediaEventHelper={new MediaEventHelper(event)} />,
);
const img = container.querySelector(".mx_MImageBody_thumbnail")!;
await userEvent.hover(img);
expect(container.querySelector(".mx_MImageBody_banner")).toHaveTextContent("...alt for a test image");
});
});

View file

@ -0,0 +1,35 @@
/*
Copyright 2023 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React from "react";
import { render } from "@testing-library/react";
import PresenceLabel from "../../../../src/components/views/rooms/PresenceLabel";
describe("<PresenceLabel/>", () => {
it("should render 'Offline' for presence=offline", () => {
const { asFragment } = render(<PresenceLabel presenceState="offline" />);
expect(asFragment()).toMatchInlineSnapshot(`
<DocumentFragment>
<div
class="mx_PresenceLabel"
>
Offline
</div>
</DocumentFragment>
`);
});
});

View file

@ -22,15 +22,36 @@ import React from "react";
import AddExistingToSpaceDialog from "../../../../src/components/views/dialogs/AddExistingToSpaceDialog";
import SettingsStore from "../../../../src/settings/SettingsStore";
import DMRoomMap from "../../../../src/utils/DMRoomMap";
import { mkSpace, stubClient } from "../../../test-utils";
import { mkRoom, mkSpace, stubClient } from "../../../test-utils";
describe("<AddExistingToSpaceDialog />", () => {
beforeEach(() => {
jest.spyOn(Element.prototype, "clientHeight", "get").mockReturnValue(600);
});
it("looks as expected", () => {
const client = stubClient();
const dialog = renderAddExistingToSpaceDialog(client);
expect(dialog.asFragment()).toMatchSnapshot();
});
it("should show 'no results' if appropriate", () => {
const client = stubClient();
const { getByText } = renderAddExistingToSpaceDialog(client);
expect(getByText("No results")).toBeInTheDocument();
});
it("should not show 'no results' if we have results to show", () => {
const client = stubClient();
mocked(client.getVisibleRooms).mockReturnValue([
mkSpace(client, "!space2:example.com"),
mkRoom(client, "!room2:example.com"),
]);
const { queryByText, getByText } = renderAddExistingToSpaceDialog(client);
expect(queryByText("No results")).not.toBeInTheDocument();
expect(getByText("!room2:example.com")).toBeInTheDocument();
});
describe("If the feature_dynamic_room_predecessors is not enabled", () => {
beforeEach(() => {
jest.spyOn(SettingsStore, "getValue").mockReturnValue(false);

View file

@ -44,6 +44,11 @@ describe("QuickSettingsButton", () => {
expect(getQuickSettingsButton()).toBeInTheDocument();
});
it("should render the quick settings button in expanded mode", () => {
const { asFragment } = render(<QuickSettingsButton isPanelCollapsed={false} />);
expect(asFragment()).toMatchSnapshot();
});
describe("when the quick settings are open", () => {
beforeEach(async () => {
renderQuickSettingsButton();

View file

@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`QuickSettingsButton should render the quick settings button in expanded mode 1`] = `
<DocumentFragment>
<div
aria-expanded="true"
aria-label="Quick settings"
class="mx_AccessibleButton mx_QuickSettingsButton expanded"
role="button"
tabindex="0"
>
Settings
</div>
</DocumentFragment>
`;