2015-08-10 17:11:27 -04:00
|
|
|
import DiscourseURL from 'discourse/lib/url';
|
2015-05-15 11:03:27 -04:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
|
2016-07-28 11:57:30 -04:00
|
|
|
acceptance("Category Edit", {
|
|
|
|
loggedIn: true,
|
|
|
|
settings: { email_in: true }
|
|
|
|
});
|
2015-05-15 11:03:27 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("Can open the category modal", assert => {
|
2015-05-15 11:03:27 -04:00
|
|
|
visit("/c/bug");
|
|
|
|
|
|
|
|
click('.edit-category');
|
|
|
|
andThen(() => {
|
2017-08-30 15:29:51 -04:00
|
|
|
assert.ok(visible('.d-modal'), 'it pops up a modal');
|
2015-05-15 11:03:27 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
click('a.close');
|
|
|
|
andThen(() => {
|
2017-08-30 15:29:51 -04:00
|
|
|
assert.ok(!visible('.d-modal'), 'it closes the modal');
|
2015-05-15 11:03:27 -04:00
|
|
|
});
|
|
|
|
});
|
2015-07-02 12:06:24 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("Change the category color", assert => {
|
2015-07-02 12:06:24 -04:00
|
|
|
visit("/c/bug");
|
|
|
|
|
|
|
|
click('.edit-category');
|
|
|
|
fillIn('#edit-text-color', '#ff0000');
|
|
|
|
click('#save-category');
|
|
|
|
andThen(() => {
|
2017-08-30 15:29:51 -04:00
|
|
|
assert.ok(!visible('.d-modal'), 'it closes the modal');
|
2015-08-10 17:11:27 -04:00
|
|
|
assert.equal(DiscourseURL.redirectedTo, '/c/bug', 'it does one of the rare full page redirects');
|
2015-07-02 12:06:24 -04:00
|
|
|
});
|
|
|
|
});
|
2015-07-02 16:18:59 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("Change the topic template", assert => {
|
2015-07-02 16:18:59 -04:00
|
|
|
visit("/c/bug");
|
|
|
|
|
|
|
|
click('.edit-category');
|
|
|
|
click('.edit-category-topic-template');
|
2015-09-28 14:01:16 -04:00
|
|
|
fillIn('.d-editor-input', 'this is the new topic template');
|
2015-07-02 16:18:59 -04:00
|
|
|
click('#save-category');
|
|
|
|
andThen(() => {
|
2017-08-30 15:29:51 -04:00
|
|
|
assert.ok(!visible('.d-modal'), 'it closes the modal');
|
2015-08-10 17:11:27 -04:00
|
|
|
assert.equal(DiscourseURL.redirectedTo, '/c/bug', 'it does one of the rare full page redirects');
|
2015-07-02 16:18:59 -04:00
|
|
|
});
|
|
|
|
});
|
2016-07-28 11:57:30 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("Error Saving", assert => {
|
2016-07-28 11:57:30 -04:00
|
|
|
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-08 11:31:30 -05:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("Subcategory list settings", assert => {
|
2017-12-22 07:08:12 -05:00
|
|
|
const categoryChooser = selectKit('.edit-category-tab-general .category-chooser');
|
|
|
|
|
2017-03-08 11:31:30 -05:00
|
|
|
visit("/c/bug");
|
|
|
|
|
|
|
|
click('.edit-category');
|
|
|
|
click('.edit-category-settings');
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(!visible(".subcategory-list-style-field"), "subcategory list style isn't visible by default");
|
2017-03-08 11:31:30 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
click(".show-subcategory-list-field input[type=checkbox]");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2017-03-08 11:31:30 -05:00
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(visible(".subcategory-list-style-field"), "subcategory list style is shown if show subcategory list is checked");
|
2017-03-08 11:31:30 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
click('.edit-category-general');
|
2017-12-22 07:08:12 -05:00
|
|
|
categoryChooser.expand().selectRowByValue(3);
|
2017-03-08 11:31:30 -05:00
|
|
|
click('.edit-category-settings');
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2017-03-08 11:31:30 -05:00
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
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-03-08 11:31:30 -05:00
|
|
|
});
|
2017-08-30 11:04:17 -04:00
|
|
|
});
|