Fix hang on import that includes an HTML attachment
Closes #734, for the moment
This commit is contained in:
parent
42968949b6
commit
74cf2a3c22
5 changed files with 119 additions and 24 deletions
|
@ -38,4 +38,37 @@ describe("Zotero_File_Interface", function() {
|
|||
}
|
||||
assert.deepEqual(savedItems, trueItems, "saved items match inputs")
|
||||
});
|
||||
|
||||
it('should import an item and snapshot from Zotero RDF', function* () {
|
||||
var tmpDir = yield getTempDirectory();
|
||||
var rdfFile = OS.Path.join(tmpDir, 'test.rdf');
|
||||
yield OS.File.copy(OS.Path.join(getTestDataDirectory().path, 'book_and_snapshot.rdf'), rdfFile);
|
||||
yield OS.File.makeDir(OS.Path.join(tmpDir, 'files'));
|
||||
yield OS.File.makeDir(OS.Path.join(tmpDir, 'files', 2));
|
||||
yield OS.File.copy(
|
||||
OS.Path.join(getTestDataDirectory().path, 'test.html'),
|
||||
OS.Path.join(tmpDir, 'files', 2, 'test.html')
|
||||
);
|
||||
|
||||
var promise = waitForItemEvent('add');
|
||||
Zotero.debug(yield Zotero.File.getContentsAsync(rdfFile));
|
||||
yield win.Zotero_File_Interface.importFile(Zotero.File.pathToFile(rdfFile))
|
||||
var ids = yield promise;
|
||||
assert.lengthOf(ids, 1);
|
||||
|
||||
// Check book
|
||||
var item = Zotero.Items.get(ids[0]);
|
||||
assert.equal(item.itemTypeID, Zotero.ItemTypes.getID('book'));
|
||||
|
||||
// Check attachment
|
||||
var ids = item.getAttachments();
|
||||
assert.lengthOf(ids, 1);
|
||||
var attachment = Zotero.Items.get(ids[0]);
|
||||
assert.equal(attachment.attachmentCharset, 'utf-8');
|
||||
|
||||
// Check indexing
|
||||
var matches = yield Zotero.Fulltext.findTextInItems([attachment.id], 'test');
|
||||
assert.lengthOf(matches, 1);
|
||||
assert.propertyVal(matches[0], 'id', attachment.id);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue