FIX: Ensure allowed_tags and allowed_tag_groups can be removed (#16454)
This commit is contained in:
parent
e7f3702d9b
commit
9c33f6de05
|
@ -218,14 +218,8 @@ const Category = RestModel.extend({
|
||||||
all_topics_wiki: this.all_topics_wiki,
|
all_topics_wiki: this.all_topics_wiki,
|
||||||
allow_unlimited_owner_edits_on_first_post: this
|
allow_unlimited_owner_edits_on_first_post: this
|
||||||
.allow_unlimited_owner_edits_on_first_post,
|
.allow_unlimited_owner_edits_on_first_post,
|
||||||
allowed_tags:
|
allowed_tags: this.allowed_tags,
|
||||||
this.allowed_tags && this.allowed_tags.length > 0
|
allowed_tag_groups: this.allowed_tag_groups,
|
||||||
? this.allowed_tags
|
|
||||||
: null,
|
|
||||||
allowed_tag_groups:
|
|
||||||
this.allowed_tag_groups && this.allowed_tag_groups.length > 0
|
|
||||||
? this.allowed_tag_groups
|
|
||||||
: null,
|
|
||||||
allow_global_tags: this.allow_global_tags,
|
allow_global_tags: this.allow_global_tags,
|
||||||
required_tag_groups: this.required_tag_groups,
|
required_tag_groups: this.required_tag_groups,
|
||||||
sort_order: this.sort_order,
|
sort_order: this.sort_order,
|
||||||
|
|
|
@ -10,6 +10,7 @@ import DiscourseURL from "discourse/lib/url";
|
||||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
|
import pretender from "discourse/tests/helpers/create-pretender";
|
||||||
|
|
||||||
acceptance("Category Edit", function (needs) {
|
acceptance("Category Edit", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
|
@ -95,6 +96,48 @@ acceptance("Category Edit", function (needs) {
|
||||||
|
|
||||||
await click("#save-category");
|
await click("#save-category");
|
||||||
assert.strictEqual(count(".required-tag-group-row"), 1);
|
assert.strictEqual(count(".required-tag-group-row"), 1);
|
||||||
|
|
||||||
|
await click(".delete-required-tag-group");
|
||||||
|
assert.strictEqual(count(".required-tag-group-row"), 0);
|
||||||
|
|
||||||
|
await click("#save-category");
|
||||||
|
assert.strictEqual(count(".required-tag-group-row"), 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Editing allowed tags and tag groups", async function (assert) {
|
||||||
|
await visit("/c/bug/edit/tags");
|
||||||
|
|
||||||
|
const allowedTagChooser = selectKit("#category-allowed-tags");
|
||||||
|
await allowedTagChooser.expand();
|
||||||
|
await allowedTagChooser.selectRowByValue("monkey");
|
||||||
|
|
||||||
|
const allowedTagGroupChooser = selectKit("#category-allowed-tag-groups");
|
||||||
|
await allowedTagGroupChooser.expand();
|
||||||
|
await allowedTagGroupChooser.selectRowByValue("TagGroup1");
|
||||||
|
|
||||||
|
await click("#save-category");
|
||||||
|
|
||||||
|
const payload = JSON.parse(
|
||||||
|
pretender.handledRequests[pretender.handledRequests.length - 1]
|
||||||
|
.requestBody
|
||||||
|
);
|
||||||
|
assert.deepEqual(payload.allowed_tags, ["monkey"]);
|
||||||
|
assert.deepEqual(payload.allowed_tag_groups, ["TagGroup1"]);
|
||||||
|
|
||||||
|
await allowedTagChooser.expand();
|
||||||
|
await allowedTagChooser.deselectItemByValue("monkey");
|
||||||
|
|
||||||
|
await allowedTagGroupChooser.expand();
|
||||||
|
await allowedTagGroupChooser.deselectItemByValue("TagGroup1");
|
||||||
|
|
||||||
|
await click("#save-category");
|
||||||
|
|
||||||
|
const removePayload = JSON.parse(
|
||||||
|
pretender.handledRequests[pretender.handledRequests.length - 1]
|
||||||
|
.requestBody
|
||||||
|
);
|
||||||
|
assert.deepEqual(removePayload.allowed_tags, []);
|
||||||
|
assert.deepEqual(removePayload.allowed_tag_groups, []);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Index Route", async function (assert) {
|
test("Index Route", async function (assert) {
|
||||||
|
|
Loading…
Reference in New Issue