@@ -88,43 +88,7 @@ describe('Publish Action Tests', () => {
8888 return { request, context } ;
8989 }
9090
91- describe ( 'no indexing or sitemap configuration' , ( ) => {
92- beforeEach ( ( ) => {
93- nock . indexConfig ( null ) ;
94- nock . sitemapConfig ( null ) ;
95- nock . content ( )
96- . head ( '/live/sitemap.json' )
97- . reply ( 200 , [ ] )
98- . putObject ( '/live/sitemap.json' )
99- . reply ( 201 ) ;
100- } ) ;
101-
102- it ( 'publish document' , async ( ) => {
103- nock . content ( )
104- . head ( '/preview/index.md' )
105- . reply ( 200 , '' , { 'last-modified' : 'Thu, 08 Jul 2021 10:04:16 GMT' } )
106- . copyObject ( '/live/index.md' )
107- . reply ( 200 , new xml2js . Builder ( ) . buildObject ( {
108- CopyObjectResult : {
109- LastModified : '2021-05-05T08:37:23.000Z' ,
110- ETag : '"f278c0035a9b4398629613a33abe6451"' ,
111- } ,
112- } ) )
113- . head ( '/live/index.md' )
114- . reply ( 200 , '' , { 'last-modified' : 'Thu, 08 Jul 2021 10:04:16 GMT' } ) ;
115-
116- const { request, context } = setupTest ( '/' ) ;
117- const response = await main ( request , context ) ;
118-
119- assert . strictEqual ( response . status , 200 ) ;
120- assert . deepStrictEqual ( purgeInfos , [
121- { path : '/' } ,
122- { path : '/index.plain.html' } ,
123- { key : 'DiyvKbkf2MaZORJJ' } ,
124- { key : '8lnjgOWBwsoqAQXB' } ,
125- ] ) ;
126- } ) ;
127-
91+ describe ( 'documents that do not trigger index update' , ( ) => {
12892 it ( 'publish redirects' , async ( ) => {
12993 nock . content ( )
13094 . head ( '/preview/redirects.json' )
@@ -165,15 +129,6 @@ describe('Publish Action Tests', () => {
165129 ETag : '"f278c0035a9b4398629613a33abe6451"' ,
166130 } ,
167131 } ) )
168- . getObject ( '/live/redirects.json' )
169- . reply ( 200 , {
170- default : {
171- data : {
172- source : '/from' ,
173- destination : '/to' ,
174- } ,
175- } ,
176- } )
177132 . head ( '/live/redirects.json' )
178133 . reply ( 200 , '' , { 'last-modified' : 'Thu, 08 Jul 2021 10:04:16 GMT' } ) ;
179134
@@ -187,27 +142,6 @@ describe('Publish Action Tests', () => {
187142 assert . strictEqual ( response . status , 200 ) ;
188143 } ) ;
189144
190- it ( 'publish metadata' , async ( ) => {
191- nock . content ( )
192- . head ( '/preview/metadata.json' )
193- . reply ( 200 )
194- . copyObject ( '/live/metadata.json' )
195- . reply ( 200 , new xml2js . Builder ( ) . buildObject ( {
196- CopyObjectResult : {
197- LastModified : '2021-05-05T08:37:23.000Z' ,
198- ETag : '"f278c0035a9b4398629613a33abe6451"' ,
199- } ,
200- } ) )
201- . head ( '/live/metadata.json' )
202- . reply ( 200 , '' , { 'last-modified' : 'Thu, 08 Jul 2021 10:04:16 GMT' } ) ;
203-
204- const { request, context } = setupTest ( METADATA_JSON_PATH ) ;
205- const response = await main ( request , context ) ;
206-
207- assert . strictEqual ( response . status , 200 ) ;
208- assert . deepStrictEqual ( surrogates , [ 'U_NW4adJU7Qazf-I' ] ) ;
209- } ) ;
210-
211145 it ( 'reports an error when `contentBusCopy` returns 404' , async ( ) => {
212146 nock . content ( )
213147 . head ( '/preview/index.md' )
@@ -230,6 +164,68 @@ describe('Publish Action Tests', () => {
230164 'x-error' : `source does not exist: helix-content-bus/${ SITE_CONFIG . content . contentBusId } /preview/index.md` ,
231165 } ) ;
232166 } ) ;
167+ } ) ;
168+
169+ describe ( 'sitemap, but no indexing configuration' , ( ) => {
170+ const SITEMAP_CONFIG = `
171+ version: 1
172+ sitemaps:
173+ default:
174+ source: /sitemap-index.json
175+ destination: /sitemap.xml
176+ ` ;
177+
178+ beforeEach ( ( ) => {
179+ nock . indexConfig ( null ) ;
180+ nock . sitemapConfig ( SITEMAP_CONFIG ) ;
181+ } ) ;
182+
183+ it ( 'publish document' , async ( ) => {
184+ nock . content ( )
185+ . head ( '/preview/index.md' )
186+ . reply ( 200 , '' , { 'last-modified' : 'Thu, 08 Jul 2021 10:04:16 GMT' } )
187+ . copyObject ( '/live/index.md' )
188+ . reply ( 200 , new xml2js . Builder ( ) . buildObject ( {
189+ CopyObjectResult : {
190+ LastModified : '2021-05-05T08:37:23.000Z' ,
191+ ETag : '"f278c0035a9b4398629613a33abe6451"' ,
192+ } ,
193+ } ) )
194+ . head ( '/live/index.md' )
195+ . reply ( 200 , '' , { 'last-modified' : 'Thu, 08 Jul 2021 10:04:16 GMT' } ) ;
196+
197+ const { request, context } = setupTest ( '/' ) ;
198+ const response = await main ( request , context ) ;
199+
200+ assert . strictEqual ( response . status , 200 ) ;
201+ assert . deepStrictEqual ( purgeInfos , [
202+ { path : '/' } ,
203+ { path : '/index.plain.html' } ,
204+ { key : 'DiyvKbkf2MaZORJJ' } ,
205+ { key : '8lnjgOWBwsoqAQXB' } ,
206+ ] ) ;
207+ } ) ;
208+
209+ it ( 'publish metadata' , async ( ) => {
210+ nock . content ( )
211+ . head ( '/preview/metadata.json' )
212+ . reply ( 200 )
213+ . copyObject ( '/live/metadata.json' )
214+ . reply ( 200 , new xml2js . Builder ( ) . buildObject ( {
215+ CopyObjectResult : {
216+ LastModified : '2021-05-05T08:37:23.000Z' ,
217+ ETag : '"f278c0035a9b4398629613a33abe6451"' ,
218+ } ,
219+ } ) )
220+ . head ( '/live/metadata.json' )
221+ . reply ( 200 , '' , { 'last-modified' : 'Thu, 08 Jul 2021 10:04:16 GMT' } ) ;
222+
223+ const { request, context } = setupTest ( METADATA_JSON_PATH ) ;
224+ const response = await main ( request , context ) ;
225+
226+ assert . strictEqual ( response . status , 200 ) ;
227+ assert . deepStrictEqual ( surrogates , [ 'U_NW4adJU7Qazf-I' ] ) ;
228+ } ) ;
233229
234230 it ( 'tweaks status when `contentBusCopy` returns 404 and a redirect matches' , async ( ) => {
235231 nock . content ( )
@@ -242,13 +238,14 @@ describe('Publish Action Tests', () => {
242238 Message : 'The specified key does not exist.' ,
243239 } ,
244240 } ) )
241+ . head ( '/live/index.md' )
242+ . reply ( 404 )
245243 . putObject ( '/live/index.md' )
246244 . reply ( 201 , function fn ( uri , body ) {
247245 assert . strictEqual ( this . req . headers [ 'x-amz-meta-redirect-location' ] , '/target' ) ;
248246 assert . strictEqual ( body , '/target' ) ;
249247 } )
250248 . head ( '/live/index.md' )
251- . twice ( )
252249 . reply ( 200 , '' , { 'last-modified' : 'Thu, 08 Jul 2021 10:04:16 GMT' } ) ;
253250
254251 const { request, context } = setupTest ( '/' , {
0 commit comments