Skip to content

Commit

Permalink
add end 2 end test
Browse files Browse the repository at this point in the history
  • Loading branch information
patricebender committed Sep 11, 2024
1 parent 1051200 commit 0c193c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/bookshop/srv/draft-enabled-service.cds
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using { sap.capire.bookshop as my } from '../db/schema';
service DraftService {
@odata.draft.enabled
entity DraftEnabledBooks
{
key ID : Integer;
title : String;
}

@odata.draft.enabled
entity MoreDraftEnabledBooks as projection on my.Books;
}
14 changes: 14 additions & 0 deletions test/scenarios/bookshop/update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,18 @@ describe('Bookshop - Update', () => {
const res = await UPSERT.into('DraftService.DraftEnabledBooks').entries({ ID: 42, title: 'Foo' })
expect(res).to.equal(1)
})

test('with path expressions on draft enabled service entity', async () => {
// make sure `isActiveEntity` is not used in `UPDATE … where (<key>) in <subquery>`
// as it is a virtual <key>
const { MoreDraftEnabledBooks } = cds.entities('DraftService')
const updateRichardsBooks = UPDATE.entity(MoreDraftEnabledBooks)
.where(`author.name = 'Richard Carpenter'`)
.set('ID = 42')
const selectRichardsBooks = CQL`SELECT * FROM ${MoreDraftEnabledBooks} where author.name = 'Richard Carpenter'`

await cds.run(updateRichardsBooks)
const afterUpdate = await cds.db.run(selectRichardsBooks)
expect(afterUpdate[0]).to.have.property('ID').that.equals(42)
})
})

0 comments on commit 0c193c4

Please sign in to comment.