@@ -52,7 +52,7 @@ beforeEach(() => {
5252} ) ;
5353
5454async function startServer (
55- mount : ( app : Server , serverBaseUrl : URL ) = > void ,
55+ mount : ( app : Server ) = > void ,
5656) : Promise < { server : http$Server , baseUrl : string } > {
5757 const app = connect ( ) ;
5858 const server = http . createServer ( app ) ;
@@ -62,19 +62,18 @@ async function startServer(
6262 throw new Error ( 'Expected the server to listen on a TCP port' ) ;
6363 }
6464 const baseUrl = `http://localhost:${ address . port } ` ;
65- mount ( app , new URL ( baseUrl ) ) ;
65+ mount ( app ) ;
6666 app . use ( ( req , res ) => {
6767 res . writeHead ( 404 ) ;
6868 res . end ( ) ;
6969 } ) ;
7070 return { server, baseUrl} ;
7171}
7272
73- function mountOpenStackFrame ( app : Server , serverBaseUrl : URL ) {
73+ function mountOpenStackFrame ( app : Server ) {
7474 app . use (
7575 '/open-stack-frame' ,
7676 require ( '../openStackFrameMiddleware' ) . default ( {
77- serverBaseUrl,
7877 watchFolders : [ projectRoot ] ,
7978 } ) ,
8079 ) ;
@@ -85,14 +84,10 @@ function stopServer(server: http$Server): Promise<void> {
8584 return new Promise ( resolve => server . close ( ( ) => resolve ( ) ) ) ;
8685}
8786
88- function postFrame(
89- baseUrl: string,
90- body: string,
91- headers?: { Origin ? : string } ,
92- ): Promise< Response > {
87+ function postFrame(baseUrl: string, body: string): Promise< Response > {
9388 return fetch ( baseUrl + '/open-stack-frame' , {
9489 method : 'POST' ,
95- headers : { ... headers , 'Content-Type' : 'application/json' } ,
90+ headers : { 'Content-Type' : 'application/json' } ,
9691 body,
9792 } ) ;
9893}
@@ -129,17 +124,6 @@ describe('/open-stack-frame', () => {
129124 expect ( launchEditor ) . toHaveBeenCalledTimes ( 1 ) ;
130125 } ) ;
131126
132- test ( 'refuses a cross-origin request' , async ( ) => {
133- const resp = await postFrame (
134- baseUrl ,
135- JSON . stringify ( { file : appFile , lineNumber : 12 } ) ,
136- { Origin : 'https://example.com' } ,
137- ) ;
138-
139- expect ( resp . status ) . toBe ( 403 ) ;
140- expect ( launchEditor ) . not . toHaveBeenCalled ( ) ;
141- } ) ;
142-
143127 test ( 'rejects a body that is not JSON' , async ( ) => {
144128 const resp = await postFrame ( baseUrl , 'not json' ) ;
145129
@@ -188,30 +172,3 @@ describe('/open-stack-frame', () => {
188172 expect ( launchEditor ) . not . toHaveBeenCalled ( ) ;
189173 } ) ;
190174} );
191-
192- describe('/open-stack-frame behind a middleware that serves it', () => {
193- let server : http$Server ;
194- let baseUrl : string ;
195-
196- beforeEach ( async ( ) => {
197- ( { server, baseUrl} = await startServer ( ( app , serverBaseUrl ) => {
198- app . use ( '/open-stack-frame' , ( req , res , next ) => {
199- res . end ( 'handled upstream' ) ;
200- next ( ) ;
201- } ) ;
202- mountOpenStackFrame ( app , serverBaseUrl ) ;
203- } ) ) ;
204- } ) ;
205-
206- afterEach ( ( ) => stopServer ( server ) ) ;
207-
208- test ( 'leaves the response to that middleware' , async ( ) => {
209- const resp = await postFrame (
210- baseUrl ,
211- JSON . stringify ( { file : appFile , lineNumber : 12 } ) ,
212- ) ;
213-
214- expect ( await resp . text ( ) ) . toBe ( 'handled upstream' ) ;
215- expect ( launchEditor ) . not . toHaveBeenCalled ( ) ;
216- } ) ;
217- } );
0 commit comments