DEV: avoid sending events to a destroying object and enable few skipped tests (#15030)

This commit is contained in:
Andrei Prigorshnev 2021-12-01 18:21:44 +04:00 committed by GitHub
parent 4bdb956a0d
commit f37375f582
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -275,6 +275,10 @@ export default Controller.extend(ModalFunctionality, {
postAction
.act(this.model, params)
.then(() => {
if (this.isDestroying || this.isDestroyed) {
return;
}
if (!params.skipClose) {
this.send("closeModal");
}
@ -286,7 +290,9 @@ export default Controller.extend(ModalFunctionality, {
});
})
.catch((error) => {
this.send("closeModal");
if (!this.isDestroying && !this.isDestroyed) {
this.send("closeModal");
}
popupAjaxError(error);
});
},

View File

@ -6,7 +6,7 @@ import {
} from "discourse/tests/helpers/qunit-helpers";
import { click, fillIn, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { skip, test } from "qunit";
import { test } from "qunit";
import userFixtures from "discourse/tests/fixtures/user-fixtures";
import { run } from "@ember/runloop";
@ -153,7 +153,7 @@ acceptance("flagging", function (needs) {
assert.ok(!exists(".bootbox.modal:visible"));
});
skip("CTRL + ENTER accepts the modal", async function (assert) {
test("CTRL + ENTER accepts the modal", async function (assert) {
await visit("/t/internationalization-localization/280");
await openFlagModal();
@ -169,7 +169,7 @@ acceptance("flagging", function (needs) {
assert.ok(!exists("#discourse-modal:visible"), "The modal was closed");
});
skip("CMD or WINDOWS-KEY + ENTER accepts the modal", async function (assert) {
test("CMD or WINDOWS-KEY + ENTER accepts the modal", async function (assert) {
await visit("/t/internationalization-localization/280");
await openFlagModal();