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.
This commit is contained in:
Dan Stillman 2016-04-27 15:57:38 -04:00
parent 5a4dddcbc6
commit f52e93dd16

View file

@ -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');