mirror of
https://github.com/zotero/zotero.git
synced 2026-09-27 01:21:27 +00:00
Test for subsequent updates providing stale changed object data
From #5297
This commit is contained in:
parent
ded8dca668
commit
ee35361608
2 changed files with 16 additions and 3 deletions
|
|
@ -1190,6 +1190,8 @@ Zotero.DataObject.prototype._postSave = function (env) {
|
||||||
let rel = env.relationsToUnregister[i];
|
let rel = env.relationsToUnregister[i];
|
||||||
Zotero.Relations.unregister(this._objectType, this.id, rel[0], rel[1]);
|
Zotero.Relations.unregister(this._objectType, this.id, rel[0], rel[1]);
|
||||||
}
|
}
|
||||||
|
this._changed = {};
|
||||||
|
this._previousData = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2000,15 +2000,26 @@ describe("Zotero.Item", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should include changed field data in notifier extraData", async function () {
|
it("should include changed field data in notifier extraData", async function () {
|
||||||
var item = await createDataObject('item', { title: 'old value' });
|
var item = await createDataObject('item', { title: 'first' });
|
||||||
|
|
||||||
var promise = waitForNotifierEvent('modify', 'item');
|
var promise = waitForNotifierEvent('modify', 'item');
|
||||||
item.setField('title', 'new value');
|
item.setField('title', 'second');
|
||||||
|
item.setField('extra', 'extra');
|
||||||
await item.saveTx();
|
await item.saveTx();
|
||||||
|
|
||||||
var { ids, extraData } = await promise;
|
var { ids, extraData } = await promise;
|
||||||
|
|
||||||
assert.deepPropertyVal(extraData[ids[0]], 'changed', { title: 'old value' });
|
// "first" -> "second", old value is "first" and "extra" was empty
|
||||||
|
assert.deepPropertyVal(extraData[ids[0]], 'changed', { title: 'first', extra: false });
|
||||||
|
|
||||||
|
var promise = waitForNotifierEvent('modify', 'item');
|
||||||
|
item.setField('title', 'third');
|
||||||
|
await item.saveTx();
|
||||||
|
|
||||||
|
var { ids, extraData } = await promise;
|
||||||
|
|
||||||
|
// "second" -> "third", old value is "second", and we don't notify about "extra" because it's not changed this time
|
||||||
|
assert.deepPropertyVal(extraData[ids[0]], 'changed', { title: 'second' });
|
||||||
});
|
});
|
||||||
|
|
||||||
// 'deleted' and 'tags' use a different, newer mechanism for marking changes
|
// 'deleted' and 'tags' use a different, newer mechanism for marking changes
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue