DEV: add acceptance test for encoded subcategory

follow-up on 63323bd7a8

Add acceptance tests on ember routing to ensure that ember can route
to a sub-category via slug-only.

63323bd7a8
This commit is contained in:
Jeff Wong 2020-05-27 16:57:56 -07:00
parent b10e995d9d
commit ee60488e6a

View File

@ -0,0 +1,56 @@
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");
});