mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 21:43:38 +08:00
ee60488e6a
follow-up on63323bd7a8
Add acceptance tests on ember routing to ensure that ember can route to a sub-category via slug-only.63323bd7a8
57 lines
1.8 KiB
JavaScript
57 lines
1.8 KiB
JavaScript
import { acceptance } from "helpers/qunit-helpers";
|
|
import DiscoveryFixtures from "fixtures/discovery_fixtures";
|
|
|
|
acceptance("Encoded Sub Category Discovery", {
|
|
pretend(server, helper) {
|
|
server.get(
|
|
"/c/%E6%BC%A2%E5%AD%97-parent/%E6%BC%A2%E5%AD%97-subcategory/6/l/latest.json",
|
|
() => {
|
|
return helper.response(
|
|
DiscoveryFixtures["/latest_can_create_topic.json"]
|
|
);
|
|
}
|
|
);
|
|
server.get(
|
|
"/c/%E6%BC%A2%E5%AD%97-parent/%E6%BC%A2%E5%AD%97-subcategory/find_by_slug.json",
|
|
() => {
|
|
//respond with an error here: these tests are to check that ember can route this itself without falling back to rails
|
|
return helper.response(500, {});
|
|
}
|
|
);
|
|
},
|
|
settings: {
|
|
slug_generation_method: "encoded"
|
|
},
|
|
site: {
|
|
categories: [
|
|
{
|
|
id: 5,
|
|
name: "漢字-parent",
|
|
slug: "%E6%BC%A2%E5%AD%97-parent",
|
|
permission: null
|
|
},
|
|
{
|
|
id: 6,
|
|
name: "漢字-subcategory",
|
|
slug: "%E6%BC%A2%E5%AD%97-subcategory",
|
|
permission: null,
|
|
parent_category_id: 5
|
|
}
|
|
]
|
|
}
|
|
});
|
|
|
|
QUnit.test("Visit subcategory by slug", async assert => {
|
|
let bodySelector =
|
|
"body.category-\\%E6\\%BC\\%A2\\%E5\\%AD\\%97-parent-\\%E6\\%BC\\%A2\\%E5\\%AD\\%97-subcategory";
|
|
await visit("/c/%E6%BC%A2%E5%AD%97-parent/%E6%BC%A2%E5%AD%97-subcategory");
|
|
assert.ok($(bodySelector).length, "has the default navigation");
|
|
assert.ok(exists(".topic-list"), "The list of topics was rendered");
|
|
assert.ok(exists(".topic-list .topic-list-item"), "has topics");
|
|
|
|
await visit("/c/漢字-parent/漢字-subcategory");
|
|
assert.ok($(bodySelector).length, "has the default navigation");
|
|
assert.ok(exists(".topic-list"), "The list of topics was rendered");
|
|
assert.ok(exists(".topic-list .topic-list-item"), "has topics");
|
|
});
|