2015-08-11 05:11:27 +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,
|
|
|
|
settings: { email_in: true }
|
|
|
|
});
|
2015-05-15 23:03:27 +08:00
|
|
|
|
2015-08-25 16:42:19 +08:00
|
|
|
test("Can open the category modal", assert => {
|
2015-05-15 23:03:27 +08:00
|
|
|
visit("/c/bug");
|
|
|
|
|
|
|
|
click('.edit-category');
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(visible('#discourse-modal'), 'it pops up a modal');
|
|
|
|
});
|
|
|
|
|
|
|
|
click('a.close');
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(!visible('#discourse-modal'), 'it closes the modal');
|
|
|
|
});
|
|
|
|
});
|
2015-07-03 00:06:24 +08:00
|
|
|
|
2015-08-25 16:42:19 +08:00
|
|
|
test("Change the category color", assert => {
|
2015-07-03 00:06:24 +08:00
|
|
|
visit("/c/bug");
|
|
|
|
|
|
|
|
click('.edit-category');
|
|
|
|
fillIn('#edit-text-color', '#ff0000');
|
|
|
|
click('#save-category');
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(!visible('#discourse-modal'), 'it closes the modal');
|
2015-08-11 05:11:27 +08:00
|
|
|
assert.equal(DiscourseURL.redirectedTo, '/c/bug', 'it does one of the rare full page redirects');
|
2015-07-03 00:06:24 +08:00
|
|
|
});
|
|
|
|
});
|
2015-07-03 04:18:59 +08:00
|
|
|
|
2015-08-25 16:42:19 +08:00
|
|
|
test("Change the topic template", assert => {
|
2015-07-03 04:18:59 +08:00
|
|
|
visit("/c/bug");
|
|
|
|
|
|
|
|
click('.edit-category');
|
|
|
|
click('.edit-category-topic-template');
|
2015-09-29 02:01:16 +08:00
|
|
|
fillIn('.d-editor-input', 'this is the new topic template');
|
2015-07-03 04:18:59 +08:00
|
|
|
click('#save-category');
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(!visible('#discourse-modal'), 'it closes the modal');
|
2015-08-11 05:11:27 +08:00
|
|
|
assert.equal(DiscourseURL.redirectedTo, '/c/bug', '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
|
|
|
|
|
|
|
test("Error Saving", assert => {
|
|
|
|
visit("/c/bug");
|
|
|
|
|
|
|
|
click('.edit-category');
|
|
|
|
click('.edit-category-settings');
|
|
|
|
fillIn('.email-in', 'duplicate@example.com');
|
|
|
|
click('#save-category');
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(visible('#modal-alert'));
|
|
|
|
assert.equal(find('#modal-alert').html(), "duplicate email");
|
|
|
|
});
|
|
|
|
});
|
2017-03-09 00:31:30 +08:00
|
|
|
|
|
|
|
test("Subcategory list settings", () => {
|
|
|
|
visit("/c/bug");
|
|
|
|
|
|
|
|
click('.edit-category');
|
|
|
|
click('.edit-category-settings');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
ok(!visible(".subcategory-list-style-field"), "subcategory list style isn't visible by default");
|
|
|
|
});
|
|
|
|
|
|
|
|
click(".show-subcategory-list-field input[type=checkbox]");
|
|
|
|
andThen(() => {
|
|
|
|
ok(visible(".subcategory-list-style-field"), "subcategory list style is shown if show subcategory list is checked");
|
|
|
|
});
|
|
|
|
|
|
|
|
click('.edit-category-general');
|
|
|
|
selectDropdown('.edit-category-tab-general .category-combobox', 2);
|
|
|
|
|
|
|
|
click('.edit-category-settings');
|
|
|
|
andThen(() => {
|
|
|
|
ok(!visible(".show-subcategory-list-field"), "show subcategory list isn't visible for child categories");
|
|
|
|
ok(!visible(".subcategory-list-style-field"), "subcategory list style isn't visible for child categories");
|
|
|
|
});
|
|
|
|
});
|