Maybe fix noteeditor test failures for real
This commit is contained in:
parent
7609ef35bc
commit
c43823ad60
|
@ -8,20 +8,27 @@ describe("Note Editor", function () {
|
||||||
zp = win.ZoteroPane;
|
zp = win.ZoteroPane;
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function* () {
|
|
||||||
// Avoid "this._editor is undefined" error and incorrect note selection between tests,
|
|
||||||
// though there's definitely a better way to fix this
|
|
||||||
yield Zotero.Promise.delay(150);
|
|
||||||
});
|
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
win.close();
|
win.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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) => {
|
||||||
|
noteEditor.noteField.onInit(() => resolve(noteEditor));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("Tags box", function () {
|
describe("Tags box", function () {
|
||||||
it("should open new row for editing if no tags", function* () {
|
it("should open new row for editing if no tags", function* () {
|
||||||
var note = yield createDataObject('item', { itemType: 'note' });
|
var note = yield createDataObject('item', { itemType: 'note', note: "A" });
|
||||||
var noteEditor = win.document.getElementById('zotero-note-editor');
|
var noteEditor = yield waitForNoteEditor(note);
|
||||||
var linksBox = noteEditor._id('links-box');
|
var linksBox = noteEditor._id('links-box');
|
||||||
linksBox.tagsClick();
|
linksBox.tagsClick();
|
||||||
var tagsBox = linksBox.id('tagsPopup').firstChild;
|
var tagsBox = linksBox.id('tagsPopup').firstChild;
|
||||||
|
@ -32,8 +39,8 @@ describe("Note Editor", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should only open one new row for editing", function* () {
|
it("should only open one new row for editing", function* () {
|
||||||
var note = yield createDataObject('item', { itemType: 'note' });
|
var note = yield createDataObject('item', { itemType: 'note', note: "B" });
|
||||||
var noteEditor = win.document.getElementById('zotero-note-editor');
|
var noteEditor = yield waitForNoteEditor(note);
|
||||||
var linksBox = noteEditor._id('links-box');
|
var linksBox = noteEditor._id('links-box');
|
||||||
linksBox.tagsClick();
|
linksBox.tagsClick();
|
||||||
// Close and reopen
|
// Close and reopen
|
||||||
|
@ -50,13 +57,14 @@ describe("Note Editor", function () {
|
||||||
|
|
||||||
it("should show tags in alphabetical order", function* () {
|
it("should show tags in alphabetical order", function* () {
|
||||||
var note = new Zotero.Item('note');
|
var note = new Zotero.Item('note');
|
||||||
|
note.setNote('C');
|
||||||
note.addTag('B');
|
note.addTag('B');
|
||||||
yield note.saveTx();
|
yield note.saveTx();
|
||||||
note.addTag('A');
|
note.addTag('A');
|
||||||
note.addTag('C');
|
note.addTag('C');
|
||||||
yield note.saveTx();
|
yield note.saveTx();
|
||||||
|
|
||||||
var noteEditor = win.document.getElementById('zotero-note-editor');
|
var noteEditor = yield waitForNoteEditor(note);
|
||||||
var linksBox = noteEditor._id('links-box');
|
var linksBox = noteEditor._id('links-box');
|
||||||
assert.equal(linksBox.id('tags').summary, "A, B, C");
|
assert.equal(linksBox.id('tags').summary, "A, B, C");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user