@@ -18,22 +18,35 @@ describe("VS Code Routes", ["--disable-workspace-trust"], {}, async () => {
1818 const pathname = getMaybeProxiedPathname ( url )
1919 expect ( pathname ) . toBe ( route )
2020
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 [ ] = [ ]
2826 switch ( route ) {
2927 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 \/ / )
3032 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 \/ / )
3237 break
3338 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 \/ / )
3543 break
3644 }
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+ }
3750 }
3851 } )
3952} )
0 commit comments