@@ -85,26 +85,17 @@ describe('CatalogService', () => {
8585 } )
8686
8787 /**
88- * The JuniorReader policy adds attribute filters with an OR condition to the query:
89- * - access to Eleonora is granted as its description hints at a happy ending
88+ * The JuniorReader policy adds attribute filters for genre to the query:
9089 * - access to Catweazle is granted as its genre is Fantasy
90+ * - access to The Raven, Eleonora is granted as their genre is Mystery
9191 */
92- it ( '/Books should return 2 Books (Eleonora, Catweazle )' , async ( ) => {
92+ it ( '/Books should return 3 Books (Catweazle, The Raven, Eleonora )' , async ( ) => {
9393 const { status, data } = await GET `/odata/v4/catalog/Books`
9494 expect ( status ) . toBe ( 200 )
95- expect ( data . value ?. length ) . toBe ( 2 )
96- expect ( data . value ) . toContainEqual ( expect . objectContaining ( { title : 'Eleonora' } ) )
97- expect ( data . value ) . toContainEqual ( expect . objectContaining ( { title : 'Catweazle' } ) )
98- } )
99-
100- /**
101- * On /ListOfBooks, the AMS description attribute is not mapped to a cds element, so access to Eleonora is forbidden
102- */
103- it ( '/ListOfBooks should return 1 Book (Catweazle)' , async ( ) => {
104- const { status, data } = await GET `/odata/v4/catalog/ListOfBooks`
105- expect ( status ) . toBe ( 200 )
106- expect ( data . value ?. length ) . toBe ( 1 )
95+ expect ( data . value ?. length ) . toBe ( 3 )
10796 expect ( data . value ) . toContainEqual ( expect . objectContaining ( { title : 'Catweazle' } ) )
97+ expect ( data . value ) . toContainEqual ( expect . objectContaining ( { title : 'The Raven' } ) )
98+ expect ( data . value ) . toContainEqual ( expect . objectContaining ( { title : 'Eleonora' } ) )
10899 } )
109100
110101 // Book 201 = Wuthering Heights
@@ -115,11 +106,11 @@ describe('CatalogService', () => {
115106 } )
116107 } )
117108
118- // Book 252 = Eleonora
119- it ( '/Books/252 /getStockedValue() should return 7770 ' , async ( ) => {
120- const { status, data } = await GET `/odata/v4/catalog/Books/252 /getStockedValue()`
109+ // Book 271 = Catweazle
110+ it ( '/Books/271 /getStockedValue() should return 3300 ' , async ( ) => {
111+ const { status, data } = await GET `/odata/v4/catalog/Books/271 /getStockedValue()`
121112 expect ( status ) . toBe ( 200 )
122- expect ( data . value ) . toBe ( 7770 )
113+ expect ( data . value ) . toBe ( 3300 )
123114 } )
124115
125116 // 15711.35 = stocked value over ALL books because instance-based filters are NOT supported by CAP for functions bound to more than one entity
@@ -196,7 +187,7 @@ describe('CatalogService', () => {
196187 /**
197188 * The ReadCatalog API policy grants access to books with stock < 30
198189 */
199- it ( '/Books should return 2 Books (Eleonora, Catweazle )' , async ( ) => {
190+ it ( '/Books should return 3 Books with stock < 30 (Catweazle, Wuthering Heights, Jane Eyre )' , async ( ) => {
200191 const { status, data } = await GET `/odata/v4/catalog/Books`
201192 expect ( status ) . toBe ( 200 )
202193 expect ( data . value ?. length ) . toBe ( 3 )
@@ -227,9 +218,9 @@ describe('CatalogService', () => {
227218 } )
228219
229220 /**
230- * The JuniorReader policy adds attribute filters with an OR condition to the query:
221+ * The JuniorReader policy adds attribute filters for genre to the query:
231222 * - access to Catweazle is granted as its genre is Fantasy
232- * - access to Eleonora is granted as its description hints at a happy ending but filtered out by stock < 30 from ReadCatalog policy
223+ * - access to The Raven and Eleonora is granted as their genre is Mystery but filtered out by stock < 30 from ReadCatalog policy
233224 */
234225 it ( '/Books should return 1 Book (Catweazle)' , async ( ) => {
235226 const { status, data } = await GET `/odata/v4/catalog/Books`
0 commit comments