FIX: Ensure `required_tag_group` is defined on new category records (#20600)

Attaching required tag groups to new categories failed because
`required_tag_group` was undefined on the new category records

This fix sets an empty `required_tag_group` property on the new category
records.
This commit is contained in:
Selase Krakani 2023-03-09 11:57:37 +00:00 committed by GitHub
parent ba1b95c9f4
commit ec40693f89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -32,6 +32,7 @@ export default DiscourseRoute.extend({
topic_featured_link_allowed: true,
custom_fields: {},
search_priority: SEARCH_PRIORITIES.normal,
required_tag_groups: [],
});
},

View File

@ -8,6 +8,7 @@ import DiscourseURL from "discourse/lib/url";
import I18n from "I18n";
import sinon from "sinon";
import { test } from "qunit";
import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("Category New", function (needs) {
needs.user();
@ -21,6 +22,15 @@ acceptance("Category New", function (needs) {
await fillIn("input.category-name", "testing");
assert.strictEqual(query(".badge-category").innerText, "testing");
await click(".edit-category-nav .edit-category-tags a");
await click("button.add-required-tag-group");
const tagSelector = selectKit(
".required-tag-group-row .select-kit.tag-group-chooser"
);
await tagSelector.expand();
await tagSelector.selectRowByValue("TagGroup1");
await click("#save-category");
assert.strictEqual(
@ -29,6 +39,15 @@ acceptance("Category New", function (needs) {
"it transitions to the category edit route"
);
await click(".edit-category-nav .edit-category-tags a");
assert.ok(
exists(
".required-tag-group-row .select-kit-header[data-value='TagGroup1']"
),
"it shows saved required tag group"
);
assert.strictEqual(
query(".edit-category-title h2").innerText,
I18n.t("category.edit_dialog_title", {