mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-10-31 16:23:03 +00:00
test: adapt unit tests to HealthChat fork customizations
This commit is contained in:
@@ -1688,8 +1688,9 @@ describe("<MatrixChat />", () => {
|
||||
await flushPromises();
|
||||
expect(Lifecycle.attemptDelegatedAuthLogin).toHaveBeenCalled();
|
||||
|
||||
// should just show the welcome screen
|
||||
await rendered.findByText("Welcome to Test");
|
||||
// should just show the welcome screen (wait for welcome page chrome render; HealthChat's
|
||||
// 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();
|
||||
});
|
||||
|
||||
|
||||
+3
-48
@@ -140,57 +140,12 @@ exports[`<MatrixChat /> Multi-tab lockout waits for other tab to stop during sta
|
||||
class="mx_Welcome"
|
||||
>
|
||||
<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
|
||||
class="mx_DefaultWelcome_buttons"
|
||||
class="mx_WelcomePage_body"
|
||||
>
|
||||
<a
|
||||
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>
|
||||
Couldn't load page
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
|
||||
@@ -33,6 +33,7 @@ import { getPowerLevels } from "../../../../../src/components/viewmodels/right_p
|
||||
import { RightPanelPhases } from "../../../../../src/stores/right-panel/RightPanelStorePhases";
|
||||
import { MatrixClientPeg } from "../../../../../src/MatrixClientPeg";
|
||||
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
|
||||
import { SdkContextClass } from "../../../../../src/contexts/SDKContext";
|
||||
import Modal from "../../../../../src/Modal";
|
||||
import { clearAllModals, flushPromises } from "../../../../test-utils";
|
||||
import ErrorDialog from "../../../../../src/components/views/dialogs/ErrorDialog";
|
||||
@@ -134,6 +135,9 @@ beforeEach(() => {
|
||||
|
||||
jest.spyOn(MatrixClientPeg, "get").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 />", () => {
|
||||
|
||||
@@ -667,8 +667,8 @@ describe("RoomHeader", () => {
|
||||
const button = screen.getByRole("button", { name: "Video call" });
|
||||
expect(button).not.toHaveAttribute("aria-disabled", "true");
|
||||
await user.click(button);
|
||||
const elementCallButton = screen.getByRole("menuitem", { name: "Element Call" });
|
||||
const legacyCallButton = screen.getByRole("menuitem", { name: "Legacy Call" });
|
||||
const elementCallButton = screen.getByRole("menuitem", { name: _t("voip|element_call") });
|
||||
const legacyCallButton = screen.getByRole("menuitem", { name: _t("voip|legacy_call") });
|
||||
expect(elementCallButton).toBeInTheDocument();
|
||||
expect(legacyCallButton).toBeInTheDocument();
|
||||
});
|
||||
@@ -684,8 +684,8 @@ describe("RoomHeader", () => {
|
||||
const button = screen.getByRole("button", { name: "Voice call" });
|
||||
expect(button).not.toHaveAttribute("aria-disabled", "true");
|
||||
await user.click(button);
|
||||
const elementCallButton = screen.getByRole("menuitem", { name: "Element Call" });
|
||||
const legacyCallButton = screen.getByRole("menuitem", { name: "Legacy Call" });
|
||||
const elementCallButton = screen.getByRole("menuitem", { name: _t("voip|element_call") });
|
||||
const legacyCallButton = screen.getByRole("menuitem", { name: _t("voip|legacy_call") });
|
||||
expect(elementCallButton).toBeInTheDocument();
|
||||
expect(legacyCallButton).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -18,6 +18,7 @@ import { mkStubRoom, stubClient } from "../../../../test-utils";
|
||||
import { ToastContext, type ToastRack } from "../../../../../src/contexts/ToastContext";
|
||||
import { OwnProfileStore } from "../../../../../src/stores/OwnProfileStore";
|
||||
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
|
||||
import { SdkContextClass } from "../../../../../src/contexts/SDKContext";
|
||||
import Modal from "../../../../../src/Modal";
|
||||
|
||||
interface MockedAvatarSettingProps {
|
||||
@@ -86,6 +87,9 @@ describe("ProfileSettings", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
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 = {
|
||||
displayToast: jest.fn().mockReturnValue(jest.fn()),
|
||||
};
|
||||
|
||||
+3
@@ -85,6 +85,9 @@ describe("<AccountUserSettingsTab />", () => {
|
||||
|
||||
stores = new SdkContextClass();
|
||||
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
|
||||
const mockOidcClientStore = {} as unknown as OidcClientStore;
|
||||
jest.spyOn(stores, "oidcClientStore", "get").mockReturnValue(mockOidcClientStore);
|
||||
|
||||
+4
-4
@@ -42,14 +42,14 @@ exports[`<AccountUserSettingsTab /> 3pids should display 3pid email addresses an
|
||||
>
|
||||
<input
|
||||
autocomplete="email"
|
||||
id="mx_Field_3"
|
||||
id="mx_Field_113"
|
||||
label="Email Address"
|
||||
placeholder="Email Address"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
<label
|
||||
for="mx_Field_3"
|
||||
for="mx_Field_113"
|
||||
>
|
||||
Email Address
|
||||
</label>
|
||||
@@ -154,14 +154,14 @@ exports[`<AccountUserSettingsTab /> 3pids should display 3pid email addresses an
|
||||
</span>
|
||||
<input
|
||||
autocomplete="tel-national"
|
||||
id="mx_Field_4"
|
||||
id="mx_Field_114"
|
||||
label="Phone Number"
|
||||
placeholder="Phone Number"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
<label
|
||||
for="mx_Field_4"
|
||||
for="mx_Field_114"
|
||||
>
|
||||
Phone Number
|
||||
</label>
|
||||
|
||||
@@ -10,9 +10,17 @@ import RequiresSettingsController from "../../../../src/settings/controllers/Req
|
||||
import { SettingLevel } from "../../../../src/settings/SettingLevel";
|
||||
import SettingsStore from "../../../../src/settings/SettingsStore";
|
||||
import MatrixClientBackedController from "../../../../src/settings/controllers/MatrixClientBackedController";
|
||||
import { Layout } from "../../../../src/settings/enums/Layout";
|
||||
import { getMockClientWithEventEmitter, mockClientMethodsServer } from "../../../test-utils";
|
||||
|
||||
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(() => {
|
||||
SettingsStore.reset();
|
||||
});
|
||||
|
||||
@@ -25,6 +25,9 @@ const PresentationProbe: React.FC = () => {
|
||||
|
||||
describe("EventPresentationContextProvider", () => {
|
||||
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);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user