From f52e93dd165ba8a7970df6622859164b6a438043 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 27 Apr 2016 15:57:38 -0400 Subject: [PATCH] Fix intermittent test failures saving from loaded RIS file 1c19fe8d81 isn't sufficient for local files, because detection is run twice, so a translator may not be available when the detect callback is run. This changes the test to poll for the translate icon, which is a bit of a hack but does the job. Unfortunately this isn't perfect either, because it seems the RIS detection sometimes just isn't run, which means that the icon never changes and the test times out. Maybe @simonster has an idea why that's happening. --- test/tests/browserTest.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/tests/browserTest.js b/test/tests/browserTest.js index 10e8f88c29..8aadad95ce 100644 --- a/test/tests/browserTest.js +++ b/test/tests/browserTest.js @@ -16,6 +16,18 @@ describe("Zotero_Browser", function () { Zotero.ProgressWindowSet.closeAll(); }) + var waitForTranslateIcon = Zotero.Promise.coroutine(function* () { + var button = win.document.getElementById('zotero-toolbar-save-button'); + if (button.classList.contains('translate')) { + return; + } + Zotero.debug("Waiting for translator icon"); + do { + yield Zotero.Promise.delay(50); + } + while (!button.classList.contains('translate')); + }); + it("should save webpage to My Library if the Zotero pane hasn't been opened yet in a Firefox window", function* () { var win = yield loadBrowserWindow(); @@ -114,6 +126,9 @@ describe("Zotero_Browser", function () { win.loadURI(uri); yield deferred.promise; + // Detection runs twice for local files, so wait for the icon to actually appear + yield waitForTranslateIcon(); + yield loadZoteroPane(win); var collection = yield createDataObject('collection');