@@ -195,6 +195,95 @@ describe('Navigation', () => {
195195 ) ;
196196 } ) . rejects . toThrow ( ) ;
197197 } ) ;
198+
199+ it ( 'should fallback to status=draft if status differs from draft or published' , async ( ) => {
200+ // Given
201+ const navigation = getMockNavigation ( ) ;
202+ const render = jest . fn ( ) ;
203+ const mockClientService = asProxy < ClientService > ( { render } ) ;
204+ const idOrSlug = faker . string . uuid ( ) ;
205+ const type = faker . helpers . arrayElement ( [ 'FLAT' , 'TREE' , 'RFR' ] ) ;
206+ const menuOnly = faker . datatype . boolean ( ) ;
207+
208+ render . mockResolvedValue ( navigation ) ;
209+
210+ ( getPluginService as jest . Mock ) . mockReturnValue ( mockClientService ) ;
211+
212+ const clientController = buildClientController ( { strapi } ) ;
213+ // When
214+ const resultDraft = await clientController . render (
215+ asProxy < KoaContext > ( {
216+ params : { idOrSlug } ,
217+ query : {
218+ type,
219+ menuOnly,
220+ status : faker . string . sample ( ) ,
221+ } ,
222+ } )
223+ ) ;
224+
225+ // Then
226+ expect ( resultDraft ) . toEqual ( navigation ) ;
227+ // When
228+ const resultPublished = await clientController . render (
229+ asProxy < KoaContext > ( {
230+ params : { idOrSlug } ,
231+ query : {
232+ type,
233+ menuOnly,
234+ status : 'published' ,
235+ } ,
236+ } )
237+ ) ;
238+
239+ // Then
240+ expect ( resultPublished ) . toEqual ( navigation ) ;
241+ } ) ;
242+
243+ it ( 'should sanitize populate query param' , async ( ) => {
244+ // Given
245+ const navigation = getMockNavigation ( ) ;
246+ const render = jest . fn ( ) ;
247+ const mockClientService = asProxy < ClientService > ( { render } ) ;
248+ const idOrSlug = faker . string . uuid ( ) ;
249+ const type = faker . helpers . arrayElement ( [ 'FLAT' , 'TREE' , 'RFR' ] ) ;
250+ const menuOnly = faker . datatype . boolean ( ) ;
251+
252+ render . mockResolvedValue ( navigation ) ;
253+
254+ ( getPluginService as jest . Mock ) . mockReturnValue ( mockClientService ) ;
255+
256+ const clientController = buildClientController ( { strapi } ) ;
257+ // When
258+ const resultTrue = await clientController . render (
259+ asProxy < KoaContext > ( {
260+ params : { idOrSlug } ,
261+ query : {
262+ type,
263+ menuOnly,
264+ populate : { foo : { populate : 'true' } }
265+ } ,
266+ } )
267+ ) ;
268+
269+ // Then
270+ expect ( resultTrue ) . toEqual ( navigation ) ;
271+
272+ // When
273+ const resultFalse = await clientController . render (
274+ asProxy < KoaContext > ( {
275+ params : { idOrSlug } ,
276+ query : {
277+ type,
278+ menuOnly,
279+ populate : { foo : { populate : 'false' } }
280+ } ,
281+ } )
282+ ) ;
283+
284+ // Then
285+ expect ( resultFalse ) . toEqual ( navigation ) ;
286+ } ) ;
198287 } ) ;
199288
200289 describe ( 'renderChild()' , ( ) => {
0 commit comments