This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/acceptance/topic-entrance-test.js
2022-07-17 20:15:28 +02:00

28 lines
900 B
JavaScript

import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { click, triggerKeyEvent, visit } from "@ember/test-helpers";
import { test } from "qunit";
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"),
"topic entrance modal appears"
);
assert.equal(
document.activeElement,
topicEntrance.querySelector(".jump-top"),
"the jump top button has focus when the modal is shown"
);
await triggerKeyEvent(topicEntrance, "keydown", "Escape");
assert.ok(
topicEntrance.classList.contains("hidden"),
"topic entrance modal disappears after pressing esc"
);
});
});