mirror of
https://github.com/vector-im/element-call.git
synced 2026-10-16 23:45:50 +00:00
Fix some tests
This commit is contained in:
@@ -58,7 +58,6 @@ import { ConnectionState, type Connection } from "../remoteMembers/Connection";
|
|||||||
import { type Publisher } from "./Publisher";
|
import { type Publisher } from "./Publisher";
|
||||||
import { initializeWidget } from "../../../widget";
|
import { initializeWidget } from "../../../widget";
|
||||||
import { nullHostBridge } from "../../../HostBridge";
|
import { nullHostBridge } from "../../../HostBridge";
|
||||||
import { type SFUConfig } from "../../../livekit/auth";
|
|
||||||
import * as livekitAuth from "../../../livekit/auth";
|
import * as livekitAuth from "../../../livekit/auth";
|
||||||
|
|
||||||
initializeWidget();
|
initializeWidget();
|
||||||
@@ -320,15 +319,9 @@ describe("LocalMembership", () => {
|
|||||||
const mockTransport: UnstableLivekitTransport = {
|
const mockTransport: UnstableLivekitTransport = {
|
||||||
type: "livekit",
|
type: "livekit",
|
||||||
url: "https://sfu.example.org",
|
url: "https://sfu.example.org",
|
||||||
|
livekit_service_url: "https://jwt.example.org",
|
||||||
} as UnstableLivekitTransport;
|
} as UnstableLivekitTransport;
|
||||||
|
|
||||||
const mockSFUConfig: SFUConfig = {
|
|
||||||
jwt: "foo",
|
|
||||||
livekitAlias: "bar",
|
|
||||||
livekitIdentity: "baz",
|
|
||||||
url: "bro",
|
|
||||||
};
|
|
||||||
|
|
||||||
const connectionTransportAConnected = {
|
const connectionTransportAConnected = {
|
||||||
livekitRoom: mockLivekitRoom({
|
livekitRoom: mockLivekitRoom({
|
||||||
localParticipant: {
|
localParticipant: {
|
||||||
@@ -345,10 +338,10 @@ describe("LocalMembership", () => {
|
|||||||
livekitRoom: mockLivekitRoom({}),
|
livekitRoom: mockLivekitRoom({}),
|
||||||
} as unknown as Connection;
|
} as unknown as Connection;
|
||||||
|
|
||||||
const authCallSpy = vi
|
const delegationSpy = vi
|
||||||
.spyOn(livekitAuth, "getSFUConfig")
|
.spyOn(livekitAuth, "delegateDelayedLeave")
|
||||||
.mockResolvedValue(mockSFUConfig);
|
.mockResolvedValue();
|
||||||
afterEach(() => authCallSpy.mockClear());
|
afterEach(() => delegationSpy.mockClear());
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
["no", null, timings],
|
["no", null, timings],
|
||||||
@@ -357,7 +350,11 @@ describe("LocalMembership", () => {
|
|||||||
"https://matrix.example.org/_matrix/client/unstable/io.element.msc4195/rtc/livekit/delegate_delayed_leave",
|
"https://matrix.example.org/_matrix/client/unstable/io.element.msc4195/rtc/livekit/delegate_delayed_leave",
|
||||||
delegatedTimings,
|
delegatedTimings,
|
||||||
],
|
],
|
||||||
["transport", "/a/delegate_delayed_leave", delegatedTimings],
|
[
|
||||||
|
"transport",
|
||||||
|
"https://jwt.example.org/delegate_delayed_leave",
|
||||||
|
delegatedTimings,
|
||||||
|
],
|
||||||
])(
|
])(
|
||||||
"joins session with %s delegation support",
|
"joins session with %s delegation support",
|
||||||
async (_serviceName, delegationUrl, delayedLeaveTimings) => {
|
async (_serviceName, delegationUrl, delayedLeaveTimings) => {
|
||||||
@@ -390,27 +387,23 @@ describe("LocalMembership", () => {
|
|||||||
delayedLeaveTimings,
|
delayedLeaveTimings,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(authCallSpy).not.toHaveBeenCalled();
|
expect(delegationSpy).not.toHaveBeenCalled();
|
||||||
delayId$.next("leave1");
|
delayId$.next("leave1");
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
if (delegationUrl === null) {
|
if (delegationUrl === null) {
|
||||||
expect(authCallSpy).not.toHaveBeenCalled();
|
expect(delegationSpy).not.toHaveBeenCalled();
|
||||||
} else {
|
} else {
|
||||||
// Delegation is supported in this test case, so go on to check that
|
// Delegation is supported in this test case, so go on to check that
|
||||||
// LocalMember actually performs delegation
|
// LocalMember actually performs delegation
|
||||||
const expectDelegation = (delayId: string) =>
|
const expectDelegation = (delayId: string) =>
|
||||||
expect(authCallSpy).toHaveBeenLastCalledWith(
|
expect(delegationSpy).toHaveBeenLastCalledWith({
|
||||||
mockedClient,
|
client: mockedClient,
|
||||||
ownMemberMock,
|
membership: ownMemberMock,
|
||||||
"a",
|
transport: mockTransport,
|
||||||
"!test-room-id:example.org",
|
roomId: "!test-room-id:example.org",
|
||||||
{
|
delayId,
|
||||||
matrixRTCMode: MATRIX_RTC_MODE,
|
logger: expect.anything(),
|
||||||
delayEndpointBaseUrl: "https://matrix.example.org",
|
});
|
||||||
delayId,
|
|
||||||
},
|
|
||||||
expect.anything(),
|
|
||||||
);
|
|
||||||
|
|
||||||
expectDelegation("leave1");
|
expectDelegation("leave1");
|
||||||
delayId$.next("leave2"); // Can change delegated leaves
|
delayId$.next("leave2"); // Can change delegated leaves
|
||||||
|
|||||||
Reference in New Issue
Block a user