test: record ColorSwatchPicker review regressions and findings
This commit is contained in:
@@ -778,3 +778,42 @@ describe("ColorSwatchPicker owner composition", () => {
|
||||
expect(items(w)[2]!.attributes("aria-selected")).toBe("true");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("ColorSwatchPicker activation lifecycle and dynamic focus", () => {
|
||||
it("ignores secondary mouse buttons", async () => {
|
||||
const w = picker();
|
||||
items(w)[1]!.element.dispatchEvent(new MouseEvent("mousedown", { bubbles: true, cancelable: true, button: 2 }));
|
||||
await w.vm.$nextTick();
|
||||
expect(w.getComponent(ColorSwatchPicker).emitted("update:modelValue")).toBeUndefined();
|
||||
});
|
||||
it("clears pressed state after the primary mouse release", async () => {
|
||||
const w = picker();
|
||||
press(items(w)[0]!);
|
||||
items(w)[0]!.element.dispatchEvent(new MouseEvent("mouseup", { bubbles: true, cancelable: true, button: 0 }));
|
||||
await w.vm.$nextTick();
|
||||
expect(items(w)[0]!.attributes("data-pressed")).toBeUndefined();
|
||||
});
|
||||
it("keeps an enabled tab entry after dynamically disabling the focused item", async () => {
|
||||
const off = shallowRef(false);
|
||||
const w = render(defineComponent({
|
||||
components: { ColorSwatchPicker, ColorSwatchPickerItem },
|
||||
setup: () => ({ off }),
|
||||
template: `<ColorSwatchPicker><ColorSwatchPickerItem color="#F43F5E" :is-disabled="off"/><ColorSwatchPickerItem color="#D946EF"/></ColorSwatchPicker>`,
|
||||
}));
|
||||
items(w)[0]!.element.focus();
|
||||
await w.vm.$nextTick();
|
||||
off.value = true;
|
||||
await w.vm.$nextTick();
|
||||
await w.vm.$nextTick();
|
||||
const root = w.get("[data-slot=color-swatch-picker]");
|
||||
const enabledTabEntries = [root, ...items(w)].filter(node => node.attributes("tabindex") === "0" && node.attributes("aria-disabled") !== "true");
|
||||
expect(enabledTabEntries).toHaveLength(1);
|
||||
});
|
||||
it("supports click-only activation used by assistive technology", async () => {
|
||||
const w = picker();
|
||||
items(w)[1]!.element.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true, detail: 0 }));
|
||||
await w.vm.$nextTick();
|
||||
expect(items(w)[1]!.attributes("aria-selected")).toBe("true");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user