File tree Expand file tree Collapse file tree 4 files changed +62
-2
lines changed Expand file tree Collapse file tree 4 files changed +62
-2
lines changed Original file line number Diff line number Diff line change 11import  {  test ,  expect  }  from  '@playwright/test' ; 
2- import  {  createSandboxAblyAPIKey  }  from  '../lib/ablySandbox.js' ; 
2+ import  {  createSandboxAblyAPIKey  }  from  '../../ lib/ablySandbox.js' ; 
33
44test . describe ( 'CDN bundle' ,  ( )  =>  { 
55  /** 
Original file line number Diff line number Diff line change 1+ /* 
2+  * test_cdn_bundle.ts: 
3+  * 
4+  * Tests the bundle that the .github/workflows/cdn.yml workflow will upload to the CDN. 
5+  * 
6+  * It does this by checking that a webpage which imports this bundle is able to create and use a Spaces client. 
7+  */ 
8+ 
9+ import  playwright  from  'playwright' ; 
10+ import  {  createSandboxAblyAPIKey  }  from  '../lib/ably_sandbox.js' ; 
11+ import  {  startWebServer  }  from  './lib/web_server.js' ; 
12+ 
13+ async  function  runTest ( testPageURL : URL )  { 
14+   const  browser  =  await  playwright . chromium . launch ( ) ; 
15+   const  page  =  await  browser . newPage ( ) ; 
16+ 
17+   page . on ( 'console' ,  ( consoleMessage )  =>  { 
18+     console . log ( '[browser]' ,  consoleMessage ) ; 
19+   } ) ; 
20+ 
21+   const  pageResultPromise  =  new  Promise < void > ( ( resolve ,  reject )  =>  { 
22+     page . exposeFunction ( 'onResult' ,  ( error : Error  |  null )  =>  { 
23+       if  ( error )  { 
24+         console . log ( 'Browser returned control to test runner, with error' ,  error ) ; 
25+         reject ( error ) ; 
26+       }  else  { 
27+         console . log ( 'Browser returned control to test runner' ) ; 
28+         resolve ( ) ; 
29+       } 
30+     } ) ; 
31+ 
32+     page . exposeFunction ( 'createSandboxAblyAPIKey' ,  createSandboxAblyAPIKey ) ; 
33+   } ) ; 
34+ 
35+   console . log ( 'Running test in browser' ) ; 
36+ 
37+   try  { 
38+     await  page . goto ( testPageURL . toString ( ) ) ; 
39+     await  pageResultPromise ; 
40+   }  finally  { 
41+     await  browser . close ( ) ; 
42+   } 
43+ } 
44+ 
45+ ( async  ( )  =>  { 
46+   const  port  =  4567 ; 
47+   const  webServer  =  await  startWebServer ( port ) ; 
48+ 
49+   try  { 
50+     await  runTest ( new  URL ( `http://localhost:${ port }  ` ) ) ; 
51+   }  finally  { 
52+     await  webServer . stop ( ) ; 
53+   } 
54+ } ) ( ) ; 
Original file line number Diff line number Diff line change 11import  https  from  'node:https' ; 
2- import  testAppSetup  from  '../../ ably-common/test-resources/test-app-setup.json' ; 
2+ import  testAppSetup  from  '../ably-common/test-resources/test-app-setup.json' ; 
33
44export  interface  TestApp  { 
55  keys : TestAppKey [ ] ; 
Original file line number Diff line number Diff line change 1+ {
2+   "extends" : " ../../tsconfig.base.json"  ,
3+   "compilerOptions" : {
4+     "resolveJsonModule" : true 
5+   }
6+ }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments