@@ -233,7 +233,7 @@ describe('Module - Core', () => {
233233 Core . config ( JSON . stringify ( config ) ) ;
234234 await Core . renderAsyncFragment ( 'test' ) ;
235235 await Core . renderAsyncFragment ( 'test' ) ;
236-
236+
237237 expect ( fetchStub . calledOnce ) . to . eq ( true ) ;
238238 expect ( fetchStub . getCall ( 0 ) . lastArg . headers ) . to . haveOwnProperty ( "originalurl" ) ;
239239 expect ( stubAsyncRenderResponse . calledOnce ) . to . eq ( true ) ;
@@ -288,7 +288,71 @@ describe('Module - Core', () => {
288288 Core . config ( JSON . stringify ( config ) ) ;
289289 await Core . renderAsyncFragment ( 'test' ) ;
290290 await Core . renderAsyncFragment ( 'test' ) ;
291-
291+
292+ expect ( fetchStub . calledOnce ) . to . eq ( true ) ;
293+ expect ( fetchStub . getCall ( 0 ) . lastArg . headers ) . to . haveOwnProperty ( "originalurl" ) ;
294+ expect ( stubAsyncRenderResponse . calledOnce ) . to . eq ( true ) ;
295+ } ) ;
296+
297+ it ( 'should render async fragment withoutPathname' , async ( ) => {
298+ const source = "source/" ;
299+ const assets = [
300+ {
301+ name : 'bundle1' ,
302+ dependent : [ 'vendor1' ] ,
303+ preLoaded : false ,
304+ link : 'bundle1.js' ,
305+ fragment : 'test' ,
306+ loadMethod : RESOURCE_LOADING_TYPE . ON_PAGE_RENDER ,
307+ type : RESOURCE_TYPE . JS
308+ }
309+ ] as IPageLibAsset [ ] ;
310+ const dependencies = [
311+ {
312+ name : 'vendor1' ,
313+ link : 'vendor1.js' ,
314+ preLoaded : false
315+ }
316+ ] as IPageLibDependency [ ] ;
317+ const config = {
318+ dependencies,
319+ assets,
320+ fragments : [ {
321+ name : 'test' ,
322+ attributes : {
323+ if : "false" ,
324+ withoutPathname : "true"
325+ } ,
326+ chunked : true ,
327+ clientAsync : true ,
328+ clientAsyncForce : undefined ,
329+ onDemand : undefined ,
330+ criticalCss : undefined ,
331+ source,
332+ asyncDecentralized : false
333+ } ] ,
334+ page : 'page' ,
335+ peers : [ ]
336+ } as IPageLibConfiguration ;
337+
338+ const fragmentContainer = global . window . document . createElement ( 'div' ) ;
339+ fragmentContainer . setAttribute ( 'puzzle-fragment' , 'test' ) ;
340+ global . window . document . body . appendChild ( fragmentContainer ) ;
341+
342+ const fetchStub = global . fetch as SinonStub ;
343+ const stubAsyncRenderResponse = sandbox . stub ( Core as any , "asyncRenderResponse" ) . resolves ( ) ;
344+
345+ Core . config ( JSON . stringify ( config ) ) ;
346+ await Core . renderAsyncFragment ( 'test' ) ;
347+ await Core . renderAsyncFragment ( 'test' ) ;
348+
349+ const fragmentRequestUrl = `${ source } ?__renderMode=stream&if=false&withoutPathname=true` ;
350+ expect ( fetchStub . calledWith ( fragmentRequestUrl , {
351+ headers : {
352+ originalurl : window . location . pathname
353+ } ,
354+ credentials : 'include'
355+ } ) ) . to . eq ( true ) ;
292356 expect ( fetchStub . calledOnce ) . to . eq ( true ) ;
293357 expect ( fetchStub . getCall ( 0 ) . lastArg . headers ) . to . haveOwnProperty ( "originalurl" ) ;
294358 expect ( stubAsyncRenderResponse . calledOnce ) . to . eq ( true ) ;
@@ -307,7 +371,7 @@ describe('Module - Core', () => {
307371
308372 Core . config ( JSON . stringify ( config ) ) ;
309373 const result = Core . renderAsyncFragment ( 'test' ) ;
310-
374+
311375 expect ( result ) . to . be . a ( 'promise' ) ;
312376 } ) ;
313377
@@ -353,7 +417,8 @@ describe('Module - Core', () => {
353417
354418 Core . config ( JSON . stringify ( config ) ) ;
355419 const result = Core . renderAsyncFragment ( 'test' ) ;
356-
420+
357421 expect ( result ) . to . be . a ( 'promise' ) ;
358422 } ) ;
359- } ) ;
423+
424+ } ) ;
0 commit comments