FIX: reset bool site setting not updating checkbox (#30999)

This commit is contained in:
Renato Atilio 2025-01-27 10:53:27 -03:00 committed by GitHub
parent 5d1c696240
commit 0d240308c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 5 deletions

View File

@ -1,15 +1,15 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { htmlSafe } from "@ember/template";
import { isEmpty } from "@ember/utils";
export default class Bool extends Component {
@tracked
enabled = isEmpty(this.args.value)
? false
: this.args.value.toString() === "true";
get enabled() {
return isEmpty(this.args.value)
? false
: this.args.value.toString() === "true";
}
@action
onToggle(event) {

View File

@ -250,6 +250,33 @@ module(
.exists("the cancel button is shown");
});
test("resetting to the default value changes the content of checkbox field", async function (assert) {
this.set("setting", {
setting: "test_setting",
value: "true",
default: "false",
type: "bool",
});
await render(hbs`<SiteSetting @setting={{this.setting}} />`);
assert
.dom("input[type=checkbox]")
.isChecked("the checkbox contains the custom value");
await click(".setting-controls__undo");
assert
.dom("input[type=checkbox]")
.isNotChecked("the checkbox now contains the default value");
assert
.dom(".setting-controls__undo")
.doesNotExist("the reset button is not shown");
assert.dom(".setting-controls__ok").exists("the save button is shown");
assert
.dom(".setting-controls__cancel")
.exists("the cancel button is shown");
});
test("clearing the input field keeps the cancel button and the validation error shown", async function (assert) {
this.set("setting", {
setting: "max_image_size_kb",