Skip to content

Commit

Permalink
get rid of more memberhsip manager usage in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
toger5 committed Jan 9, 2025
1 parent e9c23e2 commit b292450
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions spec/unit/matrixrtc/MatrixRTCSession.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ describe("MatrixRTCSession", () => {
type: "livekit",
},
},

"_@alice:example.org_AAAAAAA",
);
await Promise.race([sentDelayedState, new Promise((resolve) => realSetTimeout(resolve, 500))]);
Expand Down Expand Up @@ -458,6 +457,7 @@ describe("MatrixRTCSession", () => {
});
});

const userStateKey = `${!useOwnedStateEvents ? "_" : ""}@alice:example.org_AAAAAAA`;
// preparing the delayed disconnect should handle ratelimiting
const sendDelayedStateAttempt = new Promise<void>((resolve) => {
const error = new MatrixError({ errcode: "M_LIMIT_EXCEEDED" });
Expand All @@ -481,16 +481,19 @@ describe("MatrixRTCSession", () => {
return Promise.reject(error);
});
});
// needed to join so that myMembershipManager gets created

sess!.joinRoomSession([activeFocusConfig], activeFocus, {
membershipServerSideExpiryTimeout: 9000,
});

expect((sess as any).membershipManager).toHaveProperty("membershipServerSideExpiryTimeout", 9000);
await sendDelayedStateExceedAttempt.then(); // needed to resolve after the send attempt catches
expect((sess as any).membershipManager).toHaveProperty("membershipServerSideExpiryTimeout", 7500);

await sendDelayedStateAttempt;
const callProps = (d: number) => {
return [mockRoom!.roomId, { delay: d }, "org.matrix.msc3401.call.member", {}, userStateKey];
};
expect(client._unstable_sendDelayedStateEvent).toHaveBeenNthCalledWith(1, ...callProps(9000));
expect(client._unstable_sendDelayedStateEvent).toHaveBeenNthCalledWith(2, ...callProps(7500));

jest.advanceTimersByTime(5000);

await sendStateEventAttempt.then(); // needed to resolve after resendIfRateLimited catches
Expand All @@ -509,7 +512,7 @@ describe("MatrixRTCSession", () => {
foci_preferred: [activeFocusConfig],
focus_active: activeFocus,
} satisfies SessionMembershipData,
`${!useOwnedStateEvents ? "_" : ""}@alice:example.org_AAAAAAA`,
userStateKey,
);
await sentDelayedState;

Expand Down

0 comments on commit b292450

Please sign in to comment.