From 5b0729610d20411dc2868580af6f1ff679173038 Mon Sep 17 00:00:00 2001 From: sjvans <30337871+sjvans@users.noreply.github.com> Date: Wed, 29 May 2024 12:20:52 +0200 Subject: [PATCH] chore: adjust tests for cds^8 (#662) - update does not return deep (as per odata spec) - adjustment to fix in lean draft (with new adapter) --- sqlite/test/deep/deepInputProcessing.test.js | 17 ++++++++++++----- sqlite/test/lean-draft.test.js | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sqlite/test/deep/deepInputProcessing.test.js b/sqlite/test/deep/deepInputProcessing.test.js index 3ff549b92..08557f047 100644 --- a/sqlite/test/deep/deepInputProcessing.test.js +++ b/sqlite/test/deep/deepInputProcessing.test.js @@ -1,6 +1,6 @@ const cds = require('../../../test/cds') -const { POST, PUT } = cds.test(__dirname, 'deep.cds') +const { POST, PUT, GET } = cds.test(__dirname, 'deep.cds') describe('UUID Generation', () => { test('generate UUID on insert', async () => { @@ -55,10 +55,12 @@ describe('UUID Generation', () => { }) expect(resUpdate.status).toBe(200) + const resRead = await GET(`/bla/RootUUID(${uuid})?$expand=toOneChild($expand=toManySubChild)`) + // foreign keys are set correctly (deep) - expect(resUpdate.data.toOneChild.ID).toEqual(resUpdate.data.toOneChild_ID) - expect(resUpdate.data.toOneChild.ID).toEqual(resUpdate.data.toOneChild.toManySubChild[0].backlink_ID) - expect(resUpdate.data.toOneChild.ID).toEqual(resUpdate.data.toOneChild.toManySubChild[1].backlink_ID) + expect(resRead.data.toOneChild.ID).toEqual(resRead.data.toOneChild_ID) + expect(resRead.data.toOneChild.ID).toEqual(resRead.data.toOneChild.toManySubChild[0].backlink_ID) + expect(resRead.data.toOneChild.ID).toEqual(resRead.data.toOneChild.toManySubChild[1].backlink_ID) }) test('generate UUID on update programmatically', async () => { @@ -124,11 +126,16 @@ describe('UUID Generation', () => { toOneChild: null, }) expect(resUpdate.status).toBe(200) - expect(resUpdate.data).toMatchObject({ '@odata.context': '$metadata#RootUUID/$entity', ID: uuid, name: null, + }) + + const resRead = await GET(`/bla/RootUUID(${uuid})?$expand=toOneChild`) + expect(resRead.data).toMatchObject({ + ID: uuid, + name: null, toOneChild: null, }) }) diff --git a/sqlite/test/lean-draft.test.js b/sqlite/test/lean-draft.test.js index 40d6c7fbf..b3c898ea5 100644 --- a/sqlite/test/lean-draft.test.js +++ b/sqlite/test/lean-draft.test.js @@ -692,7 +692,7 @@ describe('draft tests', () => { Price: null, CurrencyCode_code: null, to_Booking_BookingUUID: BookingUUID, - to_Travel_TravelUUID: null, // Should be TravelUUID! + to_Travel_TravelUUID: cds.env.features.odata_new_adapter ? TravelUUID : null, // Should be TravelUUID! to_Supplement_SupplementID: null, HasActiveEntity: false, IsActiveEntity: false,