Skip to content

Commit b569cee

Browse files
committed
force relay in e2e
1 parent fb80d05 commit b569cee

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

tests/demo-react.spec.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ import { Browser, expect, type Page, test } from "@playwright/test";
1212
const PULSEBEAM_BASE_URL = process.env.PULSEBEAM_BASE_URL ||
1313
"https://cloud.pulsebeam.dev/grpc";
1414

15+
const PRESETS = {
16+
baseUrl: PULSEBEAM_BASE_URL,
17+
forceRelay: "on",
18+
mock: "on",
19+
};
20+
21+
function toUrl(base: string, presets: typeof PRESETS): string {
22+
return base +
23+
`?mock=${presets.mock}&baseUrl=${presets.baseUrl}&forceRelay=${presets.forceRelay}`;
24+
}
25+
1526
// https://playwright.dev/docs/test-retries#serial-mode
1627
test.describe.configure({ mode: "serial" });
1728

@@ -40,18 +51,18 @@ async function waitForStableVideo(
4051
expect(await video.evaluate((v: HTMLVideoElement) => v.readyState)).toBe(
4152
4,
4253
);
43-
await page.waitForTimeout(delayMs).catch(() => {});
54+
await page.waitForTimeout(delayMs).catch(() => { });
4455
return;
4556
} catch (_e) {
46-
await page.waitForTimeout(1000).catch(() => {});
57+
await page.waitForTimeout(1000).catch(() => { });
4758
}
4859
}
4960

5061
throw new Error("waitForStableVideo timeout");
5162
}
5263

5364
async function assertClick(btn: Locator) {
54-
await btn.click({ timeout: 1000 }).catch(() => {});
65+
await btn.click({ timeout: 1000 }).catch(() => { });
5566
await expect(btn).not.toBeVisible();
5667
}
5768

@@ -81,9 +92,10 @@ function getAllPairs<T>(list: T[]): [T, T][] {
8192
}
8293

8394
test(`load`, async ({ browser, browserName, baseURL }) => {
95+
const url = toUrl(baseURL!, PRESETS);
8496
const context = await browser.newContext();
8597
const page = await context.newPage();
86-
await page.goto(baseURL! + "?mock=on");
98+
await page.goto(url);
8799
await waitForStableVideo(page, "", 1000);
88100
});
89101

@@ -109,7 +121,7 @@ test.describe("Connect", () => {
109121
// basic connection test a->b
110122
for (const [bA, bB] of pairs) {
111123
test(`${bA}_${bB} basic connection`, async ({ baseURL }) => {
112-
const url = baseURL + "?mock=on&baseUrl=" + PULSEBEAM_BASE_URL;
124+
const url = toUrl(baseURL!, PRESETS);
113125
const group = `${randId()}`;
114126
const peerA = `__${bA}_A`;
115127
const peerB = `__${bB}_B`;
@@ -143,7 +155,7 @@ test.describe("Connect", () => {
143155

144156
// Disconnect and reconnect with role reversal
145157
test(`${bA}_${bB} disconnect and reconnect`, async ({ baseURL }) => {
146-
const url = `${baseURL}?mock=on&baseUrl=${PULSEBEAM_BASE_URL}`;
158+
const url = toUrl(baseURL!, PRESETS);
147159
const group = `${randId()}`;
148160
const peerA = `__${bA}_A`;
149161
const peerB = `__${bB}_B`;

0 commit comments

Comments
 (0)