fix(collection): finish B02a boundary checks and stage acceptance

This commit is contained in:
maoyingjie
2026-10-25 16:45:07 +08:00
parent c8b0aa26c3
commit ff486fb665
8 changed files with 100 additions and 3 deletions
+44
View File
@@ -708,3 +708,47 @@ describe("B02a round 2 regressions", () => {
expect(wrapper.vm.eligible().map((record) => record.key)).toEqual([99]);
});
});
describe("B02a final boundary checks", () => {
it("shows static empty feedback for an initially empty or removed collection", async () => {
const options = ref<string[]>([]);
const wrapper = mount(
defineComponent({
setup: () => () =>
h(ListBox, null, {
default: () =>
options.value.map((id) =>
h(ListBoxItem, { id, key: id }, () => id),
),
empty: () => h("p", { "data-test": "static-empty" }, "Empty"),
}),
}),
{ attachTo: document.body },
);
wrappers.push(wrapper);
await nextTick();
await settle();
expect(queryOne('[data-test="static-empty"]')).not.toBeNull();
options.value = ["A"];
await nextTick();
await settle();
expect(queryOne('[data-test="static-empty"]')).toBeNull();
options.value = [];
await nextTick();
await settle();
expect(queryOne('[data-test="static-empty"]')).not.toBeNull();
});
it("does not press the parent row from an embedded control", async () => {
await mountHarness();
await type("");
const row = queryAll('[role="option"]')[0];
const button = document.createElement("button");
row.appendChild(button);
const down = pointerEvent("pointerdown");
button.dispatchEvent(down);
await nextTick();
expect(down.defaultPrevented).toBe(false);
expect(row.hasAttribute("data-pressed")).toBe(false);
});
});
+9
View File
@@ -0,0 +1,9 @@
/** jsdom has no Element.scrollTo. Supply only the method used by VueUse;
* geometry and visible-window assertions still belong to real browser checks.
* Set up each test realm explicitly so probes work alone and in any order. */
if (
typeof Element !== "undefined" &&
typeof Element.prototype.scrollTo !== "function"
) {
Element.prototype.scrollTo = () => {};
}