Fix saving to My Library if Zotero pane hasn't been opened
This commit is contained in:
parent
9c53fe893c
commit
23e01fcefd
5 changed files with 84 additions and 36 deletions
|
@ -1,10 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
describe("Zotero_Browser", function () {
|
||||
var win;
|
||||
var win, collection;
|
||||
|
||||
before(function* () {
|
||||
win = yield loadBrowserWindow();
|
||||
collection = yield createDataObject('collection');
|
||||
});
|
||||
|
||||
after(function* () {
|
||||
|
@ -15,6 +16,55 @@ describe("Zotero_Browser", function () {
|
|||
Zotero.ProgressWindowSet.closeAll();
|
||||
})
|
||||
|
||||
|
||||
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();
|
||||
|
||||
var uri = OS.Path.join(getTestDataDirectory().path, "snapshot", "index.html");
|
||||
var deferred = Zotero.Promise.defer();
|
||||
win.Zotero_Browser.addDetectCallback(() => deferred.resolve());
|
||||
win.loadURI(uri);
|
||||
yield deferred.promise;
|
||||
|
||||
var promise = waitForWindow('chrome://zotero/content/progressWindow.xul', function (progressWin) {
|
||||
assert.include(
|
||||
progressWin.document.documentElement.textContent,
|
||||
"Test"
|
||||
);
|
||||
});
|
||||
yield win.Zotero_Browser.scrapeThisPage();
|
||||
yield promise;
|
||||
|
||||
win.close();
|
||||
});
|
||||
|
||||
it("should save journal article to My Library if the Zotero pane hasn't been opened yet in a Firefox window", function* () {
|
||||
Zotero.Prefs.set('lastViewedFolder', collection.collectionTreeViewID);
|
||||
|
||||
var win = yield loadBrowserWindow();
|
||||
|
||||
var deferred = Zotero.Promise.defer();
|
||||
win.Zotero_Browser.addDetectCallback(() => deferred.resolve());
|
||||
var uri = OS.Path.join(
|
||||
getTestDataDirectory().path, "metadata", "journalArticle-single.html"
|
||||
);
|
||||
win.loadURI(uri);
|
||||
yield deferred.promise;
|
||||
|
||||
var promise1 = waitForWindow('chrome://zotero/content/progressWindow.xul', function (progressWin) {});
|
||||
var promise2 = waitForItemEvent('add');
|
||||
yield win.Zotero_Browser.scrapeThisPage();
|
||||
yield promise1;
|
||||
var ids = yield promise2;
|
||||
var items = Zotero.Items.get(ids);
|
||||
assert.lengthOf(items, 1);
|
||||
assert.equal(items[0].libraryID, Zotero.Libraries.userLibraryID);
|
||||
assert.equal(Zotero.ItemTypes.getName(items[0].itemTypeID), 'journalArticle');
|
||||
assert.lengthOf(items[0].getCollections(), 0);
|
||||
|
||||
win.close();
|
||||
});
|
||||
|
||||
it("should save webpage to current collection", function* () {
|
||||
var uri = OS.Path.join(getTestDataDirectory().path, "snapshot", "index.html");
|
||||
var deferred = Zotero.Promise.defer();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue