mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 00:37:06 +08:00
FIX: In newer embers, it's triggerKeyEvent
not keyEvent
This commit is contained in:
parent
504aaad838
commit
410214e5a9
|
@ -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); // enter
|
||||
assert.ok(
|
||||
exists(".row.setting.overridden"),
|
||||
"saving via Enter key marks setting as overriden"
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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); // enter
|
||||
|
||||
assert.ok(
|
||||
queryAll(".values .value").length === 4,
|
||||
|
|
|
@ -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", () => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user