mirror of
https://github.com/zotero/zotero.git
synced 2026-10-07 02:58:09 +00:00
Poll for expected tag selector state in flaky tests
Selecting a collection doesn't wait for the tag selector to re-render, so waitForTagSelector() could be resolved by the initial render instead of the awaited change, and the assertions could run against a stale tag list.
This commit is contained in:
parent
b3b6e7f33d
commit
d0a32a3b4f
1 changed files with 7 additions and 12 deletions
|
|
@ -86,15 +86,13 @@ describe("Tag Selector", function () {
|
|||
}]);
|
||||
var item2 = createUnsavedDataObject('item', { collections: [collection.id] });
|
||||
item2.setTags(["A", "B"]);
|
||||
var promise = waitForTagSelector(win);
|
||||
await Zotero.DB.executeTransaction(async function () {
|
||||
await item1.save();
|
||||
await item2.save();
|
||||
});
|
||||
await promise;
|
||||
await waitForCallback(() => getRegularTags().length == 2, 50, 5);
|
||||
|
||||
var tags = getRegularTags();
|
||||
assert.sameMembers(tags, ['A', 'B']);
|
||||
assert.sameMembers(getRegularTags(), ['A', 'B']);
|
||||
});
|
||||
|
||||
it("should show tags from annotations for attachments in scope", async function () {
|
||||
|
|
@ -219,13 +217,14 @@ describe("Tag Selector", function () {
|
|||
item2.setTags([tag2]);
|
||||
var item3 = createUnsavedDataObject('item', { collections: [collection.id] });
|
||||
item3.setTags([tag3]);
|
||||
var promise = waitForTagSelector(win);
|
||||
await Zotero.DB.executeTransaction(async function () {
|
||||
await item1.save();
|
||||
await item2.save();
|
||||
await item3.save();
|
||||
});
|
||||
await promise;
|
||||
await waitForCallback(
|
||||
() => [tag1, tag2, tag3].every(tag => getRegularTags().includes(tag)), 50, 5
|
||||
);
|
||||
|
||||
var tags = getRegularTags();
|
||||
assert.includeMembers(tags, [tag1, tag2, tag3]);
|
||||
|
|
@ -454,14 +453,10 @@ describe("Tag Selector", function () {
|
|||
})
|
||||
|
||||
it("should show a colored tag at the top of the list even when linked to no items", async function () {
|
||||
var tagElems = tagSelectorElem.querySelectorAll('.tag-selector-item');
|
||||
var count = tagElems.length;
|
||||
|
||||
await Zotero.Tags.setColor(libraryID, "Top", '#AAAAAA');
|
||||
await waitForTagSelector(win);
|
||||
await waitForCallback(() => getColoredTags().includes("Top"), 50, 5);
|
||||
|
||||
tagElems = tagSelectorElem.querySelectorAll('.tag-selector-item');
|
||||
assert.equal(tagElems.length, count + 1);
|
||||
assert.equal(tagSelectorElem.querySelector('.tag-selector-item').textContent, "Top");
|
||||
});
|
||||
|
||||
it("shouldn't re-insert a new tag that matches an existing color", async function () {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue