A platform for community discussion. Free, open, simple.
FIX: Avoid frozen form writes when loading board column categories (#43730)
Régis Hanol3cccbd3f73b8
diff --git a/plugins/boards/assets/javascripts/discourse/components/modal/boards-column-settings.gjs b/plugins/boards/assets/javascripts/discourse/components/modal/boards-column-settings.gjsindex 8687d9b07f9..743d7b808b2 100644--- a/plugins/boards/assets/javascripts/discourse/components/modal/boards-column-settings.gjs+++ b/plugins/boards/assets/javascripts/discourse/components/modal/boards-column-settings.gjs@@ -264,7 +264,7 @@ export default class BoardsColumnSettings extends Component {<CategoryChooser@onChange={{fn this.onCategoryChange field}}@options={{hash clearable=true}}- @value={{data.move_to_category_id}}+ @value={{readonly data.move_to_category_id}}/></field.Control></form.Field>diff --git a/plugins/boards/test/javascripts/components/boards-column-settings-test.gjs b/plugins/boards/test/javascripts/components/boards-column-settings-test.gjsnew file mode 100644index 00000000000..b119e933706--- /dev/null+++ b/plugins/boards/test/javascripts/components/boards-column-settings-test.gjs@@ -0,0 +1,36 @@+import { click, getRootElement, render } from "@ember/test-helpers";+import { module, test } from "qunit";+import { setupRenderingTest } from "discourse/tests/helpers/component-test";+import pretender, { response } from "discourse/tests/helpers/create-pretender";+import BoardsColumnSettings from "discourse/plugins/boards/discourse/components/modal/boards-column-settings";+import BoardsFabricators from "discourse/plugins/boards/discourse/lib/fabricators";++const CATEGORY_ID = 12345;+const CATEGORY_NAME = "Unvisited category";++module("Integration | Component | BoardsColumnSettings", function (hooks) {+ setupRenderingTest(hooks);++ test("loads the destination category without writing to frozen form data", async function (assert) {+ this.site.set("lazy_load_categories", true);+ this.owner.lookup("service:modal").containerElement = getRootElement();+ const fabricators = new BoardsFabricators(this.owner);+ this.model = {+ board: fabricators.board(),+ column: fabricators.column(),+ };+ this.model.column.move_to_category_id = CATEGORY_ID;+ pretender.get("/categories/find", () =>+ response({ categories: [{ id: CATEGORY_ID, name: CATEGORY_NAME }] })+ );++ await render(+ <template><BoardsColumnSettings @model={{this.model}} /></template>+ );+ await click(".show-advanced");++ assert+ .dom(".category-chooser .select-kit-header")+ .includesText(CATEGORY_NAME);+ });+});