mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-03 16:10:05 +00:00
test: adapt unit tests to HealthChat fork customizations
This commit is contained in:
@@ -1688,8 +1688,9 @@ describe("<MatrixChat />", () => {
|
|||||||
await flushPromises();
|
await flushPromises();
|
||||||
expect(Lifecycle.attemptDelegatedAuthLogin).toHaveBeenCalled();
|
expect(Lifecycle.attemptDelegatedAuthLogin).toHaveBeenCalled();
|
||||||
|
|
||||||
// should just show the welcome screen
|
// should just show the welcome screen (wait for welcome page chrome render; HealthChat's
|
||||||
await rendered.findByText("Welcome to Test");
|
// Welcome renders an EmbeddedPage body that does not load under jsdom, so assert on the chrome)
|
||||||
|
await rendered.findByText("Powered by Matrix");
|
||||||
expect(rendered.container).toMatchSnapshot();
|
expect(rendered.container).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+3
-48
@@ -140,57 +140,12 @@ exports[`<MatrixChat /> Multi-tab lockout waits for other tab to stop during sta
|
|||||||
class="mx_Welcome"
|
class="mx_Welcome"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="mx_DefaultWelcome"
|
class="mx_WelcomePage mx_WelcomePage_loggedIn"
|
||||||
>
|
>
|
||||||
<a
|
|
||||||
class="mx_DefaultWelcome_logo"
|
|
||||||
href="https://element.io"
|
|
||||||
rel="noopener"
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
alt="Test"
|
|
||||||
src="themes/element/img/logos/element-logo.svg"
|
|
||||||
/>
|
|
||||||
</a>
|
|
||||||
<h1
|
|
||||||
class="_typography_6v6n8_153 _font-heading-md-semibold_6v6n8_112"
|
|
||||||
>
|
|
||||||
Welcome to Test
|
|
||||||
</h1>
|
|
||||||
<div
|
<div
|
||||||
class="mx_DefaultWelcome_buttons"
|
class="mx_WelcomePage_body"
|
||||||
>
|
>
|
||||||
<a
|
Couldn't load page
|
||||||
class="_button_1nw83_8"
|
|
||||||
data-kind="primary"
|
|
||||||
data-size="md"
|
|
||||||
href="#/login"
|
|
||||||
role="link"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
Sign in
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
class="_button_1nw83_8"
|
|
||||||
data-kind="secondary"
|
|
||||||
data-size="md"
|
|
||||||
href="#/register"
|
|
||||||
role="link"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
Create account
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
class="_button_1nw83_8"
|
|
||||||
data-kind="tertiary"
|
|
||||||
data-size="md"
|
|
||||||
href="#/directory"
|
|
||||||
role="link"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
Explore rooms
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import { getPowerLevels } from "../../../../../src/components/viewmodels/right_p
|
|||||||
import { RightPanelPhases } from "../../../../../src/stores/right-panel/RightPanelStorePhases";
|
import { RightPanelPhases } from "../../../../../src/stores/right-panel/RightPanelStorePhases";
|
||||||
import { MatrixClientPeg } from "../../../../../src/MatrixClientPeg";
|
import { MatrixClientPeg } from "../../../../../src/MatrixClientPeg";
|
||||||
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
|
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
|
||||||
|
import { SdkContextClass } from "../../../../../src/contexts/SDKContext";
|
||||||
import Modal from "../../../../../src/Modal";
|
import Modal from "../../../../../src/Modal";
|
||||||
import { clearAllModals, flushPromises } from "../../../../test-utils";
|
import { clearAllModals, flushPromises } from "../../../../test-utils";
|
||||||
import ErrorDialog from "../../../../../src/components/views/dialogs/ErrorDialog";
|
import ErrorDialog from "../../../../../src/components/views/dialogs/ErrorDialog";
|
||||||
@@ -134,6 +135,9 @@ beforeEach(() => {
|
|||||||
|
|
||||||
jest.spyOn(MatrixClientPeg, "get").mockReturnValue(mockClient);
|
jest.spyOn(MatrixClientPeg, "get").mockReturnValue(mockClient);
|
||||||
jest.spyOn(MatrixClientPeg, "safeGet").mockReturnValue(mockClient);
|
jest.spyOn(MatrixClientPeg, "safeGet").mockReturnValue(mockClient);
|
||||||
|
// HealthChat's UserExtendedProfileInfo reads SdkContextClass.instance.userProfilesStore,
|
||||||
|
// which requires the singleton client to be set (it is, on login, in the real app).
|
||||||
|
SdkContextClass.instance.client = mockClient;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("<UserInfo />", () => {
|
describe("<UserInfo />", () => {
|
||||||
|
|||||||
@@ -667,8 +667,8 @@ describe("RoomHeader", () => {
|
|||||||
const button = screen.getByRole("button", { name: "Video call" });
|
const button = screen.getByRole("button", { name: "Video call" });
|
||||||
expect(button).not.toHaveAttribute("aria-disabled", "true");
|
expect(button).not.toHaveAttribute("aria-disabled", "true");
|
||||||
await user.click(button);
|
await user.click(button);
|
||||||
const elementCallButton = screen.getByRole("menuitem", { name: "Element Call" });
|
const elementCallButton = screen.getByRole("menuitem", { name: _t("voip|element_call") });
|
||||||
const legacyCallButton = screen.getByRole("menuitem", { name: "Legacy Call" });
|
const legacyCallButton = screen.getByRole("menuitem", { name: _t("voip|legacy_call") });
|
||||||
expect(elementCallButton).toBeInTheDocument();
|
expect(elementCallButton).toBeInTheDocument();
|
||||||
expect(legacyCallButton).toBeInTheDocument();
|
expect(legacyCallButton).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
@@ -684,8 +684,8 @@ describe("RoomHeader", () => {
|
|||||||
const button = screen.getByRole("button", { name: "Voice call" });
|
const button = screen.getByRole("button", { name: "Voice call" });
|
||||||
expect(button).not.toHaveAttribute("aria-disabled", "true");
|
expect(button).not.toHaveAttribute("aria-disabled", "true");
|
||||||
await user.click(button);
|
await user.click(button);
|
||||||
const elementCallButton = screen.getByRole("menuitem", { name: "Element Call" });
|
const elementCallButton = screen.getByRole("menuitem", { name: _t("voip|element_call") });
|
||||||
const legacyCallButton = screen.getByRole("menuitem", { name: "Legacy Call" });
|
const legacyCallButton = screen.getByRole("menuitem", { name: _t("voip|legacy_call") });
|
||||||
expect(elementCallButton).toBeInTheDocument();
|
expect(elementCallButton).toBeInTheDocument();
|
||||||
expect(legacyCallButton).toBeInTheDocument();
|
expect(legacyCallButton).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { mkStubRoom, stubClient } from "../../../../test-utils";
|
|||||||
import { ToastContext, type ToastRack } from "../../../../../src/contexts/ToastContext";
|
import { ToastContext, type ToastRack } from "../../../../../src/contexts/ToastContext";
|
||||||
import { OwnProfileStore } from "../../../../../src/stores/OwnProfileStore";
|
import { OwnProfileStore } from "../../../../../src/stores/OwnProfileStore";
|
||||||
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
|
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
|
||||||
|
import { SdkContextClass } from "../../../../../src/contexts/SDKContext";
|
||||||
import Modal from "../../../../../src/Modal";
|
import Modal from "../../../../../src/Modal";
|
||||||
|
|
||||||
interface MockedAvatarSettingProps {
|
interface MockedAvatarSettingProps {
|
||||||
@@ -86,6 +87,9 @@ describe("ProfileSettings", () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
client = stubClient();
|
client = stubClient();
|
||||||
|
// HealthChat's ExtendedProfileSettings reads the global SdkContextClass.instance.userProfilesStore,
|
||||||
|
// which requires the singleton client to be set (it is, on login, in the real app).
|
||||||
|
SdkContextClass.instance.client = client;
|
||||||
toastRack = {
|
toastRack = {
|
||||||
displayToast: jest.fn().mockReturnValue(jest.fn()),
|
displayToast: jest.fn().mockReturnValue(jest.fn()),
|
||||||
};
|
};
|
||||||
|
|||||||
+3
@@ -85,6 +85,9 @@ describe("<AccountUserSettingsTab />", () => {
|
|||||||
|
|
||||||
stores = new SdkContextClass();
|
stores = new SdkContextClass();
|
||||||
stores.client = mockClient;
|
stores.client = mockClient;
|
||||||
|
// HealthChat's ExtendedProfileSettings (mounted via UserProfileSettings) reads the global
|
||||||
|
// SdkContextClass.instance.userProfilesStore, which requires the singleton client to be set.
|
||||||
|
SdkContextClass.instance.client = mockClient;
|
||||||
// stub out this store completely to avoid mocking initialisation
|
// stub out this store completely to avoid mocking initialisation
|
||||||
const mockOidcClientStore = {} as unknown as OidcClientStore;
|
const mockOidcClientStore = {} as unknown as OidcClientStore;
|
||||||
jest.spyOn(stores, "oidcClientStore", "get").mockReturnValue(mockOidcClientStore);
|
jest.spyOn(stores, "oidcClientStore", "get").mockReturnValue(mockOidcClientStore);
|
||||||
|
|||||||
+4
-4
@@ -42,14 +42,14 @@ exports[`<AccountUserSettingsTab /> 3pids should display 3pid email addresses an
|
|||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
autocomplete="email"
|
autocomplete="email"
|
||||||
id="mx_Field_3"
|
id="mx_Field_113"
|
||||||
label="Email Address"
|
label="Email Address"
|
||||||
placeholder="Email Address"
|
placeholder="Email Address"
|
||||||
type="text"
|
type="text"
|
||||||
value=""
|
value=""
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
for="mx_Field_3"
|
for="mx_Field_113"
|
||||||
>
|
>
|
||||||
Email Address
|
Email Address
|
||||||
</label>
|
</label>
|
||||||
@@ -154,14 +154,14 @@ exports[`<AccountUserSettingsTab /> 3pids should display 3pid email addresses an
|
|||||||
</span>
|
</span>
|
||||||
<input
|
<input
|
||||||
autocomplete="tel-national"
|
autocomplete="tel-national"
|
||||||
id="mx_Field_4"
|
id="mx_Field_114"
|
||||||
label="Phone Number"
|
label="Phone Number"
|
||||||
placeholder="Phone Number"
|
placeholder="Phone Number"
|
||||||
type="text"
|
type="text"
|
||||||
value=""
|
value=""
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
for="mx_Field_4"
|
for="mx_Field_114"
|
||||||
>
|
>
|
||||||
Phone Number
|
Phone Number
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
@@ -10,9 +10,17 @@ import RequiresSettingsController from "../../../../src/settings/controllers/Req
|
|||||||
import { SettingLevel } from "../../../../src/settings/SettingLevel";
|
import { SettingLevel } from "../../../../src/settings/SettingLevel";
|
||||||
import SettingsStore from "../../../../src/settings/SettingsStore";
|
import SettingsStore from "../../../../src/settings/SettingsStore";
|
||||||
import MatrixClientBackedController from "../../../../src/settings/controllers/MatrixClientBackedController";
|
import MatrixClientBackedController from "../../../../src/settings/controllers/MatrixClientBackedController";
|
||||||
|
import { Layout } from "../../../../src/settings/enums/Layout";
|
||||||
import { getMockClientWithEventEmitter, mockClientMethodsServer } from "../../../test-utils";
|
import { getMockClientWithEventEmitter, mockClientMethodsServer } from "../../../test-utils";
|
||||||
|
|
||||||
describe("RequiresSettingsController", () => {
|
describe("RequiresSettingsController", () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
// HealthChat changed the default "layout" to Bubble. These tests use "useCompactLayout" as a
|
||||||
|
// sample boolean setting, but its IncompatibleController forces it to false unless layout is
|
||||||
|
// Group, so pin the layout to Group to keep useCompactLayout effective.
|
||||||
|
await SettingsStore.setValue("layout", null, SettingLevel.DEVICE, Layout.Group);
|
||||||
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
SettingsStore.reset();
|
SettingsStore.reset();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ const PresentationProbe: React.FC = () => {
|
|||||||
|
|
||||||
describe("EventPresentationContextProvider", () => {
|
describe("EventPresentationContextProvider", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
// HealthChat changed the default "layout" to Bubble, but useCompactLayout's IncompatibleController
|
||||||
|
// only allows compact density when the layout is Group. Pin it so the compact-layout test is meaningful.
|
||||||
|
await SettingsStore.setValue("layout", null, SettingLevel.DEVICE, Layout.Group);
|
||||||
await SettingsStore.setValue("useCompactLayout", null, SettingLevel.DEVICE, false);
|
await SettingsStore.setValue("useCompactLayout", null, SettingLevel.DEVICE, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user