@@ -142,10 +142,11 @@ describe('Item Published', () => {
142142 category : selectedCategories [ 1 ] ,
143143 } ) ;
144144
145+ const categoryId = selectedCategories . map ( ( { id } ) => id ) ;
145146 const res = await app . inject ( {
146147 method : HttpMethod . GET ,
147148 url : `${ ITEMS_ROUTE_PREFIX } /collections${ qs . stringify (
148- { categoryId : selectedCategories . map ( ( { id } ) => id ) } ,
149+ { categoryId } ,
149150 { addQueryPrefix : true , arrayFormat : 'repeat' } ,
150151 ) } `,
151152 } ) ;
@@ -167,10 +168,11 @@ describe('Item Published', () => {
167168 // one random item category
168169 await ItemCategoryRepository . save ( { item : collections [ 2 ] , category : categories [ 2 ] } ) ;
169170
171+ const categoryId = selectedCategories . map ( ( { id } ) => id ) . join ( ',' ) ;
170172 const res = await app . inject ( {
171173 method : HttpMethod . GET ,
172174 url : `${ ITEMS_ROUTE_PREFIX } /collections${ qs . stringify (
173- { categoryId : selectedCategories . map ( ( { id } ) => id ) . join ( ',' ) } ,
175+ { categoryId } ,
174176 { addQueryPrefix : true , arrayFormat : 'repeat' } ,
175177 ) } `,
176178 } ) ;
@@ -233,6 +235,27 @@ describe('Item Published', () => {
233235 const items = Object . values ( result ) . map ( ( i ) => i . item ) ;
234236 expectManyItems ( items as Item [ ] , [ otherParentItem , parentItem ] ) ;
235237 } ) ;
238+ it ( 'Get publish info of non public item returns forbidden' , async ( ) => {
239+ // simple item not public and not published
240+ const { item } = await saveItemAndMembership ( { member } ) ;
241+ const res = await app . inject ( {
242+ method : HttpMethod . GET ,
243+ url : `${ ITEMS_ROUTE_PREFIX } /collections/${ item . id } /informations` ,
244+ } ) ;
245+ expect ( res . statusCode ) . toBe ( StatusCodes . FORBIDDEN ) ;
246+ } ) ;
247+ it ( 'Get publish info of public item that is not published yet returns null' , async ( ) => {
248+ const { item } = await saveItemAndMembership ( { member } ) ;
249+ // make item public
250+ await ItemTagRepository . post ( member , item , ItemTagType . Public ) ;
251+
252+ const res = await app . inject ( {
253+ method : HttpMethod . GET ,
254+ url : `${ ITEMS_ROUTE_PREFIX } /collections/${ item . id } /informations` ,
255+ } ) ;
256+ expect ( res . statusCode ) . toBe ( StatusCodes . OK ) ;
257+ expect ( res . json ( ) ) . toBe ( null ) ;
258+ } ) ;
236259 it ( 'Throw if category id is invalid' , async ( ) => {
237260 const res = await app . inject ( {
238261 method : HttpMethod . GET ,
0 commit comments