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

@ -606,11 +606,14 @@ function createUnsavedDataObject(objectType, params = {}) {
return obj;
}
var createDataObject = Zotero.Promise.coroutine(function* (objectType, params = {}, saveOptions) {
async function createDataObject(objectType, params = {}, saveOptions) {
var obj = createUnsavedDataObject(objectType, params);
yield obj.saveTx(saveOptions);
var options = {
skipSelect: (objectType == 'item' || objectType == 'feedItem') ? false : true
};
await obj.saveTx(Object.assign(options, saveOptions));
return obj;
});
}
function getNameProperty(objectType) {
return objectType == 'item' ? 'title' : 'name';