mirror of
https://github.com/discourse/discourse.git
synced 2025-02-24 07:04:26 +08:00
FIX: reset bool site setting not updating checkbox (#30999)
This commit is contained in:
parent
5d1c696240
commit
0d240308c8
@ -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) {
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user