DEV: Use key names in triggerKeyEvent (#17535)

This commit is contained in:
Jarek Radosz 2022-07-17 20:15:28 +02:00 committed by GitHub
parent 5538b8442e
commit c3f7a45821
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 97 additions and 103 deletions

View File

@ -15,8 +15,6 @@ import siteSettingFixture from "discourse/tests/fixtures/site-settings";
import { test } from "qunit";
import pretender from "discourse/tests/helpers/create-pretender";
const ENTER_KEYCODE = 13;
acceptance("Admin - Site Settings", function (needs) {
let updatedTitle;
@ -108,7 +106,7 @@ acceptance("Admin - Site Settings", function (needs) {
);
await fillIn(".input-setting-string", "Test");
await triggerKeyEvent(".input-setting-string", "keydown", ENTER_KEYCODE);
await triggerKeyEvent(".input-setting-string", "keydown", "Enter");
assert.ok(
exists(".row.setting.overridden"),
"saving via Enter key marks setting as overridden"
@ -176,13 +174,13 @@ acceptance("Admin - Site Settings", function (needs) {
await click(".select-kit-header.multi-select-header");
await fillIn(".select-kit-filter input", "cat.?.domain");
await triggerKeyEvent(".select-kit-filter input", "keydown", ENTER_KEYCODE);
await triggerKeyEvent(".select-kit-filter input", "keydown", "Enter");
await fillIn(".select-kit-filter input", "*.domain");
await triggerKeyEvent(".select-kit-filter input", "keydown", ENTER_KEYCODE);
await triggerKeyEvent(".select-kit-filter input", "keydown", "Enter");
await fillIn(".select-kit-filter input", "proper.com");
await triggerKeyEvent(".select-kit-filter input", "keydown", ENTER_KEYCODE);
await triggerKeyEvent(".select-kit-filter input", "keydown", "Enter");
await click("button.ok");

View File

@ -3,8 +3,6 @@ import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { setCaretPosition } from "discourse/lib/utilities";
const BACKSPACE_KEYCODE = 8;
acceptance("Composer - editor mentions", function (needs) {
needs.user();
needs.settings({ enable_mentions: true });
@ -37,15 +35,15 @@ acceptance("Composer - editor mentions", function (needs) {
// Emulate user pressing backspace in the editor
const editor = query(".d-editor-input");
await triggerKeyEvent(".d-editor-input", "keydown", "@".charCodeAt(0));
await triggerKeyEvent(".d-editor-input", "keydown", "@");
await fillIn(".d-editor-input", "abc @");
await setCaretPosition(editor, 5);
await triggerKeyEvent(".d-editor-input", "keyup", "@".charCodeAt(0));
await triggerKeyEvent(".d-editor-input", "keyup", "@");
await triggerKeyEvent(".d-editor-input", "keydown", "u".charCodeAt(0));
await triggerKeyEvent(".d-editor-input", "keydown", "U");
await fillIn(".d-editor-input", "abc @u");
await setCaretPosition(editor, 6);
await triggerKeyEvent(".d-editor-input", "keyup", "u".charCodeAt(0));
await triggerKeyEvent(".d-editor-input", "keyup", "U");
await click(".autocomplete.ac-user .selected");
@ -62,13 +60,13 @@ acceptance("Composer - editor mentions", function (needs) {
await fillIn(".d-editor-input", "abc @user a");
// Emulate user typing `@` and `u` in the editor
await triggerKeyEvent(".d-editor-input", "keydown", BACKSPACE_KEYCODE);
await triggerKeyEvent(".d-editor-input", "keydown", "Backspace");
await fillIn(".d-editor-input", "abc @user ");
await triggerKeyEvent(".d-editor-input", "keyup", BACKSPACE_KEYCODE);
await triggerKeyEvent(".d-editor-input", "keyup", "Backspace");
await triggerKeyEvent(".d-editor-input", "keydown", BACKSPACE_KEYCODE);
await triggerKeyEvent(".d-editor-input", "keydown", "Backspace");
await fillIn(".d-editor-input", "abc @user");
await triggerKeyEvent(".d-editor-input", "keyup", BACKSPACE_KEYCODE);
await triggerKeyEvent(".d-editor-input", "keyup", "Backspace");
await click(".autocomplete.ac-user .selected");
@ -88,14 +86,14 @@ acceptance("Composer - editor mentions", function (needs) {
await fillIn(".d-editor-input", "abc @user 123");
await setCaretPosition(editor, 9);
await triggerKeyEvent(".d-editor-input", "keydown", BACKSPACE_KEYCODE);
await triggerKeyEvent(".d-editor-input", "keydown", "Backspace");
await fillIn(".d-editor-input", "abc @use 123");
await triggerKeyEvent(".d-editor-input", "keyup", BACKSPACE_KEYCODE);
await triggerKeyEvent(".d-editor-input", "keyup", "Backspace");
await setCaretPosition(editor, 8);
await triggerKeyEvent(".d-editor-input", "keydown", BACKSPACE_KEYCODE);
await triggerKeyEvent(".d-editor-input", "keydown", "Backspace");
await fillIn(".d-editor-input", "abc @us 123");
await triggerKeyEvent(".d-editor-input", "keyup", BACKSPACE_KEYCODE);
await triggerKeyEvent(".d-editor-input", "keyup", "Backspace");
await setCaretPosition(editor, 7);
await click(".autocomplete.ac-user .selected");

View File

@ -73,21 +73,21 @@ acceptance("Composer - Hyperlink", function (needs) {
await click(".d-editor button.link");
await fillIn(".modal-body .link-url", "http://google.com");
await triggerKeyEvent(".modal-body .link-url", "keyup", 32);
await triggerKeyEvent(".modal-body .link-url", "keyup", "Space");
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 triggerKeyEvent(".modal-body .link-url", "keyup", 32);
await triggerKeyEvent(".modal-body .link-url", "keyup", "Space");
assert.ok(
exists(".internal-link-results"),
"shows internal links search dropdown when entering keywords"
);
await triggerKeyEvent(".insert-link", "keydown", 40);
await triggerKeyEvent(".insert-link", "keydown", 13);
await triggerKeyEvent(".insert-link", "keydown", "ArrowDown");
await triggerKeyEvent(".insert-link", "keydown", "Enter");
assert.ok(
!exists(".internal-link-results"),

View File

@ -182,8 +182,8 @@ acceptance("Composer - Image Preview", function (needs) {
"correct alt text in input"
);
await triggerKeyEvent(altTextInput, "keypress", "[".charCodeAt(0));
await triggerKeyEvent(altTextInput, "keypress", "]".charCodeAt(0));
await triggerKeyEvent(altTextInput, "keypress", "[");
await triggerKeyEvent(altTextInput, "keypress", "]");
assert.equal(query(altTextInput).value, "zorro", "does not input [ ] keys");
await fillIn(altTextInput, "steak");
@ -298,7 +298,7 @@ acceptance("Composer - Image Preview", function (needs) {
await click(editAltTextButton);
await fillIn(altTextInput, "tomtom");
await triggerKeyEvent(altTextInput, "keypress", 13);
await triggerKeyEvent(altTextInput, "keypress", "Enter");
assert.equal(
query(".d-editor-input").value,
@ -320,7 +320,7 @@ acceptance("Composer - Image Preview", function (needs) {
await click(editAltTextButton);
await fillIn(altTextInput, "");
await triggerKeyEvent(altTextInput, "keypress", 13);
await triggerKeyEvent(altTextInput, "keypress", "Enter");
assert.equal(
query(".d-editor-input").value,
@ -332,7 +332,7 @@ acceptance("Composer - Image Preview", function (needs) {
await click(editAltTextButton);
await fillIn(altTextInput, "tomtom");
await triggerKeyEvent(altTextInput, "keypress", 13);
await triggerKeyEvent(altTextInput, "keypress", "Enter");
assert.equal(
query(".d-editor-input").value,

View File

@ -70,7 +70,7 @@ acceptance("Create Account - User Fields", function (needs) {
test("can submit with enter", async function (assert) {
await visit("/");
await click("header .sign-up-button");
await triggerKeyEvent(".modal-footer .btn-primary", "keydown", 13);
await triggerKeyEvent(".modal-footer .btn-primary", "keydown", "Enter");
assert.strictEqual(
count("#modal-alert:visible"),

View File

@ -62,7 +62,11 @@ acceptance("Do not disturb", function (needs) {
"There are 4 duration choices"
);
await triggerKeyEvent(".do-not-disturb-tile:nth-child(1)", "keydown", 13);
await triggerKeyEvent(
".do-not-disturb-tile:nth-child(1)",
"keydown",
"Enter"
);
assert.ok(
query(".do-not-disturb-modal.hidden"),

View File

@ -50,12 +50,12 @@ acceptance("Emoji", function (needs) {
await click("#topic-footer-buttons .btn.create");
await fillIn(".d-editor-input", ":s");
await triggerKeyEvent(".d-editor-input", "keyup", 40); // ensures a keyup is triggered
await triggerKeyEvent(".d-editor-input", "keyup", "ArrowDown"); // ensures a keyup is triggered
assert.notOk(exists(".autocomplete.ac-emoji"));
await fillIn(".d-editor-input", ":sw");
await triggerKeyEvent(".d-editor-input", "keyup", 40); // ensures a keyup is triggered
await triggerKeyEvent(".d-editor-input", "keyup", "ArrowDown"); // ensures a keyup is triggered
assert.ok(exists(".autocomplete.ac-emoji"));
});

View File

@ -47,7 +47,7 @@ acceptance("Fast Edit", function (needs) {
const textNode = query("#post_1 .cooked p").childNodes[0];
await selectText(textNode, 9);
await triggerKeyEvent(document, "keypress", "e".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "E");
assert.ok(exists("#fast-edit-input"), "fast editor is open");
assert.strictEqual(

View File

@ -33,37 +33,37 @@ acceptance("Keyboard Shortcuts - Anonymous Users", function (needs) {
test("go to first suggested topic", async function (assert) {
await visit("/t/this-is-a-test-topic/9");
await triggerKeyEvent(document, "keypress", "g".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "s".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "G");
await triggerKeyEvent(document, "keypress", "S");
assert.strictEqual(currentURL(), "/t/this-is-a-test-topic/9");
// Suggested topics elements exist.
await visit("/t/internationalization-localization/280");
await triggerKeyEvent(document, "keypress", "g".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "s".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "G");
await triggerKeyEvent(document, "keypress", "S");
assert.strictEqual(currentURL(), "/t/polls-are-still-very-buggy/27331/4");
await visit("/t/1-3-0beta9-no-rate-limit-popups/28830");
await triggerKeyEvent(document, "keypress", "g".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "s".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "G");
await triggerKeyEvent(document, "keypress", "S");
assert.strictEqual(currentURL(), "/t/keyboard-shortcuts-are-awesome/27331");
});
test("j/k navigation moves selection up/down", async function (assert) {
await visit("/t/this-is-a-test-topic/9");
await triggerKeyEvent(document, "keypress", "j".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "J");
assert.ok(
exists(".post-stream .topic-post.selected #post_1"),
"first post is selected"
);
await triggerKeyEvent(document, "keypress", "j".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "J");
assert.ok(
exists(".post-stream .topic-post.selected #post_2"),
"pressing j moves selection to next post"
);
await triggerKeyEvent(document, "keypress", "k".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "K");
assert.ok(
exists(".post-stream .topic-post.selected #post_1"),
"pressing k moves selection to previous post"
@ -115,8 +115,8 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
exists("#dismiss-topics-top"),
"dismiss unread top button is present"
);
await triggerKeyEvent(document, "keypress", "x".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "t".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "X");
await triggerKeyEvent(document, "keypress", "T");
assert.ok(
exists("#dismiss-read-confirm"),
"confirmation modal to dismiss unread is present"
@ -145,8 +145,8 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
exists("#dismiss-topics-top"),
"dismiss unread top button is hidden"
);
await triggerKeyEvent(document, "keypress", "x".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "t".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "X");
await triggerKeyEvent(document, "keypress", "T");
assert.ok(
exists("#dismiss-read-confirm"),
"confirmation modal to dismiss unread is present"
@ -174,8 +174,8 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
document.getElementById("ember-testing-container").scrollTop = 0;
await visit("/new");
assert.ok(exists("#dismiss-new-top"), "dismiss new top button is present");
await triggerKeyEvent(document, "keypress", "x".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "r".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "X");
await triggerKeyEvent(document, "keypress", "R");
assert.strictEqual(resetNewCalled, 1);
// we get rid of all but one topic so the top dismiss button doesn't
@ -191,8 +191,8 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
exists("#dismiss-new-top"),
"dismiss new top button has been hidden"
);
await triggerKeyEvent(document, "keypress", "x".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "r".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "X");
await triggerKeyEvent(document, "keypress", "R");
assert.strictEqual(resetNewCalled, 2);
// restore the original topic list
@ -214,8 +214,8 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
"dismiss new bottom button is present"
);
await triggerKeyEvent(document, "keypress", "x".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "r".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "X");
await triggerKeyEvent(document, "keypress", "R");
assert.strictEqual(resetNewCalled, 1);
});

View File

@ -50,7 +50,7 @@ acceptance("Modal", function (needs) {
await click(".login-button");
assert.strictEqual(count(".d-modal:visible"), 1, "modal should reappear");
await triggerKeyEvent("#main-outlet", "keydown", 27);
await triggerKeyEvent("#main-outlet", "keydown", "Escape");
assert.ok(!exists(".d-modal:visible"), "ESC should close the modal");
// eslint-disable-next-line no-undef
@ -69,7 +69,7 @@ acceptance("Modal", function (needs) {
1,
"modal should not disappear when you click outside"
);
await triggerKeyEvent("#main-outlet", "keyup", 27);
await triggerKeyEvent("#main-outlet", "keyup", "Escape");
assert.strictEqual(
count(".d-modal:visible"),
1,
@ -142,7 +142,7 @@ acceptance("Modal Keyboard Events", function (needs) {
await visit("/t/internationalization-localization/280");
await click(".toggle-admin-menu");
await click(".admin-topic-timer-update button");
await triggerKeyEvent(".d-modal", "keydown", 13);
await triggerKeyEvent(".d-modal", "keydown", "Enter");
assert.strictEqual(
count("#modal-alert:visible"),
@ -157,13 +157,13 @@ acceptance("Modal Keyboard Events", function (needs) {
assert.ok(exists(".d-modal:visible"), "modal should be visible");
await triggerKeyEvent("#main-outlet", "keydown", 27);
await triggerKeyEvent("#main-outlet", "keydown", "Escape");
assert.ok(!exists(".d-modal:visible"), "ESC should close the modal");
await click(".topic-body button.reply");
await click(".d-editor-button-bar .btn.link");
await triggerKeyEvent(".d-modal", "keydown", 13);
await triggerKeyEvent(".d-modal", "keydown", "Enter");
assert.ok(
!exists(".d-modal:visible"),

View File

@ -11,13 +11,6 @@ import selectKit from "discourse/tests/helpers/select-kit-helper";
import { skip, test } from "qunit";
import { DEFAULT_TYPE_FILTER } from "discourse/widgets/search-menu";
const keyEnter = 13;
const keyArrowDown = 40;
const keyArrowUp = 38;
const keyEsc = 27;
const keyA = 65;
const keyBackSpace = 8;
acceptance("Search - Anonymous", function (needs) {
needs.pretender((server, helper) => {
server.get("/search/query", (request) => {
@ -88,7 +81,7 @@ acceptance("Search - Anonymous", function (needs) {
"shows matching user results"
);
await triggerKeyEvent(".search-menu", "keydown", keyArrowDown);
await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");
await click(document.activeElement);
assert.ok(
@ -203,7 +196,7 @@ acceptance("Search - Anonymous", function (needs) {
await fillIn("#search-term", "a proper");
await query("input#search-term").focus();
await triggerKeyEvent(".search-menu", "keydown", keyArrowDown);
await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");
await click(document.activeElement);
assert.ok(
@ -233,7 +226,7 @@ acceptance("Search - Anonymous", function (needs) {
await fillIn("#search-term", "dev");
await query("input#search-term").focus();
await triggerKeyEvent(".search-menu", "keydown", keyArrowDown);
await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");
await click(document.activeElement);
assert.ok(
@ -243,7 +236,7 @@ acceptance("Search - Anonymous", function (needs) {
await fillIn("#search-term", "");
await query("input#search-term").focus();
await triggerKeyEvent("input#search-term", "keydown", keyBackSpace);
await triggerKeyEvent("input#search-term", "keydown", "Backspace");
assert.ok(
!exists(".search-menu .search-context"),
@ -267,7 +260,7 @@ acceptance("Search - Anonymous", function (needs) {
await fillIn("#search-term", "proper");
await query("input#search-term").focus();
await triggerKeyEvent(".search-menu", "keydown", keyArrowDown);
await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");
await click(document.activeElement);
assert.ok(
@ -402,7 +395,7 @@ acceptance("Search - Authenticated", function (needs) {
await click("#search-button");
await fillIn("#search-term", "plans");
await query("input#search-term").focus();
await triggerKeyEvent(".search-menu", "keydown", keyArrowDown);
await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");
await click(document.activeElement);
assert.notStrictEqual(count(".search-menu .results .item"), 0);
@ -423,13 +416,13 @@ acceptance("Search - Authenticated", function (needs) {
assert.ok(exists(query(`${container} ul li`)), "has a list of items");
await triggerKeyEvent("#search-term", "keydown", keyEnter);
await triggerKeyEvent("#search-term", "keydown", "Enter");
assert.ok(
exists(query(`${container} .search-result-topic`)),
"has topic results"
);
await triggerKeyEvent("#search-term", "keydown", keyArrowDown);
await triggerKeyEvent("#search-term", "keydown", "ArrowDown");
assert.strictEqual(
document.activeElement.getAttribute("href"),
@ -437,7 +430,7 @@ acceptance("Search - Authenticated", function (needs) {
"arrow down selects first element"
);
await triggerKeyEvent("#search-term", "keydown", keyArrowDown);
await triggerKeyEvent("#search-term", "keydown", "ArrowDown");
assert.strictEqual(
document.activeElement.getAttribute("href"),
@ -445,10 +438,10 @@ acceptance("Search - Authenticated", function (needs) {
"arrow down selects next element"
);
await triggerKeyEvent("#search-term", "keydown", keyArrowDown);
await triggerKeyEvent("#search-term", "keydown", keyArrowDown);
await triggerKeyEvent("#search-term", "keydown", keyArrowDown);
await triggerKeyEvent("#search-term", "keydown", keyArrowDown);
await triggerKeyEvent("#search-term", "keydown", "ArrowDown");
await triggerKeyEvent("#search-term", "keydown", "ArrowDown");
await triggerKeyEvent("#search-term", "keydown", "ArrowDown");
await triggerKeyEvent("#search-term", "keydown", "ArrowDown");
assert.strictEqual(
document.activeElement.getAttribute("href"),
@ -456,12 +449,12 @@ acceptance("Search - Authenticated", function (needs) {
"arrow down sets focus to more results link"
);
await triggerKeyEvent(".search-menu", "keydown", keyEsc);
await triggerKeyEvent(".search-menu", "keydown", "Escape");
assert.ok(!exists(".search-menu:visible"), "Esc removes search dropdown");
await click("#search-button");
await triggerKeyEvent(".search-menu", "keydown", keyArrowDown);
await triggerKeyEvent(".search-menu", "keydown", keyArrowUp);
await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");
await triggerKeyEvent(".search-menu", "keydown", "ArrowUp");
assert.strictEqual(
document.activeElement.tagName.toLowerCase(),
@ -469,15 +462,15 @@ acceptance("Search - Authenticated", function (needs) {
"arrow up sets focus to search term input"
);
await triggerKeyEvent(".search-menu", "keydown", keyEsc);
await triggerKeyEvent(".search-menu", "keydown", "Escape");
await click("#create-topic");
await click("#search-button");
await triggerKeyEvent(".search-menu", "keydown", keyArrowDown);
await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");
const firstLink = query(`${container} li:nth-child(1) a`).getAttribute(
"href"
);
await triggerKeyEvent(".search-menu", "keydown", keyA);
await triggerKeyEvent(".search-menu", "keydown", "A");
assert.strictEqual(
query("#reply-control textarea").value,
@ -486,14 +479,14 @@ acceptance("Search - Authenticated", function (needs) {
);
await click("#search-button");
await triggerKeyEvent("#search-term", "keydown", keyEnter);
await triggerKeyEvent("#search-term", "keydown", "Enter");
assert.ok(
exists(query(`${container} .search-result-topic`)),
"has topic results"
);
await triggerKeyEvent("#search-term", "keydown", keyEnter);
await triggerKeyEvent("#search-term", "keydown", "Enter");
assert.ok(
exists(query(`.search-container`)),
@ -507,7 +500,7 @@ acceptance("Search - Authenticated", function (needs) {
// new search launched, Enter key should be reset
await click("#search-button");
assert.ok(exists(query(`${container} ul li`)), "has a list of items");
await triggerKeyEvent("#search-term", "keydown", keyEnter);
await triggerKeyEvent("#search-term", "keydown", "Enter");
assert.ok(exists(query(`.search-menu`)), "search dropdown is visible");
});
@ -819,7 +812,7 @@ acceptance("Search - assistant", function (needs) {
await fillIn("#search-term", "");
await query("input#search-term").focus();
await triggerKeyEvent("input#search-term", "keydown", keyBackSpace);
await triggerKeyEvent("input#search-term", "keydown", "Backspace");
assert.notOk(exists(".btn.search-context"), "it removes the button");
@ -832,7 +825,7 @@ acceptance("Search - assistant", function (needs) {
await fillIn("#search-term", "emoji");
await query("input#search-term").focus();
await triggerKeyEvent("#search-term", "keydown", keyEnter);
await triggerKeyEvent("#search-term", "keydown", "Enter");
assert.strictEqual(
count(".search-menu .search-result-topic"),

View File

@ -2,11 +2,11 @@ import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { click, triggerKeyEvent, visit } from "@ember/test-helpers";
import { test } from "qunit";
const ESC_KEYCODE = 27;
acceptance("Topic Entrance Modal", function () {
test("can be closed with the esc key", async function (assert) {
await visit("/");
await click(".topic-list-item button.posts-map");
const topicEntrance = query("#topic-entrance");
assert.ok(
!topicEntrance.classList.contains("hidden"),
@ -17,7 +17,8 @@ acceptance("Topic Entrance Modal", function () {
topicEntrance.querySelector(".jump-top"),
"the jump top button has focus when the modal is shown"
);
await triggerKeyEvent(topicEntrance, "keydown", ESC_KEYCODE);
await triggerKeyEvent(topicEntrance, "keydown", "Escape");
assert.ok(
topicEntrance.classList.contains("hidden"),
"topic entrance modal disappears after pressing esc"

View File

@ -132,7 +132,7 @@ acceptance("Topic - Quote button - keyboard shortcut", function (needs) {
test("Can use keyboard shortcut to quote selected text", async function (assert) {
await visit("/t/internationalization-localization/280");
await selectText("#post_1 .cooked");
await triggerKeyEvent(document, "keypress", "q".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "Q");
assert.ok(exists(".d-editor-input"), "the editor is open");
assert.ok(

View File

@ -427,8 +427,8 @@ acceptance("Topic featured links", function (needs) {
async function (assert) {
await visit("/t/internationalization-localization/280");
await selectText("#post_5 blockquote");
await triggerKeyEvent(document, "keypress", "j".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "t".charCodeAt(0));
await triggerKeyEvent(document, "keypress", "J");
await triggerKeyEvent(document, "keypress", "T");
assert.ok(
query(".d-editor-input").value.includes(

View File

@ -59,7 +59,7 @@ acceptance("User Directory", function () {
const secondHeading =
".users-directory table th:nth-child(2) .header-contents";
await triggerKeyEvent(secondHeading, "keypress", 13);
await triggerKeyEvent(secondHeading, "keypress", "Enter");
assert.ok(
query(`${secondHeading} .d-icon-chevron-up`),

View File

@ -220,10 +220,10 @@ module("Integration | Component | d-button", function (hooks) {
hbs`<DButton @action={{this.action}} @onKeyDown={{this.onKeyDown}} />`
);
await triggerKeyEvent(".btn", "keydown", 32);
await triggerKeyEvent(".btn", "keydown", "Space");
assert.strictEqual(this.foo, "bar");
await triggerKeyEvent(".btn", "keydown", 13);
await triggerKeyEvent(".btn", "keydown", "Enter");
assert.strictEqual(this.foo, "bar");
});
@ -235,10 +235,10 @@ module("Integration | Component | d-button", function (hooks) {
await render(hbs`<DButton @action={{this.action}} />`);
await triggerKeyEvent(".btn", "keydown", 32);
await triggerKeyEvent(".btn", "keydown", "Space");
assert.strictEqual(this.foo, null);
await triggerKeyEvent(".btn", "keydown", 13);
await triggerKeyEvent(".btn", "keydown", "Enter");
assert.strictEqual(this.foo, "bar");
});
});

View File

@ -96,7 +96,7 @@ module("Integration | Component | d-popover", function (hooks) {
await click(".btn");
assert.ok(exists(".d-popover.is-expanded"));
await triggerKeyEvent(document, "keydown", 27);
await triggerKeyEvent(document, "keydown", "Escape");
assert.notOk(exists(".d-popover.is-expanded"));
});
});

View File

@ -14,10 +14,10 @@ module("Integration | Component | flat-button", function (hooks) {
await render(hbs`<FlatButton @action={{this.action}} />`);
await triggerKeyEvent(".btn-flat", "keydown", 32);
await triggerKeyEvent(".btn-flat", "keydown", "Space");
assert.strictEqual(this.foo, null);
await triggerKeyEvent(".btn-flat", "keydown", 13);
await triggerKeyEvent(".btn-flat", "keydown", "Enter");
assert.strictEqual(this.foo, "bar");
});

View File

@ -39,7 +39,7 @@ module("Integration | Component | simple-list", function (hooks) {
);
await fillIn(".add-value-input", "eviltrout");
await triggerKeyEvent(".add-value-input", "keydown", 13); // enter
await triggerKeyEvent(".add-value-input", "keydown", "Enter");
assert.strictEqual(
count(".values .value"),