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:
Michael Telatynski
2026-07-06 16:09:21 +00:00
committed by GitHub
parent 20587b3495
commit dc33d736a0
30 changed files with 137 additions and 71 deletions
@@ -29,7 +29,7 @@ describe("MemberListStore", () => {
const context = new TestSDKContext();
client = stubClient();
client.baseUrl = "https://invalid.base.url.here";
context.client = client;
context._client = client;
store = new MemberListStore(context);
// alice is joined to the room.
room = new Room(roomId, client, client.getUserId()!);
@@ -194,7 +194,7 @@ describe("RoomViewStore", function () {
dis = new MatrixDispatcher();
slidingSyncManager = new MockSlidingSyncManager();
stores = new TestSDKContext();
stores.client = mockClient;
stores._client = mockClient;
stores._SlidingSyncManager = slidingSyncManager;
stores._PosthogAnalytics = new MockPosthogAnalytics();
// @ts-expect-error
@@ -30,7 +30,7 @@ describe("TypingStore", () => {
sendTyping: jest.fn(),
} as unknown as MatrixClient;
const context = new TestSDKContext();
context.client = mockClient;
context._client = mockClient;
typingStore = new TypingStore(context);
jest.spyOn(SettingsStore, "getValue").mockImplementation((name: string) => {
return name === "sendTypingNotifications";
@@ -54,7 +54,7 @@ describe("WidgetPermissionStore", () => {
);
mockClient = stubClient();
const context = new TestSDKContext();
context.client = mockClient;
context._client = mockClient;
widgetPermissionStore = new WidgetPermissionStore(context);
});