mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Check for permalinks before showing the 404 page
Limitations: the user profile "open external links in new tab setting" is slightly broken for "External URL" permalinks. Remove the copy from the admin permalinks page stating that this doesn't work.
This commit is contained in:
@@ -1,8 +1,49 @@
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
import pretender from "helpers/create-pretender";
|
||||
acceptance("Unknown");
|
||||
|
||||
QUnit.test("Unknown URL", async assert => {
|
||||
assert.expect(1);
|
||||
QUnit.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");
|
||||
});
|
||||
|
||||
QUnit.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"));
|
||||
});
|
||||
|
||||
QUnit.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"));
|
||||
});
|
||||
|
||||
@@ -267,12 +267,11 @@ export function applyDefaultHandlers(pretender) {
|
||||
pretender.put("/t/:id/recover", success);
|
||||
pretender.put("/t/:id/publish", success);
|
||||
|
||||
pretender.get("/404-body", () => {
|
||||
return [
|
||||
200,
|
||||
{ "Content-Type": "text/html" },
|
||||
"<div class='page-not-found'>not found</div>"
|
||||
];
|
||||
pretender.get("/permalink-check.json", () => {
|
||||
return response({
|
||||
found: false,
|
||||
html: "<div class='page-not-found'>not found</div>"
|
||||
});
|
||||
});
|
||||
|
||||
pretender.delete("/draft.json", success);
|
||||
|
||||
Reference in New Issue
Block a user