Skip to content

Commit 3491a68

Browse files
authored
Merge pull request #3576 from element-hq/toger5/fix-skipped-tests
Refactor local transport testing and local membership initialization
2 parents 1aa1af2 + 294b90b commit 3491a68

25 files changed

+1488
-458
lines changed

locales/en/app.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@
6464
"developer_mode": {
6565
"always_show_iphone_earpiece": "Show iPhone earpiece option on all platforms",
6666
"crypto_version": "Crypto version: {{version}}",
67+
"custom_livekit_url": {
68+
"current_url": "Currently set to: ",
69+
"from_config": "Currently, no overwrite is set. Url from well-known or config is used.",
70+
"label": "Custom Livekit-url",
71+
"reset": "Reset overwrite",
72+
"save": "Save",
73+
"saving": "Saving..."
74+
},
6775
"debug_tile_layout_label": "Debug tile layout",
6876
"device_id": "Device ID: {{id}}",
6977
"duplicate_tiles_label": "Number of additional tile copies per participant",

playwright/fixtures/widget-user.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ export const widgetTest = test.extend<MyFixtures>({
159159
} = await registerUser(browser, userB);
160160

161161
// Invite the second user
162-
await ewPage1.getByRole("button", { name: "Add", exact: true }).click();
162+
await ewPage1
163+
.getByRole("navigation", { name: "Room list" })
164+
.getByRole("button", { name: "New conversation" })
165+
.click();
166+
163167
await ewPage1.getByRole("menuitem", { name: "New Room" }).click();
164168
await ewPage1.getByRole("textbox", { name: "Name" }).fill("Welcome Room");
165169
await ewPage1.getByRole("button", { name: "Create room" }).click();

src/config/ConfigOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export interface ConfigOptions {
122122
delayed_leave_event_delay_ms?: number;
123123

124124
/**
125-
* The time (in milliseconds) after which a we consider a delayed event restart http request to have failed.
125+
* The time (in milliseconds) after which we consider a delayed event restart http request to have failed.
126126
* Setting this to a lower value will result in more frequent retries but also a higher chance of failiour.
127127
*
128128
* In the presence of network packet loss (hurting TCP connections), the custom delayedEventRestartLocalTimeoutMs

src/livekit/openIDSFU.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ export type OpenIDClientParts = Pick<
2121
MatrixClient,
2222
"getOpenIdToken" | "getDeviceId"
2323
>;
24-
24+
/**
25+
* Gets a bearer token from the homeserver and then use it to authenticate
26+
* to the matrix RTC backend in order to get acces to the SFU.
27+
* It has built-in retry for calls to the homeserver with a backoff policy.
28+
* @param client
29+
* @param serviceUrl
30+
* @param matrixRoomId
31+
* @returns Object containing the token information
32+
* @throws FailToGetOpenIdToken
33+
*/
2534
export async function getSFUConfigWithOpenID(
2635
client: OpenIDClientParts,
2736
serviceUrl: string,

src/room/GroupCallErrorBoundary.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
WebBrowserIcon,
2323
} from "@vector-im/compound-design-tokens/assets/web/icons";
2424
import { Button } from "@vector-im/compound-web";
25+
import { logger } from "matrix-js-sdk/lib/logger";
2526

2627
import {
2728
ConnectionLostError,
@@ -53,7 +54,7 @@ const ErrorPage: FC<ErrorPageProps> = ({
5354
widget,
5455
}: ErrorPageProps): ReactElement => {
5556
const { t } = useTranslation();
56-
57+
logger.error("Error boundary caught:", error);
5758
let icon: ComponentType<SVGAttributes<SVGElement>>;
5859
switch (error.category) {
5960
case ErrorCategory.CONFIGURATION_ISSUE:

src/room/GroupCallView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export const GroupCallView: FC<Props> = ({
159159
};
160160
}, [rtcSession]);
161161

162+
// TODO move this into the callViewModel LocalMembership.ts
162163
useTypedEventEmitter(
163164
rtcSession,
164165
MatrixRTCSessionEvent.MembershipManagerError,

src/room/InCallView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ export const InCallView: FC<InCallViewProps> = ({
266266
const sharingScreen = useBehavior(vm.sharingScreen$);
267267

268268
const ringOverlay = useBehavior(vm.ringOverlay$);
269-
const fatalCallError = useBehavior(vm.configError$);
269+
const fatalCallError = useBehavior(vm.fatalError$);
270270
// Stop the rendering and throw for the error boundary
271271
if (fatalCallError) throw fatalCallError;
272272

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
Copyright 2025 New Vector Ltd.
3+
4+
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
5+
Please see LICENSE in the repository root for full details.
6+
*/
7+
8+
import { describe, expect, it, vi } from "vitest";
9+
import { render, waitFor } from "@testing-library/react";
10+
11+
import type { MatrixClient } from "matrix-js-sdk";
12+
import type { Room as LivekitRoom } from "livekit-client";
13+
import { DeveloperSettingsTab } from "./DeveloperSettingsTab";
14+
15+
// Mock url params hook to avoid environment-dependent snapshot churn.
16+
vi.mock("../UrlParams", () => ({
17+
useUrlParams: (): { mocked: boolean; answer: number } => ({
18+
mocked: true,
19+
answer: 42,
20+
}),
21+
}));
22+
23+
// Provide a minimal mock of a Livekit Room structure used by the component.
24+
function createMockLivekitRoom(
25+
wsUrl: string,
26+
serverInfo: object,
27+
metadata: string,
28+
): { isLocal: boolean; url: string; room: LivekitRoom } {
29+
const mockRoom = {
30+
serverInfo,
31+
metadata,
32+
engine: { client: { ws: { url: wsUrl } } },
33+
} as unknown as LivekitRoom;
34+
35+
return {
36+
isLocal: true,
37+
url: wsUrl,
38+
room: mockRoom,
39+
};
40+
}
41+
42+
// Minimal MatrixClient mock with only the methods used by the component.
43+
function createMockMatrixClient(): MatrixClient {
44+
return {
45+
doesServerSupportUnstableFeature: vi.fn().mockResolvedValue(true), // ensure stickyEventsSupported eventually becomes true
46+
getCrypto: (): { getVersion: () => string } | undefined => ({
47+
getVersion: () => "crypto-1.0.0",
48+
}),
49+
getUserId: () => "@alice:example.org",
50+
getDeviceId: () => "DEVICE123",
51+
} as unknown as MatrixClient;
52+
}
53+
54+
describe("DeveloperSettingsTab", () => {
55+
it("renders and matches snapshot", async () => {
56+
const client = createMockMatrixClient();
57+
58+
const livekitRooms: {
59+
room: LivekitRoom;
60+
url: string;
61+
isLocal?: boolean;
62+
}[] = [
63+
createMockLivekitRoom(
64+
"wss://local-sfu.example.org",
65+
{ region: "local", version: "1.2.3" },
66+
"local-metadata",
67+
),
68+
{
69+
isLocal: false,
70+
url: "wss://remote-sfu.example.org",
71+
room: {
72+
serverInfo: { region: "remote", version: "4.5.6" },
73+
metadata: "remote-metadata",
74+
engine: { client: { ws: { url: "wss://remote-sfu.example.org" } } },
75+
} as unknown as LivekitRoom,
76+
},
77+
];
78+
79+
const { container } = render(
80+
<DeveloperSettingsTab
81+
client={client}
82+
livekitRooms={livekitRooms}
83+
env={{ MY_MOCK_ENV: 10, ENV: "test" } as unknown as ImportMetaEnv}
84+
/>,
85+
);
86+
87+
// Wait for the async sticky events feature check to resolve so the final UI
88+
// (e.g. enabled Matrix_2_0 radio button) appears deterministically.
89+
await waitFor(() =>
90+
expect(client.doesServerSupportUnstableFeature).toHaveBeenCalled(),
91+
);
92+
93+
expect(container).toMatchSnapshot();
94+
});
95+
});

0 commit comments

Comments
 (0)