Skip to content

Commit 20906d5

Browse files
committed
bleh
1 parent 2c8c3fb commit 20906d5

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

site/e2e/expectUrl.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { expect, type Page, waitFor } from "@playwright/test";
2+
3+
export const expectUrl = expect.extend({
4+
async toHavePath(page: Page, pathname: string) {
5+
let url;
6+
let pass;
7+
8+
try {
9+
await waitFor(() => {
10+
url = new URL(page.url());
11+
expect(url.pathname).toBe(pathname);
12+
});
13+
pass = true;
14+
} catch {
15+
pass = false;
16+
}
17+
18+
return {
19+
message: () => "foob",
20+
pass,
21+
name: "toHavePath",
22+
expected: pathname,
23+
actual: url.toString(),
24+
};
25+
},
26+
});

site/e2e/helpers.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
Response,
3232
type RichParameter,
3333
} from "./provisionerGenerated";
34+
import { expectUrl } from "./expectUrl";
3435

3536
// requiresEnterpriseLicense will skip the test if we're not running with an enterprise license
3637
export function requiresEnterpriseLicense() {
@@ -52,7 +53,9 @@ export const createWorkspace = async (
5253
await page.goto("/templates/" + templateName + "/workspace", {
5354
waitUntil: "domcontentloaded",
5455
});
55-
await expect(page).toHaveURL("/templates/" + templateName + "/workspace");
56+
await expectUrl(page).toHavePathName(
57+
"/templates/" + templateName + "/workspace",
58+
);
5659

5760
const name = randomName();
5861
await page.getByLabel("name").fill(name);
@@ -61,7 +64,7 @@ export const createWorkspace = async (
6164
await page.getByTestId("form-submit").click();
6265

6366
// We can't use `toHaveURL` because that causes issues with searchParams
64-
await expect(new URL(page.url()).pathname).toBe("/@admin/" + name);
67+
await expectUrl(page.url())).toHavePathName("/@admin/" + name);
6568

6669
await page.waitForSelector("*[data-testid='build-status'] >> text=Running", {
6770
state: "visible",

0 commit comments

Comments
 (0)