2019-02-06 16:43:07 -05:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
2020-03-02 14:24:31 -05:00
|
|
|
import pretender from "helpers/create-pretender";
|
2019-02-06 16:43:07 -05:00
|
|
|
|
|
|
|
acceptance("Keyboard Shortcuts", { loggedIn: true });
|
|
|
|
|
|
|
|
test("go to first suggested topic", async (assert) => {
|
2020-03-02 14:24:31 -05:00
|
|
|
pretender.get("/t/27331/4.json", () => [
|
2019-02-06 16:43:07 -05:00
|
|
|
200,
|
|
|
|
{ "Content-Type": "application/json" },
|
|
|
|
{},
|
|
|
|
]);
|
|
|
|
|
2020-03-02 14:24:31 -05:00
|
|
|
pretender.get("/t/27331.json", () => [
|
2019-02-06 16:43:07 -05:00
|
|
|
200,
|
|
|
|
{ "Content-Type": "application/json" },
|
|
|
|
{},
|
|
|
|
]);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* No suggested topics exist.
|
|
|
|
*/
|
|
|
|
|
2020-03-02 14:24:31 -05:00
|
|
|
pretender.get("/t/9/last.json", () => [
|
2019-02-06 16:43:07 -05:00
|
|
|
200,
|
|
|
|
{ "Content-Type": "application/json" },
|
|
|
|
{},
|
|
|
|
]);
|
|
|
|
|
|
|
|
await visit("/t/this-is-a-test-topic/9");
|
|
|
|
await keyEvent(document, "keypress", "g".charCodeAt(0));
|
|
|
|
await keyEvent(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));
|
|
|
|
assert.equal(currentURL(), "/t/polls-are-still-very-buggy/27331/4");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Suggested topic is returned by server.
|
|
|
|
*/
|
|
|
|
|
2020-03-02 14:24:31 -05:00
|
|
|
pretender.get("/t/28830/last.json", () => [
|
2019-02-06 16:43:07 -05:00
|
|
|
200,
|
|
|
|
{ "Content-Type": "application/json" },
|
|
|
|
{
|
|
|
|
suggested_topics: [
|
|
|
|
{
|
|
|
|
id: 27331,
|
|
|
|
slug: "keyboard-shortcuts-are-awesome",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
|
|
|
|
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));
|
|
|
|
assert.equal(currentURL(), "/t/keyboard-shortcuts-are-awesome/27331");
|
|
|
|
});
|