Skip to content

Commit 9a2afbb

Browse files
committed
Fixes failing tests
1 parent 962a7e3 commit 9a2afbb

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

contentcuration/contentcuration/frontend/channelEdit/vuex/contentNode/__tests__/actions.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ describe('contentNode actions', () => {
3636
jest
3737
.spyOn(ContentNode, 'fetchModel')
3838
.mockImplementation(() => Promise.resolve(contentNodeDatum));
39+
jest
40+
.spyOn(ContentNode, 'getAncestors')
41+
.mockImplementation(() => Promise.resolve([contentNodeDatum]));
3942
return ContentNode._add({ title: 'notatest', parent: newId, lft: 2 }).then(() => {
4043
store = storeFactory({
4144
modules: {

contentcuration/contentcuration/frontend/shared/data/resources.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,9 +1775,10 @@ export const ContentNode = new TreeResource({
17751775
* @return {Promise<void>}
17761776
*/
17771777
async updateAncestors({ id, includeSelf = false, ignoreChanges = false }, updateCallback) {
1778-
// getAncestors contains interactions with non-Dexie APIs, so we need to call it from outside
1779-
// the transaction as this isn't recommended and is a major cause of transaction related errors.
1780-
// Read more here: https://dexie.org/docs/DexieErrors/Dexie.PrematureCommitError
1778+
// getAncestors invokes a non-Dexie API, so it must be called outside the transaction.
1779+
// Invoking it within a transaction can lead to transaction-related issues, including premature
1780+
// commit errors, which are a common problem when mixing non-Dexie API calls with transactions.
1781+
// See: https://dexie.org/docs/DexieErrors/Dexie.PrematureCommitError
17811782
const ancestors = await this.getAncestors(id);
17821783

17831784
return await this.transaction({ mode: 'rw' }, async () => {

0 commit comments

Comments
 (0)