Merge pull request #12107 from dacook/buu/fixes

[BUU] Style and behaviour updates
This commit is contained in:
Rachel Arnould
2024-02-05 11:33:06 +01:00
committed by GitHub
8 changed files with 64 additions and 17 deletions

View File

@@ -16,7 +16,7 @@ describe("PopoutController", () => {
<div data-controller="popout">
<button id="button" data-popout-target="button">On demand</button>
<div id="dialog" data-popout-target="dialog" style="display: none;">
<input id="input1" value="value1">
<input id="input1" value="value1" required>
<label>
<input id="input2" type="checkbox" value="value2" data-action="change->popout#closeIfChecked">
label2
@@ -42,7 +42,21 @@ describe("PopoutController", () => {
expectToBeShown(dialog);
});
it("doesn't show the dialog on other key press (tab)", () => {
it("shows and updates on number press", () => {
button.dispatchEvent(new KeyboardEvent("keydown", { key: "1" }));
expectToBeShown(dialog);
expect(input1.value).toBe("1");
});
it("shows and updates on character press", () => {
button.dispatchEvent(new KeyboardEvent("keydown", { key: "a" }));
expectToBeShown(dialog);
expect(input1.value).toBe("a");
});
it("doesn't show the dialog on control key press (tab)", () => {
button.dispatchEvent(new KeyboardEvent("keydown", { keyCode: 9 }));
expectToBeClosed(dialog);
@@ -89,6 +103,14 @@ describe("PopoutController", () => {
expect(input2.checked).toBe(false);
expectToBeShown(dialog);
});
it("doesn't close the dialog when a field is invalid", () => {
input1.value = "" // field is required
input4.click();
expectToBeShown(dialog);
// Browser will show a validation message
});
});
describe("Cleaning up", () => {