Fix saving of single files to library root via save button
This commit is contained in:
parent
ea1486f62f
commit
20ece48a57
4 changed files with 44 additions and 5 deletions
|
@ -42,7 +42,9 @@ function loadBrowserWindow() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Loads a Zotero pane in a new window and selects My Library. Returns the containing window.
|
||||
* Opens the Zotero pane and selects My Library. Returns the containing window.
|
||||
*
|
||||
* @param {Window} [win] - Existing window to use; if not specified, a new window is opened
|
||||
*/
|
||||
var loadZoteroPane = Zotero.Promise.coroutine(function* (win) {
|
||||
if (!win) {
|
||||
|
|
|
@ -55,6 +55,45 @@ describe("Zotero_Browser", function () {
|
|||
assert.isTrue(collection.hasItem(items[0].id));
|
||||
})
|
||||
|
||||
it("should save PDF to library root", function* () {
|
||||
var uri = OS.Path.join(getTestDataDirectory().path, "test.pdf");
|
||||
var deferred = Zotero.Promise.defer();
|
||||
win.addEventListener('pageshow', () => deferred.resolve());
|
||||
win.loadURI(uri);
|
||||
yield deferred.promise;
|
||||
|
||||
yield loadZoteroPane(win);
|
||||
|
||||
var promise = waitForItemEvent('add');
|
||||
yield win.Zotero_Browser.scrapeThisPage();
|
||||
var ids = yield promise;
|
||||
var items = Zotero.Items.get(ids);
|
||||
assert.lengthOf(items, 1);
|
||||
assert.equal(Zotero.ItemTypes.getName(items[0].itemTypeID), 'attachment');
|
||||
assert.equal(items[0].getField('title'), 'test.pdf');
|
||||
assert.equal(items[0].attachmentContentType, 'application/pdf');
|
||||
assert.equal(Zotero.Attachments.linkModeToName(items[0].attachmentLinkMode), 'imported_url');
|
||||
});
|
||||
|
||||
it("should save PDF to current collection", function* () {
|
||||
var uri = OS.Path.join(getTestDataDirectory().path, "test.pdf");
|
||||
var deferred = Zotero.Promise.defer();
|
||||
win.addEventListener('pageshow', () => deferred.resolve());
|
||||
win.loadURI(uri);
|
||||
yield deferred.promise;
|
||||
|
||||
yield loadZoteroPane(win);
|
||||
var collection = yield createDataObject('collection');
|
||||
|
||||
var promise = waitForItemEvent('add');
|
||||
yield win.Zotero_Browser.scrapeThisPage();
|
||||
var ids = yield promise;
|
||||
var items = Zotero.Items.get(ids);
|
||||
assert.lengthOf(items, 1);
|
||||
assert.equal(Zotero.ItemTypes.getName(items[0].itemTypeID), 'attachment');
|
||||
assert.isTrue(collection.hasItem(items[0].id));
|
||||
});
|
||||
|
||||
it("shouldn't save webpage to My Publications", 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