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/unknown-test.js
Robin Ward 71d37953d5 REFACTOR: Import QUnit and related helpers rather than globals
We used many global functions to handle tests when they should be
imported like other libraries in our application. This also gets us
closer to the way Ember CLI prefers our tests to be laid out.
2020-10-07 11:50:49 -04:00

51 lines
1.3 KiB
JavaScript

import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import pretender from "discourse/tests/helpers/create-pretender";
acceptance("Unknown");
test("Permalink Unknown URL", async (assert) => {
await visit("/url-that-doesn't-exist");
assert.ok(exists(".page-not-found"), "The not found content is present");
});
test("Permalink URL to a Topic", async (assert) => {
pretender.get("/permalink-check.json", () => {
return [
200,
{ "Content-Type": "application/json" },
{
found: true,
internal: true,
target_url: "/t/internationalization-localization/280",
},
];
});
await visit("/viewtopic.php?f=8&t=280");
assert.ok(exists(".topic-post"));
});
test("Permalink URL to a static page", async (assert) => {
pretender.get("/permalink-check.json", () => {
return [
200,
{ "Content-Type": "application/json" },
{
found: true,
internal: true,
target_url: "/faq",
},
];
});
await visit("/not-the-url-for-faq");
// body is outside of #ember-testing-container and needs to be targeted
// through document instead of find
assert.ok(
document.querySelector("body.static-faq"),
"routed to the faq page"
);
assert.ok(exists(".body-page"));
});