diff --git a/app/assets/javascripts/discourse/app/components/ace-editor.gjs b/app/assets/javascripts/discourse/app/components/ace-editor.gjs
index a3aad9981d3..213ffda552e 100644
--- a/app/assets/javascripts/discourse/app/components/ace-editor.gjs
+++ b/app/assets/javascripts/discourse/app/components/ace-editor.gjs
@@ -3,6 +3,7 @@ import { tracked } from "@glimmer/tracking";
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
import didUpdate from "@ember/render-modifiers/modifiers/did-update";
import { service } from "@ember/service";
+import { registerWaiter } from "@ember/test";
import { modifier } from "ember-modifier";
import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
import loadAce from "discourse/lib/load-ace-editor";
@@ -70,6 +71,12 @@ export default class AceEditor extends Component {
this.skipChangePropagation = true;
this.editor.getSession().setValue(this.args.content || "");
this.skipChangePropagation = false;
+
+ if (isTesting()) {
+ let finished = false;
+ registerWaiter(() => finished);
+ this.editor.renderer.once("afterRender", () => (finished = true));
+ }
});
constructor() {
@@ -165,7 +172,7 @@ export default class AceEditor extends Component {
@bind
editorIdChanged() {
if (this.autofocus) {
- this.send("focus");
+ this.focus();
}
}
diff --git a/app/assets/javascripts/discourse/tests/integration/components/ace-editor-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/ace-editor-test.gjs
index 880f5ef09e5..d1ce7d1eb87 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/ace-editor-test.gjs
+++ b/app/assets/javascripts/discourse/tests/integration/components/ace-editor-test.gjs
@@ -7,34 +7,52 @@ module("Integration | Component | ace-editor", function (hooks) {
setupRenderingTest(hooks);
test("css editor", async function (assert) {
- await render();
+ await render(
+
+ );
assert.dom(".ace_editor").exists("it renders the ace editor");
});
test("html editor", async function (assert) {
await render(
- wat" />
+ wat"
+ style="width: 300px; height: 200px"
+ />
);
assert.dom(".ace_editor").exists("it renders the ace editor");
});
test("sql editor", async function (assert) {
await render(
-
+
);
assert.dom(".ace_editor").exists("it renders the ace editor");
});
test("yaml editor", async function (assert) {
await render(
-
+
);
assert.dom(".ace_editor").exists("it renders the ace editor");
});
test("javascript editor", async function (assert) {
await render(
-
+
);
assert.dom(".ace_editor").exists("it renders the ace editor");
});
@@ -45,6 +63,7 @@ module("Integration | Component | ace-editor", function (hooks) {
@mode="sql"
@content="SELECT * FROM users"
@disabled={{true}}
+ style="width: 300px; height: 200px"
/>
);
diff --git a/app/assets/javascripts/discourse/tests/integration/components/form-kit/controls/code-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/form-kit/controls/code-test.gjs
index 0032105c2e3..344aecfc72e 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/form-kit/controls/code-test.gjs
+++ b/app/assets/javascripts/discourse/tests/integration/components/form-kit/controls/code-test.gjs
@@ -14,7 +14,7 @@ module("Integration | Component | FormKit | Controls | Code", function (hooks) {
await render(
-
+
);