Fix test failures due to rapid attachment note initialization

81739c7a66 prevented new windows from working after a restart error,
and full-text tests (and possibly others) create attachments quickly in
a way that was causing init callbacks to receive a TinyMCE editor with
missing functions (possibly because they were already removed?). This
just ignores those errors, which isn't a great solution, but it probably
won't happen in real use, so let's see if it works.
This commit is contained in:
Dan Stillman 2020-03-14 02:42:14 -04:00
parent 440b65935e
commit ad6c3f7a09

View file

@ -534,6 +534,12 @@
return ; return ;
} }
// Hack to ignore incomplete editors due to rapid note creation in tests
if (Zotero.test && !this._editor.getContent) {
Zotero.logError("editor.getContent doesn't exist");
return;
}
if (this.value == val) { if (this.value == val) {
Zotero.debug("Textbox value hasn't changed"); Zotero.debug("Textbox value hasn't changed");
this._changed = false; this._changed = false;
@ -623,6 +629,11 @@
<parameter name="callback"/> <parameter name="callback"/>
<body><![CDATA[ <body><![CDATA[
if (this.initialized) { if (this.initialized) {
// Hack to ignore incomplete editors due to rapid note creation in tests
if (Zotero.test && !this._editor.setMode) {
Zotero.logError("editor.setMode doesn't exist after initialization");
return;
}
callback(this._editor); callback(this._editor);
} }
else { else {
@ -741,6 +752,11 @@
let cb; let cb;
if (this._onInitCallbacks) { if (this._onInitCallbacks) {
while (cb = this._onInitCallbacks.shift()) { while (cb = this._onInitCallbacks.shift()) {
// Hack to ignore incomplete editors due to rapid note creation in tests
if (Zotero.test && !this._editor.setMode) {
Zotero.logError("editor.setMode doesn't exist");
return;
}
cb(this._editor); cb(this._editor);
} }
} }