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:
@@ -85,7 +85,7 @@ describe("<LoggedInView />", () => {
|
||||
mockClient.setPushRuleActions.mockReset().mockResolvedValue({});
|
||||
// @ts-expect-error
|
||||
mockClient.pushProcessor = new PushProcessor(mockClient);
|
||||
mockSdkContext.client = mockClient;
|
||||
mockSdkContext._client = mockClient;
|
||||
});
|
||||
|
||||
describe("synced push rules", () => {
|
||||
|
||||
@@ -112,7 +112,7 @@ describe("PipContainer", () => {
|
||||
sdkContext = new TestSDKContext();
|
||||
// @ts-ignore PipContainer uses SDKContext in the constructor
|
||||
SDKContextClass.instance = sdkContext;
|
||||
sdkContext.client = client;
|
||||
sdkContext._client = client;
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -23,8 +23,8 @@ import { RightPanelPhases } from "../../../../src/stores/right-panel/RightPanelS
|
||||
import RightPanelStore from "../../../../src/stores/right-panel/RightPanelStore";
|
||||
import { UPDATE_EVENT } from "../../../../src/stores/AsyncStore";
|
||||
import { WidgetLayoutStore } from "../../../../src/stores/widgets/WidgetLayoutStore";
|
||||
import { SDKContextClass } from "../../../../src/contexts/SDKContextClass";
|
||||
import { RoomPermalinkCreator } from "../../../../src/utils/permalinks/Permalinks";
|
||||
import { TestSDKContext } from "../../TestSDKContext.ts";
|
||||
|
||||
const RightPanelBase = wrapInMatrixClientContext(_RightPanel);
|
||||
|
||||
@@ -32,14 +32,14 @@ describe("RightPanel", () => {
|
||||
const resizeNotifier = new ResizeNotifier();
|
||||
|
||||
let cli: MockedObject<MatrixClient>;
|
||||
let context: SDKContextClass;
|
||||
let context: TestSDKContext;
|
||||
let RightPanel: React.ComponentType<React.ComponentProps<typeof RightPanelBase>>;
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
cli = mocked(MatrixClientPeg.safeGet());
|
||||
DMRoomMap.makeShared(cli);
|
||||
context = new SDKContextClass();
|
||||
context.client = cli;
|
||||
context = new TestSDKContext();
|
||||
context._client = cli;
|
||||
RightPanel = wrapInSdkContext(RightPanelBase, context);
|
||||
});
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ import { DirectoryMember } from "../../../../src/utils/direct-messages";
|
||||
import { createDmLocalRoom } from "../../../../src/utils/dm/createDmLocalRoom";
|
||||
import { UPDATE_EVENT } from "../../../../src/stores/AsyncStore";
|
||||
import { SDKContext } from "../../../../src/contexts/SDKContext";
|
||||
import { SDKContextClass } from "../../../../src/contexts/SDKContextClass";
|
||||
import { TestSDKContext } from "../../TestSDKContext.ts";
|
||||
import WidgetUtils from "../../../../src/utils/WidgetUtils";
|
||||
import { WidgetType } from "../../../../src/widgets/WidgetType";
|
||||
import WidgetStore from "../../../../src/stores/WidgetStore";
|
||||
@@ -86,7 +86,7 @@ describe("RoomView", () => {
|
||||
let cli: MockedObject<MatrixClient>;
|
||||
let room: Room;
|
||||
let rooms: Map<string, Room>;
|
||||
let stores: SDKContextClass;
|
||||
let stores: TestSDKContext;
|
||||
let crypto: CryptoApi;
|
||||
|
||||
// mute some noise
|
||||
@@ -111,8 +111,8 @@ describe("RoomView", () => {
|
||||
room.on(RoomEvent.TimelineReset, (...args) => cli.emit(RoomEvent.TimelineReset, ...args));
|
||||
|
||||
DMRoomMap.makeShared(cli);
|
||||
stores = new SDKContextClass();
|
||||
stores.client = cli;
|
||||
stores = new TestSDKContext();
|
||||
stores._client = cli;
|
||||
stores.rightPanelStore.useUnitTestClient(cli);
|
||||
|
||||
crypto = cli.getCrypto()!;
|
||||
|
||||
Reference in New Issue
Block a user