Move language settings to 'preferences' (#12723)
* Move language settings to 'preferences' Their new home is in this tab * Update snapshot * Move playwright test code * Add test * tests * Update screenshot
This commit is contained in:
parent
dcf7643d4a
commit
81f29d13dc
9 changed files with 198 additions and 110 deletions
|
@ -15,7 +15,8 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React from "react";
|
||||
import { fireEvent, render, RenderResult, waitFor } from "@testing-library/react";
|
||||
import { fireEvent, render, RenderResult, screen, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
|
||||
import PreferencesUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/PreferencesUserSettingsTab";
|
||||
import { MatrixClientPeg } from "../../../../../../src/MatrixClientPeg";
|
||||
|
@ -23,6 +24,7 @@ import { mockPlatformPeg, stubClient } from "../../../../../test-utils";
|
|||
import SettingsStore from "../../../../../../src/settings/SettingsStore";
|
||||
import { SettingLevel } from "../../../../../../src/settings/SettingLevel";
|
||||
import MatrixClientBackedController from "../../../../../../src/settings/controllers/MatrixClientBackedController";
|
||||
import PlatformPeg from "../../../../../../src/PlatformPeg";
|
||||
|
||||
describe("PreferencesUserSettingsTab", () => {
|
||||
beforeEach(() => {
|
||||
|
@ -38,6 +40,43 @@ describe("PreferencesUserSettingsTab", () => {
|
|||
expect(asFragment()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should reload when changing language", async () => {
|
||||
const reloadStub = jest.fn();
|
||||
PlatformPeg.get()!.reload = reloadStub;
|
||||
|
||||
renderTab();
|
||||
const languageDropdown = await screen.findByRole("button", { name: "Language Dropdown" });
|
||||
expect(languageDropdown).toBeInTheDocument();
|
||||
|
||||
await userEvent.click(languageDropdown);
|
||||
|
||||
const germanOption = await screen.findByText("Deutsch");
|
||||
await userEvent.click(germanOption);
|
||||
expect(reloadStub).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should not show spell check setting if unsupported", async () => {
|
||||
PlatformPeg.get()!.supportsSpellCheckSettings = jest.fn().mockReturnValue(false);
|
||||
|
||||
renderTab();
|
||||
expect(screen.queryByRole("switch", { name: "Allow spell check" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should enable spell check", async () => {
|
||||
const spellCheckEnableFn = jest.fn();
|
||||
PlatformPeg.get()!.supportsSpellCheckSettings = jest.fn().mockReturnValue(true);
|
||||
PlatformPeg.get()!.getSpellCheckEnabled = jest.fn().mockReturnValue(false);
|
||||
PlatformPeg.get()!.setSpellCheckEnabled = spellCheckEnableFn;
|
||||
|
||||
renderTab();
|
||||
const toggle = await screen.findByRole("switch", { name: "Allow spell check" });
|
||||
expect(toggle).toHaveAttribute("aria-checked", "false");
|
||||
|
||||
await userEvent.click(toggle);
|
||||
|
||||
expect(spellCheckEnableFn).toHaveBeenCalledWith(true);
|
||||
});
|
||||
|
||||
describe("send read receipts", () => {
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
|
|
|
@ -15,6 +15,44 @@ exports[`PreferencesUserSettingsTab should render 1`] = `
|
|||
<div
|
||||
class="mx_SettingsSection_subSections"
|
||||
>
|
||||
<div
|
||||
class="mx_SettingsSubsection"
|
||||
>
|
||||
<div
|
||||
class="mx_SettingsSubsectionHeading"
|
||||
>
|
||||
<h3
|
||||
class="mx_Heading_h4 mx_SettingsSubsectionHeading_heading"
|
||||
>
|
||||
Language
|
||||
</h3>
|
||||
</div>
|
||||
<div
|
||||
class="mx_SettingsSubsection_content"
|
||||
>
|
||||
<div
|
||||
class="mx_SettingsSubsection_contentStretch"
|
||||
>
|
||||
Application language
|
||||
<div
|
||||
class="mx_Spinner"
|
||||
>
|
||||
<div
|
||||
aria-label="Loading…"
|
||||
class="mx_Spinner_icon"
|
||||
data-testid="spinner"
|
||||
role="progressbar"
|
||||
style="width: 32px; height: 32px;"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="mx_GeneralUserSettingsTab_section_hint"
|
||||
>
|
||||
The app will reload after selecting another language
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="mx_SettingsSubsection"
|
||||
>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue