@@ -248,6 +248,33 @@ describe("change log integration test", () => {
248
248
expect ( isUsedChange . entity ) . to . equal ( "Book" ) ;
249
249
expect ( isUsedChange . valueChangedFrom ) . to . equal ( "" ) ;
250
250
expect ( isUsedChange . valueChangedTo ) . to . equal ( "true" ) ;
251
+
252
+ // Test for Unmanaged entity(Create)
253
+ const unmanagedAction = POST . bind (
254
+ { } ,
255
+ `/odata/v4/admin/Schools(ID=5ab2a87b-3a56-4d97-a697-7af72333c123,IsActiveEntity=false)/classes` ,
256
+ {
257
+ ID : "9d703c23-54a8-4eff-81c1-cdec5c4267c5" ,
258
+ name : "Biology 101" ,
259
+ teacher : "Mr. Smith" ,
260
+ up__ID : "9d703c23-54a8-4eff-81c1-cdce6b0528c4"
261
+ }
262
+ ) ;
263
+ await utils . apiAction ( "admin" , "Schools" , "5ab2a87b-3a56-4d97-a697-7af72333c123" , "AdminService" , unmanagedAction ) ;
264
+ const schoolChanges = await adminService . run (
265
+ SELECT . from ( ChangeView ) . where ( {
266
+ entity : "sap.capire.bookshop.Schools" ,
267
+ attribute : "classes" ,
268
+ } )
269
+ ) ;
270
+
271
+ expect ( schoolChanges . length ) . to . equal ( 1 ) ;
272
+ const schoolChange = schoolChanges [ 0 ] ;
273
+ expect ( schoolChange . entityKey ) . to . equal ( "5ab2a87b-3a56-4d97-a697-7af72333c123" ) ;
274
+ expect ( schoolChange . attribute ) . to . equal ( "classes" ) ;
275
+ expect ( schoolChange . modification ) . to . equal ( "Create" ) ;
276
+ expect ( schoolChange . valueChangedFrom ) . to . equal ( "" ) ;
277
+ expect ( schoolChange . valueChangedTo ) . to . equal ( "Biology 101, Mr. Smith" ) ;
251
278
} ) ;
252
279
253
280
it ( "2.2 Child entity update - should log basic data type changes (ERP4SMEPREPWORKAPPPLAT-32 ERP4SMEPREPWORKAPPPLAT-613)" , async ( ) => {
@@ -357,6 +384,33 @@ describe("change log integration test", () => {
357
384
358
385
expect ( priceChanges . length ) . to . equal ( 0 ) ;
359
386
387
+ // Test for Unmanaged entity(Create)
388
+ const unmanagedAction = POST . bind (
389
+ { } ,
390
+ `/odata/v4/admin/Schools(ID=5ab2a87b-3a56-4d97-a697-7af72333c123,IsActiveEntity=false)/classes` ,
391
+ {
392
+ ID : "9d703c23-54a8-4eff-81c1-cdec5c4267c5" ,
393
+ name : "Biology 101" ,
394
+ teacher : "Mr. Smith" ,
395
+ up__ID : "9d703c23-54a8-4eff-81c1-cdce6b0528c4"
396
+ }
397
+ ) ;
398
+ await utils . apiAction ( "admin" , "Schools" , "5ab2a87b-3a56-4d97-a697-7af72333c123" , "AdminService" , unmanagedAction ) ;
399
+ const schoolChanges = await adminService . run (
400
+ SELECT . from ( ChangeView ) . where ( {
401
+ entity : "sap.capire.bookshop.Schools" ,
402
+ attribute : "classes" ,
403
+ } )
404
+ ) ;
405
+
406
+ expect ( schoolChanges . length ) . to . equal ( 1 ) ;
407
+ const schoolChange = schoolChanges [ 0 ] ;
408
+ expect ( schoolChange . entityKey ) . to . equal ( "5ab2a87b-3a56-4d97-a697-7af72333c123" ) ;
409
+ expect ( schoolChange . attribute ) . to . equal ( "classes" ) ;
410
+ expect ( schoolChange . modification ) . to . equal ( "Create" ) ;
411
+ expect ( schoolChange . valueChangedFrom ) . to . equal ( "" ) ;
412
+ expect ( schoolChange . valueChangedTo ) . to . equal ( "Biology 101, Mr. Smith" ) ;
413
+
360
414
delete cds . services . AdminService . entities . Books . elements . price [ "@changelog" ] ;
361
415
} ) ;
362
416
@@ -431,6 +485,24 @@ describe("change log integration test", () => {
431
485
expect ( volumnTitleChange . entity ) . to . equal ( "Volumn" ) ;
432
486
expect ( volumnTitleChange . valueChangedFrom ) . to . equal ( "Wuthering Heights I" ) ;
433
487
expect ( volumnTitleChange . valueChangedTo ) . to . equal ( "" ) ;
488
+
489
+ // Test for Unmanaged entity(Delete)
490
+ const unmanagedAction = DELETE . bind ( { } , `/odata/v4/admin/Schools_classes(up__ID=5ab2a87b-3a56-4d97-a697-7af72333c123,ID=9d703c23-54a8-4eff-81c1-cdec5a0422c3,IsActiveEntity=false)` ) ;
491
+ await utils . apiAction ( "admin" , "Schools" , "5ab2a87b-3a56-4d97-a697-7af72333c123" , "AdminService" , unmanagedAction ) ;
492
+ const schoolChanges = await adminService . run (
493
+ SELECT . from ( ChangeView ) . where ( {
494
+ entity : "sap.capire.bookshop.Schools" ,
495
+ attribute : "classes" ,
496
+ } )
497
+ ) ;
498
+
499
+ expect ( schoolChanges . length ) . to . equal ( 1 ) ;
500
+ const schoolChange = schoolChanges [ 0 ] ;
501
+ expect ( schoolChange . entityKey ) . to . equal ( "5ab2a87b-3a56-4d97-a697-7af72333c123" ) ;
502
+ expect ( schoolChange . attribute ) . to . equal ( "classes" ) ;
503
+ expect ( schoolChange . modification ) . to . equal ( "Delete" ) ;
504
+ expect ( schoolChange . valueChangedFrom ) . to . equal ( "Physics 500, Mrs. Johnson" ) ;
505
+ expect ( schoolChange . valueChangedTo ) . to . equal ( "" ) ;
434
506
} ) ;
435
507
436
508
it ( "2.4 Child entity update without objectID annotation - should log object type for object ID (ERP4SMEPREPWORKAPPPLAT-32 ERP4SMEPREPWORKAPPPLAT-613 ERP4SMEPREPWORKAPPPLAT-538)" , async ( ) => {
0 commit comments