A platform for community discussion. Free, open, simple.
FIX: In newer embers, it's `triggerKeyEvent` not `keyEvent`
Robin Ward410214e5a9ba
diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.jsindex 7481b03f0e4..8c026a84242 100644--- a/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js@@ -3,7 +3,7 @@ import { exists } from "discourse/tests/helpers/qunit-helpers";import {fillIn,click,- keyEvent,+ triggerKeyEvent,visit,currentURL,} from "@ember/test-helpers";@@ -98,7 +98,7 @@ acceptance("Admin - Site Settings", function (needs) {);await fillIn(".input-setting-string", "Test");- await keyEvent(".input-setting-string", "keydown", 13); // enter+ await triggerKeyEvent(".input-setting-string", "keydown", 13); // enterassert.ok(exists(".row.setting.overridden"),"saving via Enter key marks setting as overriden"diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.jsindex 76618865d98..2878445b8a7 100644--- a/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js@@ -1,6 +1,6 @@import { queryAll } from "discourse/tests/helpers/qunit-helpers";import { exists } from "discourse/tests/helpers/qunit-helpers";-import { click, fillIn, keyEvent, visit } from "@ember/test-helpers";+import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";import { test } from "qunit";import { acceptance } from "discourse/tests/helpers/qunit-helpers";@@ -71,21 +71,21 @@ acceptance("Composer - Hyperlink", function (needs) {await click(".d-editor button.link");await fillIn(".modal-body .link-url", "http://google.com");- await keyEvent(".modal-body .link-url", "keyup", 32);+ await triggerKeyEvent(".modal-body .link-url", "keyup", 32);assert.ok(!exists(".internal-link-results"),"does not show internal links search dropdown when inputting a url");await fillIn(".modal-body .link-url", "local");- await keyEvent(".modal-body .link-url", "keyup", 32);+ await triggerKeyEvent(".modal-body .link-url", "keyup", 32);assert.ok(exists(".internal-link-results"),"shows internal links search dropdown when entering keywords");- await keyEvent(".insert-link", "keydown", 40);- await keyEvent(".insert-link", "keydown", 13);+ await triggerKeyEvent(".insert-link", "keydown", 40);+ await triggerKeyEvent(".insert-link", "keydown", 13);assert.ok(!exists(".internal-link-results"),diff --git a/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js b/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.jsindex a855d3e08e9..f9bdf7bd582 100644--- a/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js@@ -1,4 +1,4 @@-import { keyEvent, visit, currentURL } from "@ember/test-helpers";+import { triggerKeyEvent, visit, currentURL } from "@ember/test-helpers";import { test } from "qunit";import { acceptance } from "discourse/tests/helpers/qunit-helpers";@@ -25,19 +25,19 @@ acceptance("Keyboard Shortcuts", function (needs) {test("go to first suggested topic", async function (assert) {await visit("/t/this-is-a-test-topic/9");- await keyEvent(document, "keypress", "g".charCodeAt(0));- await keyEvent(document, "keypress", "s".charCodeAt(0));+ await triggerKeyEvent(document, "keypress", "g".charCodeAt(0));+ await triggerKeyEvent(document, "keypress", "s".charCodeAt(0));assert.equal(currentURL(), "/t/this-is-a-test-topic/9");// Suggested topics elements exist.await visit("/t/internationalization-localization/280");- await keyEvent(document, "keypress", "g".charCodeAt(0));- await keyEvent(document, "keypress", "s".charCodeAt(0));+ await triggerKeyEvent(document, "keypress", "g".charCodeAt(0));+ await triggerKeyEvent(document, "keypress", "s".charCodeAt(0));assert.equal(currentURL(), "/t/polls-are-still-very-buggy/27331/4");await visit("/t/1-3-0beta9-no-rate-limit-popups/28830");- await keyEvent(document, "keypress", "g".charCodeAt(0));- await keyEvent(document, "keypress", "s".charCodeAt(0));+ await triggerKeyEvent(document, "keypress", "g".charCodeAt(0));+ await triggerKeyEvent(document, "keypress", "s".charCodeAt(0));assert.equal(currentURL(), "/t/keyboard-shortcuts-are-awesome/27331");});});diff --git a/app/assets/javascripts/discourse/tests/acceptance/modal-test.js b/app/assets/javascripts/discourse/tests/acceptance/modal-test.jsindex 71bb2720680..2ddea16a25b 100644--- a/app/assets/javascripts/discourse/tests/acceptance/modal-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/modal-test.js@@ -1,5 +1,5 @@import { queryAll } from "discourse/tests/helpers/qunit-helpers";-import { click, keyEvent, visit } from "@ember/test-helpers";+import { click, triggerKeyEvent, visit } from "@ember/test-helpers";import { skip, test } from "qunit";import I18n from "I18n";import { run } from "@ember/runloop";@@ -54,7 +54,7 @@ acceptance("Modal", function (needs) {"modal should reappear");- await keyEvent("#main-outlet", "keyup", 27);+ await triggerKeyEvent("#main-outlet", "keyup", 27);assert.ok(queryAll(".d-modal:visible").length === 0,"ESC should close the modal"@@ -73,7 +73,7 @@ acceptance("Modal", function (needs) {queryAll(".d-modal:visible").length === 1,"modal should not disappear when you click outside");- await keyEvent("#main-outlet", "keyup", 27);+ await triggerKeyEvent("#main-outlet", "keyup", 27);assert.ok(queryAll(".d-modal:visible").length === 1,"ESC should not close the modal"@@ -139,7 +139,7 @@ acceptance("Modal Keyboard Events", function (needs) {await click(".toggle-admin-menu");await click(".topic-admin-status-update button");- await keyEvent(".d-modal", "keyup", 13);+ await triggerKeyEvent(".d-modal", "keyup", 13);assert.ok(queryAll("#modal-alert:visible").length === 1,@@ -150,7 +150,7 @@ acceptance("Modal Keyboard Events", function (needs) {"hitting Enter does not dismiss modal due to alert error");- await keyEvent("#main-outlet", "keyup", 27);+ await triggerKeyEvent("#main-outlet", "keyup", 27);assert.ok(queryAll(".d-modal:visible").length === 0,"ESC should close the modal"@@ -160,7 +160,7 @@ acceptance("Modal Keyboard Events", function (needs) {await click(".d-editor-button-bar .btn.link");- await keyEvent(".d-modal", "keyup", 13);+ await triggerKeyEvent(".d-modal", "keyup", 13);assert.ok(queryAll(".d-modal:visible").length === 0,"modal should disappear on hitting Enter"diff --git a/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.jsindex ac3fb3320e2..ba4bc64e521 100644--- a/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js@@ -1,4 +1,4 @@-import { keyEvent, visit } from "@ember/test-helpers";+import { triggerKeyEvent, visit } from "@ember/test-helpers";import { test } from "qunit";import { acceptance } from "discourse/tests/helpers/qunit-helpers";import { withPluginApi } from "discourse/lib/plugin-api";@@ -21,7 +21,7 @@ acceptance("Plugin Keyboard Shortcuts - Logged In", function (needs) {});await visit("/t/this-is-a-test-topic/9");- await keyEvent(document, "keypress", "]".charCodeAt(0));+ await triggerKeyEvent(document, "keypress", "]".charCodeAt(0));assert.equal($("#added-element").length,1,diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.jsindex ba29fc060be..d0af70768e2 100644--- a/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js@@ -1,6 +1,6 @@import { queryAll } from "discourse/tests/helpers/qunit-helpers";import { exists } from "discourse/tests/helpers/qunit-helpers";-import { keyEvent, visit, fillIn, click } from "@ember/test-helpers";+import { triggerKeyEvent, visit, fillIn, click } from "@ember/test-helpers";import { skip, test } from "qunit";import selectKit from "discourse/tests/helpers/select-kit-helper";import {@@ -128,7 +128,11 @@ acceptance("Search - Full Page", function (needs) {await fillIn(".search-query", "none");await fillIn(".search-advanced-options .user-selector", "admin");await click(".search-advanced-options .user-selector");- await keyEvent(".search-advanced-options .user-selector", "keydown", 8);+ await triggerKeyEvent(+ ".search-advanced-options .user-selector",+ "keydown",+ 8+ );waitFor(assert, async () => {assert.ok(diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-test.jsindex cab201b2e34..d9f72c0a2ea 100644--- a/app/assets/javascripts/discourse/tests/acceptance/search-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/search-test.js@@ -1,6 +1,6 @@import { queryAll } from "discourse/tests/helpers/qunit-helpers";import { exists } from "discourse/tests/helpers/qunit-helpers";-import { click, keyEvent, fillIn, visit } from "@ember/test-helpers";+import { click, triggerKeyEvent, fillIn, visit } from "@ember/test-helpers";import { test } from "qunit";import selectKit from "discourse/tests/helpers/select-kit-helper";import { acceptance } from "discourse/tests/helpers/qunit-helpers";@@ -28,7 +28,7 @@ acceptance("Search - Anonymous", function (needs) {assert.ok(!exists(".search-menu .results ul li"), "no results by default");await fillIn("#search-term", "dev");- await keyEvent("#search-term", "keyup", 16);+ await triggerKeyEvent("#search-term", "keyup", 16);assert.ok(exists(".search-menu .results ul li"), "it shows results");assert.ok(exists(".search-menu .results ul li .topic-title[data-topic-id]"),@@ -54,7 +54,7 @@ acceptance("Search - Anonymous", function (needs) {await click("#search-button");await fillIn("#search-term", "evil");- await keyEvent("#search-term", "keyup", 16);+ await triggerKeyEvent("#search-term", "keyup", 16);assert.ok(exists(".search-menu .results ul li"), "it shows results");});@@ -97,7 +97,7 @@ acceptance("Search - Anonymous", function (needs) {await click("#search-button");await fillIn("#search-term", "a proper");await click(".search-context input[type='checkbox']");- await keyEvent("#search-term", "keyup", 16);+ await triggerKeyEvent("#search-term", "keyup", 16);assert.ok(exists(".search-menu .results ul li"), "it shows results");@@ -187,7 +187,7 @@ acceptance("Search - with tagging enabled", function (needs) {await click("#search-button");await fillIn("#search-term", "dev");- await keyEvent("#search-term", "keyup", 16);+ await triggerKeyEvent("#search-term", "keyup", 16);const tags = queryAll(".search-menu .results ul li:eq(0) .discourse-tags").text()diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-test.jsindex 3a109cdd6a2..7b8b35ff781 100644--- a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js@@ -1,6 +1,6 @@import { queryAll } from "discourse/tests/helpers/qunit-helpers";import { exists } from "discourse/tests/helpers/qunit-helpers";-import { click, keyEvent, fillIn, visit } from "@ember/test-helpers";+import { click, triggerKeyEvent, fillIn, visit } from "@ember/test-helpers";import { test } from "qunit";import I18n from "I18n";import { withPluginApi } from "discourse/lib/plugin-api";@@ -394,8 +394,8 @@ acceptance("Topic featured links", function (needs) {test("Quoting a quote with replyAsNewTopic keeps the original poster name", async function (assert) {await visit("/t/internationalization-localization/280");selectText("#post_5 blockquote");- await keyEvent(document, "keypress", "j".charCodeAt(0));- await keyEvent(document, "keypress", "t".charCodeAt(0));+ await triggerKeyEvent(document, "keypress", "j".charCodeAt(0));+ await triggerKeyEvent(document, "keypress", "t".charCodeAt(0));assert.ok(queryAll(".d-editor-input")diff --git a/app/assets/javascripts/discourse/tests/integration/components/simple-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/simple-list-test.jsindex bbbaa39a3f9..75ccc2e1223 100644--- a/app/assets/javascripts/discourse/tests/integration/components/simple-list-test.js+++ b/app/assets/javascripts/discourse/tests/integration/components/simple-list-test.js@@ -1,7 +1,7 @@import { queryAll } from "discourse/tests/helpers/qunit-helpers";import { moduleForComponent } from "ember-qunit";import componentTest from "discourse/tests/helpers/component-test";-import { click, keyEvent, fillIn } from "@ember/test-helpers";+import { click, triggerKeyEvent, fillIn } from "@ember/test-helpers";moduleForComponent("simple-list", { integration: true });@@ -33,7 +33,7 @@ componentTest("adding a value", {);await fillIn(".add-value-input", "eviltrout");- await keyEvent(".add-value-input", "keydown", 13); // enter+ await triggerKeyEvent(".add-value-input", "keydown", 13); // enterassert.ok(queryAll(".values .value").length === 4,diff --git a/app/assets/javascripts/test-shims.js b/app/assets/javascripts/test-shims.jsindex 1cb229415c0..31b717adcaa 100644--- a/app/assets/javascripts/test-shims.js+++ b/app/assets/javascripts/test-shims.js@@ -37,12 +37,12 @@ define("@ember/test-helpers", () => {"currentRouteName","fillIn","setResolver",- "keyEvent",].forEach((attr) => {helpers[attr] = function () {return window[attr](...arguments);};});+ helpers.triggerKeyEvent = window.keyEvent;return helpers;});define("pretender", () => {