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`` ); - fillIn(".date-picker", "2019-01-02"); - triggerEvent(".date-picker", "change"); + await fillIn(".date-picker", "2019-01-02"); + await triggerEvent(".date-picker", "change"); assert.true(this.date.isSame(DEFAULT_DATE)); }); @@ -38,8 +38,8 @@ module("Integration | Component | date-input", function (hooks) { hbs`` ); - fillIn(".date-picker", "2019-02-02"); - triggerEvent(".date-picker", "change"); + await fillIn(".date-picker", "2019-02-02"); + await triggerEvent(".date-picker", "change"); assert.true(this.date.isSame(moment("2019-02-02"))); }); diff --git a/app/assets/javascripts/discourse/tests/integration/components/home-logo-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/home-logo-test.gjs index 5cdecb904e8..7a9f9966a78 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/home-logo-test.gjs +++ b/app/assets/javascripts/discourse/tests/integration/components/home-logo-test.gjs @@ -177,9 +177,7 @@ module("Integration | Component | home-logo", function (hooks) { test("the home logo href url defaults to /", async function (assert) { await render(); - assert - .dom(".home-logo-wrapper-outlet a") - .hasAttribute("href", "/", "home logo href equals /"); + assert.dom(".title a").hasAttribute("href", "/", "home logo href equals /"); }); test("api.registerHomeLogoHrefCallback can be used to change the logo href url", async function (assert) { @@ -190,7 +188,7 @@ module("Integration | Component | home-logo", function (hooks) { await render(); assert - .dom(".home-logo-wrapper-outlet a") + .dom(".title a") .hasAttribute( "href", "https://example.com", diff --git a/app/assets/javascripts/discourse/tests/integration/components/input-size-test.js b/app/assets/javascripts/discourse/tests/integration/components/input-size-test.js index fa85f76287e..c67e9727cd2 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/input-size-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/input-size-test.js @@ -1,4 +1,4 @@ -import { render } from "@ember/test-helpers"; +import { find, render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; @@ -14,13 +14,13 @@ module( ); assert.strictEqual( - document.querySelector(".btn:nth-child(1)").offsetHeight, - document.querySelector(".btn:nth-child(2)").offsetHeight, + find(".btn:nth-child(1)").offsetHeight, + find(".btn:nth-child(2)").offsetHeight, "have equal height" ); assert.strictEqual( - document.querySelector(".btn:nth-child(1)").offsetHeight, - document.querySelector(".btn:nth-child(3)").offsetHeight, + find(".btn:nth-child(1)").offsetHeight, + find(".btn:nth-child(3)").offsetHeight, "have equal height" ); }); @@ -31,8 +31,8 @@ module( ); assert.strictEqual( - document.querySelector("input").offsetHeight, - document.querySelector(".btn").offsetHeight, + find("input").offsetHeight, + find(".btn").offsetHeight, "have equal height" ); }); @@ -43,8 +43,8 @@ module( ); assert.strictEqual( - document.querySelector("input").offsetHeight, - document.querySelector(".combo-box").offsetHeight, + find("input").offsetHeight, + find(".combo-box").offsetHeight, "have equal height" ); });