Fix serialization of the result level seeded for a migrated childNote

The condition seeded by _loadConditions() used `mode: undefined`, but
toJSON() only omits the "/mode" suffix when the mode is exactly false
(what parseCondition() returns), so a saved search migrated from the
obsolete childNote condition serialized -- and synced -- the condition
as "resultLevel/undefined".
This commit is contained in:
Dan Stillman 2026-07-05 16:40:17 -04:00
parent c43f028c96
commit d95d8f294d
2 changed files with 6 additions and 3 deletions

View file

@ -198,7 +198,9 @@ Zotero.Searches = function () {
search._conditions[id] = {
id,
condition: 'resultLevel',
mode: undefined,
// No mode -- parseCondition() uses false, and toJSON() only omits the
// "/mode" suffix for an exact false
mode: false,
operator: 'item',
value: ''
};

View file

@ -69,14 +69,15 @@ describe("Zotero.Search", function () {
var resultLevel = conds.find(c => c.condition == 'resultLevel');
assert.ok(resultLevel);
assert.equal(resultLevel.operator, 'item');
assert.sameMembers(s.toJSON().conditions.map(c => c.condition), ['note', 'resultLevel']);
assert.sameMembers(await s.search(), [item.id]);
await item.eraseTx();
await s.eraseTx();
});
});
describe("#save()", function () {
it("should fail without a name", async function () {
var s = new Zotero.Search;