@@ -751,12 +751,6 @@ test('should respect in-source configuration from edge functions', async (t) =>
751751 handler : ( ) => new Response ( 'Hello world' ) ,
752752 name : 'hello' ,
753753 } )
754- . withEdgeFunction ( {
755- config : ( ) => ( { path : '/internal-1' } ) ,
756- handler : ( ) => new Response ( 'Hello from an internal function' ) ,
757- internal : true ,
758- name : 'internal' ,
759- } )
760754
761755 await builder . buildAsync ( )
762756
@@ -766,11 +760,6 @@ test('should respect in-source configuration from edge functions', async (t) =>
766760 t . is ( res1 . statusCode , 200 )
767761 t . is ( res1 . body , 'Hello world' )
768762
769- const res2 = await got ( `http://localhost:${ port } /internal-1` , { throwHttpErrors : false } )
770-
771- t . is ( res2 . statusCode , 200 )
772- t . is ( res2 . body , 'Hello from an internal function' )
773-
774763 // wait for file watcher to be up and running, which might take a little
775764 // if we do not wait, the next file change will not be picked up
776765 await pause ( 500 )
@@ -781,6 +770,53 @@ test('should respect in-source configuration from edge functions', async (t) =>
781770 handler : ( ) => new Response ( 'Hello world' ) ,
782771 name : 'hello' ,
783772 } )
773+ . buildAsync ( )
774+
775+ await waitForLogMatching ( 'Reloaded edge function' )
776+
777+ const res2 = await got ( `http://localhost:${ port } /hello-1` , { throwHttpErrors : false } )
778+
779+ t . is ( res2 . statusCode , 404 )
780+
781+ const res3 = await got ( `http://localhost:${ port } /hello-2` , { throwHttpErrors : false } )
782+
783+ t . is ( res3 . statusCode , 200 )
784+ t . is ( res3 . body , 'Hello world' )
785+ } )
786+ } )
787+ } )
788+
789+ test ( 'should respect in-source configuration from internal edge functions' , async ( t ) => {
790+ await withSiteBuilder ( 'site-with-internal-edge-functions' , async ( builder ) => {
791+ const publicDir = 'public'
792+ await builder
793+ . withNetlifyToml ( {
794+ config : {
795+ build : {
796+ publish : publicDir ,
797+ } ,
798+ } ,
799+ } )
800+ . withEdgeFunction ( {
801+ config : ( ) => ( { path : '/internal-1' } ) ,
802+ handler : ( ) => new Response ( 'Hello from an internal function' ) ,
803+ internal : true ,
804+ name : 'internal' ,
805+ } )
806+
807+ await builder . buildAsync ( )
808+
809+ await withDevServer ( { cwd : builder . directory } , async ( { port, waitForLogMatching } ) => {
810+ const res1 = await got ( `http://localhost:${ port } /internal-1` , { throwHttpErrors : false } )
811+
812+ t . is ( res1 . statusCode , 200 )
813+ t . is ( res1 . body , 'Hello from an internal function' )
814+
815+ // wait for file watcher to be up and running, which might take a little
816+ // if we do not wait, the next file change will not be picked up
817+ await pause ( 500 )
818+
819+ await builder
784820 . withEdgeFunction ( {
785821 config : ( ) => ( { path : '/internal-2' } ) ,
786822 handler : ( ) => new Response ( 'Hello from an internal function' ) ,
@@ -791,23 +827,14 @@ test('should respect in-source configuration from edge functions', async (t) =>
791827
792828 await waitForLogMatching ( 'Reloaded edge function' )
793829
794- const res3 = await got ( `http://localhost:${ port } /hello-1` , { throwHttpErrors : false } )
795-
796- t . is ( res3 . statusCode , 404 )
797-
798- const res4 = await got ( `http://localhost:${ port } /hello-2` , { throwHttpErrors : false } )
799-
800- t . is ( res4 . statusCode , 200 )
801- t . is ( res4 . body , 'Hello world' )
802-
803- const res5 = await got ( `http://localhost:${ port } /internal-1` , { throwHttpErrors : false } )
830+ const res2 = await got ( `http://localhost:${ port } /internal-1` , { throwHttpErrors : false } )
804831
805- t . is ( res5 . statusCode , 404 )
832+ t . is ( res2 . statusCode , 404 )
806833
807- const res6 = await got ( `http://localhost:${ port } /internal-2` , { throwHttpErrors : false } )
834+ const res3 = await got ( `http://localhost:${ port } /internal-2` , { throwHttpErrors : false } )
808835
809- t . is ( res6 . statusCode , 200 )
810- t . is ( res6 . body , 'Hello from an internal function' )
836+ t . is ( res3 . statusCode , 200 )
837+ t . is ( res3 . body , 'Hello from an internal function' )
811838 } )
812839 } )
813840} )
0 commit comments