Fix warnings in LoginPage test
Change-Id: I844bb190e1d3ea172395035224bab497f3950912
This commit is contained in:
parent
b112689b8c
commit
03fcd8126a
|
@ -1,26 +1,32 @@
|
|||
import React from "react";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { AdminContext } from "react-admin";
|
||||
import polyglotI18nProvider from "ra-i18n-polyglot";
|
||||
import LoginPage from "./LoginPage";
|
||||
import { AppContext } from "../AppContext";
|
||||
import englishMessages from "../i18n/en";
|
||||
|
||||
const i18nProvider = polyglotI18nProvider(() => englishMessages, "en", [
|
||||
{ locale: "en", name: "English" },
|
||||
]);
|
||||
|
||||
describe("LoginForm", () => {
|
||||
it("renders with no restriction to homeserver", () => {
|
||||
render(
|
||||
<AdminContext>
|
||||
<AdminContext i18nProvider={i18nProvider}>
|
||||
<LoginPage />
|
||||
</AdminContext>
|
||||
);
|
||||
|
||||
screen.getByText("synapseadmin.auth.welcome");
|
||||
screen.getByText(englishMessages.synapseadmin.auth.welcome);
|
||||
screen.getByRole("combobox", { name: "" });
|
||||
screen.getByRole("textbox", { name: "ra.auth.username" });
|
||||
screen.getByText("ra.auth.password");
|
||||
screen.getByRole("textbox", { name: englishMessages.ra.auth.username });
|
||||
screen.getByText(englishMessages.ra.auth.password);
|
||||
const baseUrlInput = screen.getByRole("textbox", {
|
||||
name: "synapseadmin.auth.base_url",
|
||||
name: englishMessages.synapseadmin.auth.base_url,
|
||||
});
|
||||
expect(baseUrlInput.className.split(" ")).not.toContain("Mui-readOnly");
|
||||
screen.getByRole("button", { name: "ra.auth.sign_in" });
|
||||
screen.getByRole("button", { name: englishMessages.ra.auth.sign_in });
|
||||
});
|
||||
|
||||
it("renders with single restricted homeserver", () => {
|
||||
|
@ -28,21 +34,21 @@ describe("LoginForm", () => {
|
|||
<AppContext.Provider
|
||||
value={{ restrictBaseUrl: "https://matrix.example.com" }}
|
||||
>
|
||||
<AdminContext>
|
||||
<AdminContext i18nProvider={i18nProvider}>
|
||||
<LoginPage />
|
||||
</AdminContext>
|
||||
</AppContext.Provider>
|
||||
);
|
||||
|
||||
screen.getByText("synapseadmin.auth.welcome");
|
||||
screen.getByText(englishMessages.synapseadmin.auth.welcome);
|
||||
screen.getByRole("combobox", { name: "" });
|
||||
screen.getByRole("textbox", { name: "ra.auth.username" });
|
||||
screen.getByText("ra.auth.password");
|
||||
screen.getByRole("textbox", { name: englishMessages.ra.auth.username });
|
||||
screen.getByText(englishMessages.ra.auth.password);
|
||||
const baseUrlInput = screen.getByRole("textbox", {
|
||||
name: "synapseadmin.auth.base_url",
|
||||
name: englishMessages.synapseadmin.auth.base_url,
|
||||
});
|
||||
expect(baseUrlInput.className.split(" ")).toContain("Mui-readOnly");
|
||||
screen.getByRole("button", { name: "ra.auth.sign_in" });
|
||||
screen.getByRole("button", { name: englishMessages.ra.auth.sign_in });
|
||||
});
|
||||
|
||||
it("renders with multiple restricted homeservers", async () => {
|
||||
|
@ -55,17 +61,19 @@ describe("LoginForm", () => {
|
|||
],
|
||||
}}
|
||||
>
|
||||
<AdminContext>
|
||||
<AdminContext i18nProvider={i18nProvider}>
|
||||
<LoginPage />
|
||||
</AdminContext>
|
||||
</AppContext.Provider>
|
||||
);
|
||||
|
||||
screen.getByText("synapseadmin.auth.welcome");
|
||||
screen.getByText(englishMessages.synapseadmin.auth.welcome);
|
||||
screen.getByRole("combobox", { name: "" });
|
||||
screen.getByRole("textbox", { name: "ra.auth.username" });
|
||||
screen.getByText("ra.auth.password");
|
||||
screen.getByRole("combobox", { name: "synapseadmin.auth.base_url" });
|
||||
screen.getByRole("button", { name: "ra.auth.sign_in" });
|
||||
screen.getByRole("textbox", { name: englishMessages.ra.auth.username });
|
||||
screen.getByText(englishMessages.ra.auth.password);
|
||||
screen.getByRole("combobox", {
|
||||
name: englishMessages.synapseadmin.auth.base_url,
|
||||
});
|
||||
screen.getByRole("button", { name: englishMessages.ra.auth.sign_in });
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue