@@ -18,22 +18,35 @@ describe("VS Code Routes", ["--disable-workspace-trust"], {}, async () => {
18
18
const pathname = getMaybeProxiedPathname ( url )
19
19
expect ( pathname ) . toBe ( route )
20
20
21
- // TODO@jsjoeio
22
- // now that we are in a proper browser instead of scraping the HTML we
23
- // could possibly intercept requests to make sure assets are loading from
24
- // the right spot.
25
- //
26
- // Check that page loaded from correct route
27
- const html = await codeServerPage . page . innerHTML ( "html" )
21
+ // Check that assets are pointing to the right spot. Some will be
22
+ // relative, without a leading dot (VS Code's assets). Some will be
23
+ // relative with a leading dot (our assets). Others will have been
24
+ // resolved against the origin.
25
+ const matchers : string [ ] = [ ]
28
26
switch ( route ) {
29
27
case "/" :
28
+ matchers . push ( / s r c = " \. \/ m a n i f e s t .j s o n " / )
29
+ matchers . push ( / s r c = " \. \/ _ s t a t i c \/ / )
30
+ matchers . push ( / s r c = " [ a - z ] + - [ 0 - 9 a - z ] + \/ s t a t i c \/ / )
31
+ matchers . push ( / s r c = " h t t p : \/ \/ l o c a l h o s t : [ 0 - 9 ] + \/ [ a - z ] + - [ 0 - 9 a - z ] + \/ s t a t i c \/ / )
30
32
case "/vscode/" :
31
- expect ( html ) . toMatch ( / s r c = " \. \/ [ a - z ] + - [ 0 - 9 a - z ] + \/ s t a t i c \/ / )
33
+ matchers . push ( / s r c = " \. \/ m a n i f e s t .j s o n " / )
34
+ matchers . push ( / s r c = " \. \/ \. \. \/ _ s t a t i c \/ / )
35
+ matchers . push ( / s r c = " [ a - z ] + - [ 0 - 9 a - z ] + \/ s t a t i c \/ / )
36
+ matchers . push ( / s r c = " h t t p : \/ \/ l o c a l h o s t : [ 0 - 9 ] + \/ v s c o d e \/ [ a - z ] + - [ 0 - 9 a - z ] + \/ s t a t i c \/ / )
32
37
break
33
38
case "/vscode" :
34
- expect ( html ) . toMatch ( / s r c = " \. \/ v s c o d e \/ [ a - z ] + - [ 0 - 9 a - z ] + \/ s t a t i c \/ / )
39
+ matchers . push ( / s r c = " \. \/ _ s t a t i c \/ / )
40
+ matchers . push ( / s r c = " \. \/ v s c o d e \/ m a n i f e s t .j s o n " / )
41
+ matchers . push ( / s r c = " v s c o d e \/ [ a - z ] + - [ 0 - 9 a - z ] + \/ s t a t i c \/ / )
42
+ matchers . push ( / s r c = " h t t p : \/ \/ l o c a l h o s t : [ 0 - 9 ] + \/ v s c o d e \/ [ a - z ] + - [ 0 - 9 a - z ] + \/ s t a t i c \/ / )
35
43
break
36
44
}
45
+ const elements = await codeServerPage . page . locator ( "[src]" ) . all ( )
46
+ for ( const element of elements ) {
47
+ const src = await element . getAttribute ( "src" )
48
+ expect ( matchers . some ( ( m ) => m . test ( src ) ) ) . toBeTruthy ( )
49
+ }
37
50
}
38
51
} )
39
52
} )
0 commit comments