@@ -611,6 +611,22 @@ describe('setProductCacheHeaders', () => {
611611 assert . strictEqual ( resp . headers . get ( 'surrogate-control' ) , 'max-age=300, stale-while-revalidate=0' ) ;
612612 assert . strictEqual ( resp . headers . get ( 'surrogate-key' ) , 'G56lYRBKFiJX2i-A main--test-site--test-org Id9xWdjCxe493biK content-bus-id_metadata main--test-site--test-org_head content-bus-id' ) ;
613613 } ) ;
614+
615+ it ( 'overrides cache-control to no-store when state.stagePricing is true' , async ( ) => {
616+ const state = {
617+ stagePricing : true ,
618+ content : { data : { sku : 'sku' , urlKey : 'url-key' } } ,
619+ config : { route : { params : { } } } ,
620+ contentBusId : 'cbus' ,
621+ info : { path : '/test' , originalPath : '/test' } ,
622+ org : 'test-org' ,
623+ site : 'test-site' ,
624+ } ;
625+ const req = createRequest ( 'https://example.com/test' , { 'x-byo-cdn-type' : 'cloudflare' } ) ;
626+ const resp = createResponse ( ) ;
627+ await setProductCacheHeaders ( state , req , resp ) ;
628+ assert . strictEqual ( resp . headers . get ( 'cache-control' ) , 'no-store' ) ;
629+ } ) ;
614630} ) ;
615631
616632describe ( 'setIndexCacheHeaders' , ( ) => {
@@ -712,6 +728,19 @@ describe('setIndexCacheHeaders', () => {
712728 assert . notStrictEqual ( tags1 [ 0 ] , tags2 [ 0 ] ) ;
713729 assert . strictEqual ( tags1 [ 1 ] , tags2 [ 1 ] ) ; // same site key
714730 } ) ;
731+
732+ it ( 'overrides cache-control to no-store when state.stagePricing is true' , async ( ) => {
733+ const state = {
734+ stagePricing : true ,
735+ org : 'test-org' ,
736+ site : 'test-site' ,
737+ info : { path : '/products/index.json' } ,
738+ } ;
739+ const req = createRequest ( 'https://example.com/products/index.json' , { 'x-byo-cdn-type' : 'cloudflare' } ) ;
740+ const resp = createResponse ( ) ;
741+ await setIndexCacheHeaders ( state , req , resp ) ;
742+ assert . strictEqual ( resp . headers . get ( 'cache-control' ) , 'no-store' ) ;
743+ } ) ;
715744} ) ;
716745
717746describe ( 'setSitemapCacheHeaders' , ( ) => {
@@ -793,4 +822,17 @@ describe('setSitemapCacheHeaders', () => {
793822 assert . notStrictEqual ( indexTags [ 0 ] , sitemapTags [ 0 ] ) ;
794823 assert . strictEqual ( indexTags [ 1 ] , sitemapTags [ 1 ] ) ; // same site key
795824 } ) ;
825+
826+ it ( 'overrides cache-control to no-store when state.stagePricing is true' , async ( ) => {
827+ const state = {
828+ stagePricing : true ,
829+ org : 'test-org' ,
830+ site : 'test-site' ,
831+ info : { path : '/products/sitemap.xml' } ,
832+ } ;
833+ const req = createRequest ( 'https://example.com/products/sitemap.xml' , { 'x-byo-cdn-type' : 'cloudflare' } ) ;
834+ const resp = createResponse ( ) ;
835+ await setSitemapCacheHeaders ( state , req , resp ) ;
836+ assert . strictEqual ( resp . headers . get ( 'cache-control' ) , 'no-store' ) ;
837+ } ) ;
796838} ) ;
0 commit comments