File tree 2 files changed +31
-2
lines changed 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change
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
+ } ) ;
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import {
31
31
Response ,
32
32
type RichParameter ,
33
33
} from "./provisionerGenerated" ;
34
+ import { expectUrl } from "./expectUrl" ;
34
35
35
36
// requiresEnterpriseLicense will skip the test if we're not running with an enterprise license
36
37
export function requiresEnterpriseLicense ( ) {
@@ -52,7 +53,9 @@ export const createWorkspace = async (
52
53
await page . goto ( "/templates/" + templateName + "/workspace" , {
53
54
waitUntil : "domcontentloaded" ,
54
55
} ) ;
55
- await expect ( page ) . toHaveURL ( "/templates/" + templateName + "/workspace" ) ;
56
+ await expectUrl ( page ) . toHavePathName (
57
+ "/templates/" + templateName + "/workspace" ,
58
+ ) ;
56
59
57
60
const name = randomName ( ) ;
58
61
await page . getByLabel ( "name" ) . fill ( name ) ;
@@ -61,7 +64,7 @@ export const createWorkspace = async (
61
64
await page . getByTestId ( "form-submit" ) . click ( ) ;
62
65
63
66
// 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 ) ;
65
68
66
69
await page . waitForSelector ( "*[data-testid='build-status'] >> text=Running" , {
67
70
state : "visible" ,
You can’t perform that action at this time.
0 commit comments