Tests: Don't auto-select collections and searches after creation

This changes `createDataObject()` to pass `skipSelect: true` for objects
other than items. If a test is creating a bunch of collections, there's
no reason for each one to be selected and for an items list to start to
load. If a test does need a new collection or search to be selected, it
can call the new convenience function `await select(win, obj)`, which
will select the passed object in the collection tree and wait for its
items list to load. I'm hoping this reduces random test failures due to
items list churn.
This commit is contained in:
Dan Stillman 2024-06-24 02:04:52 -04:00
parent 09aad7b075
commit 173f4c491e
10 changed files with 143 additions and 149 deletions

View file

@ -18,21 +18,21 @@ describe("Zotero.LibraryTree", function() {
});
describe("#getRowIndexByID()", function () {
it("should return the row index of an item", function* () {
var collection = yield createDataObject('collection');
yield waitForItemsLoad(win);
var item = yield createDataObject('item', { collections: [collection.id] });
it("should return the row index of an item", async function () {
var collection = await createDataObject('collection');
await select(win, collection);
var item = await createDataObject('item', { collections: [collection.id] });
var view = zp.itemsView;
assert.strictEqual(view.getRowIndexByID(item.treeViewID), 0);
});
});
describe("#_removeRow()", function () {
it("should remove the last row", function* () {
var collection = yield createDataObject('collection');
yield waitForItemsLoad(win);
yield createDataObject('item', { collections: [collection.id] });
yield createDataObject('item', { collections: [collection.id] });
it("should remove the last row", async function () {
var collection = await createDataObject('collection');
await select(win, collection);
await createDataObject('item', { collections: [collection.id] });
await createDataObject('item', { collections: [collection.id] });
var view = zp.itemsView;
var treeViewID = view.getRow(1).id;