mirror of
https://github.com/discourse/discourse.git
synced 2025-06-08 00:27:32 +08:00
FIX: Category chooser not updating selection when editing reviewable (#18737)
This commit is contained in:

committed by
GitHub

parent
fd8fd0a1f0
commit
d85c89ba6d
@ -1,10 +1,13 @@
|
|||||||
import Component from "@ember/component";
|
import Component from "@glimmer/component";
|
||||||
|
import { action } from "@ember/object";
|
||||||
|
import { tracked } from "@glimmer/tracking";
|
||||||
|
|
||||||
export default Component.extend({
|
export default class extends Component {
|
||||||
actions: {
|
@tracked categoryId = this.args.value;
|
||||||
|
|
||||||
|
@action
|
||||||
onChange(category) {
|
onChange(category) {
|
||||||
this.set("value", category);
|
this.categoryId = category;
|
||||||
this.categoryChanged && this.categoryChanged(category);
|
this.args.categoryChanged?.(category);
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
});
|
|
||||||
|
@ -1 +1 @@
|
|||||||
<CategoryChooser @value={{this.value}} @onChange={{action "onChange"}} />
|
<CategoryChooser @value={{this.categoryId}} @onChange={{this.onChange}} />
|
||||||
|
@ -135,13 +135,17 @@ acceptance("Review", function (needs) {
|
|||||||
|
|
||||||
test("Editing a reviewable", async function (assert) {
|
test("Editing a reviewable", async function (assert) {
|
||||||
const topic = '.reviewable-item[data-reviewable-id="4321"]';
|
const topic = '.reviewable-item[data-reviewable-id="4321"]';
|
||||||
|
|
||||||
await visit("/review");
|
await visit("/review");
|
||||||
|
|
||||||
assert.ok(exists(`${topic} .reviewable-action.approve`));
|
assert.ok(exists(`${topic} .reviewable-action.approve`));
|
||||||
assert.ok(!exists(`${topic} .category-name`));
|
assert.ok(!exists(`${topic} .category-name`));
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
query(`${topic} .discourse-tag:nth-of-type(1)`).innerText,
|
query(`${topic} .discourse-tag:nth-of-type(1)`).innerText,
|
||||||
"hello"
|
"hello"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
query(`${topic} .discourse-tag:nth-of-type(2)`).innerText,
|
query(`${topic} .discourse-tag:nth-of-type(2)`).innerText,
|
||||||
"world"
|
"world"
|
||||||
@ -154,10 +158,12 @@ acceptance("Review", function (needs) {
|
|||||||
|
|
||||||
await click(`${topic} .reviewable-action.edit`);
|
await click(`${topic} .reviewable-action.edit`);
|
||||||
await click(`${topic} .reviewable-action.save-edit`);
|
await click(`${topic} .reviewable-action.save-edit`);
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
exists(`${topic} .reviewable-action.approve`),
|
exists(`${topic} .reviewable-action.approve`),
|
||||||
"saving without changes is a cancel"
|
"saving without changes is a cancel"
|
||||||
);
|
);
|
||||||
|
|
||||||
await click(`${topic} .reviewable-action.edit`);
|
await click(`${topic} .reviewable-action.edit`);
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
@ -167,6 +173,7 @@ acceptance("Review", function (needs) {
|
|||||||
|
|
||||||
await fillIn(".editable-field.payload-raw textarea", "new raw contents");
|
await fillIn(".editable-field.payload-raw textarea", "new raw contents");
|
||||||
await click(`${topic} .reviewable-action.cancel-edit`);
|
await click(`${topic} .reviewable-action.cancel-edit`);
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
query(`${topic} .post-body`).innerText.trim(),
|
query(`${topic} .post-body`).innerText.trim(),
|
||||||
"existing body",
|
"existing body",
|
||||||
@ -175,9 +182,16 @@ acceptance("Review", function (needs) {
|
|||||||
|
|
||||||
await click(`${topic} .reviewable-action.edit`);
|
await click(`${topic} .reviewable-action.edit`);
|
||||||
let category = selectKit(`${topic} .category-id .select-kit`);
|
let category = selectKit(`${topic} .category-id .select-kit`);
|
||||||
|
|
||||||
await category.expand();
|
await category.expand();
|
||||||
await category.selectRowByValue("6");
|
await category.selectRowByValue("6");
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
category.header().name(),
|
||||||
|
"support",
|
||||||
|
"displays the right header"
|
||||||
|
);
|
||||||
|
|
||||||
let tags = selectKit(`${topic} .payload-tags .mini-tag-chooser`);
|
let tags = selectKit(`${topic} .payload-tags .mini-tag-chooser`);
|
||||||
requests = [];
|
requests = [];
|
||||||
await tags.expand();
|
await tags.expand();
|
||||||
|
Reference in New Issue
Block a user