diff --git a/contentcuration/contentcuration/frontend/channelEdit/vuex/contentNode/__tests__/actions.spec.js b/contentcuration/contentcuration/frontend/channelEdit/vuex/contentNode/__tests__/actions.spec.js index e25fe4ed5b..328fc33f95 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/vuex/contentNode/__tests__/actions.spec.js +++ b/contentcuration/contentcuration/frontend/channelEdit/vuex/contentNode/__tests__/actions.spec.js @@ -36,6 +36,9 @@ describe('contentNode actions', () => { jest .spyOn(ContentNode, 'fetchModel') .mockImplementation(() => Promise.resolve(contentNodeDatum)); + jest + .spyOn(ContentNode, 'getAncestors') + .mockImplementation(() => Promise.resolve([contentNodeDatum])); return ContentNode._add({ title: 'notatest', parent: newId, lft: 2 }).then(() => { store = storeFactory({ modules: { diff --git a/contentcuration/contentcuration/frontend/shared/data/resources.js b/contentcuration/contentcuration/frontend/shared/data/resources.js index 0c121a8069..eebbcdf0ad 100644 --- a/contentcuration/contentcuration/frontend/shared/data/resources.js +++ b/contentcuration/contentcuration/frontend/shared/data/resources.js @@ -1775,9 +1775,10 @@ export const ContentNode = new TreeResource({ * @return {Promise} */ async updateAncestors({ id, includeSelf = false, ignoreChanges = false }, updateCallback) { - // getAncestors contains interactions with non-Dexie APIs, so we need to call it from outside - // the transaction as this isn't recommended and is a major cause of transaction related errors. - // Read more here: https://dexie.org/docs/DexieErrors/Dexie.PrematureCommitError + // getAncestors invokes a non-Dexie API, so it must be called outside the transaction. + // Invoking it within a transaction can lead to transaction-related issues, including premature + // commit errors, which are a common problem when mixing non-Dexie API calls with transactions. + // See: https://dexie.org/docs/DexieErrors/Dexie.PrematureCommitError const ancestors = await this.getAncestors(id); return await this.transaction({ mode: 'rw' }, async () => {