Account for the section header row in multi-collection tests

This commit is contained in:
Dan Stillman 2026-06-17 15:06:48 -04:00
parent 167045d000
commit bf619922c3
2 changed files with 9 additions and 5 deletions

View file

@ -160,11 +160,13 @@ describe("Advanced Search", function () {
await deck.pane.submit();
await iv.waitForLoad();
// Matching items from both collections, but not the matching item
// outside the selected collections
assert.equal(iv.rowCount, 2);
// Matching items from both collections, but not the non-matching item or the
// matching item outside the selected collections (the row count also includes the
// "2 collections selected" section header)
assert.isNumber(iv.getRowIndexByID(inFirst.id));
assert.isNumber(iv.getRowIndexByID(inSecond.id));
assert.isFalse(iv.getRowIndexByID(noMatch.id));
assert.isFalse(iv.getRowIndexByID(notInCollections.id));
await zp.setAdvancedSearchState('closed');
await selectLibrary(win);

View file

@ -2236,10 +2236,12 @@ describe("ZoteroPane", function () {
await selectMultipleCollections([collection1, collection2]);
let itemsView = zp.itemsView;
// Count how many times the item appears
// Count how many times the item appears. Compare the row's ref object
// rather than its id: a section header's ref is the library, whose id can
// collide with an item id in a fresh database.
let count = 0;
for (let i = 0; i < itemsView.rowCount; i++) {
if (itemsView.getRow(i).ref.id === item.id) {
if (itemsView.getRow(i).ref === item) {
count++;
}
}