Handle SDKContextClass client initialisation internally (#34146)
* Handle SDKContextClass `client` initialisation internally Rather than via MatrixChat - this is predominantly for Lifecycle tests as they don't use a MatrixChat and it doesn't make much sense for this component to own this state. * Fix tests
This commit is contained in:
+4
-4
@@ -16,7 +16,7 @@ import { ToastContext, ToastRack } from "@element-hq/web-shared-components";
|
||||
|
||||
import AccountUserSettingsTab from "../../../../../../../src/components/views/settings/tabs/user/AccountUserSettingsTab";
|
||||
import { SDKContext } from "../../../../../../../src/contexts/SDKContext";
|
||||
import { SDKContextClass } from "../../../../../../../src/contexts/SDKContextClass";
|
||||
import { TestSDKContext } from "../../../../../TestSDKContext.ts";
|
||||
import SettingsStore from "../../../../../../../src/settings/SettingsStore";
|
||||
import {
|
||||
getMockClientWithEventEmitter,
|
||||
@@ -51,7 +51,7 @@ describe("<AccountUserSettingsTab />", () => {
|
||||
const userId = "@alice:server.org";
|
||||
let mockClient: MockedObject<MatrixClient>;
|
||||
|
||||
let stores: SDKContextClass;
|
||||
let stores: TestSDKContext;
|
||||
|
||||
const getComponent = () => (
|
||||
<MatrixClientContext.Provider value={mockClient}>
|
||||
@@ -87,8 +87,8 @@ describe("<AccountUserSettingsTab />", () => {
|
||||
id_server_unbind_result: "success",
|
||||
});
|
||||
|
||||
stores = new SDKContextClass();
|
||||
stores.client = mockClient;
|
||||
stores = new TestSDKContext();
|
||||
stores._client = mockClient;
|
||||
// stub out this store completely to avoid mocking initialisation
|
||||
const mockOidcClientStore = {} as unknown as OidcClientStore;
|
||||
jest.spyOn(stores, "oidcClientStore", "get").mockReturnValue(mockOidcClientStore);
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@ import {
|
||||
mockPlatformPeg,
|
||||
} from "../../../../../../test-utils";
|
||||
import { SDKContext } from "../../../../../../../src/contexts/SDKContext";
|
||||
import { SDKContextClass } from "../../../../../../../src/contexts/SDKContextClass";
|
||||
import { TestSDKContext } from "../../../../../TestSDKContext.ts";
|
||||
import defaultDispatcher from "../../../../../../../src/dispatcher/dispatcher";
|
||||
import { UIFeature } from "../../../../../../../src/settings/UIFeature";
|
||||
import SettingsStore from "../../../../../../../src/settings/SettingsStore";
|
||||
@@ -42,8 +42,8 @@ describe("<SecurityUserSettingsTab />", () => {
|
||||
setIgnoredUsers,
|
||||
});
|
||||
|
||||
const sdkContext = new SDKContextClass();
|
||||
sdkContext.client = mockClient;
|
||||
const sdkContext = new TestSDKContext();
|
||||
sdkContext._client = mockClient;
|
||||
|
||||
const getComponent = () => (
|
||||
<MatrixClientContext.Provider value={mockClient}>
|
||||
|
||||
+4
-4
@@ -57,7 +57,7 @@ import { INACTIVE_DEVICE_AGE_MS } from "../../../../../../../src/components/view
|
||||
import SettingsStore from "../../../../../../../src/settings/SettingsStore";
|
||||
import { getClientInformationEventType } from "../../../../../../../src/utils/device/clientInformation";
|
||||
import { SDKContext } from "../../../../../../../src/contexts/SDKContext";
|
||||
import { SDKContextClass } from "../../../../../../../src/contexts/SDKContextClass";
|
||||
import { TestSDKContext } from "../../../../../TestSDKContext.ts";
|
||||
import { type OidcClientStore } from "../../../../../../../src/stores/oidc/OidcClientStore";
|
||||
import { makeDelegatedAuthConfig } from "../../../../../../test-utils/oidc";
|
||||
import MatrixClientContext from "../../../../../../../src/contexts/MatrixClientContext";
|
||||
@@ -134,7 +134,7 @@ describe("<SessionManagerTab />", () => {
|
||||
} as unknown as CryptoApi);
|
||||
|
||||
let mockClient!: MockedObject<MatrixClient>;
|
||||
let sdkContext: SDKContextClass;
|
||||
let sdkContext: TestSDKContext;
|
||||
|
||||
const defaultProps = {};
|
||||
const getComponent = (props = {}): React.ReactElement => (
|
||||
@@ -250,8 +250,8 @@ describe("<SessionManagerTab />", () => {
|
||||
}
|
||||
});
|
||||
|
||||
sdkContext = new SDKContextClass();
|
||||
sdkContext.client = mockClient;
|
||||
sdkContext = new TestSDKContext();
|
||||
sdkContext._client = mockClient;
|
||||
|
||||
// @ts-ignore allow delete of non-optional prop
|
||||
delete window.location;
|
||||
|
||||
Reference in New Issue
Block a user