2016-06-11 00:35:14 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
describe("Note Editor", function () {
|
|
|
|
var win, zp;
|
|
|
|
|
|
|
|
before(function* () {
|
|
|
|
win = yield loadZoteroPane();
|
|
|
|
zp = win.ZoteroPane;
|
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
|
|
|
win.close();
|
|
|
|
});
|
|
|
|
|
2017-04-01 18:29:45 +00:00
|
|
|
var waitForNoteEditor = Zotero.Promise.coroutine(function* (item) {
|
|
|
|
var noteEditor = win.document.getElementById('zotero-note-editor');
|
|
|
|
while (noteEditor.item != item) {
|
|
|
|
Zotero.debug("Waiting for note editor");
|
|
|
|
yield Zotero.Promise.delay(50);
|
|
|
|
noteEditor = win.document.getElementById('zotero-note-editor');
|
|
|
|
}
|
|
|
|
return new Zotero.Promise((resolve, reject) => {
|
2021-01-13 12:01:44 +00:00
|
|
|
noteEditor.onInit(() => resolve(noteEditor));
|
2017-04-01 18:29:45 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-06-11 00:35:14 +00:00
|
|
|
describe("Tags box", function () {
|
|
|
|
it("should open new row for editing if no tags", function* () {
|
2017-04-01 18:29:45 +00:00
|
|
|
var note = yield createDataObject('item', { itemType: 'note', note: "A" });
|
|
|
|
var noteEditor = yield waitForNoteEditor(note);
|
2016-06-11 00:35:14 +00:00
|
|
|
var linksBox = noteEditor._id('links-box');
|
|
|
|
linksBox.tagsClick();
|
|
|
|
var tagsBox = linksBox.id('tagsPopup').firstChild;
|
|
|
|
var tagRows = tagsBox.id('tagRows');
|
|
|
|
assert.equal(tagRows.childNodes.length, 1);
|
2016-11-29 09:26:58 +00:00
|
|
|
|
|
|
|
linksBox.id('tagsPopup').hidePopup();
|
2016-06-11 00:35:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should only open one new row for editing", function* () {
|
2017-04-01 18:29:45 +00:00
|
|
|
var note = yield createDataObject('item', { itemType: 'note', note: "B" });
|
|
|
|
var noteEditor = yield waitForNoteEditor(note);
|
2016-06-11 00:35:14 +00:00
|
|
|
var linksBox = noteEditor._id('links-box');
|
|
|
|
linksBox.tagsClick();
|
|
|
|
// Close and reopen
|
|
|
|
linksBox.id('tagsPopup').hidePopup();
|
|
|
|
linksBox.tagsClick();
|
|
|
|
|
|
|
|
// Should still be only one empty row
|
|
|
|
var tagsBox = linksBox.id('tagsPopup').firstChild;
|
|
|
|
var tagRows = tagsBox.id('tagRows');
|
|
|
|
assert.equal(tagRows.childNodes.length, 1);
|
2016-11-29 09:26:58 +00:00
|
|
|
|
|
|
|
linksBox.id('tagsPopup').hidePopup();
|
2016-06-11 00:35:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should show tags in alphabetical order", function* () {
|
|
|
|
var note = new Zotero.Item('note');
|
2017-04-01 18:29:45 +00:00
|
|
|
note.setNote('C');
|
2016-06-11 00:35:14 +00:00
|
|
|
note.addTag('B');
|
|
|
|
yield note.saveTx();
|
|
|
|
note.addTag('A');
|
|
|
|
note.addTag('C');
|
|
|
|
yield note.saveTx();
|
|
|
|
|
2017-04-01 18:29:45 +00:00
|
|
|
var noteEditor = yield waitForNoteEditor(note);
|
2016-06-11 00:35:14 +00:00
|
|
|
var linksBox = noteEditor._id('links-box');
|
|
|
|
assert.equal(linksBox.id('tags').summary, "A, B, C");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|