2019-06-06 16:47:10 +08:00
|
|
|
import selectKit from "helpers/select-kit-helper";
|
2018-06-15 23:03:24 +08:00
|
|
|
import DiscourseURL from "discourse/lib/url";
|
2015-05-15 23:03:27 +08:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
|
2016-07-28 23:57:30 +08:00
|
|
|
acceptance("Category Edit", {
|
|
|
|
loggedIn: true,
|
2019-03-22 13:10:20 +08:00
|
|
|
settings: { email_in: true }
|
2016-07-28 23:57:30 +08:00
|
|
|
});
|
2015-05-15 23:03:27 +08:00
|
|
|
|
2018-07-19 17:40:42 +08:00
|
|
|
QUnit.test("Can open the category modal", async assert => {
|
|
|
|
await visit("/c/bug");
|
|
|
|
|
|
|
|
await click(".edit-category");
|
|
|
|
assert.ok(visible(".d-modal"), "it pops up a modal");
|
|
|
|
|
2019-10-29 05:23:21 +08:00
|
|
|
await click("button.modal-close");
|
2018-07-19 17:40:42 +08:00
|
|
|
assert.ok(!visible(".d-modal"), "it closes the modal");
|
2015-05-15 23:03:27 +08:00
|
|
|
});
|
2015-07-03 00:06:24 +08:00
|
|
|
|
2019-03-18 15:25:45 +08:00
|
|
|
QUnit.test("Editing the category", async assert => {
|
2018-07-19 17:40:42 +08:00
|
|
|
await visit("/c/bug");
|
2019-03-22 13:10:20 +08:00
|
|
|
|
2018-07-19 17:40:42 +08:00
|
|
|
await click(".edit-category");
|
2020-05-11 23:05:40 +08:00
|
|
|
|
|
|
|
assert.equal(find(".d-modal .badge-category").text(), "bug");
|
|
|
|
await fillIn("input.category-name", "testing");
|
|
|
|
assert.equal(find(".d-modal .badge-category").text(), "testing");
|
|
|
|
|
2019-03-22 13:10:20 +08:00
|
|
|
await fillIn("#edit-text-color", "#ff0000");
|
|
|
|
|
|
|
|
await click(".edit-category-topic-template");
|
|
|
|
await fillIn(".d-editor-input", "this is the new topic template");
|
2019-03-18 15:25:45 +08:00
|
|
|
|
2019-03-22 13:10:20 +08:00
|
|
|
await click(".edit-category-settings");
|
2019-03-18 15:25:45 +08:00
|
|
|
const searchPriorityChooser = selectKit("#category-search-priority");
|
|
|
|
await searchPriorityChooser.expand();
|
|
|
|
await searchPriorityChooser.selectRowByValue(1);
|
|
|
|
|
2018-07-19 17:40:42 +08:00
|
|
|
await click("#save-category");
|
2019-03-18 15:25:45 +08:00
|
|
|
|
2018-07-19 17:40:42 +08:00
|
|
|
assert.ok(!visible(".d-modal"), "it closes the modal");
|
|
|
|
assert.equal(
|
|
|
|
DiscourseURL.redirectedTo,
|
2019-12-04 17:12:45 +08:00
|
|
|
"/c/bug/1",
|
2018-07-19 17:40:42 +08:00
|
|
|
"it does one of the rare full page redirects"
|
|
|
|
);
|
2015-07-03 04:18:59 +08:00
|
|
|
});
|
2016-07-28 23:57:30 +08:00
|
|
|
|
2019-05-29 02:16:42 +08:00
|
|
|
QUnit.skip("Edit the description without loosing progress", async assert => {
|
2019-03-18 23:14:17 +08:00
|
|
|
let win = { focus: function() {} };
|
|
|
|
let windowOpen = sandbox.stub(window, "open").returns(win);
|
|
|
|
sandbox.stub(win, "focus");
|
|
|
|
|
|
|
|
await visit("/c/bug");
|
|
|
|
|
|
|
|
await click(".edit-category");
|
|
|
|
await click(".edit-category-description");
|
|
|
|
assert.ok(
|
|
|
|
windowOpen.calledWith("/t/category-definition-for-bug/2", "_blank"),
|
|
|
|
"opens the category topic in a new tab"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2018-07-19 17:40:42 +08:00
|
|
|
QUnit.test("Error Saving", async assert => {
|
|
|
|
await visit("/c/bug");
|
|
|
|
|
|
|
|
await click(".edit-category");
|
|
|
|
await click(".edit-category-settings");
|
|
|
|
await fillIn(".email-in", "duplicate@example.com");
|
|
|
|
await click("#save-category");
|
|
|
|
assert.ok(visible("#modal-alert"));
|
|
|
|
assert.equal(find("#modal-alert").html(), "duplicate email");
|
2016-07-28 23:57:30 +08:00
|
|
|
});
|
2017-03-09 00:31:30 +08:00
|
|
|
|
2018-07-17 07:10:55 +08:00
|
|
|
QUnit.test("Subcategory list settings", async assert => {
|
2018-06-15 23:03:24 +08:00
|
|
|
const categoryChooser = selectKit(
|
|
|
|
".edit-category-tab-general .category-chooser"
|
|
|
|
);
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-17 07:10:55 +08:00
|
|
|
await visit("/c/bug");
|
|
|
|
await click(".edit-category");
|
|
|
|
await click(".edit-category-settings a");
|
2017-03-09 00:31:30 +08:00
|
|
|
|
2018-07-17 07:10:55 +08:00
|
|
|
assert.ok(
|
|
|
|
!visible(".subcategory-list-style-field"),
|
|
|
|
"subcategory list style isn't visible by default"
|
|
|
|
);
|
2017-03-09 00:31:30 +08:00
|
|
|
|
2018-07-17 07:10:55 +08:00
|
|
|
await click(".show-subcategory-list-field input[type=checkbox]");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-17 07:10:55 +08:00
|
|
|
assert.ok(
|
|
|
|
visible(".subcategory-list-style-field"),
|
|
|
|
"subcategory list style is shown if show subcategory list is checked"
|
|
|
|
);
|
2017-03-09 00:31:30 +08:00
|
|
|
|
2018-07-17 07:10:55 +08:00
|
|
|
await click(".edit-category-general");
|
2018-07-30 04:51:32 +08:00
|
|
|
await categoryChooser.expand();
|
|
|
|
await categoryChooser.selectRowByValue(3);
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-17 07:10:55 +08:00
|
|
|
await click(".edit-category-settings a");
|
|
|
|
|
|
|
|
assert.ok(
|
|
|
|
!visible(".show-subcategory-list-field"),
|
|
|
|
"show subcategory list isn't visible for child categories"
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
!visible(".subcategory-list-style-field"),
|
|
|
|
"subcategory list style isn't visible for child categories"
|
|
|
|
);
|
2017-08-30 23:04:17 +08:00
|
|
|
});
|