Fix note editor tests

This commit is contained in:
Martynas Bagdonas 2021-01-13 14:01:44 +02:00 committed by Dan Stillman
parent 232ffba2ab
commit 5266734ac9
5 changed files with 22 additions and 10 deletions

View file

@ -106,6 +106,16 @@
onReturn: this._returnHandler,
placeholder: this.placeholder
});
if (this._onInitCallback) {
this._onInitCallback();
}
}
this.onInit = (callback) => {
if (this._editorInstance) {
return callback();
}
this._onInitCallback = callback;
}
this.notify = async (event, type, ids, extraData) => {

View file

@ -126,7 +126,7 @@ class EditorInstance {
saveSync() {
if (!this._readOnly && !this._disableSaving && this._iframeWindow) {
let noteData = this._iframeWindow.wrappedJSObject.getDataSync();
let noteData = this._iframeWindow.wrappedJSObject.getDataSync(true);
if (noteData) {
noteData = JSON.parse(JSON.stringify(noteData));
}

View file

@ -282,16 +282,18 @@ describe("Item pane", function () {
// Wait for the editor
yield new Zotero.Promise((resolve, reject) => {
noteEditor.noteField.onInit(() => resolve());
})
assert.equal(noteEditor.noteField.value, '');
noteEditor.onInit(() => resolve());
});
assert.equal(noteEditor._editorInstance._iframeWindow.wrappedJSObject.getDataSync(), null);
item.setNote('<p>Test</p>');
yield item.saveTx();
assert.equal(noteEditor.noteField.value, '<p>Test</p>');
})
})
// Wait for asynchronous editor update
do {
yield Zotero.Promise.delay(10);
} while(noteEditor._editorInstance._iframeWindow.wrappedJSObject.getDataSync().html != '<div data-schema-version="1"><p>Test</p></div>');
});
});
describe("Feed buttons", function() {
describe("Mark as Read/Unread", function() {

View file

@ -20,7 +20,7 @@ describe("Note Editor", function () {
noteEditor = win.document.getElementById('zotero-note-editor');
}
return new Zotero.Promise((resolve, reject) => {
noteEditor.noteField.onInit(() => resolve(noteEditor));
noteEditor.onInit(() => resolve(noteEditor));
});
});

@ -1 +1 @@
Subproject commit 73808236baa117a0e712e21f3c0ac06af1a553f0
Subproject commit 007082af6c4a534d98bc4a6e04c899bb5e9520d8