diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-image-preview-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-image-preview-test.js index bc7d2f159cc..f56762a69b9 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-image-preview-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-image-preview-test.js @@ -368,9 +368,9 @@ acceptance("Composer - Image Preview - Plugin API", function (needs) { "My Custom Button", "custom-button-class", "lock", - (event) => { + async (event) => { if (event.target.classList.contains("custom-button-class")) { - fillIn(".d-editor-input", "custom button change"); + await fillIn(".d-editor-input", "custom button change"); } } ); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-messages-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-messages-test.js index 105444c7a93..53ee24c6179 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-messages-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-messages-test.js @@ -154,7 +154,9 @@ acceptance("Composer - Messages - Duplicate links", function (needs) { await click("button.create"); // Work around the lack of CSS transitions in the test env - triggerEvent("#reply-control", "transitionend", { propertyName: "height" }); + await triggerEvent("#reply-control", "transitionend", { + propertyName: "height", + }); assert .dom(".composer-popup") diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-test.js index a8accee4364..7941c8ce5d6 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/search-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/search-test.js @@ -15,8 +15,7 @@ import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { i18n } from "discourse-i18n"; -const clickOutside = () => - triggerEvent(document.querySelector("header.d-header"), "pointerdown"); +const clickOutside = () => triggerEvent("header.d-header", "pointerdown"); acceptance("Search - Anonymous", function (needs) { needs.pretender((server, helper) => { diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js index e0119cebe22..e830bda9781 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js @@ -406,8 +406,7 @@ acceptance("User menu", function (needs) { }); test("the profile tab", async function (assert) { - const clickOutside = () => - triggerEvent(document.querySelector("header.d-header"), "pointerdown"); + const clickOutside = () => triggerEvent("header.d-header", "pointerdown"); updateCurrentUser({ draft_count: 13 }); await visit("/"); diff --git a/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js b/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js index c3e63164af2..d2633148eaf 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js @@ -60,8 +60,11 @@ module("Integration | Component | d-editor", function (hooks) { assert.dom(".d-editor-preview").hasHtml("
zogstrip
"); }); - function jumpEnd(selector) { - const textarea = document.querySelector(selector); + function jumpEnd(textarea) { + if (typeof textarea === "string") { + textarea = document.querySelector(textarea); + } + textarea.selectionStart = textarea.value.length; textarea.selectionEnd = textarea.value.length; return textarea; diff --git a/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js b/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js index e197994ebf6..c9134c6e313 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js @@ -24,8 +24,8 @@ module("Integration | Component | date-input", function (hooks) { hbs`