chore: remove legacy SSR checks and consolidate migration maintenance
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { defineComponent, h } from "vue";
|
||||
import {
|
||||
ToastQueue,
|
||||
ToastProvider,
|
||||
Table,
|
||||
TableContent,
|
||||
TableBody,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
TableCell,
|
||||
TableColumn,
|
||||
} from "../../../packages/vue/src";
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
const queues: ToastQueue[] = [];
|
||||
afterEach(() => {
|
||||
wrappers.splice(0).forEach((w) => w.unmount());
|
||||
queues.splice(0).forEach((q) => q.destroy());
|
||||
document.body.innerHTML = "";
|
||||
});
|
||||
it("after queue swap the visible toast close action closes the new queue", async () => {
|
||||
const a = new ToastQueue({ exitDuration: 0 }),
|
||||
b = new ToastQueue({ exitDuration: 0 });
|
||||
queues.push(a, b);
|
||||
const w = mount(ToastProvider, { props: { queue: a } });
|
||||
wrappers.push(w);
|
||||
await w.setProps({ queue: b });
|
||||
b.add({ title: "new queue toast" }, { timeout: 0 });
|
||||
await flushPromises();
|
||||
expect(w.text()).toContain("new queue toast");
|
||||
await w.get('button[data-slot="toast-close"]').trigger("click");
|
||||
await flushPromises();
|
||||
expect(b.visibleToasts).toHaveLength(0);
|
||||
});
|
||||
it("row event arrays respect stopImmediatePropagation before other handlers and selection", async () => {
|
||||
const second = vi.fn(),
|
||||
select = vi.fn();
|
||||
const w = mount(
|
||||
defineComponent({
|
||||
render: () =>
|
||||
h(Table, {}, () =>
|
||||
h(
|
||||
TableContent,
|
||||
{ selectionMode: "multiple", onSelectionChange: select },
|
||||
() =>
|
||||
h(TableBody, {}, () =>
|
||||
h(
|
||||
TableRow,
|
||||
{
|
||||
rowKey: "one",
|
||||
onClick: [
|
||||
(e: MouseEvent) => e.stopImmediatePropagation(),
|
||||
second,
|
||||
],
|
||||
},
|
||||
() => h(TableCell, {}, () => "One"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
}),
|
||||
);
|
||||
wrappers.push(w);
|
||||
await w.get("tr").trigger("click");
|
||||
expect(second).not.toHaveBeenCalled();
|
||||
expect(select).not.toHaveBeenCalled();
|
||||
});
|
||||
it("a sortable column forwards user click and honors its cancellation", async () => {
|
||||
const sort = vi.fn(),
|
||||
click = vi.fn((e: MouseEvent) => e.preventDefault());
|
||||
const w = mount(
|
||||
defineComponent({
|
||||
render: () =>
|
||||
h(Table, {}, () =>
|
||||
h(TableContent, { onSortChange: sort }, () =>
|
||||
h(TableHeader, {}, () =>
|
||||
h(
|
||||
TableColumn,
|
||||
{ id: "name", allowsSorting: true, onClick: click },
|
||||
() => "Name",
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
}),
|
||||
);
|
||||
wrappers.push(w);
|
||||
await w.get("th").trigger("click");
|
||||
expect(click).toHaveBeenCalledTimes(1);
|
||||
expect(sort).not.toHaveBeenCalled();
|
||||
});
|
||||
it("baseline table header creates a header row around its columns", async () => {
|
||||
const mod = await import("../../../apps/docs/demos/table-sorting.vue");
|
||||
const w = mount(mod.default);
|
||||
wrappers.push(w);
|
||||
expect(w.find("thead > tr > th").exists()).toBe(true);
|
||||
});
|
||||
it("baseline sorting exposes the current direction on the real column header", async () => {
|
||||
const mod = await import("../../../apps/docs/demos/table-sorting.vue");
|
||||
const w = mount(mod.default);
|
||||
wrappers.push(w);
|
||||
const column = w.findAll("th")[1];
|
||||
await column.trigger("click");
|
||||
expect(column.attributes("aria-sort")).toBe("ascending");
|
||||
});
|
||||
Reference in New Issue
Block a user