Fix recognizeDocument test failures
Wait for all progress-queue rows to be done processing before moving on
to the next test. Without this, preview rendering or other operations
can cause test failures by delaying the `ZoteroPane.selectItems()` call
for the new parent item in `_processItem()` until the middle of a
following test (due to the await for file renaming [1]). If it's delayed
until after the next attachment has been created, the previous parent
item will be selected after the new attachment and `recognizeSelected()`
in the test won't work. This is most pronounced with the reader, but it
was apparently happening previously due to something else, hence the
explicit item selection (now removed) in one test.
[1] 21e50add60/chrome/content/zotero/xpcom/recognizeDocument.js (L289-L301)
This commit is contained in:
parent
0cd7a52dc0
commit
db4d7d5838
1 changed files with 9 additions and 3 deletions
|
@ -13,11 +13,18 @@ describe("Document Recognition", function() {
|
|||
yield selectLibrary(win);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(async function() {
|
||||
for(let win of getWindows("chrome://zotero/content/progressQueueDialog.xhtml")) {
|
||||
win.close();
|
||||
}
|
||||
Zotero.ProgressQueues.get('recognize').cancel();
|
||||
|
||||
// Wait for all rows to be done processing
|
||||
var queue = Zotero.ProgressQueues.get('recognize');
|
||||
while (queue.getRows().some(row => row.status == Zotero.ProgressQueue.ROW_PROCESSING)) {
|
||||
await Zotero.Promise.delay(50);
|
||||
}
|
||||
|
||||
queue.cancel();
|
||||
Zotero.RecognizeDocument.recognizeStub = null;
|
||||
Zotero.Prefs.clear('autoRenameFiles.linked');
|
||||
});
|
||||
|
@ -436,7 +443,6 @@ describe("Document Recognition", function() {
|
|||
file: testDir,
|
||||
collections: [collection.id]
|
||||
});
|
||||
await win.ZoteroPane.selectItem(attachment.id); // No idea why this is necessary for only this test
|
||||
|
||||
win.ZoteroPane.recognizeSelected();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue