chore: remove legacy SSR checks and consolidate migration maintenance
This commit is contained in:
+15
-11
@@ -1,13 +1,13 @@
|
||||
# 验证入口
|
||||
|
||||
测试按风险选择,不要求每次局部修改遍历全库。当前仅支持浏览器客户端使用,暂不支持SSR、服务端水合或Nuxt服务端渲染。除用户明确重新启用外,不开发、不修复、不新增也不运行相关专项;历史通过记录不构成支持承诺。历史SSR用例保留但默认不执行,客户端回归仍保留。
|
||||
测试按风险选择,不要求每次局部修改遍历全库。当前仅支持浏览器客户端使用,暂不支持SSR、服务端水合或Nuxt服务端渲染。除用户明确重新启用外,不开发、不修复、不新增也不运行相关专项;历史通过记录不构成支持承诺。SSR遗留文件和混合案例已删除,仅从Git查询,客户端回归保留。
|
||||
|
||||
## 日常修改
|
||||
|
||||
先选组件与共享依赖的明确测试。例如修改ComboBox/Autocomplete:
|
||||
|
||||
```sh
|
||||
pnpm exec vitest run tests/combo-box.test.ts tests/autocomplete.test.ts tests/b02-public-integration.test.ts tests/b02-review.probe.test.ts
|
||||
pnpm exec vitest run tests/combo-box.test.ts tests/autocomplete.test.ts tests/b02-public-integration.test.ts tests/regressions/collection/picker-public-contracts.test.ts
|
||||
pnpm typecheck
|
||||
```
|
||||
|
||||
@@ -23,15 +23,15 @@ pnpm test:related packages/vue/src/components/combo-box/ComboBox.vue
|
||||
|
||||
## 集成检查
|
||||
|
||||
| 命令 | 范围 |
|
||||
| ---------------------------- | --------------------------------------------------------------------------- |
|
||||
| pnpm test / pnpm test:unit | 当前客户端回归;自动排除SSR/水合专项文件与混合文件中的历史SSR/hydration案例 |
|
||||
| `pnpm test:related <源文件>` | 同一客户端范围下的静态依赖辅助筛选 |
|
||||
| pnpm typecheck | 源码/工作区类型;排除独立SSR/水合专项文件,不代替发布类型 |
|
||||
| pnpm build:docs | 库、样式与文档站静态构建,保留文档渲染要求,不视为组件SSR支持 |
|
||||
| pnpm build:playground | 浏览器验证入口生产构建 |
|
||||
| 命令 | 范围 |
|
||||
| ---------------------------- | ------------------------------------------------------------- |
|
||||
| pnpm test / pnpm test:unit | 全部现存客户端回归,没有SSR排除或skip配置 |
|
||||
| `pnpm test:related <源文件>` | 同一客户端范围下的静态依赖辅助筛选 |
|
||||
| pnpm typecheck | 源码/工作区类型,不代替发布类型 |
|
||||
| pnpm build:docs | 库、样式与文档站静态构建,保留文档渲染要求,不视为组件SSR支持 |
|
||||
| pnpm build:playground | 浏览器验证入口生产构建 |
|
||||
|
||||
vitest.config.ts统一范围,直接调用vitest也生效:排除`*ssr.test.ts`、`*hydration.test.ts`,并按用例全名排除SSR/hydrat历史场景。混合文件的其他客户端用例继续执行。范围排除会显示skipped,不是这些功能通过。已移除test:ssr命令,不新增同类专项,也不为维持旧SSR兼容而改运行时。将来只有用户明确重新启用时再决定恢复验证方案。
|
||||
现有86个测试文件包含1266项客户端用例,默认全部运行;不再维护SSR排除规则或相关命令。逐像素自动对比、完整读屏矩阵、真机矩阵、Nuxt集成暂不投入。
|
||||
|
||||
不新增普遍服务端、无document运行、ID水合稳定、Teleport服务端、Nuxt服务端适配等验收要求。NodeNext是发布类型解析模式,不代表要求SSR支持。
|
||||
|
||||
@@ -44,4 +44,8 @@ vitest.config.ts统一范围,直接调用vitest也生效:排除`*ssr.test.ts
|
||||
|
||||
## 新增与整理测试
|
||||
|
||||
先检查同一行为是否已有断言。修复时优先补到对应组件或基础协议套件;独立且有必要的场景才新建文件,以能力命名,不按“review-第几轮”新增。历史probe逐步随组件维护归并;删除前必须给出等价覆盖位置,不能通过减少期望、skip或删除反例掩盖客户端回归。用户明确移出范围的历史SSR例外由统一配置排除,不改为通过状态。共享夹具只在真实重复已确认时提取,不建立另一层测试框架。
|
||||
先检查同一行为是否已有断言。修复时优先补到对应组件或基础协议套件;独立且有必要的场景才新建文件,以能力命名,不按“review-第几轮”新增。历史probe逐步随组件维护归并;删除前必须给出等价覆盖位置,不能通过减少期望、skip或删除反例掩盖客户端回归。用户已明确移出范围的SSR历史代码已删除,不作为客户端覆盖要求。共享夹具只在真实重复已确认时提取,不建立另一层测试框架。
|
||||
|
||||
## 返修回归位置
|
||||
|
||||
20份历史review/probe/takeover/fidelity套件已按能力移入tests/regressions:toast-table、menu-dropdown、collection、overlay、color、toolbar、button-toggle、navigation-otp。文件以行为命名;断言原样保留,未来修复优先补到对应能力目录。不因减少文件数量而合并隔离的cleanup生命周期,不把本轮归组描述为重复断言已删除。
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, h, type Component } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { CalendarDate } from "@internationalized/date";
|
||||
import {
|
||||
Calendar,
|
||||
CalendarGrid,
|
||||
CalendarGridHeader,
|
||||
CalendarGridBody,
|
||||
} from "../packages/vue/src/index";
|
||||
import { defineComponent, h, type Component } from "vue";
|
||||
const demos = import.meta.glob("../apps/docs/demos/calendar-*.vue", {
|
||||
eager: true,
|
||||
import: "default",
|
||||
@@ -38,29 +30,3 @@ it("mounts all nineteen baseline demos together without duplicate IDs or Vue war
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
});
|
||||
it("hydrates an explicitly dated calendar without replacing the server grid", async () => {
|
||||
const Root = defineComponent({
|
||||
render: () =>
|
||||
h(
|
||||
Calendar,
|
||||
{
|
||||
defaultFocusedValue: new CalendarDate(2024, 2, 10),
|
||||
locale: "en-US",
|
||||
timeZone: "UTC",
|
||||
},
|
||||
() =>
|
||||
h(CalendarGrid, () => [h(CalendarGridHeader), h(CalendarGridBody)]),
|
||||
),
|
||||
});
|
||||
const host = document.createElement("div");
|
||||
host.innerHTML = await renderToString(createSSRApp(Root));
|
||||
document.body.append(host);
|
||||
const grid = host.querySelector("table");
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const app = createSSRApp(Root);
|
||||
app.mount(host);
|
||||
await flushPromises();
|
||||
expect(host.querySelector("table")).toBe(grid);
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
app.unmount();
|
||||
});
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { expect, it } from "vitest";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { CalendarDate } from "@internationalized/date";
|
||||
import {
|
||||
Calendar,
|
||||
CalendarHeader,
|
||||
CalendarHeading,
|
||||
CalendarGrid,
|
||||
CalendarGridHeader,
|
||||
CalendarGridBody,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
} from "../packages/vue/src/index";
|
||||
it("renders month and year markup without browser globals and stable explicit dates", async () => {
|
||||
const value = new CalendarDate(2024, 2, 29);
|
||||
const app = createSSRApp({
|
||||
render: () =>
|
||||
h(
|
||||
Calendar,
|
||||
{
|
||||
defaultValue: value,
|
||||
defaultFocusedValue: value,
|
||||
locale: "en-US",
|
||||
timeZone: "UTC",
|
||||
},
|
||||
() => [
|
||||
h(CalendarHeader, () => h(CalendarHeading)),
|
||||
h(CalendarGrid, () => [h(CalendarGridHeader), h(CalendarGridBody)]),
|
||||
h(CalendarYearPickerGrid, () => h(CalendarYearPickerGridBody)),
|
||||
],
|
||||
),
|
||||
});
|
||||
const html = await renderToString(app);
|
||||
expect(html).toContain('data-date="2024-02-29"');
|
||||
expect(html).toContain('data-selected="true"');
|
||||
expect(html).toContain("February 2024");
|
||||
expect(html).toContain("inert");
|
||||
});
|
||||
it("renders the actual non-Gregorian weekday/month view and day windows on the server", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(
|
||||
Calendar,
|
||||
{
|
||||
defaultFocusedValue: new CalendarDate(2024, 2, 10),
|
||||
locale: "hi-IN-u-ca-indian",
|
||||
visibleDuration: { days: 3 },
|
||||
selectionAlignment: "start",
|
||||
},
|
||||
() =>
|
||||
h(CalendarGrid, () => [h(CalendarGridHeader), h(CalendarGridBody)]),
|
||||
),
|
||||
}),
|
||||
);
|
||||
expect(html.match(/data-slot="calendar-cell"/g) ?? []).toHaveLength(3);
|
||||
expect(html).toContain("2024-02-10");
|
||||
expect(html).not.toContain("Sunday");
|
||||
});
|
||||
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, h, nextTick, ref } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, h, nextTick, ref } from "vue";
|
||||
import {
|
||||
Checkbox,
|
||||
CheckboxContent,
|
||||
@@ -401,45 +400,6 @@ for (const kind of ["checkbox", "radio"] as const) {
|
||||
expect(new FormData(two).getAll("new")).toEqual(["a"]);
|
||||
w.unmount();
|
||||
});
|
||||
it("renders and hydrates complete SSR associations and default selection", async () => {
|
||||
const view = defineComponent({
|
||||
render: () =>
|
||||
group(kind, {
|
||||
name: "choices",
|
||||
defaultValue: kind === "checkbox" ? ["b"] : "b",
|
||||
isRequired: true,
|
||||
validationBehavior: "aria",
|
||||
}),
|
||||
});
|
||||
const host = document.createElement("div");
|
||||
host.innerHTML = await renderToString(createSSRApp(view));
|
||||
document.body.append(host);
|
||||
const ids = [...host.querySelectorAll("[id]")].map((el) => el.id);
|
||||
for (const el of host.querySelectorAll(
|
||||
"[aria-describedby],[aria-labelledby]",
|
||||
))
|
||||
for (const attr of ["aria-describedby", "aria-labelledby"])
|
||||
for (const id of el.getAttribute(attr)?.split(" ") ?? [])
|
||||
expect(ids).toContain(id);
|
||||
const error = vi.spyOn(console, "error"),
|
||||
warn = vi.spyOn(console, "warn"),
|
||||
app = createSSRApp(view);
|
||||
try {
|
||||
app.mount(host);
|
||||
await tick();
|
||||
expect(error).not.toHaveBeenCalled();
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
expect(
|
||||
host.querySelectorAll<HTMLInputElement>("input[data-choice-input]")[1]
|
||||
.checked,
|
||||
).toBe(true);
|
||||
} finally {
|
||||
app.unmount();
|
||||
host.remove();
|
||||
error.mockRestore();
|
||||
warn.mockRestore();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
it("handles radio arrows, RTL, disabled skipping and caller cancellation", async () => {
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createSSRApp, defineComponent, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import Foundation from "../packages/vue/tests/fixtures/CollectionFoundation.vue";
|
||||
import SelectFoundation from "../packages/vue/tests/fixtures/SelectFoundation.vue";
|
||||
import { useCollectionRegistry } from "../packages/vue/src/components/collection/registry";
|
||||
import { useCollectionSelection } from "../packages/vue/src/components/collection/selection";
|
||||
|
||||
describe("collection foundation in real node SSR", () => {
|
||||
it("renders typed selection without browser globals", async () => {
|
||||
expect(typeof window).toBe("undefined");
|
||||
const html = await renderToString(
|
||||
createSSRApp(Foundation, { multiple: true, modelValue: [0] }),
|
||||
);
|
||||
expect(html).toContain('role="listbox"');
|
||||
expect(html.match(/aria-selected="true"/g)).toHaveLength(1);
|
||||
expect(html.match(/role="option"/g)).toHaveLength(3);
|
||||
});
|
||||
|
||||
it("keeps instance registries isolated with no DOM access", async () => {
|
||||
const Component = defineComponent({
|
||||
setup() {
|
||||
const registry = useCollectionRegistry();
|
||||
registry.register({
|
||||
key: () => 0,
|
||||
element: () => undefined,
|
||||
textValue: () => "Zero",
|
||||
disabled: () => false,
|
||||
});
|
||||
const state = useCollectionSelection({
|
||||
mode: () => "single",
|
||||
controlled: () => false,
|
||||
value: () => undefined,
|
||||
defaultValue: [0],
|
||||
onChange: () => {},
|
||||
});
|
||||
return () =>
|
||||
h("output", `${registry.ordered().length}:${state.keys.value[0]}`);
|
||||
},
|
||||
});
|
||||
const html = await renderToString(
|
||||
createSSRApp({ render: () => h("main", [h(Component), h(Component)]) }),
|
||||
);
|
||||
expect(html).toBe("<main><output>1:0</output><output>1:0</output></main>");
|
||||
});
|
||||
|
||||
it("records that raw closed Select cannot SSR its selected item label", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp(SelectFoundation, { defaultValue: 0, name: "choice" }),
|
||||
);
|
||||
expect(html).toContain('role="combobox"');
|
||||
expect(html).not.toContain("Numeric zero");
|
||||
// ItemText registers options on mount; SSR cannot discover closed descendants.
|
||||
expect(html).not.toContain('<option value="0"');
|
||||
});
|
||||
|
||||
it("records the raw Select empty-string key restriction", async () => {
|
||||
const warn = console.warn;
|
||||
console.warn = () => {};
|
||||
try {
|
||||
await expect(
|
||||
renderToString(
|
||||
createSSRApp(SelectFoundation, { includeEmpty: true, open: true }),
|
||||
),
|
||||
).rejects.toThrow("empty string");
|
||||
} finally {
|
||||
console.warn = warn;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,50 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { createSSRApp, defineComponent } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import ColorField from "../packages/vue/src/components/color-field/ColorField.vue";
|
||||
import ColorInputGroup from "../packages/vue/src/components/color-field/ColorInputGroup.vue";
|
||||
import ColorInputGroupInput from "../packages/vue/src/components/color-field/ColorInputGroupInput.vue";
|
||||
import { Label, Description, FieldError } from "../packages/vue/src/index";
|
||||
const components = {
|
||||
ColorField,
|
||||
ColorInputGroup,
|
||||
ColorInputGroupInput,
|
||||
Label,
|
||||
Description,
|
||||
FieldError,
|
||||
};
|
||||
async function html(template: string) {
|
||||
return renderToString(
|
||||
createSSRApp(defineComponent({ components, template })),
|
||||
);
|
||||
}
|
||||
describe("composed color field actual Node SSR", () => {
|
||||
it("plans an explicit leaf id before the preceding native label and field descriptions", async () => {
|
||||
const result = await html(
|
||||
'<ColorField name="color" default-value="#123456"><Label>Color</Label><ColorInputGroup><ColorInputGroupInput id="native"/></ColorInputGroup><Description>Hint</Description></ColorField>',
|
||||
);
|
||||
expect(result).toContain('for="native"');
|
||||
expect(result).toContain('id="native"');
|
||||
expect(result).toContain("aria-describedby=");
|
||||
expect(result.match(/name="color"/g)).toHaveLength(1);
|
||||
expect(result).toContain('value="#123456"');
|
||||
});
|
||||
it("uses percent display and numeric form scale with one name, without browser globals", async () => {
|
||||
const result = await html(
|
||||
'<ColorField name="saturation" channel="saturation" color-space="hsb" default-value="hsb(270,50%,50%)"><ColorInputGroup><ColorInputGroupInput/></ColorInputGroup></ColorField>',
|
||||
);
|
||||
expect(result).toContain('value="50%"');
|
||||
expect(result).toContain('value="0.5"');
|
||||
expect(result.match(/name="saturation"/g)).toHaveLength(1);
|
||||
expect(result).toContain('aria-label="saturation"');
|
||||
});
|
||||
it("keeps standalone group native attributes and excludes disabled channel submission", async () => {
|
||||
const result = await html(
|
||||
'<main><ColorInputGroup><ColorInputGroupInput name="text" default-value="plain" autocomplete="username"/></ColorInputGroup><ColorField name="alpha" channel="alpha" is-disabled default-value="#123456"><ColorInputGroup><ColorInputGroupInput/></ColorInputGroup></ColorField></main>',
|
||||
);
|
||||
expect(result).toContain('value="plain"');
|
||||
expect(result).toContain('autocomplete="username"');
|
||||
expect(result).toContain('name="alpha" disabled');
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, it, expect, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, shallowRef } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, shallowRef } from "vue";
|
||||
import ColorField from "../packages/vue/src/components/color-field/ColorField.vue";
|
||||
import ColorInputGroup from "../packages/vue/src/components/color-field/ColorInputGroup.vue";
|
||||
import ColorInputGroupInput from "../packages/vue/src/components/color-field/ColorInputGroupInput.vue";
|
||||
@@ -330,28 +329,6 @@ describe("color field composed protocol", () => {
|
||||
w.get("[data-slot=color-input-group]").attributes("data-focus-within"),
|
||||
).toBe("true");
|
||||
});
|
||||
it("hydrates prepared leaf ID and all real associations without replacing nodes", async () => {
|
||||
const App = defineComponent({
|
||||
components,
|
||||
template: `<main>${field('default-value="#123456"', 'id="leaf"')}${field('channel="saturation" color-space="hsb" default-value="hsb(270,50%,50%)"', 'id="percent"')}</main>`,
|
||||
});
|
||||
const container = document.createElement("div");
|
||||
container.innerHTML = await renderToString(createSSRApp(App));
|
||||
document.body.append(container);
|
||||
expect(container.querySelector("label")?.htmlFor).toBe("leaf");
|
||||
const nodes = [...container.querySelectorAll("input")];
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {}),
|
||||
error = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
const app = createSSRApp(App);
|
||||
app.mount(container);
|
||||
await flushPromises();
|
||||
expect([...container.querySelectorAll("input")]).toEqual(nodes);
|
||||
const ids = [...container.querySelectorAll("[id]")].map((n) => n.id);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
expect(error).not.toHaveBeenCalled();
|
||||
app.unmount();
|
||||
});
|
||||
});
|
||||
describe("color field ownership and native boundaries", () => {
|
||||
it("switches channel/name mode with only one successful named input", async () => {
|
||||
@@ -490,17 +467,6 @@ describe("color field draft validation and step grid", () => {
|
||||
expect(data(empty)).toEqual(["0"]);
|
||||
});
|
||||
});
|
||||
it("keeps Group scoped slot state reactive while planning the native label before SSR", async () => {
|
||||
const w = view(
|
||||
"<ColorField default-value=\"#123456\"><Label>Hover color</Label><ColorInputGroup v-slot=\"{isHovered}\"><ColorInputGroupInput :id=\"isHovered?'hover-input':'rest-input'\"/><Suffix>{{isHovered?'hover':'rest'}}</Suffix></ColorInputGroup></ColorField>",
|
||||
);
|
||||
expect(w.get("label").attributes("for")).toBe("rest-input");
|
||||
expect(w.get("[data-slot=color-input-group-suffix]").text()).toBe("rest");
|
||||
await w.get("[data-slot=color-input-group]").trigger("pointerenter");
|
||||
expect(w.get("[data-slot=color-input-group-suffix]").text()).toBe("hover");
|
||||
expect(input(w).attributes("id")).toBe("hover-input");
|
||||
expect(w.get("label").attributes("for")).toBe("hover-input");
|
||||
});
|
||||
it("refreshes root ARIA and native listeners even when only fallthrough attrs change", async () => {
|
||||
const invalid = shallowRef(false),
|
||||
label = shallowRef("first label"),
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { createSSRApp, defineComponent, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import Picker from "../packages/vue/tests/fixtures/ColorPickerFoundation.vue";
|
||||
import Area from "../packages/vue/tests/fixtures/ColorAreaFoundation.vue";
|
||||
import { parseColor } from "../packages/vue/src/components/color/value";
|
||||
describe("private color foundation actual Node SSR", () => {
|
||||
it("renders accepted polar values, two native axes and one submission without browser globals", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp(
|
||||
defineComponent({
|
||||
render: () =>
|
||||
h(Picker, {
|
||||
defaultValue: parseColor("hsb(270,0%,50%,.5)"),
|
||||
name: "color",
|
||||
}),
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(html).toContain("hsba(270, 0%, 50%, 0.5)");
|
||||
expect(html).toContain('aria-label="saturation"');
|
||||
expect(html).toContain('aria-label="brightness"');
|
||||
expect(html.match(/name="color"/g)).toHaveLength(1);
|
||||
expect(html).not.toContain('role="application"');
|
||||
});
|
||||
it("renders a swapped hue axis and RGB area deterministically", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp(
|
||||
defineComponent({
|
||||
render: () =>
|
||||
h("main", [
|
||||
h(Area, {
|
||||
defaultValue: "hsb(240,50%,50%)",
|
||||
xChannel: "brightness",
|
||||
yChannel: "hue",
|
||||
colorSpace: "hsb",
|
||||
}),
|
||||
h(Area, {
|
||||
defaultValue: "#123456",
|
||||
colorSpace: "rgb",
|
||||
dir: "rtl",
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(html).toContain("background-blend-mode:screen");
|
||||
expect(html).toContain("linear-gradient(to top, rgb");
|
||||
expect(html).not.toContain("NaN");
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, it, expect, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { defineComponent, shallowRef, createSSRApp } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, shallowRef } from "vue";
|
||||
import Area from "../packages/vue/tests/fixtures/ColorAreaFoundation.vue";
|
||||
import Picker from "../packages/vue/tests/fixtures/ColorPickerFoundation.vue";
|
||||
import {
|
||||
@@ -542,24 +541,4 @@ describe("private color area pointer ownership", () => {
|
||||
expect(color.toString("hsba")).toBe("hsba(240, 50%, 50%, 0.5)");
|
||||
expect(color.formatChannelValue("alpha", "en-US")).toBe("50%");
|
||||
});
|
||||
it("hydrates actual multiple picker nodes without replacing them or sharing IDs", async () => {
|
||||
const App = defineComponent({
|
||||
components: { Picker },
|
||||
template: "<main><Picker/><Picker/></main>",
|
||||
});
|
||||
const html = await renderToString(createSSRApp(App));
|
||||
const container = document.createElement("div");
|
||||
container.innerHTML = html;
|
||||
document.body.append(container);
|
||||
const before = container.querySelector("[data-color-area]");
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const app = createSSRApp(App);
|
||||
app.mount(container);
|
||||
await flushPromises();
|
||||
expect(container.querySelector("[data-color-area]")).toBe(before);
|
||||
const ids = [...container.querySelectorAll("[id]")].map((e) => e.id);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
app.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { createSSRApp, defineComponent } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import Input from "../packages/vue/tests/fixtures/ColorInputFoundation.vue";
|
||||
import Picker from "../packages/vue/tests/fixtures/ColorPickerFoundation.vue";
|
||||
describe("private color inputs actual Node SSR", () => {
|
||||
it("renders localized text and exact fractional native channel without browser globals", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp(
|
||||
defineComponent({
|
||||
components: { Input, Picker },
|
||||
template:
|
||||
'<Picker default-value="hsb(270,0%,50%,.12345)" v-slot><Input channel="alpha" locale="de-DE" name="alpha"/><Input mode="range" channel="hue" name="hue"/></Picker>',
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(html).toContain('value="12,345"');
|
||||
expect(html).toContain('value="0.12345"');
|
||||
expect(html).toContain('value="270"');
|
||||
expect(html).toContain('aria-valuetext="270°"');
|
||||
expect(html.match(/name="alpha"/g)).toHaveLength(1);
|
||||
expect(html).not.toContain("NaN");
|
||||
});
|
||||
it("renders empty fields and native validation association deterministically", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp(
|
||||
defineComponent({
|
||||
components: { Input },
|
||||
template:
|
||||
'<Input name="color" form="external" is-required aria-label="Required color"/>',
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(html).toContain('aria-required="true"');
|
||||
expect(html).toContain('form="external"');
|
||||
expect(html).toContain('value=""');
|
||||
});
|
||||
});
|
||||
@@ -1,13 +1,12 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { defineComponent, shallowRef, createSSRApp } from "vue";
|
||||
import { defineComponent, shallowRef } from "vue";
|
||||
import Input from "../packages/vue/tests/fixtures/ColorInputFoundation.vue";
|
||||
import Picker from "../packages/vue/tests/fixtures/ColorPickerFoundation.vue";
|
||||
import Area from "../packages/vue/tests/fixtures/ColorAreaFoundation.vue";
|
||||
import { Color, parseColor } from "../packages/vue/src/components/color/value";
|
||||
import { colorChannel } from "../packages/vue/src/components/color/channel";
|
||||
import { parseColorNumber } from "../packages/vue/src/components/color/text";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { Form } from "../packages/vue/src/index";
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
afterEach(() => {
|
||||
@@ -359,42 +358,3 @@ describe("color input lifecycle integration", () => {
|
||||
expect(w.getComponent(Picker).emitted("changeEnd")).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("color inputs hydration and precision", () => {
|
||||
it("does not quantize an untouched formatted alpha draft", async () => {
|
||||
const w = fixture(
|
||||
'<Input channel="alpha" default-value="hsb(270,0%,50%,.123456789012345)"/>',
|
||||
);
|
||||
await input(w).trigger("keydown", { key: "Enter" });
|
||||
expect(changes(w)).toHaveLength(0);
|
||||
});
|
||||
it("hydrates stable actual inputs, native values and IDs", async () => {
|
||||
const App = defineComponent({
|
||||
components: { Input, Picker },
|
||||
template:
|
||||
'<main><Picker default-value="hsb(270,0%,50%,.125)" v-slot><Input channel="alpha" locale="de-DE"/><Input mode="range" channel="hue"/></Picker><Input default-value="#123456"/></main>',
|
||||
});
|
||||
const container = document.createElement("div");
|
||||
container.innerHTML = await renderToString(createSSRApp(App));
|
||||
document.body.append(container);
|
||||
const nodes = [...container.querySelectorAll("[data-color-input]")];
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const error = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
const app = createSSRApp(App);
|
||||
app.mount(container);
|
||||
await flushPromises();
|
||||
expect([...container.querySelectorAll("[data-color-input]")]).toEqual(
|
||||
nodes,
|
||||
);
|
||||
expect(nodes.map((n) => (n as HTMLInputElement).value)).toEqual([
|
||||
"12,5",
|
||||
"270",
|
||||
"#123456",
|
||||
]);
|
||||
const ids = [...container.querySelectorAll("[id]")].map((n) => n.id);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
expect(error).not.toHaveBeenCalled();
|
||||
app.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { afterEach, beforeEach, describe, it, expect, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { defineComponent, shallowRef, createSSRApp } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, shallowRef } from "vue";
|
||||
import Picker from "../packages/vue/tests/fixtures/ColorPickerComposition.vue";
|
||||
import { parseColor, Color } from "../packages/vue/src/components/color/value";
|
||||
import { serializeColorValue } from "../packages/vue/src/components/color/submission";
|
||||
@@ -231,25 +230,4 @@ describe("private color owner and Popover composition", () => {
|
||||
expect(values(w)).toEqual([]);
|
||||
expect(w.get("button").element.disabled).toBe(true);
|
||||
});
|
||||
it("hydrates closed owners with one stable submission and no popup duplication", async () => {
|
||||
const App = defineComponent({
|
||||
components: { Picker },
|
||||
template: '<main><Picker name="first"/><Picker name="second"/></main>',
|
||||
});
|
||||
const container = document.createElement("div");
|
||||
container.innerHTML = await renderToString(createSSRApp(App));
|
||||
document.body.append(container);
|
||||
const nodes = [...container.querySelectorAll("input")];
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {}),
|
||||
error = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
const app = createSSRApp(App);
|
||||
app.mount(container);
|
||||
await flushPromises();
|
||||
expect([...container.querySelectorAll("input")]).toEqual(nodes);
|
||||
const ids = [...container.querySelectorAll("[id]")].map((n) => n.id);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
expect(error).not.toHaveBeenCalled();
|
||||
app.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { it, expect } from "vitest";
|
||||
import { createSSRApp, defineComponent } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import Picker from "../packages/vue/src/components/color-picker/ColorPicker.vue";
|
||||
import Trigger from "../packages/vue/src/components/color-picker/ColorPickerTrigger.vue";
|
||||
import Panel from "../packages/vue/src/components/color-picker/ColorPickerPopover.vue";
|
||||
const components = { Picker, Trigger, Panel };
|
||||
it("renders closed Picker SSR without browser globals or premature popup markup", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp(
|
||||
defineComponent({
|
||||
components,
|
||||
template:
|
||||
'<Picker v-slot="{color}" name="color"><Trigger aria-label="Choose">{{color.toString("hex")}}</Trigger><Panel aria-label="Color">Popup</Panel></Picker>',
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(html).toContain("#000000");
|
||||
expect(html).toContain('data-slot="color-picker-trigger"');
|
||||
expect(html).toContain('aria-expanded="false"');
|
||||
expect(html).not.toContain('role="dialog"');
|
||||
expect(html.match(/name="color"/g)).toHaveLength(1);
|
||||
expect(html).toContain('value="rgba(0, 0, 0, 1)"');
|
||||
});
|
||||
it("keeps Picker state isolated across server requests and strips disabled submission", async () => {
|
||||
const render = (value: string) =>
|
||||
renderToString(
|
||||
createSSRApp(
|
||||
defineComponent({
|
||||
components,
|
||||
template: `<Picker default-value="${value}" is-disabled name="color"><Trigger>Choose</Trigger></Picker>`,
|
||||
}),
|
||||
),
|
||||
);
|
||||
const [red, blue] = await Promise.all([render("#ff0000"), render("#0000ff")]);
|
||||
expect(red).toContain('value="rgba(255, 0, 0, 1)"');
|
||||
expect(blue).toContain('value="rgba(0, 0, 255, 1)"');
|
||||
expect(red).toMatch(/<input[^>]*disabled/);
|
||||
expect(blue).toMatch(/<button[^>]*disabled/);
|
||||
});
|
||||
@@ -1,40 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { createSSRApp, defineComponent } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import Slider from "../packages/vue/tests/fixtures/ColorSliderFoundation.vue";
|
||||
import Picker from "../packages/vue/tests/fixtures/ColorPickerComposition.vue";
|
||||
describe("private custom color track and picker actual Node SSR", () => {
|
||||
it("renders direction, gradient, native value and accepted thumb consistently without layout globals", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp(
|
||||
defineComponent({
|
||||
components: { Slider },
|
||||
template:
|
||||
'<Slider channel="alpha" name="alpha" orientation="vertical" dir="rtl" default-value="hsba(270,0%,50%,.12345)" aria-label="Alpha"/>',
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(html).toContain('value="0.12345"');
|
||||
expect(html).toContain("top:87.655%");
|
||||
expect(html).toContain('aria-orientation="vertical"');
|
||||
expect(html).toContain("linear-gradient(to top");
|
||||
expect(html.match(/name="alpha"/g)).toHaveLength(1);
|
||||
expect(html).not.toContain("NaN");
|
||||
});
|
||||
it("renders a single exact owner submission while closed, without popup controls", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp(
|
||||
defineComponent({
|
||||
components: { Picker },
|
||||
template:
|
||||
'<Picker name="color" default-value="hsba(270,0%,50%,.123456789012345)"/>',
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(html).toContain('value="hsba(270, 0%, 50%, 0.123456789012345)"');
|
||||
expect(html.match(/name="color"/g)).toHaveLength(1);
|
||||
expect(html).toContain('aria-expanded="false"');
|
||||
expect(html).not.toContain("data-color-slider-track");
|
||||
});
|
||||
});
|
||||
@@ -1,45 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { expect, it } from "vitest";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { parseZonedDateTime } from "@internationalized/date";
|
||||
import {
|
||||
DateField,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
Label,
|
||||
Description,
|
||||
} from "../packages/vue/src";
|
||||
it("renders public DateField and complete ISO values on Node with stable, unique field associations", async () => {
|
||||
expect(typeof window).toBe("undefined");
|
||||
const date = parseZonedDateTime(
|
||||
"2024-03-10T01:30:45-08:00[America/Los_Angeles]",
|
||||
);
|
||||
const field = () =>
|
||||
h(
|
||||
DateField,
|
||||
{
|
||||
defaultValue: date,
|
||||
name: "date",
|
||||
granularity: "minute",
|
||||
locale: "en-US",
|
||||
},
|
||||
() => [
|
||||
h(Label, () => "Date"),
|
||||
h(DateFieldGroup, () => h(DateFieldInput)),
|
||||
h(Description, () => "Help"),
|
||||
],
|
||||
);
|
||||
const app = () =>
|
||||
createSSRApp({ render: () => h("form", [field(), field()]) });
|
||||
const html = await renderToString(app());
|
||||
expect(html).toBe(await renderToString(app()));
|
||||
expect(html.match(/name="date"/g)).toHaveLength(2);
|
||||
expect(
|
||||
html.match(/value="2024-03-10T01:30:45-08:00\[America\/Los_Angeles\]"/g),
|
||||
).toHaveLength(2);
|
||||
const ids = [...html.matchAll(/ id="([^"]+)"/g)].map((match) => match[1]);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
expect(html).toContain("aria-labelledby=");
|
||||
expect(html).toContain("aria-describedby=");
|
||||
});
|
||||
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, ref } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, ref } from "vue";
|
||||
import {
|
||||
CalendarDate,
|
||||
CalendarDateTime,
|
||||
@@ -231,28 +230,6 @@ describe("DateField", () => {
|
||||
expect(part(w, "second").text()).toBe("05");
|
||||
expect(values(w)).toEqual(["2024-02-03T13:04:05"]);
|
||||
});
|
||||
it("hydrates explicit date content with unique IDs and stable nodes", async () => {
|
||||
const component = defineComponent({
|
||||
components,
|
||||
setup: () => ({ initial }),
|
||||
template: `<DateField :default-value="initial">${content}</DateField>`,
|
||||
});
|
||||
const host = document.createElement("div");
|
||||
host.innerHTML = await renderToString(createSSRApp(component));
|
||||
document.body.append(host);
|
||||
const before = host.querySelector('[data-type="day"]');
|
||||
const warnings: string[] = [];
|
||||
const app = createSSRApp(component);
|
||||
app.config.warnHandler = (message) => warnings.push(message);
|
||||
app.mount(host);
|
||||
await flushPromises();
|
||||
try {
|
||||
expect(warnings).toEqual([]);
|
||||
expect(host.querySelector('[data-type="day"]')).toBe(before);
|
||||
} finally {
|
||||
app.unmount();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("applies min/max and unavailable constraints to the shared native validator", async () => {
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { CalendarDate, parseZonedDateTime } from "@internationalized/date";
|
||||
import Field from "../packages/vue/tests/fixtures/DateFieldFoundation.vue";
|
||||
import Calendar from "../packages/vue/tests/fixtures/CalendarFoundation.vue";
|
||||
import Accepted from "../packages/vue/tests/fixtures/AcceptedDateFieldFoundation.vue";
|
||||
const initial = new CalendarDate(2024, 2, 10);
|
||||
describe("date foundation actual node SSR", () => {
|
||||
it("renders full segmented date without browser globals", async () => {
|
||||
expect(typeof window).toBe("undefined");
|
||||
const html = await renderToString(
|
||||
createSSRApp(Field, {
|
||||
defaultValue: initial,
|
||||
locale: "en-US",
|
||||
name: "date",
|
||||
}),
|
||||
);
|
||||
expect(html.match(/role="spinbutton"/g)).toHaveLength(3);
|
||||
expect(html).toContain('value="2024-02-10"');
|
||||
expect(html).toContain('aria-label="Date audit"');
|
||||
});
|
||||
it("renders leap month cells and selected date on the server", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp(Calendar, {
|
||||
defaultValue: initial,
|
||||
defaultPlaceholder: initial,
|
||||
locale: "en-US",
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('data-value="2024-02-29"');
|
||||
expect(html).toContain('data-selected="true"');
|
||||
// Installed CalendarGrid uses application, not grid; public ARIA needs explicit review.
|
||||
expect(html).toContain('role="application"');
|
||||
expect(html).toContain('role="gridcell"');
|
||||
});
|
||||
it("keeps SSR IDs stable and independent across same-page instances", async () => {
|
||||
const app = () =>
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h("main", [
|
||||
h(Field, { defaultValue: initial }),
|
||||
h(Field, { defaultValue: initial }),
|
||||
]),
|
||||
});
|
||||
const first = await renderToString(app());
|
||||
expect(first).toBe(await renderToString(app()));
|
||||
const ids = [...first.matchAll(/ id="([^"]+)"/g)].map((m) => m[1]);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
});
|
||||
it("serializes the adapted complete zone-bearing model on SSR", async () => {
|
||||
const value = parseZonedDateTime(
|
||||
"2024-03-10T01:30:45-08:00[America/Los_Angeles]",
|
||||
);
|
||||
const html = await renderToString(
|
||||
createSSRApp(Accepted, { defaultValue: value, name: "date" }),
|
||||
);
|
||||
expect(html).toContain(
|
||||
'type="hidden" name="date" value="2024-03-10T01:30:45-08:00[America/Los_Angeles]"',
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, it, expect } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, ref } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, ref } from "vue";
|
||||
import { CalendarDate, parseZonedDateTime } from "@internationalized/date";
|
||||
import Field from "../packages/vue/tests/fixtures/AcceptedDateFieldFoundation.vue";
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
@@ -127,31 +126,6 @@ it("omits disabled native values", () => {
|
||||
);
|
||||
expect(data(w)).toEqual([]);
|
||||
});
|
||||
it("hydrates the accepted date and segment identities without mismatch", async () => {
|
||||
const Component = defineComponent({
|
||||
components: { Field },
|
||||
setup: () => ({ initial }),
|
||||
template: '<Field :default-value="initial" name="date"/>',
|
||||
});
|
||||
const host = document.createElement("div");
|
||||
host.innerHTML = await renderToString(createSSRApp(Component));
|
||||
document.body.append(host);
|
||||
const before = host.querySelector('[data-reka-date-field-segment="day"]');
|
||||
const warnings: string[] = [];
|
||||
const app = createSSRApp(Component);
|
||||
app.config.warnHandler = (message) => warnings.push(message);
|
||||
app.mount(host);
|
||||
await flushPromises();
|
||||
try {
|
||||
expect(warnings).toEqual([]);
|
||||
expect(host.querySelector('[data-reka-date-field-segment="day"]')).toBe(
|
||||
before,
|
||||
);
|
||||
expect(before?.textContent).toBe("10");
|
||||
} finally {
|
||||
app.unmount();
|
||||
}
|
||||
});
|
||||
|
||||
it("preserves partial drafts but clears a completed rejected empty proposal without losing focus", async () => {
|
||||
const w = fixture(
|
||||
|
||||
@@ -322,30 +322,6 @@ describe("shared text fields", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("hydrates standard field composition without ID or attribute mismatch", async () => {
|
||||
const { createSSRApp } = await import("vue");
|
||||
const { renderToString } = await import("@vue/server-renderer");
|
||||
const app = { render: () => textField({ name: "ssr", isInvalid: true }) };
|
||||
const html = await renderToString(createSSRApp(app));
|
||||
const container = document.createElement("div");
|
||||
container.innerHTML = html;
|
||||
document.body.append(container);
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {}),
|
||||
error = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
const client = createSSRApp(app);
|
||||
client.mount(container);
|
||||
await settle();
|
||||
expect(warn.mock.calls.flat().join(" ")).not.toMatch(/hydration/i);
|
||||
expect(error.mock.calls.flat().join(" ")).not.toMatch(/hydration/i);
|
||||
const control = container.querySelector("input")!;
|
||||
for (const id of control.getAttribute("aria-describedby")!.split(" "))
|
||||
expect(container.querySelector(`[id="${id}"]`)).not.toBeNull();
|
||||
client.unmount();
|
||||
container.remove();
|
||||
warn.mockRestore();
|
||||
error.mockRestore();
|
||||
});
|
||||
|
||||
it("labels an explicit control id and follows dynamic changes", async () => {
|
||||
const id = ref("custom");
|
||||
const w = mount(
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, h, nextTick, ref } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, h, nextTick, ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
CloseButton,
|
||||
@@ -341,30 +340,6 @@ describe("SearchField shared text state", () => {
|
||||
expect((w.get("input").element as HTMLInputElement).value).toBe("keep");
|
||||
w.unmount();
|
||||
});
|
||||
it("supports SSR and hydration with explicit control ID inside group", async () => {
|
||||
const view = defineComponent({
|
||||
render: () =>
|
||||
search({ name: "q", defaultValue: "query" }, { id: "explicit-search" }),
|
||||
});
|
||||
const host = document.createElement("div");
|
||||
host.innerHTML = await renderToString(createSSRApp(view));
|
||||
document.body.append(host);
|
||||
expect(host.querySelector("label")?.htmlFor).toBe("explicit-search");
|
||||
const warn = vi.spyOn(console, "warn"),
|
||||
error = vi.spyOn(console, "error");
|
||||
const app = createSSRApp(view);
|
||||
try {
|
||||
app.mount(host);
|
||||
await settle();
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
expect(error).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
app.unmount();
|
||||
warn.mockRestore();
|
||||
error.mockRestore();
|
||||
host.remove();
|
||||
}
|
||||
});
|
||||
it("updates variant, attrs, event handlers and conditional slots without stale classes", async () => {
|
||||
const attrs = ref<Record<string, unknown>>({}),
|
||||
variant = ref<"primary" | "secondary">("primary"),
|
||||
@@ -499,22 +474,3 @@ it("keeps the baseline preview inventories and exact fieldset submission feedbac
|
||||
);
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
it("plans a grouped leaf's initial search value in SSR and restores the default ID after explicit removal", async () => {
|
||||
const id = ref<string | undefined>("temporary-search");
|
||||
const view = defineComponent({
|
||||
render: () => search({}, { id: id.value, defaultValue: "leaf initial" }),
|
||||
});
|
||||
const html = await renderToString(createSSRApp(view));
|
||||
expect(html).not.toContain('data-empty="true"');
|
||||
expect(html).toContain('value="leaf initial"');
|
||||
const w = mount(view);
|
||||
expect(w.get("label").attributes("for")).toBe("temporary-search");
|
||||
id.value = undefined;
|
||||
await settle();
|
||||
expect(w.get("input").attributes("id")).not.toBe("temporary-search");
|
||||
expect(w.get("input").attributes("id")).toBe(
|
||||
w.get("label").attributes("for"),
|
||||
);
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
+1
-16
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, h, nextTick, ref } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, nextTick, ref } from "vue";
|
||||
import { Header, HeaderRoot } from "../packages/vue/src";
|
||||
|
||||
import HeaderBasicDemo from "../apps/docs/demos/header-basic.vue";
|
||||
@@ -143,17 +142,3 @@ describe("Header types", () => {
|
||||
expect(ok.as).toBe("header");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Header SSR", () => {
|
||||
it("renders without touching browser globals", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () => h(Header, () => "操作"),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain("<header");
|
||||
expect(html).toContain('data-slot="header"');
|
||||
expect(html).toContain("hv-header");
|
||||
expect(html).toContain("操作");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,7 +3,6 @@ import { mount } from "@vue/test-utils";
|
||||
import { defineComponent, h, nextTick, ref } from "vue";
|
||||
import { readFileSync } from "node:fs";
|
||||
import {
|
||||
Description,
|
||||
FieldError,
|
||||
Form,
|
||||
InputGroup,
|
||||
@@ -14,8 +13,6 @@ import {
|
||||
Label,
|
||||
TextField,
|
||||
} from "../packages/vue/src";
|
||||
import { createSSRApp } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import InputGroupDefaultDemo from "../apps/docs/demos/input-group-default.vue";
|
||||
import InputGroupPasswordDemo from "../apps/docs/demos/input-group-password-with-toggle.vue";
|
||||
import InputGroupCopyDemo from "../apps/docs/demos/input-group-with-copy-suffix.vue";
|
||||
@@ -508,52 +505,4 @@ describe("InputGroup independent integration regression", () => {
|
||||
expect(submit).toHaveBeenCalledOnce();
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
it("hydrates explicit IDs and keeps dynamic slots, labels and descriptions current", async () => {
|
||||
const id = ref("group-a");
|
||||
const show = ref(true);
|
||||
const view = defineComponent({
|
||||
render: () =>
|
||||
h(TextField, {}, () => [
|
||||
h(Label, {}, () => "Email"),
|
||||
h(InputGroup, {}, () => [
|
||||
show.value ? h(InputGroupPrefix, {}, () => "@") : null,
|
||||
h(InputGroupInput, { id: id.value }),
|
||||
]),
|
||||
h(Description, {}, () => "Hint"),
|
||||
]),
|
||||
});
|
||||
const host = document.createElement("div");
|
||||
host.innerHTML = await renderToString(createSSRApp(view));
|
||||
document.body.append(host);
|
||||
const errors = vi.spyOn(console, "error");
|
||||
const warnings = vi.spyOn(console, "warn");
|
||||
const app = createSSRApp(view);
|
||||
try {
|
||||
app.mount(host);
|
||||
await settle();
|
||||
expect(host.querySelector("label")?.htmlFor).toBe("group-a");
|
||||
id.value = "group-b";
|
||||
show.value = false;
|
||||
await settle();
|
||||
expect(host.querySelector("label")?.htmlFor).toBe("group-b");
|
||||
expect(host.querySelector("input")?.id).toBe("group-b");
|
||||
expect(host.querySelector("[data-slot=input-group-prefix]")).toBeNull();
|
||||
const refs =
|
||||
host
|
||||
.querySelector("input")
|
||||
?.getAttribute("aria-describedby")
|
||||
?.split(" ") ?? [];
|
||||
expect(refs.length).toBeGreaterThan(0);
|
||||
for (const ref of refs)
|
||||
expect(document.getElementById(ref)).not.toBeNull();
|
||||
expect(errors).not.toHaveBeenCalled();
|
||||
expect(warnings).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
app.unmount();
|
||||
host.remove();
|
||||
errors.mockRestore();
|
||||
warnings.mockRestore();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { expect, it } from "vitest";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import {
|
||||
InputOTP,
|
||||
InputOTPGroup,
|
||||
InputOTPSlot,
|
||||
Label,
|
||||
} from "../packages/vue/src";
|
||||
it("renders composed OTP names on the real native inputs without browser globals", async () => {
|
||||
expect(typeof window).toBe("undefined");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(InputOTP, { maxLength: 2, defaultValue: "12" }, () => [
|
||||
h(Label, { id: "otp-server-label" }, () => "Security code"),
|
||||
h(InputOTPGroup, {}, () => [
|
||||
h(InputOTPSlot, { index: 0 }),
|
||||
h(InputOTPSlot, { index: 1 }),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html.match(/aria-labelledby="otp-server-label"/g)).toHaveLength(2);
|
||||
expect(html).toContain('value="1"');
|
||||
expect(html).toContain('value="2"');
|
||||
expect(html).not.toMatch(/aria-label="pin input/);
|
||||
});
|
||||
+1
-22
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, h, nextTick, ref } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, h, nextTick, ref } from "vue";
|
||||
import {
|
||||
InputOTP,
|
||||
InputOTPGroup,
|
||||
@@ -541,23 +540,3 @@ describe("InputOTP types", () => {
|
||||
expect((bad as { variant?: string }).variant).toBe("ghost");
|
||||
});
|
||||
});
|
||||
|
||||
describe("InputOTP SSR", () => {
|
||||
it("renders without touching browser globals", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(InputOTP, { maxLength: 4, name: "code", defaultValue: "12" }, () =>
|
||||
h(InputOTPGroup, () =>
|
||||
[0, 1, 2, 3].map((i) => h(InputOTPSlot, { index: i })),
|
||||
),
|
||||
),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('data-slot="input-otp"');
|
||||
expect(html).toContain("hv-input-otp");
|
||||
expect(html).toContain('data-slot="input-otp-slot"');
|
||||
expect(html).toContain("1");
|
||||
expect(html).toContain('name="code"');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createSSRApp, defineComponent, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import {
|
||||
ListBox,
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
ListBoxSection,
|
||||
Label,
|
||||
Description,
|
||||
Header,
|
||||
} from "../packages/vue/src";
|
||||
|
||||
describe("ListBox public node SSR", () => {
|
||||
it("renders selection, option names, descriptions and section names without browser globals", async () => {
|
||||
expect(typeof window).toBe("undefined");
|
||||
const app = createSSRApp(
|
||||
defineComponent({
|
||||
render: () =>
|
||||
h(ListBox, { defaultValue: [0], "aria-label": "People" }, () => [
|
||||
h(ListBoxSection, {}, () => [
|
||||
h(Header, {}, () => "Team"),
|
||||
h(ListBoxItem, { id: 0 }, () => [
|
||||
h(Label, {}, () => "Bob"),
|
||||
h(Description, {}, () => "Details"),
|
||||
h(ListBoxItemIndicator),
|
||||
]),
|
||||
]),
|
||||
h(ListBoxItem, { id: "0" }, () => "Fred"),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
const html = await renderToString(app);
|
||||
expect(html).toContain('aria-selected="true"');
|
||||
expect(html).toContain('aria-selected="false"');
|
||||
expect(html).toContain('role="listbox"');
|
||||
expect(html).toContain("aria-describedby=");
|
||||
expect(html).toContain("aria-labelledby=");
|
||||
const ids = [...html.matchAll(/ id="([^"]+)"/g)].map((match) => match[1]);
|
||||
for (const match of html.matchAll(
|
||||
/aria-(?:labelledby|describedby)="([^"]+)"/g,
|
||||
))
|
||||
for (const id of match[1].split(" ")) expect(ids).toContain(id);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
});
|
||||
|
||||
it("isolates keys/IDs across two lists and independent SSR requests", async () => {
|
||||
const app = () =>
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(
|
||||
"main",
|
||||
Array.from({ length: 2 }, () =>
|
||||
h(ListBox, { defaultValue: [""] }, () =>
|
||||
h(ListBoxItem, { id: "" }, () =>
|
||||
h(Label, {}, () => "Empty key"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
});
|
||||
const first = await renderToString(app()),
|
||||
second = await renderToString(app());
|
||||
expect(first).toBe(second);
|
||||
const ids = [...first.matchAll(/ id="([^"]+)"/g)].map((match) => match[1]);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
expect(first.match(/aria-selected="true"/g)).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
+1
-45
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, h, ref } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, h, ref } from "vue";
|
||||
import {
|
||||
ListBox,
|
||||
ListBoxItem,
|
||||
@@ -392,49 +391,6 @@ describe("ListBox public behavior", () => {
|
||||
expect(wrapper.text()).toContain("No results");
|
||||
});
|
||||
|
||||
it("hydrates selected options and label relationships without mismatches", async () => {
|
||||
const Component = defineComponent({
|
||||
render: () =>
|
||||
h(ListBox, { defaultValue: [0] }, () =>
|
||||
h(
|
||||
ListBoxItem,
|
||||
{ id: 0 },
|
||||
{
|
||||
default: () => [
|
||||
h(Label, {}, () => "Bob"),
|
||||
h(Description, {}, () => "Details"),
|
||||
],
|
||||
},
|
||||
),
|
||||
),
|
||||
});
|
||||
const host = document.createElement("div");
|
||||
host.innerHTML = await renderToString(createSSRApp(Component));
|
||||
document.body.append(host);
|
||||
const before = host.querySelector('[role="option"]')!;
|
||||
const beforeId = before.id;
|
||||
const warnings: string[] = [];
|
||||
const app = createSSRApp(Component);
|
||||
app.config.warnHandler = (message) => warnings.push(message);
|
||||
app.mount(host);
|
||||
await flushPromises();
|
||||
try {
|
||||
expect(warnings).toEqual([]);
|
||||
const after = host.querySelector('[role="option"]')!;
|
||||
expect(after).toBe(before);
|
||||
expect(after.id).toBe(beforeId);
|
||||
expect(after.getAttribute("aria-selected")).toBe("true");
|
||||
expect(after.getAttribute("aria-labelledby")).toBe(
|
||||
after.querySelector('[data-slot="label"]')?.id,
|
||||
);
|
||||
expect(after.getAttribute("aria-describedby")).toBe(
|
||||
after.querySelector('[data-slot="description"]')?.id,
|
||||
);
|
||||
} finally {
|
||||
app.unmount();
|
||||
}
|
||||
});
|
||||
|
||||
it("compiles and mounts all nine baseline demos together without warnings or duplicate IDs", async () => {
|
||||
const demos = import.meta.glob("../apps/docs/demos/list-box-*.vue", {
|
||||
eager: true,
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
import { expect, it, vi } from "vitest";
|
||||
import { createSSRApp, h, nextTick } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import {
|
||||
ToastProvider,
|
||||
ToastQueue,
|
||||
Table,
|
||||
TableContent,
|
||||
TableHeader,
|
||||
TableColumn,
|
||||
TableBody,
|
||||
TableRow,
|
||||
TableCell,
|
||||
} from "../packages/vue/src";
|
||||
it("hydrates toast and table with stable content, then keyboard selection works", async () => {
|
||||
let queue = new ToastQueue();
|
||||
queue.add({ title: "Hydrated notice" }, { timeout: 0 });
|
||||
const Root = {
|
||||
render: () =>
|
||||
h("main", [
|
||||
h(ToastProvider, { queue }),
|
||||
h(Table, () =>
|
||||
h(TableContent, { selectionMode: "multiple" }, () => [
|
||||
h(TableHeader, () =>
|
||||
h(TableColumn, { id: "name", isRowHeader: true }, () => "Name"),
|
||||
),
|
||||
h(TableBody, () =>
|
||||
h(TableRow, { rowKey: 0 }, () => h(TableCell, () => "Zero")),
|
||||
),
|
||||
]),
|
||||
),
|
||||
]),
|
||||
};
|
||||
const host = document.createElement("div");
|
||||
document.body.append(host);
|
||||
host.innerHTML = await renderToString(createSSRApp(Root));
|
||||
queue.destroy();
|
||||
queue = new ToastQueue();
|
||||
queue.add({ title: "Hydrated notice" }, { timeout: 0 });
|
||||
const error = vi.spyOn(console, "error"),
|
||||
warn = vi.spyOn(console, "warn");
|
||||
const app = createSSRApp(Root);
|
||||
app.mount(host);
|
||||
await nextTick();
|
||||
expect(
|
||||
[...error.mock.calls, ...warn.mock.calls].flat().join(" "),
|
||||
).not.toMatch(/hydration|mismatch/i);
|
||||
const row = host.querySelector("tbody tr")!;
|
||||
row.dispatchEvent(new KeyboardEvent("keydown", { key: " ", bubbles: true }));
|
||||
await nextTick();
|
||||
expect(row.getAttribute("aria-selected")).toBe("true");
|
||||
app.unmount();
|
||||
queue.destroy();
|
||||
host.remove();
|
||||
error.mockRestore();
|
||||
warn.mockRestore();
|
||||
});
|
||||
@@ -1,70 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { expect, it, vi } from "vitest";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import {
|
||||
ToastProvider,
|
||||
ToastQueue,
|
||||
toast,
|
||||
toastQueue,
|
||||
Table,
|
||||
TableContent,
|
||||
TableHeader,
|
||||
TableColumn,
|
||||
TableBody,
|
||||
TableRow,
|
||||
TableCell,
|
||||
} from "../packages/vue/src";
|
||||
it("shared client toast helper does not retain server-request content", async () => {
|
||||
expect(toast("request secret")).toBe("");
|
||||
expect(toastQueue.visibleToasts).toHaveLength(0);
|
||||
const factory = vi.fn(() => Promise.resolve("secret"));
|
||||
expect(
|
||||
toast.promise(factory, {
|
||||
loading: "Loading",
|
||||
success: (value) => value,
|
||||
error: "Error",
|
||||
}),
|
||||
).toBe("");
|
||||
expect(factory).not.toHaveBeenCalled();
|
||||
expect(
|
||||
await renderToString(createSSRApp({ render: () => h(ToastProvider) })),
|
||||
).not.toContain("request secret");
|
||||
});
|
||||
it("explicit request queues render separately without server countdowns", async () => {
|
||||
const a = new ToastQueue(),
|
||||
b = new ToastQueue();
|
||||
a.add({ title: "Request A" });
|
||||
b.add({ title: "Request B" });
|
||||
const render = (queue: ToastQueue) =>
|
||||
renderToString(createSSRApp({ render: () => h(ToastProvider, { queue }) }));
|
||||
expect(await render(a)).toContain("Request A");
|
||||
expect(await render(b)).not.toContain("Request A");
|
||||
expect(a.visibleToasts[0].timer).toBeUndefined();
|
||||
a.destroy();
|
||||
b.destroy();
|
||||
});
|
||||
it("server table preserves native row-header semantics and accepted numeric selection", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(Table, () =>
|
||||
h(
|
||||
TableContent,
|
||||
{ selectionMode: "multiple", selectedKeys: [0] },
|
||||
() => [
|
||||
h(TableHeader, () =>
|
||||
h(TableColumn, { id: "name", isRowHeader: true }, () => "Name"),
|
||||
),
|
||||
h(TableBody, () =>
|
||||
h(TableRow, { rowKey: 0 }, () => h(TableCell, () => "Zero")),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('scope="row"');
|
||||
expect(html).toContain('aria-selected="true"');
|
||||
expect(html).not.toContain("<thead><th");
|
||||
});
|
||||
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { defineComponent, ref, nextTick, createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, ref, nextTick } from "vue";
|
||||
import {
|
||||
NumberField,
|
||||
NumberFieldGroup,
|
||||
@@ -73,40 +72,6 @@ describe("NumberField public contracts", () => {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
it("hydrates control IDs and description associations without mismatches", async () => {
|
||||
const app = defineComponent({
|
||||
render: () =>
|
||||
h(NumberField, { defaultValue: 2 }, () => [
|
||||
h(Label, {}, () => "Amount"),
|
||||
h(NumberFieldGroup, {}, () => [h(NumberFieldInput)]),
|
||||
h(Description, {}, () => "Help"),
|
||||
]),
|
||||
});
|
||||
const html = await renderToString(createSSRApp(app));
|
||||
const container = document.createElement("div");
|
||||
container.innerHTML = html;
|
||||
document.body.append(container);
|
||||
const warnings: unknown[][] = [];
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation((...args) => {
|
||||
warnings.push(args);
|
||||
});
|
||||
const client = createSSRApp(app);
|
||||
try {
|
||||
client.mount(container);
|
||||
await nextTick();
|
||||
const input = container.querySelector('input[role="spinbutton"]')!;
|
||||
expect(container.querySelector("label")?.htmlFor).toBe(input.id);
|
||||
expect(
|
||||
container.querySelector(
|
||||
`[id="${input.getAttribute("aria-describedby")}"]`,
|
||||
),
|
||||
).toBeTruthy();
|
||||
expect(warnings).toEqual([]);
|
||||
} finally {
|
||||
client.unmount();
|
||||
warn.mockRestore();
|
||||
}
|
||||
});
|
||||
it("updates ARIA/class attributes and controlled ownership as props are added and removed", async () => {
|
||||
const attributes = ref<Record<string, unknown>>({});
|
||||
const w = fixture(
|
||||
@@ -340,22 +305,4 @@ describe("NumberField public contracts", () => {
|
||||
"true",
|
||||
);
|
||||
});
|
||||
it("renders SSR associations before descriptions and explicit leaf IDs", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(NumberField, {}, () => [
|
||||
h(Label, {}, () => "SSR"),
|
||||
h(NumberFieldGroup, {}, () =>
|
||||
h(NumberFieldInput, { id: "ssr-number" }),
|
||||
),
|
||||
h(Description, {}, () => "Help"),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('for="ssr-number"');
|
||||
const described = html.match(/aria-describedby="([^"]+)"/)?.[1];
|
||||
expect(described).toBeTruthy();
|
||||
expect(html).toContain(`id="${described}"`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -251,45 +251,6 @@ it("closes only the highest modal and retains the parent lock", async () => {
|
||||
expect(document.body.style.overflow).not.toBe("hidden");
|
||||
});
|
||||
|
||||
it("hydrates open portal content with stable trigger/label associations", async () => {
|
||||
const { createSSRApp } = await import("vue");
|
||||
const { renderToString } = await import("@vue/server-renderer");
|
||||
const view = defineComponent({
|
||||
components,
|
||||
template: `<OverlayDialogRoot default-open><DialogTrigger>open</DialogTrigger><OverlayPortal><OverlayBackdrop/><OverlayDialogContent>${content}</OverlayDialogContent></OverlayPortal></OverlayDialogRoot>`,
|
||||
});
|
||||
const host = document.createElement("div");
|
||||
document.body.append(host);
|
||||
host.innerHTML = await renderToString(createSSRApp(view));
|
||||
expect(host.querySelector("[role=dialog]")).toBeNull();
|
||||
const triggerId = host.querySelector("button")!.getAttribute("aria-controls");
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const error = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
const app = createSSRApp(view);
|
||||
try {
|
||||
app.mount(host);
|
||||
await settle();
|
||||
const dialog = document.querySelector("[role=dialog]")!;
|
||||
expect(dialog.id).toBe(triggerId);
|
||||
expect(
|
||||
document.getElementById(dialog.getAttribute("aria-labelledby")!)
|
||||
?.textContent,
|
||||
).toBe("Title");
|
||||
expect(
|
||||
document.getElementById(dialog.getAttribute("aria-describedby")!)
|
||||
?.textContent,
|
||||
).toBe("Hint");
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
expect(error).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
app.unmount();
|
||||
await settle();
|
||||
host.remove();
|
||||
warn.mockRestore();
|
||||
error.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it("preserves direction and language through teleport with reactive explicit overrides", async () => {
|
||||
const dir = ref<"ltr" | "rtl">("rtl");
|
||||
const locale = ref("ar");
|
||||
|
||||
+13
-16
@@ -1,24 +1,21 @@
|
||||
# 独立客户端产物验收
|
||||
|
||||
当前仅支持浏览器客户端,暂不支持SSR/水合/Nuxt服务端。除用户明确重新启用外,不开发、不修复、不运行这些专项。旧`consume-*.mjs`中不少脚本混有renderToString/服务端HTML断言,仅保留历史,不整批执行,也不复制为新任务要求。
|
||||
|
||||
## 当前需要验证什么
|
||||
|
||||
公开API/打包变化时,把最终两份tarball安装到工作区外的Vue/Vite工程,不设置源码alias;private样式包用消费者pnpm-workspace.yaml的overrides指向本地styles tarball。
|
||||
|
||||
- 在浏览器消费公开导出及发布CSS,确认核心交互、主题、布局与表单等适用契约。
|
||||
- 用相关`*-contract.ts`验证公共类型的正反例;NodeNext/bundler只是类型解析模式,不是SSR验收。
|
||||
- 不要求Node端渲染、服务端HTML、Teleport服务端或水合测试。
|
||||
|
||||
类型命令(以相关B02契约为例):
|
||||
统一入口,参数只选受影响的契约:
|
||||
|
||||
```sh
|
||||
pnpm exec tsc --noEmit --strict --skipLibCheck --target es2022 --module nodenext --moduleResolution nodenext b02-pickers-contract.ts
|
||||
pnpm exec tsc --noEmit --strict --skipLibCheck --target es2022 --module esnext --moduleResolution bundler b02-pickers-contract.ts
|
||||
node scripts/check-package.mjs b02-pickers
|
||||
node scripts/check-package.mjs calendar date-field select --offline
|
||||
```
|
||||
|
||||
`@ts-expect-error`必须实际生效;unused是类型验收失败,不能删反例。工作区typecheck使用源码alias,不能代替发布类型。
|
||||
入口先构建库/样式,在工作区外新建临时消费者,打包并安装最终tarball,检查所选公共导出/CSS/变体,再运行相应`*-contract.ts`的strict NodeNext/bundler正反例。不会启动服务或执行SSR/水合。NodeNext只是类型解析模式。支持的ID见`client-checks.json`;无效ID会在构建前失败。
|
||||
|
||||
浏览器消费夹具见[b02-consumer-app](b02-consumer-app/README.md)与[b01-consumer-app](b01-consumer-app/README.md);按相关任务使用,不无理由跑所有历史消费者。它们只导入公开包根和发布CSS。
|
||||
一次选择多个受影响ID,共享同次构建/安装;不要为每组件手动复制一套安装流程。默认消费者保留供检查,路径打印在日志中,不是新项目或长期工作目录。`--offline`仅在所需依赖已缓存时使用,安装失败不是验收通过。
|
||||
|
||||
旧SSR用例、脚本、依赖暂留作历史,不构成支持承诺或日常维护义务。依赖@vue/server-renderer仍由部分历史测试文件导入;暂不移除它,不要求为此增加新能力。
|
||||
## 契约与浏览器
|
||||
|
||||
- `client-checks.json`:导出、CSS标记、暂不公开组件的边界;`check-client.mjs`:共用检查和少数变体断言。
|
||||
- `*-contract.ts`:公开Props/事件/插槽类型正反例;`@ts-expect-error`出现unused必须修复,不能删反例。源码typecheck不能替代发布类型。
|
||||
- [B02浏览器夹具](b02-consumer-app/README.md)和[B01浏览器夹具](b01-consumer-app/README.md)保留。选择b02-pickers时,入口会把浏览器文件放入独立消费者;按输出命令显式启动,验可见/点击/焦点等核心路径。未启动时不能声称已验浏览器。
|
||||
- 新公共组件在已有数据与契约上增量扩展,不再新增consume-某批次.mjs脚本或手写另一套消费者流程。
|
||||
|
||||
旧15份consume脚本已移除;客户端导出/CSS/变体检查统一保留,服务端HTML/无document运行等断言不再维护。SSR/水合/Nuxt集成不支持。逐像素自动对比、完整读屏矩阵、真机矩阵暂不投入;基础键盘/可访问性与重点浏览器交互仍验证。
|
||||
|
||||
@@ -1,29 +1,18 @@
|
||||
# B01 独立浏览器消费夹具
|
||||
|
||||
用打包产物(`pnpm pack` 生成的 `@heroui-vue/components` / `@heroui-vue/styles` tarball)在独立 Vue 应用中真实挂载,覆盖:
|
||||
准备最终产物与浏览器文件:
|
||||
|
||||
- `selection`:带 `contain/isolation/overflow:hidden` 祖先的分组级多选长菜单(验证 Portal 脱离裁切、高度上限、真实 `role="menu"` 名称)。
|
||||
- `submenu`:三级子菜单 + 链接型菜单项。
|
||||
- `modal`:Modal 内的 Dropdown(验证层级与关闭顺序、滚动锁释放)。
|
||||
- `standalone`:独立 `Menu` 内联列表(无滚动锁、无浮动定位、不抢焦点)。
|
||||
|
||||
## 使用方式
|
||||
|
||||
```bash
|
||||
# 1. 在库仓库打包
|
||||
pnpm build
|
||||
pnpm --filter @heroui-vue/styles exec pnpm pack --pack-destination /tmp/heroui-b01-consumer
|
||||
pnpm --filter @heroui-vue/components exec pnpm pack --pack-destination /tmp/heroui-b01-consumer
|
||||
|
||||
# 2. 复制本目录到消费工程并安装
|
||||
cp -R tests/package/b01-consumer-app/. /tmp/heroui-b01-consumer/app/
|
||||
cd /tmp/heroui-b01-consumer && pnpm install
|
||||
|
||||
# 3. 打包成静态产物(esbuild 只作为构建工具,运行期仅依赖 tarball)
|
||||
esbuild app/main.js --bundle --format=esm --outfile=app/bundle.js --loader:.css=css
|
||||
|
||||
# 4. 静态服务后打开(`?only=selection|submenu|modal|standalone` 可单例)
|
||||
python3 -m http.server 5199 --bind 127.0.0.1 --directory app
|
||||
```sh
|
||||
node scripts/check-package.mjs b01-menu-dropdown
|
||||
```
|
||||
|
||||
`consume-b01-menu-dropdown.mjs` 只做导出/CSS 存在性检查;真实挂载行为以本夹具的浏览器结果为准。
|
||||
使用输出的独立消费者路径和Vite命令,显式选空闲端口启动;不再单独pack/install或引入esbuild。夹具只消费公开包和发布CSS,不用源码alias。统一入口不自动启动服务。
|
||||
|
||||
重点场景:
|
||||
|
||||
- `?only=selection`:裁切/隔离祖先中的分组多选长菜单,检查Portal、可用高度和真实menu名称。
|
||||
- `?only=submenu`:三级子菜单与链接项。
|
||||
- `?only=modal`:Modal内Dropdown,检查逐层关闭、滚动锁与焦点。
|
||||
- `?only=standalone`:独立内联Menu,不应锁滚动或抢焦点。
|
||||
|
||||
导出/CSS/类型检查由统一入口完成;真实可见、点击和焦点仍按浏览器步骤验,构建通过不代表这些操作通过。
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>B01 consumer</title>
|
||||
<link rel="stylesheet" href="./bundle.css" />
|
||||
<link rel="stylesheet" href="./style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="./bundle.js"></script>
|
||||
<script type="module" src="/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
# B02 独立浏览器消费
|
||||
|
||||
将本目录内容复制到工作区外的独立目录。安装最终 pnpm pack 产生的 components/styles 两份 tarball、Vue与Vite;pnpm-workspace.yaml的styles override指向该样式tarball。不能配置指向源码的alias。main.js只从包根/发布CSS导入,使用render函数不依赖Vue模板编译器。
|
||||
|
||||
运行 `pnpm exec vite --host 127.0.0.1 --port 5184 --strictPort`(先确认空闲;也可使用已安装的Vite二进制作为开发工具),打开实际返回URL。
|
||||
先运行`node scripts/check-package.mjs b02-pickers`统一构建、打包、安装和类型验收;它会把本夹具放入独立消费者,打印路径和Vite命令。按输出显式选空闲端口启动,不另外复制安装流程;入口不会自动启动服务。main.js只从包根/发布CSS导入,不用源码alias或Vue模板编译器。
|
||||
|
||||
1. 点ComboBox箭头,面板在视口内/锚点旁,鼠标点狗后关闭、文本狗、焦点留在输入。
|
||||
2. 点Autocomplete,搜索Texas,鼠标选择后单选关闭;点清除后恢复占位,焦点与Tab/外部点击不反跳。
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import * as lib from "@heroui-vue/components";
|
||||
|
||||
const checks = JSON.parse(
|
||||
readFileSync(new URL("./client-checks.json", import.meta.url), "utf8"),
|
||||
);
|
||||
const css = readFileSync(
|
||||
new URL(import.meta.resolve("@heroui-vue/styles/css")),
|
||||
"utf8",
|
||||
);
|
||||
for (const id of process.argv.slice(2)) {
|
||||
const spec = checks[id];
|
||||
assert(spec, `Unknown package contract: ${id}`);
|
||||
for (const name of spec.exports) assert(lib[name], `Missing export ${name}`);
|
||||
for (const token of spec.css)
|
||||
assert(css.includes(token), `Missing CSS ${token}`);
|
||||
for (const name of spec.absent ?? [])
|
||||
assert(!(name in lib), `Private component exposed: ${name}`);
|
||||
if (id === "b02-pickers") {
|
||||
assert(
|
||||
lib
|
||||
.comboBoxVariants({ fullWidth: true })
|
||||
.base()
|
||||
.includes("hv-combo-box--full-width"),
|
||||
);
|
||||
assert(
|
||||
lib
|
||||
.autocompleteVariants({ variant: "secondary" })
|
||||
.base()
|
||||
.includes("hv-autocomplete--secondary"),
|
||||
);
|
||||
}
|
||||
if (id === "list-box") {
|
||||
assert(lib.listboxVariants().includes("hv-list-box"));
|
||||
assert(
|
||||
lib
|
||||
.listboxItemVariants()
|
||||
.indicator()
|
||||
.includes("hv-list-box-item__indicator"),
|
||||
);
|
||||
}
|
||||
if (id === "slider")
|
||||
assert(lib.sliderVariants().thumb().includes("hv-slider__thumb"));
|
||||
if (id === "select")
|
||||
assert(
|
||||
lib
|
||||
.selectVariants({ variant: "secondary" })
|
||||
.base()
|
||||
.includes("hv-select--secondary"),
|
||||
);
|
||||
if (id === "b03-tag-error-message") {
|
||||
assert(/\.hv-tag-group\s*\[data-slot=["']?error-message/.test(css));
|
||||
assert(lib.tagVariants({ size: "sm" }).base().includes("hv-tag--sm"));
|
||||
assert(
|
||||
lib
|
||||
.tagVariants({ variant: "surface" })
|
||||
.base()
|
||||
.includes("hv-tag--surface"),
|
||||
);
|
||||
assert(lib.errorMessageVariants().includes("hv-error-message"));
|
||||
}
|
||||
console.log(`${id}: packed ESM exports and CSS passed (client scope)`);
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
{
|
||||
"b01-menu-dropdown": {
|
||||
"exports": [
|
||||
"DropdownRoot",
|
||||
"DropdownTrigger",
|
||||
"DropdownPopover",
|
||||
"DropdownMenu",
|
||||
"DropdownItem",
|
||||
"DropdownItemIndicator",
|
||||
"DropdownSubmenuTrigger",
|
||||
"DropdownSubmenuIndicator",
|
||||
"DropdownSection",
|
||||
"Menu",
|
||||
"MenuItem",
|
||||
"MenuItemIndicator",
|
||||
"MenuItemSubmenuIndicator",
|
||||
"MenuSection"
|
||||
],
|
||||
"css": [
|
||||
"hv-menu-item",
|
||||
"hv-menu-item__indicator--submenu",
|
||||
"hv-dropdown__popover",
|
||||
"hv-dropdown__menu",
|
||||
"data-selected"
|
||||
]
|
||||
},
|
||||
"b02-pickers": {
|
||||
"exports": [
|
||||
"ComboBox",
|
||||
"ComboBoxInputGroup",
|
||||
"ComboBoxTrigger",
|
||||
"ComboBoxValue",
|
||||
"ComboBoxPopover",
|
||||
"Autocomplete",
|
||||
"AutocompleteTrigger",
|
||||
"AutocompleteValue",
|
||||
"AutocompleteIndicator",
|
||||
"AutocompleteClearButton",
|
||||
"AutocompletePopover",
|
||||
"AutocompleteFilter",
|
||||
"comboBoxVariants",
|
||||
"autocompleteVariants"
|
||||
],
|
||||
"css": [
|
||||
".hv-combo-box",
|
||||
".hv-combo-box__input-group",
|
||||
".hv-combo-box__trigger",
|
||||
".hv-combo-box__popover",
|
||||
".hv-combo-box__value",
|
||||
".hv-autocomplete",
|
||||
".hv-autocomplete__trigger",
|
||||
".hv-autocomplete__value",
|
||||
".hv-autocomplete__indicator",
|
||||
".hv-autocomplete__clear-button",
|
||||
".hv-autocomplete__popover",
|
||||
".hv-autocomplete--secondary",
|
||||
"hv-combo-box--full-width",
|
||||
"hv-autocomplete--secondary"
|
||||
]
|
||||
},
|
||||
"b03-tag-error-message": {
|
||||
"exports": [
|
||||
"TagGroup",
|
||||
"TagGroupList",
|
||||
"Tag",
|
||||
"TagRemoveButton",
|
||||
"ErrorMessage",
|
||||
"tagVariants",
|
||||
"tagGroupVariants",
|
||||
"errorMessageVariants"
|
||||
],
|
||||
"css": [
|
||||
".hv-tag",
|
||||
".hv-tag--sm",
|
||||
".hv-tag--lg",
|
||||
".hv-tag--surface",
|
||||
".hv-tag__remove-button",
|
||||
".hv-tag-group",
|
||||
".hv-tag-group__list",
|
||||
".hv-error-message",
|
||||
"hv-tag--sm",
|
||||
"hv-tag--surface",
|
||||
"hv-error-message"
|
||||
]
|
||||
},
|
||||
"calendar": {
|
||||
"exports": [
|
||||
"Calendar",
|
||||
"CalendarRoot",
|
||||
"CalendarHeader",
|
||||
"CalendarHeading",
|
||||
"CalendarNavButton",
|
||||
"CalendarGrid",
|
||||
"CalendarGridHeader",
|
||||
"CalendarGridBody",
|
||||
"CalendarHeaderCell",
|
||||
"CalendarCell",
|
||||
"CalendarCellIndicator",
|
||||
"CalendarYearPickerTrigger",
|
||||
"CalendarYearPickerTriggerHeading",
|
||||
"CalendarYearPickerTriggerIndicator",
|
||||
"CalendarYearPickerGrid",
|
||||
"CalendarYearPickerGridBody",
|
||||
"CalendarYearPickerCell"
|
||||
],
|
||||
"css": [
|
||||
".hv-calendar__cell",
|
||||
".hv-calendar--week-view",
|
||||
".hv-calendar--day-view",
|
||||
".hv-calendar-year-picker__year-cell"
|
||||
]
|
||||
},
|
||||
"color-field-protocol": {
|
||||
"exports": [],
|
||||
"css": [
|
||||
".hv-color-field",
|
||||
".hv-color-input-group",
|
||||
".hv-color-input-group__input",
|
||||
".hv-color-input-group--secondary",
|
||||
".hv-color-input-group__prefix",
|
||||
".hv-color-input-group__suffix"
|
||||
],
|
||||
"absent": [
|
||||
"ColorArea",
|
||||
"ColorSlider",
|
||||
"ColorField",
|
||||
"ColorInputGroup",
|
||||
"ColorPicker"
|
||||
]
|
||||
},
|
||||
"color-foundation": {
|
||||
"exports": [],
|
||||
"css": [".hv-color-area", ".hv-color-area__thumb"],
|
||||
"absent": [
|
||||
"ColorArea",
|
||||
"ColorSlider",
|
||||
"ColorField",
|
||||
"ColorInputGroup",
|
||||
"ColorPicker"
|
||||
]
|
||||
},
|
||||
"color-picker-protocol": {
|
||||
"exports": [],
|
||||
"css": [
|
||||
".hv-color-picker",
|
||||
".hv-color-picker__trigger",
|
||||
".hv-color-picker__popover"
|
||||
],
|
||||
"absent": [
|
||||
"ColorArea",
|
||||
"ColorSlider",
|
||||
"ColorField",
|
||||
"ColorInputGroup",
|
||||
"ColorPicker"
|
||||
]
|
||||
},
|
||||
"color-slider-foundation": {
|
||||
"exports": [],
|
||||
"css": [
|
||||
".hv-color-slider",
|
||||
".hv-color-slider__track",
|
||||
".hv-color-slider__thumb",
|
||||
"--track-start-color",
|
||||
"--track-end-color",
|
||||
"--reka-popover-content-available-height",
|
||||
"max-height:inherit",
|
||||
"overscroll-behavior:contain"
|
||||
],
|
||||
"absent": [
|
||||
"ColorArea",
|
||||
"ColorSlider",
|
||||
"ColorField",
|
||||
"ColorInputGroup",
|
||||
"ColorPicker"
|
||||
]
|
||||
},
|
||||
"date-field": {
|
||||
"exports": [
|
||||
"DateField",
|
||||
"DateFieldRoot",
|
||||
"DateFieldGroup",
|
||||
"DateFieldInput",
|
||||
"DateFieldSegment",
|
||||
"DateFieldPrefix",
|
||||
"DateFieldSuffix",
|
||||
"DateFieldInputContainer",
|
||||
"DateInputGroup",
|
||||
"DateInputGroupInput",
|
||||
"DateInputGroupSegment",
|
||||
"DateInputGroupInputContainer",
|
||||
"DateInputGroupPrefix",
|
||||
"DateInputGroupSuffix"
|
||||
],
|
||||
"css": [
|
||||
"hv-date-field",
|
||||
"hv-date-input-group",
|
||||
"hv-date-input-group__segment",
|
||||
"hv-date-input-group--secondary"
|
||||
]
|
||||
},
|
||||
"list-box": {
|
||||
"exports": [
|
||||
"ListBox",
|
||||
"ListBoxItem",
|
||||
"ListBoxItemIndicator",
|
||||
"ListBoxSection",
|
||||
"Header",
|
||||
"Label",
|
||||
"Description",
|
||||
"listboxVariants",
|
||||
"listboxItemVariants"
|
||||
],
|
||||
"css": [
|
||||
"hv-list-box",
|
||||
"hv-list-box-item__indicator",
|
||||
".hv-list-box",
|
||||
".hv-list-box-item",
|
||||
".hv-list-box-section"
|
||||
]
|
||||
},
|
||||
"m30-m32": {
|
||||
"exports": [
|
||||
"InputOTP",
|
||||
"InputOTPGroup",
|
||||
"InputOTPSlot",
|
||||
"Label",
|
||||
"Header",
|
||||
"Pagination",
|
||||
"PaginationContent",
|
||||
"PaginationItem",
|
||||
"PaginationLink"
|
||||
],
|
||||
"css": ["hv-header", "hv-pagination", "hv-input-otp"]
|
||||
},
|
||||
"m33-m34": {
|
||||
"exports": [
|
||||
"AlertDialog",
|
||||
"AlertDialogRoot",
|
||||
"AlertDialogTrigger",
|
||||
"AlertDialogBackdrop",
|
||||
"AlertDialogContainer",
|
||||
"AlertDialogDialog",
|
||||
"AlertDialogHeader",
|
||||
"AlertDialogHeading",
|
||||
"AlertDialogBody",
|
||||
"AlertDialogFooter",
|
||||
"AlertDialogIcon",
|
||||
"AlertDialogCloseTrigger",
|
||||
"AlertDialogClose",
|
||||
"Drawer",
|
||||
"DrawerRoot",
|
||||
"DrawerTrigger",
|
||||
"DrawerBackdrop",
|
||||
"DrawerContent",
|
||||
"DrawerDialog",
|
||||
"DrawerHeader",
|
||||
"DrawerHeading",
|
||||
"DrawerBody",
|
||||
"DrawerFooter",
|
||||
"DrawerHandle",
|
||||
"DrawerCloseTrigger",
|
||||
"DrawerClose"
|
||||
],
|
||||
"css": [
|
||||
".hv-alert-dialog__dialog",
|
||||
"hv-drawer-in-from-right",
|
||||
"hv-drawer-out-to-bottom"
|
||||
]
|
||||
},
|
||||
"m35-m36": {
|
||||
"exports": [
|
||||
"Toast",
|
||||
"ToastRoot",
|
||||
"ToastProvider",
|
||||
"ToastContent",
|
||||
"ToastIndicator",
|
||||
"ToastTitle",
|
||||
"ToastDescription",
|
||||
"ToastActionButton",
|
||||
"ToastCloseButton",
|
||||
"ToastQueue",
|
||||
"toast",
|
||||
"toastQueue",
|
||||
"createToastFunction",
|
||||
"Table",
|
||||
"TableRoot",
|
||||
"TableContent",
|
||||
"TableHeader",
|
||||
"TableColumn",
|
||||
"TableBody",
|
||||
"TableRow",
|
||||
"TableCell",
|
||||
"TableScrollContainer",
|
||||
"TableFooter",
|
||||
"TableResizableContainer",
|
||||
"TableColumnResizer",
|
||||
"TableLoadMore",
|
||||
"TableLoadMoreItem",
|
||||
"TableLoadMoreContent",
|
||||
"TableCollection",
|
||||
"TableSortableColumnHeader"
|
||||
],
|
||||
"css": [".hv-toast-region", ".hv-table__column-resizer", "data-exiting"]
|
||||
},
|
||||
"select": {
|
||||
"exports": [
|
||||
"Select",
|
||||
"SelectTrigger",
|
||||
"SelectValue",
|
||||
"SelectIndicator",
|
||||
"SelectClearButton",
|
||||
"SelectPopover",
|
||||
"ListBox",
|
||||
"ListBoxItem",
|
||||
"Label",
|
||||
"selectVariants"
|
||||
],
|
||||
"css": [
|
||||
"hv-select--secondary",
|
||||
".hv-select",
|
||||
".hv-select__trigger",
|
||||
".hv-select__value",
|
||||
".hv-select__clear-button",
|
||||
".hv-select__indicator",
|
||||
".hv-select__popover"
|
||||
]
|
||||
},
|
||||
"slider": {
|
||||
"exports": [
|
||||
"Slider",
|
||||
"SliderTrack",
|
||||
"SliderFill",
|
||||
"SliderThumb",
|
||||
"SliderOutput",
|
||||
"SliderMarks",
|
||||
"Label",
|
||||
"sliderVariants"
|
||||
],
|
||||
"css": [".hv-slider__track", "hv-slider__thumb"]
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/**
|
||||
* Independent ESM/CSS consumption for B01 Menu/Dropdown.
|
||||
* Copy into a fresh consumer that installs packed tarballs (no source alias).
|
||||
*/
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
const mod = await import("@heroui-vue/components");
|
||||
const {
|
||||
DropdownRoot,
|
||||
DropdownTrigger,
|
||||
DropdownPopover,
|
||||
DropdownMenu,
|
||||
DropdownItem,
|
||||
DropdownItemIndicator,
|
||||
DropdownSubmenuTrigger,
|
||||
DropdownSubmenuIndicator,
|
||||
DropdownSection,
|
||||
Menu,
|
||||
MenuItem,
|
||||
MenuItemIndicator,
|
||||
MenuItemSubmenuIndicator,
|
||||
MenuSection,
|
||||
} = mod;
|
||||
|
||||
const expected = {
|
||||
DropdownRoot,
|
||||
DropdownTrigger,
|
||||
DropdownPopover,
|
||||
DropdownMenu,
|
||||
DropdownItem,
|
||||
DropdownItemIndicator,
|
||||
DropdownSubmenuTrigger,
|
||||
DropdownSubmenuIndicator,
|
||||
DropdownSection,
|
||||
Menu,
|
||||
MenuItem,
|
||||
MenuItemIndicator,
|
||||
MenuItemSubmenuIndicator,
|
||||
MenuSection,
|
||||
};
|
||||
for (const [name, value] of Object.entries(expected)) {
|
||||
if (!value) {
|
||||
console.error("missing export", name);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
const cssPath = import.meta.resolve("@heroui-vue/styles/css");
|
||||
const css = readFileSync(new URL(cssPath), "utf8");
|
||||
for (const token of [
|
||||
"hv-menu-item",
|
||||
"hv-menu-item__indicator--submenu",
|
||||
"hv-dropdown__popover",
|
||||
"hv-dropdown__menu",
|
||||
"data-selected",
|
||||
]) {
|
||||
if (!css.includes(token)) {
|
||||
console.error("css missing", token);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("b01 menu/dropdown ESM+CSS consume ok");
|
||||
@@ -1,159 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import * as lib from "@heroui-vue/components";
|
||||
|
||||
for (const name of [
|
||||
"ComboBox",
|
||||
"ComboBoxInputGroup",
|
||||
"ComboBoxTrigger",
|
||||
"ComboBoxValue",
|
||||
"ComboBoxPopover",
|
||||
"Autocomplete",
|
||||
"AutocompleteTrigger",
|
||||
"AutocompleteValue",
|
||||
"AutocompleteIndicator",
|
||||
"AutocompleteClearButton",
|
||||
"AutocompletePopover",
|
||||
"AutocompleteFilter",
|
||||
"comboBoxVariants",
|
||||
"autocompleteVariants",
|
||||
])
|
||||
assert(lib[name], name);
|
||||
|
||||
const items = [
|
||||
{ id: "cat", textValue: "猫" },
|
||||
{ id: "dog", textValue: "狗" },
|
||||
];
|
||||
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h("main", [
|
||||
h(
|
||||
lib.ComboBox,
|
||||
{ "aria-label": "动物", defaultSelectedKey: "cat", name: "animal" },
|
||||
{
|
||||
default: () => [
|
||||
h(lib.Label, null, () => "动物"),
|
||||
h(lib.ComboBoxInputGroup, null, {
|
||||
default: () => [h(lib.Input, {}), h(lib.ComboBoxTrigger)],
|
||||
}),
|
||||
h(lib.ComboBoxPopover, null, {
|
||||
default: () =>
|
||||
h(lib.ListBox, null, {
|
||||
default: () =>
|
||||
items.map((item) =>
|
||||
h(
|
||||
lib.ListBoxItem,
|
||||
{
|
||||
id: item.id,
|
||||
key: item.id,
|
||||
textValue: item.textValue,
|
||||
},
|
||||
() => item.textValue,
|
||||
),
|
||||
),
|
||||
}),
|
||||
}),
|
||||
],
|
||||
},
|
||||
),
|
||||
h(
|
||||
lib.Autocomplete,
|
||||
{ "aria-label": "州", name: "state", defaultValue: "dog" },
|
||||
{
|
||||
default: () => [
|
||||
h(lib.AutocompleteTrigger, null, {
|
||||
default: () => [
|
||||
h(lib.AutocompleteValue),
|
||||
h(lib.AutocompleteClearButton),
|
||||
h(lib.AutocompleteIndicator),
|
||||
],
|
||||
}),
|
||||
h(lib.AutocompletePopover, null, {
|
||||
default: () =>
|
||||
h(lib.AutocompleteFilter, null, {
|
||||
default: () => [
|
||||
h(
|
||||
lib.SearchField,
|
||||
{ "aria-label": "搜索" },
|
||||
{
|
||||
default: () =>
|
||||
h(lib.SearchFieldGroup, null, {
|
||||
default: () => [h(lib.SearchFieldInput)],
|
||||
}),
|
||||
},
|
||||
),
|
||||
h(lib.ListBox, null, {
|
||||
default: () =>
|
||||
items.map((item) =>
|
||||
h(
|
||||
lib.ListBoxItem,
|
||||
{
|
||||
id: item.id,
|
||||
key: item.id,
|
||||
textValue: item.textValue,
|
||||
},
|
||||
() => item.textValue,
|
||||
),
|
||||
),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
}),
|
||||
],
|
||||
},
|
||||
),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
|
||||
assert(html.includes('data-slot="combo-box"'), "combo-box root");
|
||||
assert(html.includes('role="combobox"'), "combobox input role");
|
||||
assert(html.includes('data-slot="combo-box-trigger"'), "combo box trigger");
|
||||
assert(html.includes('name="animal"'), "combo box form name");
|
||||
assert(html.includes('data-slot="autocomplete"'), "autocomplete root");
|
||||
assert(
|
||||
html.includes('data-slot="autocomplete-trigger"'),
|
||||
"autocomplete trigger",
|
||||
);
|
||||
assert(html.includes('role="button"'), "autocomplete trigger is a button");
|
||||
assert(html.includes('name="state"'), "autocomplete form name");
|
||||
assert(html.includes("猫"), "combo box preselected label");
|
||||
|
||||
const css = readFileSync(
|
||||
"node_modules/@heroui-vue/styles/dist/styles.css",
|
||||
"utf8",
|
||||
);
|
||||
for (const rule of [
|
||||
".hv-combo-box",
|
||||
".hv-combo-box__input-group",
|
||||
".hv-combo-box__trigger",
|
||||
".hv-combo-box__popover",
|
||||
".hv-combo-box__value",
|
||||
".hv-autocomplete",
|
||||
".hv-autocomplete__trigger",
|
||||
".hv-autocomplete__value",
|
||||
".hv-autocomplete__indicator",
|
||||
".hv-autocomplete__clear-button",
|
||||
".hv-autocomplete__popover",
|
||||
".hv-autocomplete--secondary",
|
||||
])
|
||||
assert(css.includes(rule), `missing CSS ${rule}`);
|
||||
|
||||
assert(
|
||||
lib
|
||||
.comboBoxVariants({ fullWidth: true })
|
||||
.base()
|
||||
.includes("hv-combo-box--full-width"),
|
||||
);
|
||||
assert(
|
||||
lib
|
||||
.autocompleteVariants({ variant: "secondary" })
|
||||
.base()
|
||||
.includes("hv-autocomplete--secondary"),
|
||||
);
|
||||
|
||||
console.log("B02 pickers consumption OK");
|
||||
@@ -1,88 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import * as lib from "@heroui-vue/components";
|
||||
|
||||
for (const name of [
|
||||
"TagGroup",
|
||||
"TagGroupList",
|
||||
"Tag",
|
||||
"TagRemoveButton",
|
||||
"ErrorMessage",
|
||||
"tagVariants",
|
||||
"tagGroupVariants",
|
||||
"errorMessageVariants",
|
||||
])
|
||||
assert(lib[name], name);
|
||||
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(
|
||||
lib.TagGroup,
|
||||
{
|
||||
"aria-label": "分类",
|
||||
selectionMode: "multiple",
|
||||
modelValue: ["news"],
|
||||
onRemove: () => {},
|
||||
},
|
||||
{
|
||||
default: () => [
|
||||
h(lib.TagGroupList, null, {
|
||||
default: () => [
|
||||
h(lib.Tag, { id: "news" }, { default: () => "资讯" }),
|
||||
h(
|
||||
lib.Tag,
|
||||
{ id: 0, isDisabled: true },
|
||||
{ default: () => "零" },
|
||||
),
|
||||
],
|
||||
}),
|
||||
h(lib.ErrorMessage, null, { default: () => "请至少选择一项" }),
|
||||
],
|
||||
},
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
assert(html.includes('role="grid"'), "grid role on the list");
|
||||
assert(html.includes('aria-label="分类"'), "grid carries the group label");
|
||||
assert(html.includes('aria-multiselectable="true"'), "multiple selection flag");
|
||||
assert(html.includes('role="row"'), "rows for tags");
|
||||
assert(html.includes('aria-selected="true"'), "accepted selection");
|
||||
assert(html.includes('aria-disabled="true"'), "disabled tag");
|
||||
assert(html.includes("Remove tag 资讯"), "composed remove button name");
|
||||
assert(html.includes('data-slot="tag-remove-button"'), "remove button slot");
|
||||
assert(html.includes('data-slot="error-message"'), "error message slot");
|
||||
assert(html.includes('slot="errorMessage"'), "baseline error message marker");
|
||||
|
||||
const css = readFileSync(
|
||||
"node_modules/@heroui-vue/styles/dist/styles.css",
|
||||
"utf8",
|
||||
);
|
||||
for (const rule of [
|
||||
".hv-tag",
|
||||
".hv-tag--sm",
|
||||
".hv-tag--lg",
|
||||
".hv-tag--surface",
|
||||
".hv-tag__remove-button",
|
||||
".hv-tag-group",
|
||||
".hv-tag-group__list",
|
||||
".hv-error-message",
|
||||
])
|
||||
assert(css.includes(rule), `missing CSS rule ${rule}`);
|
||||
// The list padding rule must survive minification for Description/ErrorMessage.
|
||||
assert(
|
||||
/\.hv-tag-group\s*\[data-slot=["']?error-message/.test(css),
|
||||
"missing tag-group error-message padding rule",
|
||||
);
|
||||
|
||||
assert.equal(typeof lib.tagVariants({ size: "sm" }).base, "function");
|
||||
assert(lib.tagVariants({ size: "sm" }).base().includes("hv-tag--sm"));
|
||||
assert(
|
||||
lib.tagVariants({ variant: "surface" }).base().includes("hv-tag--surface"),
|
||||
);
|
||||
assert(lib.errorMessageVariants().includes("hv-error-message"));
|
||||
|
||||
console.log("B03 tag/error-message consumption OK");
|
||||
@@ -1,63 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { CalendarDate } from "@internationalized/date";
|
||||
import * as ui from "@heroui-vue/components";
|
||||
const names = [
|
||||
"Calendar",
|
||||
"CalendarRoot",
|
||||
"CalendarHeader",
|
||||
"CalendarHeading",
|
||||
"CalendarNavButton",
|
||||
"CalendarGrid",
|
||||
"CalendarGridHeader",
|
||||
"CalendarGridBody",
|
||||
"CalendarHeaderCell",
|
||||
"CalendarCell",
|
||||
"CalendarCellIndicator",
|
||||
"CalendarYearPickerTrigger",
|
||||
"CalendarYearPickerTriggerHeading",
|
||||
"CalendarYearPickerTriggerIndicator",
|
||||
"CalendarYearPickerGrid",
|
||||
"CalendarYearPickerGridBody",
|
||||
"CalendarYearPickerCell",
|
||||
];
|
||||
for (const name of names) assert.ok(ui[name], name);
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(
|
||||
ui.Calendar,
|
||||
{
|
||||
defaultValue: new CalendarDate(2024, 2, 29),
|
||||
defaultFocusedValue: new CalendarDate(2024, 2, 29),
|
||||
locale: "en-US",
|
||||
timeZone: "UTC",
|
||||
},
|
||||
() => [
|
||||
h(ui.CalendarHeading),
|
||||
h(ui.CalendarGrid, () => [
|
||||
h(ui.CalendarGridHeader),
|
||||
h(ui.CalendarGridBody),
|
||||
]),
|
||||
h(ui.CalendarYearPickerGrid, () => h(ui.CalendarYearPickerGridBody)),
|
||||
],
|
||||
),
|
||||
}),
|
||||
);
|
||||
assert.match(html, /2024-02-29/);
|
||||
assert.match(html, /data-selected="true"/);
|
||||
assert.match(html, /February 2024/);
|
||||
const css = fs.readFileSync(
|
||||
import.meta.resolve("@heroui-vue/styles/css").replace("file://", ""),
|
||||
"utf8",
|
||||
);
|
||||
for (const token of [
|
||||
".hv-calendar__cell",
|
||||
".hv-calendar--week-view",
|
||||
".hv-calendar--day-view",
|
||||
".hv-calendar-year-picker__year-cell",
|
||||
])
|
||||
assert.ok(css.includes(token), token);
|
||||
console.log("Calendar independent tarball ESM/Node SSR/CSS passed");
|
||||
@@ -1,21 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import * as ui from "@heroui-vue/components";
|
||||
const css = fs.readFileSync(
|
||||
new URL(import.meta.resolve("@heroui-vue/styles/css")),
|
||||
"utf8",
|
||||
);
|
||||
for (const name of [
|
||||
".hv-color-field",
|
||||
".hv-color-input-group",
|
||||
".hv-color-input-group__input",
|
||||
".hv-color-input-group--secondary",
|
||||
".hv-color-input-group__prefix",
|
||||
".hv-color-input-group__suffix",
|
||||
])
|
||||
assert.ok(css.includes(name), name);
|
||||
for (const name of ["ColorField", "ColorInputGroup", "ColorPicker"])
|
||||
assert.equal(name in ui, false);
|
||||
console.log(
|
||||
"Color field protocol styles present; unfinished public contracts stay private.",
|
||||
);
|
||||
@@ -1,18 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import * as ui from "@heroui-vue/components";
|
||||
const css = fs.readFileSync(
|
||||
new URL(import.meta.resolve("@heroui-vue/styles/css")),
|
||||
"utf8",
|
||||
);
|
||||
assert.ok(css.includes(".hv-color-area"));
|
||||
assert.ok(css.includes(".hv-color-area__thumb"));
|
||||
assert.ok(css.includes("--color-area-thumb-color"));
|
||||
assert.ok(css.includes("data-dragging"));
|
||||
// The new implementation is deliberately private until public contracts and demos land.
|
||||
assert.equal("ColorArea" in ui, false);
|
||||
assert.equal("ColorPicker" in ui, false);
|
||||
assert.equal("parseColor" in ui, false);
|
||||
console.log(
|
||||
"Color foundation tarball: staged CSS present, no public placeholder exports.",
|
||||
);
|
||||
@@ -1,19 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import * as ui from "@heroui-vue/components";
|
||||
const css = fs.readFileSync(
|
||||
new URL(import.meta.resolve("@heroui-vue/styles/css")),
|
||||
"utf8",
|
||||
);
|
||||
for (const name of [
|
||||
".hv-color-picker",
|
||||
".hv-color-picker__trigger",
|
||||
".hv-color-picker__popover",
|
||||
"--tw-enter-scale:.95",
|
||||
])
|
||||
assert.ok(css.includes(name), name);
|
||||
for (const name of ["ColorPicker", "ColorPickerTrigger", "ColorPickerPopover"])
|
||||
assert.equal(name in ui, false);
|
||||
console.log(
|
||||
"Picker protocol CSS present; unfinished public exports remain private.",
|
||||
);
|
||||
@@ -1,23 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import * as ui from "@heroui-vue/components";
|
||||
const css = fs.readFileSync(
|
||||
new URL(import.meta.resolve("@heroui-vue/styles/css")),
|
||||
"utf8",
|
||||
);
|
||||
for (const marker of [
|
||||
".hv-color-slider",
|
||||
".hv-color-slider__track",
|
||||
".hv-color-slider__thumb",
|
||||
"--track-start-color",
|
||||
"--track-end-color",
|
||||
"--reka-popover-content-available-height",
|
||||
"max-height:inherit",
|
||||
"overscroll-behavior:contain",
|
||||
])
|
||||
assert.ok(css.includes(marker), marker);
|
||||
for (const name of ["ColorSlider", "ColorField", "ColorPicker"])
|
||||
assert.equal(name in ui, false);
|
||||
console.log(
|
||||
"Color slider foundation CSS and Popover constraints present; private components stay private.",
|
||||
);
|
||||
@@ -1,58 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { parseZonedDateTime } from "@internationalized/date";
|
||||
import * as c from "@heroui-vue/components";
|
||||
import { readFile } from "node:fs/promises";
|
||||
for (const key of [
|
||||
"DateField",
|
||||
"DateFieldRoot",
|
||||
"DateFieldGroup",
|
||||
"DateFieldInput",
|
||||
"DateFieldSegment",
|
||||
"DateFieldPrefix",
|
||||
"DateFieldSuffix",
|
||||
"DateFieldInputContainer",
|
||||
"DateInputGroup",
|
||||
"DateInputGroupInput",
|
||||
"DateInputGroupSegment",
|
||||
"DateInputGroupInputContainer",
|
||||
"DateInputGroupPrefix",
|
||||
"DateInputGroupSuffix",
|
||||
])
|
||||
assert.ok(c[key], key);
|
||||
const date = parseZonedDateTime(
|
||||
"2024-03-10T01:30:45-08:00[America/Los_Angeles]",
|
||||
);
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(
|
||||
c.DateField,
|
||||
{ defaultValue: date, granularity: "minute", name: "date" },
|
||||
() => [
|
||||
h(c.Label, () => "Date"),
|
||||
h(c.DateFieldGroup, () => h(c.DateFieldInput)),
|
||||
h(c.Description, () => "Help"),
|
||||
],
|
||||
),
|
||||
}),
|
||||
);
|
||||
assert.ok(
|
||||
html.includes('value="2024-03-10T01:30:45-08:00[America/Los_Angeles]"'),
|
||||
);
|
||||
assert.equal((html.match(/name="date"/g) || []).length, 1);
|
||||
assert.ok(html.includes("aria-labelledby="));
|
||||
assert.ok(html.includes("aria-describedby="));
|
||||
const css = await readFile(
|
||||
import.meta.resolve("@heroui-vue/styles/css").replace("file://", ""),
|
||||
"utf8",
|
||||
);
|
||||
for (const name of [
|
||||
"hv-date-field",
|
||||
"hv-date-input-group",
|
||||
"hv-date-input-group__segment",
|
||||
"hv-date-input-group--secondary",
|
||||
])
|
||||
assert.ok(css.includes(name), name);
|
||||
console.log("DateField tarball ESM/SSR/CSS: passed");
|
||||
@@ -1,52 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import {
|
||||
ListBox,
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
ListBoxSection,
|
||||
Header,
|
||||
Label,
|
||||
Description,
|
||||
listboxVariants,
|
||||
listboxItemVariants,
|
||||
} from "@heroui-vue/components";
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(ListBox, { modelValue: [0], "aria-label": "People" }, () => [
|
||||
h(ListBoxSection, {}, () => [
|
||||
h(Header, {}, () => "Team"),
|
||||
h(ListBoxItem, { id: 0 }, () => [
|
||||
h(Label, {}, () => "Bob"),
|
||||
h(Description, {}, () => "Details"),
|
||||
h(ListBoxItemIndicator),
|
||||
]),
|
||||
]),
|
||||
h(ListBoxItem, { id: "0" }, () => "Fred"),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
assert.equal((html.match(/aria-selected="true"/g) ?? []).length, 1);
|
||||
assert(html.includes('role="group"'));
|
||||
assert(html.includes('aria-labelledby="'));
|
||||
assert(html.includes('aria-describedby="'));
|
||||
assert(listboxVariants().includes("hv-list-box"));
|
||||
assert(
|
||||
listboxItemVariants().indicator().includes("hv-list-box-item__indicator"),
|
||||
);
|
||||
const css = readFileSync(
|
||||
new URL(import.meta.resolve("@heroui-vue/styles/css")),
|
||||
"utf8",
|
||||
);
|
||||
for (const name of [
|
||||
".hv-list-box",
|
||||
".hv-list-box-item",
|
||||
".hv-list-box-section",
|
||||
])
|
||||
assert(css.includes(name));
|
||||
console.log(
|
||||
"ListBox independent tarball: ESM, SSR, typed selection, labels and CSS passed.",
|
||||
);
|
||||
@@ -1,49 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import {
|
||||
InputOTP,
|
||||
InputOTPGroup,
|
||||
InputOTPSlot,
|
||||
Label,
|
||||
Header,
|
||||
Pagination,
|
||||
PaginationContent,
|
||||
PaginationItem,
|
||||
PaginationLink,
|
||||
} from "@heroui-vue/components";
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h("div", [
|
||||
h(Header, {}, () => "Heading"),
|
||||
h(Pagination, {}, () =>
|
||||
h(PaginationContent, {}, () =>
|
||||
h(PaginationItem, {}, () =>
|
||||
h(PaginationLink, { "aria-current": "step" }, () => "1"),
|
||||
),
|
||||
),
|
||||
),
|
||||
h(InputOTP, { maxLength: 2, defaultValue: "12", name: "code" }, () => [
|
||||
h(Label, { id: "consumer-label" }, () => "Security code"),
|
||||
h(InputOTPGroup, {}, () => [
|
||||
h(InputOTPSlot, { index: 0 }),
|
||||
h(InputOTPSlot, { index: 1 }),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
assert(html.includes('data-slot="header"'));
|
||||
assert(html.includes('aria-current="step"'));
|
||||
assert.equal(html.match(/aria-labelledby="consumer-label"/g)?.length, 2);
|
||||
assert(html.includes('value="12"'));
|
||||
assert(html.includes('name="code"'));
|
||||
const css = readFileSync(
|
||||
new URL(import.meta.resolve("@heroui-vue/styles/css")),
|
||||
"utf8",
|
||||
);
|
||||
for (const name of ["hv-header", "hv-pagination", "hv-input-otp"])
|
||||
assert(css.includes(name));
|
||||
console.log("M30–M32 independent tarball ESM/SSR/ARIA/CSS passed.");
|
||||
@@ -1,63 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import * as library from "@heroui-vue/components";
|
||||
for (const name of [
|
||||
"AlertDialog",
|
||||
"AlertDialogRoot",
|
||||
"AlertDialogTrigger",
|
||||
"AlertDialogBackdrop",
|
||||
"AlertDialogContainer",
|
||||
"AlertDialogDialog",
|
||||
"AlertDialogHeader",
|
||||
"AlertDialogHeading",
|
||||
"AlertDialogBody",
|
||||
"AlertDialogFooter",
|
||||
"AlertDialogIcon",
|
||||
"AlertDialogCloseTrigger",
|
||||
"AlertDialogClose",
|
||||
"Drawer",
|
||||
"DrawerRoot",
|
||||
"DrawerTrigger",
|
||||
"DrawerBackdrop",
|
||||
"DrawerContent",
|
||||
"DrawerDialog",
|
||||
"DrawerHeader",
|
||||
"DrawerHeading",
|
||||
"DrawerBody",
|
||||
"DrawerFooter",
|
||||
"DrawerHandle",
|
||||
"DrawerCloseTrigger",
|
||||
"DrawerClose",
|
||||
])
|
||||
assert(library[name], name);
|
||||
for (const family of ["AlertDialog", "Drawer"]) {
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(library[family], {}, () => [
|
||||
h(
|
||||
library[`${family}Trigger`],
|
||||
{ as: "button" },
|
||||
() => `Open ${family}`,
|
||||
),
|
||||
h(library[`${family}Backdrop`], {}, () =>
|
||||
family === "Drawer"
|
||||
? h(library.DrawerContent)
|
||||
: h(library.AlertDialogContainer),
|
||||
),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
assert(html.includes(`Open ${family}`));
|
||||
assert(html.includes('aria-expanded="false"'));
|
||||
}
|
||||
const css = readFileSync(
|
||||
new URL(import.meta.resolve("@heroui-vue/styles/css")),
|
||||
"utf8",
|
||||
);
|
||||
assert(css.includes(".hv-alert-dialog__dialog"));
|
||||
assert(css.includes("hv-drawer-in-from-right"));
|
||||
assert(css.includes("hv-drawer-out-to-bottom"));
|
||||
console.log("M33-M34 tarball ESM exports, node SSR and CSS passed");
|
||||
@@ -1,78 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import * as lib from "@heroui-vue/components";
|
||||
for (const name of [
|
||||
"Toast",
|
||||
"ToastRoot",
|
||||
"ToastProvider",
|
||||
"ToastContent",
|
||||
"ToastIndicator",
|
||||
"ToastTitle",
|
||||
"ToastDescription",
|
||||
"ToastActionButton",
|
||||
"ToastCloseButton",
|
||||
"ToastQueue",
|
||||
"toast",
|
||||
"toastQueue",
|
||||
"createToastFunction",
|
||||
"Table",
|
||||
"TableRoot",
|
||||
"TableContent",
|
||||
"TableHeader",
|
||||
"TableColumn",
|
||||
"TableBody",
|
||||
"TableRow",
|
||||
"TableCell",
|
||||
"TableScrollContainer",
|
||||
"TableFooter",
|
||||
"TableResizableContainer",
|
||||
"TableColumnResizer",
|
||||
"TableLoadMore",
|
||||
"TableLoadMoreItem",
|
||||
"TableLoadMoreContent",
|
||||
"TableCollection",
|
||||
"TableSortableColumnHeader",
|
||||
])
|
||||
assert(lib[name], name);
|
||||
assert.equal(lib.toast("server secret"), "");
|
||||
assert.equal(lib.toastQueue.visibleToasts.length, 0);
|
||||
const queue = new lib.ToastQueue();
|
||||
queue.add({ title: "Request-local notification" });
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h("main", [
|
||||
h(lib.ToastProvider, { queue }),
|
||||
h(lib.Table, () =>
|
||||
h(
|
||||
lib.TableContent,
|
||||
{ selectionMode: "single", selectedKeys: [0] },
|
||||
() => [
|
||||
h(lib.TableHeader, () =>
|
||||
h(lib.TableColumn, { isRowHeader: true }, () => "Name"),
|
||||
),
|
||||
h(lib.TableBody, () =>
|
||||
h(lib.TableRow, { rowKey: 0 }, () =>
|
||||
h(lib.TableCell, () => "Zero"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
assert(html.includes("Request-local notification"));
|
||||
assert(html.includes('scope="row"'));
|
||||
assert(html.includes('aria-selected="true"'));
|
||||
queue.destroy();
|
||||
const css = readFileSync(
|
||||
new URL(import.meta.resolve("@heroui-vue/styles/css")),
|
||||
"utf8",
|
||||
);
|
||||
assert(css.includes(".hv-toast-region"));
|
||||
assert(css.includes(".hv-table__column-resizer"));
|
||||
assert(css.includes("data-exiting"));
|
||||
console.log("M35/M36 tarball exports, actual node SSR and CSS passed");
|
||||
@@ -1,70 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import {
|
||||
Select,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
SelectIndicator,
|
||||
SelectClearButton,
|
||||
SelectPopover,
|
||||
ListBox,
|
||||
ListBoxItem,
|
||||
Label,
|
||||
selectVariants,
|
||||
} from "@heroui-vue/components";
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(
|
||||
Select,
|
||||
{
|
||||
defaultValue: [0, "0", ""],
|
||||
selectionMode: "multiple",
|
||||
name: "choices",
|
||||
},
|
||||
() => [
|
||||
h(Label, {}, () => "Choice"),
|
||||
h(SelectTrigger, {}, () => [
|
||||
h(SelectValue),
|
||||
h(SelectClearButton),
|
||||
h(SelectIndicator),
|
||||
]),
|
||||
h(SelectPopover, {}, () =>
|
||||
h(ListBox, {}, () => [
|
||||
h(ListBoxItem, { id: 0, textValue: "Numeric" }, () => "Numeric"),
|
||||
h(ListBoxItem, { id: "0", textValue: "String" }, () => "String"),
|
||||
h(ListBoxItem, { id: "", textValue: "Empty" }, () => "Empty"),
|
||||
]),
|
||||
),
|
||||
],
|
||||
),
|
||||
}),
|
||||
);
|
||||
assert(html.includes("Numeric, String, Empty"));
|
||||
assert(html.includes('name="choices"'));
|
||||
assert.equal((html.match(/data-index="\d" selected/g) ?? []).length, 3);
|
||||
assert(!html.includes('role="listbox"'));
|
||||
assert(html.includes('aria-haspopup="listbox"'));
|
||||
assert(
|
||||
selectVariants({ variant: "secondary" })
|
||||
.base()
|
||||
.includes("hv-select--secondary"),
|
||||
);
|
||||
const css = readFileSync(
|
||||
new URL(import.meta.resolve("@heroui-vue/styles/css")),
|
||||
"utf8",
|
||||
);
|
||||
for (const part of [
|
||||
".hv-select",
|
||||
".hv-select__trigger",
|
||||
".hv-select__value",
|
||||
".hv-select__clear-button",
|
||||
".hv-select__indicator",
|
||||
".hv-select__popover",
|
||||
])
|
||||
assert(css.includes(part));
|
||||
console.log(
|
||||
"Select independent tarball: ESM, SSR labels, raw native values, variants and CSS passed.",
|
||||
);
|
||||
@@ -1,45 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import {
|
||||
Slider,
|
||||
SliderTrack,
|
||||
SliderFill,
|
||||
SliderThumb,
|
||||
SliderOutput,
|
||||
SliderMarks,
|
||||
Label,
|
||||
sliderVariants,
|
||||
} from "@heroui-vue/components";
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(Slider, { defaultValue: [20, 80], dir: "rtl" }, () => [
|
||||
h(Label, {}, () => "Price"),
|
||||
h(SliderOutput),
|
||||
h(SliderTrack, {}, () => [
|
||||
h(SliderFill),
|
||||
h(SliderThumb, { name: "min" }),
|
||||
h(SliderThumb, { name: "max", index: 1 }),
|
||||
]),
|
||||
h(SliderMarks),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
assert(html.includes('aria-valuenow="20"'));
|
||||
assert(html.includes('aria-valuenow="80"'));
|
||||
assert(html.includes("right:20%"));
|
||||
assert(html.includes('name="min"'));
|
||||
assert(html.includes('name="max"'));
|
||||
const css = readFileSync(
|
||||
new URL(import.meta.resolve("@heroui-vue/styles/css")),
|
||||
"utf8",
|
||||
);
|
||||
assert(css.includes(".hv-slider__track"));
|
||||
assert(css.includes("prefers-reduced-motion"));
|
||||
assert(!css.includes(".hv-slider__thumb:after:not(:is())"));
|
||||
assert(sliderVariants().thumb().includes("hv-slider__thumb"));
|
||||
console.log(
|
||||
"Independent tarball consumer: ESM, SSR, CSS and six named parts passed.",
|
||||
);
|
||||
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, h, nextTick, ref } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, h, nextTick, ref } from "vue";
|
||||
import {
|
||||
Pagination,
|
||||
PaginationContent,
|
||||
@@ -583,41 +582,3 @@ describe("Pagination types", () => {
|
||||
expect(okLink.isActive).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Pagination SSR", () => {
|
||||
it("renders without touching browser globals", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(Pagination, { size: "sm" }, () => [
|
||||
h(PaginationSummary, () => "显示第 1–10 条,共 120 条结果"),
|
||||
h(PaginationContent, () => [
|
||||
h(PaginationItem, () =>
|
||||
h(PaginationPrevious, { isDisabled: true }, () => [
|
||||
h(PaginationPreviousIcon),
|
||||
h("span", "上一页"),
|
||||
]),
|
||||
),
|
||||
h(PaginationItem, () =>
|
||||
h(PaginationLink, { isActive: true }, () => "1"),
|
||||
),
|
||||
h(PaginationItem, () => h(PaginationEllipsis)),
|
||||
h(PaginationItem, () =>
|
||||
h(PaginationNext, () => [
|
||||
h("span", "下一页"),
|
||||
h(PaginationNextIcon),
|
||||
]),
|
||||
),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('data-slot="pagination"');
|
||||
expect(html).toContain("hv-pagination--sm");
|
||||
expect(html).toContain('dir="auto"');
|
||||
expect(html).toContain('aria-current="page"');
|
||||
expect(html).toContain('data-active="true"');
|
||||
expect(html).toContain("…");
|
||||
expect(html).toContain("disabled");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -222,58 +222,6 @@ it("bridges explicit PopoverDialog labels and forwards dynamic attrs to actual s
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("hydrates public roots then resolves all portal ARIA references without duplicate IDs", async () => {
|
||||
const { createSSRApp } = await import("vue");
|
||||
const { renderToString } = await import("@vue/server-renderer");
|
||||
const { Modal, ModalBackdrop, ModalContainer, ModalDialog, ModalHeading } =
|
||||
await import("../packages/vue/src");
|
||||
const appView = defineComponent({
|
||||
components: {
|
||||
...components,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalHeading,
|
||||
},
|
||||
template: `<div><Modal default-open><Button>Modal</Button><ModalBackdrop><ModalContainer><ModalDialog><ModalHeading>Modal Heading</ModalHeading></ModalDialog></ModalContainer></ModalBackdrop></Modal><Popover default-open><Button>Popover</Button>${content}</Popover><Tooltip default-open><Button>Tooltip</Button><TooltipContent>Hint</TooltipContent></Tooltip></div>`,
|
||||
});
|
||||
const host = document.createElement("div");
|
||||
document.body.append(host);
|
||||
host.innerHTML = await renderToString(createSSRApp(appView));
|
||||
const warnings = vi.spyOn(console, "warn").mockImplementation(() => {}),
|
||||
errors = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
const app = createSSRApp(appView);
|
||||
try {
|
||||
app.mount(host);
|
||||
await flushPromises();
|
||||
const ids = Array.from(document.querySelectorAll("[id]")).map(
|
||||
(el) => el.id,
|
||||
);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
for (const el of document.querySelectorAll(
|
||||
"[aria-controls],[aria-labelledby],[aria-describedby]",
|
||||
))
|
||||
for (const name of [
|
||||
"aria-controls",
|
||||
"aria-labelledby",
|
||||
"aria-describedby",
|
||||
])
|
||||
for (const id of (el.getAttribute(name) || "")
|
||||
.split(" ")
|
||||
.filter(Boolean))
|
||||
expect(document.getElementById(id), id).not.toBeNull();
|
||||
expect(warnings).not.toHaveBeenCalled();
|
||||
expect(errors).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
app.unmount();
|
||||
await flushPromises();
|
||||
host.remove();
|
||||
warnings.mockRestore();
|
||||
errors.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it("cancels a pending hover close when the parent closes and reopens the controlled tooltip", async () => {
|
||||
vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
|
||||
const open = ref(false);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { componentItems } from "../apps/docs/.vitepress/theme/navigation";
|
||||
import { describe, it, expect, afterEach, vi } from "vitest";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { describe, it, expect, afterEach } from "vitest";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, h, nextTick, ref } from "vue";
|
||||
import { defineComponent, h, nextTick, ref } from "vue";
|
||||
import {
|
||||
Label,
|
||||
TextField,
|
||||
@@ -762,70 +761,3 @@ it("isolates indicator labels from both surrounding and nested field scopes", as
|
||||
);
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
it("hydrates complete label associations with nested field isolation", async () => {
|
||||
const show = ref(true);
|
||||
const Example = defineComponent({
|
||||
render: () =>
|
||||
h("div", {}, [
|
||||
h(ProgressBar, {}, () => [
|
||||
h(Label, {}, () => "Progress"),
|
||||
...(show.value
|
||||
? [h(Label, { id: "extra-progress-label" }, () => "Detail")]
|
||||
: []),
|
||||
h(TextField, {}, () => [h(Label, {}, () => "Field"), h(Input)]),
|
||||
]),
|
||||
h(Meter, {}, () => h(Label, {}, () => "Storage")),
|
||||
h(ProgressCircle, {}, () => h(Label, {}, () => "Loading")),
|
||||
]),
|
||||
});
|
||||
const html = await renderToString(createSSRApp(Example));
|
||||
const host = document.createElement("div");
|
||||
host.innerHTML = html;
|
||||
document.body.append(host);
|
||||
function assertReferences() {
|
||||
const ids = [...host.querySelectorAll("[id]")].map((el) => el.id);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
for (const el of host.querySelectorAll("[aria-labelledby],[for]")) {
|
||||
for (const id of (
|
||||
el.getAttribute("aria-labelledby") ??
|
||||
el.getAttribute("for") ??
|
||||
""
|
||||
)
|
||||
.split(" ")
|
||||
.filter(Boolean))
|
||||
expect(ids).toContain(id);
|
||||
}
|
||||
}
|
||||
assertReferences();
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const error = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
const app = createSSRApp(Example);
|
||||
try {
|
||||
app.mount(host);
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
assertReferences();
|
||||
const progress = host.querySelector("[data-slot=progress-bar]")!;
|
||||
const nestedLabel = host.querySelector(
|
||||
"[data-slot=textfield] [data-slot=label]",
|
||||
)!;
|
||||
expect(progress.getAttribute("aria-labelledby")?.split(" ")).not.toContain(
|
||||
nestedLabel.id,
|
||||
);
|
||||
show.value = false;
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
assertReferences();
|
||||
expect(progress.getAttribute("aria-labelledby")).not.toContain(
|
||||
"extra-progress-label",
|
||||
);
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
expect(error).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
app.unmount();
|
||||
host.remove();
|
||||
warn.mockRestore();
|
||||
error.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { createSSRApp, defineComponent, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { CalendarDate, parseZonedDateTime } from "@internationalized/date";
|
||||
import Range from "../packages/vue/tests/fixtures/RangeCalendarFoundation.vue";
|
||||
describe("range foundation actual node SSR", () => {
|
||||
it("renders complete semantic ranges, namespace and closed year layer without browser globals", async () => {
|
||||
const start = new CalendarDate(2024, 2, 10),
|
||||
end = start.add({ days: 3 });
|
||||
const html = await renderToString(
|
||||
createSSRApp(
|
||||
defineComponent({
|
||||
render: () =>
|
||||
h(Range, {
|
||||
defaultValue: { start, end },
|
||||
timeZone: "UTC",
|
||||
"aria-label": "Trip dates",
|
||||
}),
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(html).toContain('data-slot="range-calendar-grid"');
|
||||
expect(html).toContain('role="grid"');
|
||||
expect(html).toContain('data-selection-start="true"');
|
||||
expect(html).toContain('data-selection-end="true"');
|
||||
expect(html).toContain('aria-hidden="true" inert');
|
||||
expect(html).not.toContain('name="');
|
||||
});
|
||||
it("retains full zoned accepted endpoints while rendering a locale-specific leap month", async () => {
|
||||
const start = parseZonedDateTime(
|
||||
"2024-02-28T13:14:45.123-08:00[America/Los_Angeles]",
|
||||
),
|
||||
end = start.add({ days: 2 });
|
||||
const html = await renderToString(
|
||||
createSSRApp(
|
||||
defineComponent({
|
||||
render: () =>
|
||||
h(Range, {
|
||||
defaultValue: { start, end },
|
||||
locale: "fa-IR-u-ca-persian",
|
||||
timeZone: "America/Los_Angeles",
|
||||
visibleDuration: { weeks: 2 },
|
||||
}),
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(html).toContain("hv-range-calendar--week-view");
|
||||
expect(html).toContain('data-selected="true"');
|
||||
expect(html).not.toContain("Invalid Date");
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, shallowRef, type Component } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, shallowRef, type Component } from "vue";
|
||||
import {
|
||||
CalendarDate,
|
||||
CalendarDateTime,
|
||||
@@ -538,26 +537,4 @@ describe("private range selection and shared calendar integration", () => {
|
||||
.replace(/\s+/g, " "),
|
||||
).toBe("January – March 2024");
|
||||
});
|
||||
it("hydrates an actual shared range table without replacing SSR nodes or leaking duplicate IDs", async () => {
|
||||
const App = defineComponent({
|
||||
components: { Range },
|
||||
setup: () => ({ initial }),
|
||||
template:
|
||||
'<div><Range :default-focused-value="initial" :default-value="{start:initial,end:initial.add({days:2})}"/><Range :default-focused-value="initial"/></div>',
|
||||
});
|
||||
const html = await renderToString(createSSRApp(App));
|
||||
const container = document.createElement("div");
|
||||
container.innerHTML = html;
|
||||
document.body.append(container);
|
||||
const table = container.querySelector("table");
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const app = createSSRApp(App);
|
||||
app.mount(container);
|
||||
await flushPromises();
|
||||
expect(container.querySelector("table")).toBe(table);
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
const ids = Array.from(container.querySelectorAll("[id]"), (n) => n.id);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
app.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import {
|
||||
ButtonGroup,
|
||||
ToggleButton,
|
||||
ToggleButtonGroup,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
afterEach(async () => {
|
||||
wrappers.splice(0).forEach((w) => w.unmount());
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { computed, defineComponent, h, nextTick, provide, ref } from "vue";
|
||||
import { ListBox, ListBoxItem } from "../packages/vue/src";
|
||||
import { ListBox, ListBoxItem } from "../../../packages/vue/src";
|
||||
import {
|
||||
collectionOwnerKey,
|
||||
type CollectionOwner,
|
||||
type OwnedCollection,
|
||||
} from "../packages/vue/src/components/collection/owner";
|
||||
import Harness from "../packages/vue/tests/fixtures/FilterVirtualCombobox.vue";
|
||||
} from "../../../packages/vue/src/components/collection/owner";
|
||||
import Harness from "../../../packages/vue/tests/fixtures/FilterVirtualCombobox.vue";
|
||||
const mounted: { unmount(): void }[] = [];
|
||||
afterEach(() => {
|
||||
while (mounted.length) mounted.pop()!.unmount();
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
import { afterEach, it, expect, vi } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { computed, defineComponent, h, nextTick, provide, ref } from "vue";
|
||||
import { ListBox, ListBoxItem } from "../packages/vue/src";
|
||||
import { ListBox, ListBoxItem } from "../../../packages/vue/src";
|
||||
import {
|
||||
collectionOwnerKey,
|
||||
type CollectionOwner,
|
||||
type OwnedCollection,
|
||||
} from "../packages/vue/src/components/collection/owner";
|
||||
import Harness from "../packages/vue/tests/fixtures/FilterVirtualCombobox.vue";
|
||||
} from "../../../packages/vue/src/components/collection/owner";
|
||||
import Harness from "../../../packages/vue/tests/fixtures/FilterVirtualCombobox.vue";
|
||||
const roots: { unmount(): void }[] = [];
|
||||
const settle = async () => {
|
||||
await nextTick();
|
||||
+1
-1
@@ -20,7 +20,7 @@ import {
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldClearButton,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
const roots: { unmount(): void }[] = [];
|
||||
const tick = async () => {
|
||||
await nextTick();
|
||||
+1
-1
@@ -7,7 +7,7 @@ import {
|
||||
ColorSliderRoot,
|
||||
ColorSliderTrack,
|
||||
ColorSliderThumb,
|
||||
} from "../packages/vue/tests/fixtures/color-probe";
|
||||
} from "../../../packages/vue/tests/fixtures/color-probe";
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
afterEach(() => {
|
||||
wrappers.splice(0).forEach((w) => w.unmount());
|
||||
+1
-1
@@ -9,7 +9,7 @@ import {
|
||||
getChannelRange,
|
||||
getChannelValue,
|
||||
getAreaBackgroundStyle,
|
||||
} from "../packages/vue/tests/fixtures/color-probe";
|
||||
} from "../../../packages/vue/tests/fixtures/color-probe";
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
afterEach(() => {
|
||||
wrappers.splice(0).forEach((w) => w.unmount());
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
import Surface from "../packages/vue/src/components/surface/Surface.vue";
|
||||
import { surfaceContextKey } from "../packages/vue/src/components/surface/context";
|
||||
import Surface from "../../../packages/vue/src/components/surface/Surface.vue";
|
||||
import { surfaceContextKey } from "../../../packages/vue/src/components/surface/context";
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { defineComponent, h, ref, inject } from "vue";
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
DropdownSubmenuIndicator,
|
||||
DropdownItem,
|
||||
Menu,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
const cleanup: (() => void)[] = [];
|
||||
afterEach(() => {
|
||||
cleanup
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import { Button, DropdownTrigger } from "../packages/vue/src";
|
||||
import { Button, DropdownTrigger } from "../../../packages/vue/src";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { defineComponent, h } from "vue";
|
||||
import {
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
DropdownSubmenuIndicator,
|
||||
Menu,
|
||||
MenuItem,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
const cleanup: (() => void)[] = [];
|
||||
afterEach(() => {
|
||||
cleanup
|
||||
+3
-3
@@ -12,7 +12,7 @@ import {
|
||||
Form,
|
||||
Pagination,
|
||||
PaginationLink,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
afterEach(async () => {
|
||||
wrappers.splice(0).forEach((w) => w.unmount());
|
||||
@@ -264,9 +264,9 @@ it("OTP resizing retains existing empty slot indices", async () => {
|
||||
});
|
||||
it("OTP form and validation examples have unique field IDs on the same page", async () => {
|
||||
const formDemo =
|
||||
await import("../apps/docs/demos/input-otp-form-example.vue");
|
||||
await import("../../../apps/docs/demos/input-otp-form-example.vue");
|
||||
const validationDemo =
|
||||
await import("../apps/docs/demos/input-otp-with-validation.vue");
|
||||
await import("../../../apps/docs/demos/input-otp-with-validation.vue");
|
||||
const wrapper = mount(
|
||||
defineComponent({
|
||||
render: () => h("div", [h(formDemo.default), h(validationDemo.default)]),
|
||||
+1
-1
@@ -7,7 +7,7 @@ import {
|
||||
DrawerContent,
|
||||
DrawerDialog,
|
||||
DrawerHeading,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
afterEach(async () => {
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { defineComponent, h, nextTick, ref } from "vue";
|
||||
import { useDrawerDrag } from "../packages/vue/src/components/drawer/useDrawerDrag";
|
||||
import { useDrawerDrag } from "../../../packages/vue/src/components/drawer/useDrawerDrag";
|
||||
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
afterEach(() => wrappers.splice(0).forEach((w) => w.unmount()));
|
||||
+1
-1
@@ -14,7 +14,7 @@ import {
|
||||
ToastContent,
|
||||
ToastTitle,
|
||||
ToastDescription,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
const cleanup: (() => void)[] = [];
|
||||
afterEach(() => {
|
||||
cleanup
|
||||
+2
-2
@@ -12,7 +12,7 @@ import {
|
||||
TableCell,
|
||||
ToastProvider,
|
||||
ToastQueue,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
const queues: ToastQueue[] = [];
|
||||
afterEach(() => {
|
||||
@@ -103,7 +103,7 @@ it("default action respects the caller's disabled state", () => {
|
||||
});
|
||||
it("the default toast demo escapes the containing preview", async () => {
|
||||
vi.useFakeTimers();
|
||||
const mod = await import("../apps/docs/demos/toast-default.vue");
|
||||
const mod = await import("../../../apps/docs/demos/toast-default.vue");
|
||||
const host = document.createElement("div");
|
||||
host.className = "component-preview-container";
|
||||
document.body.append(host);
|
||||
+1
-1
@@ -16,7 +16,7 @@ import {
|
||||
TableColumn,
|
||||
TableColumnResizer,
|
||||
TableSortableColumnHeader,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
const queues: ToastQueue[] = [];
|
||||
afterEach(() => {
|
||||
+2
-2
@@ -13,7 +13,7 @@ import {
|
||||
TableSortableColumnHeader,
|
||||
ToastProvider,
|
||||
ToastQueue,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
const queues: ToastQueue[] = [];
|
||||
afterEach(() => {
|
||||
@@ -346,7 +346,7 @@ it("load-more observes its scroll container and deduplicates an in-flight reques
|
||||
},
|
||||
);
|
||||
const { TableLoadMoreItem, TableLoadMoreContent, TableScrollContainer } =
|
||||
await import("../packages/vue/src");
|
||||
await import("../../../packages/vue/src");
|
||||
const loading = ref(false);
|
||||
const load = vi.fn();
|
||||
const w = mount(
|
||||
+2
-2
@@ -12,7 +12,7 @@ import {
|
||||
TableRow,
|
||||
TableCell,
|
||||
TableSortableColumnHeader,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
const queues: ToastQueue[] = [];
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
afterEach(() => {
|
||||
@@ -65,7 +65,7 @@ it("promise resolving after early close does not create a replacement notificati
|
||||
expect(q.visibleToasts).toHaveLength(0);
|
||||
});
|
||||
it("variant demo renders actual Vue labels rather than JSX-like literals", async () => {
|
||||
const mod = await import("../apps/docs/demos/toast-variants.vue");
|
||||
const mod = await import("../../../apps/docs/demos/toast-variants.vue");
|
||||
const w = mount(mod.default);
|
||||
wrappers.push(w);
|
||||
expect(w.findAll("button").map((b) => b.text())).toEqual([
|
||||
+2
-2
@@ -12,7 +12,7 @@ import {
|
||||
TableBody,
|
||||
TableRow,
|
||||
TableCell,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
const queues: ToastQueue[] = [];
|
||||
afterEach(() => {
|
||||
@@ -129,7 +129,7 @@ it("the provider exposed toast factory uses the current queue after replacement"
|
||||
expect(b.visibleToasts.map((t) => t.content.title)).toContain("current");
|
||||
});
|
||||
it("selection demo select-all checks the actual row controls", async () => {
|
||||
const mod = await import("../apps/docs/demos/table-selection.vue");
|
||||
const mod = await import("../../../apps/docs/demos/table-selection.vue");
|
||||
const w = mount(mod.default);
|
||||
wrappers.push(w);
|
||||
const controls = w.findAll('input[type="checkbox"]');
|
||||
+3
-3
@@ -11,7 +11,7 @@ import {
|
||||
TableRow,
|
||||
TableCell,
|
||||
TableColumn,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
const queues: ToastQueue[] = [];
|
||||
afterEach(() => {
|
||||
@@ -91,13 +91,13 @@ it("a sortable column forwards user click and honors its cancellation", async ()
|
||||
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 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 mod = await import("../../../apps/docs/demos/table-sorting.vue");
|
||||
const w = mount(mod.default);
|
||||
wrappers.push(w);
|
||||
const column = w.findAll("th")[1];
|
||||
+1
-1
@@ -24,7 +24,7 @@ import {
|
||||
ToastQueue,
|
||||
ToastTitle,
|
||||
createToastFunction,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
const queues: ToastQueue[] = [];
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
Toolbar,
|
||||
ToggleButton,
|
||||
ToggleButtonGroup,
|
||||
} from "../packages/vue/src";
|
||||
} from "../../../packages/vue/src";
|
||||
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
afterEach(() => {
|
||||
@@ -260,40 +260,6 @@ it("matches all 7/10 fixed baseline previews and mounts every shared SFC without
|
||||
expect(error.mock.calls).toEqual([]);
|
||||
});
|
||||
|
||||
it("hydrates initial IDs without mismatches and updates the actual linked panel", async () => {
|
||||
const { createSSRApp } = await import("vue");
|
||||
const { renderToString } = await import("@vue/server-renderer");
|
||||
const html = await renderToString(createSSRApp(BasicTabs));
|
||||
const root = document.createElement("div");
|
||||
root.innerHTML = html;
|
||||
document.body.appendChild(root);
|
||||
const before = Array.from(root.querySelectorAll("[role=tab]")).map(
|
||||
(el) => el.id,
|
||||
);
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {}),
|
||||
error = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
const app = createSSRApp(BasicTabs);
|
||||
app.mount(root);
|
||||
await settle();
|
||||
try {
|
||||
expect(
|
||||
Array.from(root.querySelectorAll("[role=tab]")).map((el) => el.id),
|
||||
).toEqual(before);
|
||||
expect(warn.mock.calls).toEqual([]);
|
||||
expect(error.mock.calls).toEqual([]);
|
||||
const last = root.querySelectorAll("[role=tab]")[2] as HTMLElement;
|
||||
last.dispatchEvent(
|
||||
new MouseEvent("mousedown", { bubbles: true, button: 0 }),
|
||||
);
|
||||
await settle();
|
||||
expect(
|
||||
document.getElementById(last.getAttribute("aria-controls")!)?.hidden,
|
||||
).toBe(false);
|
||||
} finally {
|
||||
app.unmount();
|
||||
}
|
||||
});
|
||||
|
||||
it("preserves dynamic caller ARIA through the native slot boundary", async () => {
|
||||
const controls = ref("external"),
|
||||
label = ref("label-one");
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import {
|
||||
Select,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
SelectPopover,
|
||||
ListBox,
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
Label,
|
||||
Description,
|
||||
} from "../packages/vue/src";
|
||||
function select() {
|
||||
return h(
|
||||
Select,
|
||||
{ defaultValue: [0, "0", ""], selectionMode: "multiple", name: "choices" },
|
||||
() => [
|
||||
h(Label, {}, () => "选择"),
|
||||
h(SelectTrigger, {}, () => h(SelectValue)),
|
||||
h(Description, {}, () => "帮助"),
|
||||
h(SelectPopover, {}, () =>
|
||||
h(ListBox, {}, () => [
|
||||
h(ListBoxItem, { id: 0 }, () => [
|
||||
h(Label, {}, () => "Number"),
|
||||
h(Description, {}, () => "Excluded"),
|
||||
h(ListBoxItemIndicator),
|
||||
]),
|
||||
h(ListBoxItem, { id: "0" }, () => "String"),
|
||||
h(ListBoxItem, { id: "" }, () => "Empty"),
|
||||
]),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
describe("Select server rendering", () => {
|
||||
it("renders closed metadata and repeated native selected values without browser globals", async () => {
|
||||
expect(typeof window).toBe("undefined");
|
||||
const html = await renderToString(
|
||||
createSSRApp({ render: () => h("form", [select(), select()]) }),
|
||||
);
|
||||
expect(html.match(/Number, String, Empty/g)).toHaveLength(2);
|
||||
expect(html.match(/data-index="\d" selected/g)).toHaveLength(6);
|
||||
expect(html).not.toContain('role="listbox"');
|
||||
expect(html).not.toContain("Excluded");
|
||||
const ids = [...html.matchAll(/ id="([^"]+)"/g)].map((m) => m[1]);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
for (const match of html.matchAll(
|
||||
/aria-(?:labelledby|describedby)="([^"]+)"/g,
|
||||
))
|
||||
for (const id of match[1].split(" ")) expect(ids).toContain(id);
|
||||
});
|
||||
it("uses explicit metadata for opaque options and isolates SSR request IDs", async () => {
|
||||
const app = () =>
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(
|
||||
Select,
|
||||
{ defaultValue: 0, items: [{ id: 0, textValue: "Known" }] },
|
||||
() => h(SelectTrigger, {}, () => h(SelectValue)),
|
||||
),
|
||||
});
|
||||
const first = await renderToString(app());
|
||||
expect(first).toContain("Known");
|
||||
expect(first).toBe(await renderToString(app()));
|
||||
});
|
||||
it("rejects duplicate or malformed keys before mounting", async () => {
|
||||
const app = (items: { id: string | number; textValue: string }[]) =>
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(Select, { items }, () =>
|
||||
h(SelectTrigger, {}, () => h(SelectValue)),
|
||||
),
|
||||
});
|
||||
await expect(
|
||||
renderToString(
|
||||
app([
|
||||
{ id: "a", textValue: "A" },
|
||||
{ id: "a", textValue: "B" },
|
||||
]),
|
||||
),
|
||||
).rejects.toThrow("Duplicate collection key");
|
||||
});
|
||||
});
|
||||
+1
-89
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount, flushPromises, DOMWrapper } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, h, ref } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, ref } from "vue";
|
||||
import {
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
@@ -187,19 +186,6 @@ describe("Select public contracts", () => {
|
||||
expect(trigger(w).attributes("aria-expanded")).toBe("false");
|
||||
expect(trigger(w).attributes("aria-label")).toBe("Named");
|
||||
});
|
||||
it("renders selected labels and native submission on SSR without mounting popup", async () => {
|
||||
const app = createSSRApp(
|
||||
defineComponent({
|
||||
components,
|
||||
template: `<Select name="choice" :default-value="0">${content}</Select>`,
|
||||
}),
|
||||
);
|
||||
const html = await renderToString(app);
|
||||
expect(html).toContain("Zero number");
|
||||
expect(html).not.toContain('role="listbox"');
|
||||
expect(html).toContain('name="choice"');
|
||||
expect(html).toContain('value="0" data-index="0" selected');
|
||||
});
|
||||
});
|
||||
|
||||
describe("Select form and collection changes", () => {
|
||||
@@ -344,80 +330,6 @@ describe("Select popup boundary", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Select hydration and baseline demos", () => {
|
||||
it("hydrates default closed metadata, IDs and native selection without mismatches", async () => {
|
||||
const Component = defineComponent({
|
||||
components,
|
||||
template: `<Select name="choice" :default-value="0">${content}</Select>`,
|
||||
});
|
||||
const host = document.createElement("div");
|
||||
host.innerHTML = await renderToString(createSSRApp(Component));
|
||||
document.body.append(host);
|
||||
const before = host.querySelector('[data-slot="select-trigger"]');
|
||||
const warnings: string[] = [];
|
||||
const app = createSSRApp(Component);
|
||||
app.config.warnHandler = (message) => warnings.push(message);
|
||||
app.mount(host);
|
||||
await flushPromises();
|
||||
try {
|
||||
expect(warnings).toEqual([]);
|
||||
expect(host.querySelector('[data-slot="select-trigger"]')).toBe(before);
|
||||
expect(
|
||||
host.querySelector("select")?.selectedOptions[0].dataset.index,
|
||||
).toBe("0");
|
||||
} finally {
|
||||
app.unmount();
|
||||
}
|
||||
});
|
||||
it("mounts all nineteen source demos with unique IDs and real async data", async () => {
|
||||
const original = globalThis.fetch;
|
||||
globalThis.fetch = async () =>
|
||||
new Response(
|
||||
JSON.stringify({ next: null, results: [{ name: "bulbasaur" }] }),
|
||||
{ status: 200, headers: { "content-type": "application/json" } },
|
||||
);
|
||||
try {
|
||||
const demos = import.meta.glob("../apps/docs/demos/select-*.vue", {
|
||||
eager: true,
|
||||
import: "default",
|
||||
});
|
||||
expect(Object.keys(demos)).toHaveLength(19);
|
||||
const warnings: string[] = [];
|
||||
const w = mount(
|
||||
defineComponent({
|
||||
render: () =>
|
||||
h(
|
||||
"main",
|
||||
Object.values(demos).map((component) =>
|
||||
h(component as ReturnType<typeof defineComponent>),
|
||||
),
|
||||
),
|
||||
}),
|
||||
{
|
||||
attachTo: document.body,
|
||||
global: {
|
||||
config: { warnHandler: (message) => warnings.push(message) },
|
||||
},
|
||||
},
|
||||
);
|
||||
wrappers.push(w);
|
||||
await flushPromises();
|
||||
expect(warnings).toEqual([]);
|
||||
const ids = w.findAll("[id]").map((node) => node.attributes("id"));
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
expect(w.findAll('[data-slot="select-trigger"]')).toHaveLength(23);
|
||||
const asyncDemo = w
|
||||
.findAllComponents(Select)
|
||||
.find(
|
||||
(component) => component.props("placeholder") === "请选择宝可梦",
|
||||
)!;
|
||||
expect(asyncDemo.get("select").text()).toContain("bulbasaur");
|
||||
} finally {
|
||||
globalThis.fetch = original;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("Select names, cancellation and closed keyboard", () => {
|
||||
it("moves focus on field Label click without opening the menu", async () => {
|
||||
const w = fixture(`<Select>${content}</Select>`);
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { expect, it } from "vitest";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import Foundation from "../packages/vue/tests/fixtures/SliderFoundation.vue";
|
||||
|
||||
it("records that raw collection thumbs have no value or stable position on the server", async () => {
|
||||
expect(typeof window).toBe("undefined");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () => h(Foundation, { defaultValue: [20, 80] }),
|
||||
}),
|
||||
);
|
||||
expect(html.match(/role="slider"/g)).toHaveLength(2);
|
||||
expect(html).not.toContain("aria-valuenow=");
|
||||
expect(html).toContain("display:none");
|
||||
});
|
||||
@@ -1,37 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { expect, it } from "vitest";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import {
|
||||
Slider,
|
||||
SliderTrack,
|
||||
SliderFill,
|
||||
SliderThumb,
|
||||
SliderOutput,
|
||||
Label,
|
||||
} from "../packages/vue/src";
|
||||
it("renders explicit native range values, positions and composed label on the server", async () => {
|
||||
expect(typeof window).toBe("undefined");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(Slider, { defaultValue: [20, 80] }, () => [
|
||||
h(Label, {}, () => "Price"),
|
||||
h(SliderOutput),
|
||||
h(SliderTrack, {}, () => [
|
||||
h(SliderFill),
|
||||
h(SliderThumb, { name: "min" }),
|
||||
h(SliderThumb, { index: 1, name: "max" }),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('aria-valuenow="20"');
|
||||
expect(html).toContain('aria-valuenow="80"');
|
||||
expect(html).toContain("left:20%");
|
||||
expect(html).toContain("left:80%");
|
||||
expect(html).not.toContain("display:none");
|
||||
const labelId = html.match(/<span[^>]*id="([^"]+)"/)?.[1];
|
||||
expect(labelId).toBeDefined();
|
||||
expect(html).toContain(`aria-labelledby="${labelId}"`);
|
||||
});
|
||||
+1
-35
@@ -1,7 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, h, ref } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { defineComponent, ref } from "vue";
|
||||
import {
|
||||
Slider,
|
||||
SliderTrack,
|
||||
@@ -241,39 +240,6 @@ describe("Slider public contracts", () => {
|
||||
expect(sliders(wrapper)[0].attributes("aria-describedby")).toBeUndefined();
|
||||
expect(wrapper.find(".custom-thumb").exists()).toBe(false);
|
||||
});
|
||||
it("hydrates explicit range positions and names without warnings", async () => {
|
||||
const app = {
|
||||
render: () =>
|
||||
h(Slider, { defaultValue: [20, 80] }, () => [
|
||||
h(Label, {}, () => "Price"),
|
||||
h(SliderTrack, {}, () => [
|
||||
h(SliderFill),
|
||||
h(SliderThumb),
|
||||
h(SliderThumb, { index: 1 }),
|
||||
]),
|
||||
]),
|
||||
};
|
||||
const html = await renderToString(createSSRApp(app));
|
||||
const container = document.createElement("div");
|
||||
container.innerHTML = html;
|
||||
document.body.append(container);
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const error = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
const client = createSSRApp(app);
|
||||
try {
|
||||
client.mount(container);
|
||||
await flushPromises();
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
expect(error).not.toHaveBeenCalled();
|
||||
expect(
|
||||
[...container.querySelectorAll("input")].map((input) => input.value),
|
||||
).toEqual(["20", "80"]);
|
||||
} finally {
|
||||
client.unmount();
|
||||
warn.mockRestore();
|
||||
error.mockRestore();
|
||||
}
|
||||
});
|
||||
it("compiles and mounts all nine baseline demos without Vue warnings", async () => {
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
try {
|
||||
|
||||
@@ -1,601 +0,0 @@
|
||||
// @vitest-environment node
|
||||
import { it, expect } from "vitest";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Input,
|
||||
Switch,
|
||||
Surface,
|
||||
Link,
|
||||
LinkIcon,
|
||||
Spinner,
|
||||
TextArea,
|
||||
} from "../packages/vue/src";
|
||||
it("renders the initial components without browser globals", async () => {
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(Card, () => [
|
||||
h(Button, () => "保存"),
|
||||
h(Input, { modelValue: "名称" }),
|
||||
h(Switch, { checked: true, "aria-label": "通知" }),
|
||||
h(Surface, { variant: "secondary" }, () => h("span", "表面")),
|
||||
h(Link, { href: "#" }, () => ["链接", h(LinkIcon)]),
|
||||
h(Spinner),
|
||||
h(TextArea, { modelValue: "备注" }),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain("保存");
|
||||
expect(html).toContain('value="名称"');
|
||||
expect(html).toContain('role="switch"');
|
||||
expect(html).toContain("hv-surface--secondary");
|
||||
expect(html).toContain('data-slot="link"');
|
||||
expect(html).toContain('role="status"');
|
||||
expect(html).toContain('data-slot="textarea"');
|
||||
});
|
||||
|
||||
it("renders complete field associations without browser globals", async () => {
|
||||
const { TextField, Label, Description, FieldError, Form } =
|
||||
await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(Form, {}, () => [
|
||||
h(
|
||||
TextField,
|
||||
{ name: "email", defaultValue: "a@example.com", isInvalid: true },
|
||||
() => [
|
||||
h(Label, {}, () => "Email"),
|
||||
h(Input),
|
||||
h(Description, {}, () => "Hint"),
|
||||
h(FieldError, {}, () => "Error"),
|
||||
],
|
||||
),
|
||||
h(TextField, { name: "notes" }, () => [
|
||||
h(Label, {}, () => "Notes"),
|
||||
h(TextArea),
|
||||
h(Description, {}, () => "Other hint"),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
const ids = [...html.matchAll(/\sid="([^"]+)"/g)].map((match) => match[1]);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
const refs = [
|
||||
...html.matchAll(/(?:for|aria-describedby)="([^"]+)"/g),
|
||||
].flatMap((match) => match[1].split(" "));
|
||||
expect(refs.length).toBeGreaterThan(3);
|
||||
for (const id of refs) expect(ids).toContain(id);
|
||||
expect(html).toContain('value="a@example.com"');
|
||||
});
|
||||
|
||||
it("associates labels with explicit grouped control IDs on the server", async () => {
|
||||
const {
|
||||
TextField,
|
||||
Label,
|
||||
InputGroup,
|
||||
InputGroupInput,
|
||||
InputGroupTextArea,
|
||||
Description,
|
||||
} = await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h("div", {}, [
|
||||
h(TextField, {}, () => [
|
||||
h(Label, {}, () => "Email"),
|
||||
h(InputGroup, {}, () => [
|
||||
h(InputGroupInput, { id: "grouped-email" }),
|
||||
]),
|
||||
h(Description, {}, () => "Hint"),
|
||||
]),
|
||||
h(TextField, {}, () => [
|
||||
h(Label, {}, () => "Notes"),
|
||||
h(InputGroup, {}, () => [
|
||||
h(InputGroupTextArea, { id: "grouped-notes" }),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('for="grouped-email"');
|
||||
expect(html).toContain('for="grouped-notes"');
|
||||
const ids = [...html.matchAll(/\sid="([^"]+)"/g)].map((m) => m[1]);
|
||||
const refs = [
|
||||
...html.matchAll(/(?:for|aria-describedby)="([^"]+)"/g),
|
||||
].flatMap((m) => m[1].split(" "));
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
for (const id of refs) expect(ids).toContain(id);
|
||||
});
|
||||
|
||||
it("renders disabled fieldsets and search fields without browser globals", async () => {
|
||||
const {
|
||||
Fieldset,
|
||||
FieldsetLegend,
|
||||
SearchField,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldClearButton,
|
||||
Label,
|
||||
Description,
|
||||
} = await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(Fieldset, { disabled: true }, () => [
|
||||
h(FieldsetLegend, {}, () => h(Button, {}, () => "Exempt")),
|
||||
h(SearchField, { defaultValue: "query", name: "q" }, () => [
|
||||
h(Label, {}, () => "Query"),
|
||||
h(SearchFieldGroup, {}, () => [
|
||||
h(SearchFieldInput, { id: "ssr-search" }),
|
||||
h(SearchFieldClearButton),
|
||||
]),
|
||||
h(Description, {}, () => "Hint"),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('for="ssr-search"');
|
||||
expect(html).toContain('type="search"');
|
||||
expect(html).toContain('value="query"');
|
||||
expect(html).toContain('data-slot="search-field-clear-button"');
|
||||
expect(html).toContain('data-disabled="true"');
|
||||
});
|
||||
|
||||
it("renders choice groups and nested content associations without browser globals", async () => {
|
||||
const {
|
||||
CheckboxGroup,
|
||||
Checkbox,
|
||||
CheckboxContent,
|
||||
RadioGroup,
|
||||
Radio,
|
||||
RadioContent,
|
||||
Label,
|
||||
Description,
|
||||
} = await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h("form", {}, [
|
||||
h(
|
||||
CheckboxGroup,
|
||||
{ name: "features", defaultValue: ["a"], isRequired: true },
|
||||
() => [
|
||||
h(Label, {}, () => "Features"),
|
||||
h(Checkbox, { value: "a" }, () =>
|
||||
h(CheckboxContent, {}, () => [
|
||||
"A",
|
||||
h(Description, {}, () => "Nested hint"),
|
||||
]),
|
||||
),
|
||||
],
|
||||
),
|
||||
h(RadioGroup, { name: "plan", defaultValue: "pro" }, () => [
|
||||
h(Label, {}, () => "Plan"),
|
||||
h(Radio, { value: "basic" }, () =>
|
||||
h(RadioContent, {}, () => "Basic"),
|
||||
),
|
||||
h(Radio, { value: "pro" }, () => h(RadioContent, {}, () => "Pro")),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('name="features"');
|
||||
expect(html).toContain('name="plan"');
|
||||
expect(html).toContain('value="pro" checked');
|
||||
const ids = [...html.matchAll(/\sid="([^"]+)"/g)].map((m) => m[1]);
|
||||
const refs = [
|
||||
...html.matchAll(/aria-(?:labelledby|describedby)="([^"]+)"/g),
|
||||
].flatMap((m) => m[1].split(" "));
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
expect(refs.length).toBeGreaterThan(2);
|
||||
for (const id of refs) expect(ids).toContain(id);
|
||||
});
|
||||
|
||||
it("renders typography, empty state and breadcrumbs without browser globals", async () => {
|
||||
const {
|
||||
Typography,
|
||||
TypographyHeading,
|
||||
TypographyParagraph,
|
||||
TypographyCode,
|
||||
TypographyProse,
|
||||
EmptyState,
|
||||
Breadcrumbs,
|
||||
BreadcrumbsItem,
|
||||
} = await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h("div", {}, [
|
||||
h(Typography, { type: "h2" }, () => "排版标题"),
|
||||
h(TypographyHeading, { level: 3 }, () => "三级标题"),
|
||||
h(TypographyParagraph, { size: "sm" }, () => "正文"),
|
||||
h(TypographyCode, {}, () => "code"),
|
||||
h(TypographyProse, {}, () => h("p", "富文本段落")),
|
||||
h(EmptyState),
|
||||
h(Breadcrumbs, {}, () => [
|
||||
h(BreadcrumbsItem, { href: "#home" }, () => "首页"),
|
||||
h(BreadcrumbsItem, null, () => "当前页"),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
|
||||
expect(html).toContain("<h2");
|
||||
expect(html).toContain("hv-typography--h2");
|
||||
expect(html).toContain('data-type="h3"');
|
||||
expect(html).toContain("No results found");
|
||||
expect(html).toContain('aria-label="Breadcrumbs"');
|
||||
expect(html).toContain('aria-current="page"');
|
||||
expect(html).toContain('data-current="true"');
|
||||
expect(html).toContain("hv-breadcrumbs__separator");
|
||||
expect(html).toContain("富文本段落");
|
||||
});
|
||||
|
||||
it("renders progress and meter indicators without browser globals", async () => {
|
||||
const {
|
||||
Label,
|
||||
Meter,
|
||||
MeterFill,
|
||||
MeterOutput,
|
||||
MeterTrack,
|
||||
ProgressBar,
|
||||
ProgressBarFill,
|
||||
ProgressBarOutput,
|
||||
ProgressBarTrack,
|
||||
ProgressCircle,
|
||||
ProgressCircleFillCircle,
|
||||
ProgressCircleTrack,
|
||||
ProgressCircleTrackCircle,
|
||||
} = await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h("div", {}, [
|
||||
h(ProgressBar, { value: 60 }, () => [
|
||||
h(Label, null, () => "加载中"),
|
||||
h(ProgressBarOutput),
|
||||
h(ProgressBarTrack, null, () => h(ProgressBarFill)),
|
||||
]),
|
||||
h(
|
||||
ProgressCircle,
|
||||
{ isIndeterminate: true, "aria-label": "加载中" },
|
||||
() => [
|
||||
h(ProgressCircleTrack, null, () => [
|
||||
h(ProgressCircleTrackCircle),
|
||||
h(ProgressCircleFillCircle),
|
||||
]),
|
||||
],
|
||||
),
|
||||
h(Meter, { value: 40, "aria-label": "存储空间" }, () => [
|
||||
h(MeterOutput),
|
||||
h(MeterTrack, null, () => h(MeterFill)),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
|
||||
expect(html).toContain('role="progressbar"');
|
||||
expect(html).toContain('aria-valuenow="60"');
|
||||
expect(html).toContain('aria-valuetext="60%"');
|
||||
expect(html).toContain("hv-progress-bar__fill");
|
||||
expect(html).toContain("hv-progress-circle__fill-circle");
|
||||
// Indeterminate progress must not expose aria-valuenow.
|
||||
expect(html.match(/aria-valuenow/g)).toHaveLength(2);
|
||||
expect(html).toContain('role="meter progressbar"');
|
||||
expect(html).toContain('aria-valuenow="40"');
|
||||
expect(html).toContain('data-slot="meter-output"');
|
||||
// Label association ids are present in the server HTML and resolve to labels.
|
||||
const labelledby = html.match(/aria-labelledby="([^"]+)"/)?.[1];
|
||||
expect(labelledby).toBeTruthy();
|
||||
for (const id of labelledby!.split(/\s+/)) {
|
||||
expect(html).toMatch(new RegExp(`id="${id}"[^>]*data-slot="label"`));
|
||||
}
|
||||
});
|
||||
|
||||
it("renders disclosure group and accordion without browser globals", async () => {
|
||||
const {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
Disclosure,
|
||||
DisclosureContent,
|
||||
DisclosureGroup,
|
||||
DisclosureHeading,
|
||||
DisclosureTrigger,
|
||||
} = await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h("div", {}, [
|
||||
h(DisclosureGroup, { defaultExpandedKeys: ["a"] }, () => [
|
||||
h(Disclosure, { id: "a" }, () => [
|
||||
h(DisclosureHeading, {}, () =>
|
||||
h(DisclosureTrigger, {}, () => "标题A"),
|
||||
),
|
||||
h(DisclosureContent, {}, () => "内容A"),
|
||||
]),
|
||||
]),
|
||||
h(Accordion, { defaultExpandedKeys: ["x"] }, () => [
|
||||
h(AccordionItem, { id: "x" }, () => [
|
||||
h(AccordionHeading, {}, () =>
|
||||
h(AccordionTrigger, {}, () => "手风琴"),
|
||||
),
|
||||
h(AccordionPanel, {}, () => h(AccordionBody, {}, () => "正文")),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('data-slot="disclosure-group"');
|
||||
expect(html).toContain('aria-expanded="true"');
|
||||
expect(html).toContain('data-slot="accordion-item"');
|
||||
expect(html).toContain("正文");
|
||||
const controls = [...html.matchAll(/aria-controls="([^"]+)"/g)].map(
|
||||
(m) => m[1],
|
||||
);
|
||||
expect(controls.length).toBeGreaterThan(0);
|
||||
for (const id of controls) {
|
||||
expect(html).toContain(`id="${id}"`);
|
||||
}
|
||||
});
|
||||
|
||||
it("renders overlay state and closed/open roots without accessing browser globals", async () => {
|
||||
const { useOverlayState, ConfigProvider } =
|
||||
await import("../packages/vue/src");
|
||||
const { default: OverlayDialogRoot } =
|
||||
await import("../packages/vue/src/components/overlay/OverlayDialogRoot.vue");
|
||||
const { default: OverlayPortal } =
|
||||
await import("../packages/vue/src/components/overlay/OverlayPortal.vue");
|
||||
const { default: OverlayDialogContent } =
|
||||
await import("../packages/vue/src/components/overlay/OverlayDialogContent.vue");
|
||||
const { DialogTrigger, DialogTitle, DialogDescription } =
|
||||
await import("../packages/vue/src/components/overlay/primitives");
|
||||
for (const initiallyOpen of [false, true]) {
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
setup() {
|
||||
const state = useOverlayState({ defaultOpen: initiallyOpen });
|
||||
return () =>
|
||||
h(
|
||||
ConfigProvider,
|
||||
{ dir: "rtl", locale: "ar", teleportTo: "#portals" },
|
||||
() =>
|
||||
h(OverlayDialogRoot, { state }, () => [
|
||||
h(DialogTrigger, {}, () => "Open"),
|
||||
h(OverlayPortal, {}, () =>
|
||||
h(OverlayDialogContent, {}, () => [
|
||||
h(DialogTitle, {}, () => "Title"),
|
||||
h(DialogDescription, {}, () => "Hint"),
|
||||
]),
|
||||
),
|
||||
]),
|
||||
);
|
||||
},
|
||||
}),
|
||||
);
|
||||
expect(html).toContain(`aria-expanded="${initiallyOpen}"`);
|
||||
expect(html).not.toContain('role="dialog"'); // Portals deliberately render after client mount.
|
||||
}
|
||||
});
|
||||
|
||||
it("renders public Modal Popover and Tooltip roots without browser globals", async () => {
|
||||
const {
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalHeading,
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
} = await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h("div", {}, [
|
||||
h(Modal, { defaultOpen: true }, () => [
|
||||
h(Button, {}, () => "Modal"),
|
||||
h(ModalBackdrop, {}, () =>
|
||||
h(ModalContainer, {}, () =>
|
||||
h(ModalDialog, {}, () => h(ModalHeading, {}, () => "Heading")),
|
||||
),
|
||||
),
|
||||
]),
|
||||
h(Popover, { defaultOpen: true }, () => [
|
||||
h(Button, {}, () => "Popover"),
|
||||
h(PopoverContent, {}, () =>
|
||||
h(PopoverDialog, {}, () =>
|
||||
h(PopoverHeading, {}, () => "Heading"),
|
||||
),
|
||||
),
|
||||
]),
|
||||
h(Tooltip, { defaultOpen: true }, () => [
|
||||
h(Button, {}, () => "Tooltip"),
|
||||
h(TooltipContent, {}, () => "Hint"),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('aria-expanded="true"');
|
||||
expect(html).toContain("aria-describedby=");
|
||||
expect(html).not.toContain('role="dialog"');
|
||||
expect(html).not.toContain('role="tooltip"');
|
||||
});
|
||||
|
||||
it("renders ScrollShadow and Tabs without browser globals and resolves initial panel IDs", async () => {
|
||||
const { ScrollShadow, Tabs, TabsList, TabsTab, TabsPanel, TabsIndicator } =
|
||||
await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(Tabs, {}, () => [
|
||||
h(TabsList, { "aria-label": "SSR tabs" }, () => [
|
||||
h(TabsTab, { value: "a" }, () => ["A", h(TabsIndicator)]),
|
||||
h(TabsTab, { value: "b" }, () => ["B", h(TabsIndicator)]),
|
||||
]),
|
||||
h(TabsPanel, { value: "a" }, () =>
|
||||
h(ScrollShadow, { visibility: "bottom" }, () => "SSR content"),
|
||||
),
|
||||
h(TabsPanel, { value: "b" }, () => "not selected"),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('aria-selected="true"');
|
||||
expect(html).toContain('data-bottom-scroll="true"');
|
||||
expect(html).toContain("SSR content");
|
||||
expect(html).not.toContain("not selected");
|
||||
const controls = html.match(/aria-controls="([^"]+)"/)?.[1];
|
||||
expect(controls).toBeTruthy();
|
||||
expect(html).toContain(`id="${controls}"`);
|
||||
});
|
||||
|
||||
it("renders ButtonGroup and Toggle families without browser globals", async () => {
|
||||
const {
|
||||
Button,
|
||||
ButtonGroup,
|
||||
ButtonGroupSeparator,
|
||||
ToggleButton,
|
||||
ToggleButtonGroup,
|
||||
ToggleButtonGroupSeparator,
|
||||
} = await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () => [
|
||||
h(ButtonGroup, { size: "sm", variant: "secondary" }, () => [
|
||||
h(Button, () => "First"),
|
||||
h(Button, () => [h(ButtonGroupSeparator), "Second"]),
|
||||
]),
|
||||
h(ToggleButton, { defaultSelected: true }, () => "Like"),
|
||||
h(
|
||||
ToggleButtonGroup,
|
||||
{ selectionMode: "multiple", defaultSelectedKeys: ["bold"] },
|
||||
() => [
|
||||
h(ToggleButton, { id: "bold" }, () => "Bold"),
|
||||
h(ToggleButton, { id: "italic" }, () => [
|
||||
h(ToggleButtonGroupSeparator),
|
||||
"Italic",
|
||||
]),
|
||||
],
|
||||
),
|
||||
],
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('data-slot="button-group"');
|
||||
expect(html).toContain("hv-button--sm");
|
||||
expect(html).toContain("hv-button--secondary");
|
||||
expect(html).toContain('data-slot="button-group-separator"');
|
||||
expect(html).toContain('aria-pressed="true"');
|
||||
expect(html).toContain('data-slot="toggle-button-group"');
|
||||
expect(html).toContain('role="toolbar"');
|
||||
expect(html).toContain('data-selected="true"');
|
||||
expect(html).toContain('data-slot="toggle-button-group-separator"');
|
||||
});
|
||||
|
||||
it("keeps ToggleButton group keys out of DOM ids on the server", async () => {
|
||||
const { ToggleButton, ToggleButtonGroup } =
|
||||
await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(ToggleButtonGroup, { selectionMode: "multiple" }, () => [
|
||||
h(ToggleButton, { id: 1 }, () => "number"),
|
||||
h(ToggleButton, { id: "1" }, () => "string"),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).not.toMatch(/id="1"/);
|
||||
expect(html).toContain("number");
|
||||
expect(html).toContain("string");
|
||||
const ids = [...html.matchAll(/id="([^"]+)"/g)].map((m) => m[1]);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
});
|
||||
|
||||
it("keeps standalone ToggleButton DOM ids stable on the server", async () => {
|
||||
const { ToggleButton } = await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () => h(ToggleButton, { id: "like-toggle" }, () => "Like"),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('id="like-toggle"');
|
||||
});
|
||||
|
||||
it("renders Toolbar with nested groups without browser globals", async () => {
|
||||
const {
|
||||
Toolbar,
|
||||
Button,
|
||||
ButtonGroup,
|
||||
Separator,
|
||||
ToggleButton,
|
||||
ToggleButtonGroup,
|
||||
} = await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(
|
||||
Toolbar,
|
||||
{
|
||||
"aria-label": "文本格式",
|
||||
orientation: "vertical",
|
||||
isAttached: true,
|
||||
},
|
||||
() => [
|
||||
h(ToggleButtonGroup, { selectionMode: "multiple" }, () => [
|
||||
h(ToggleButton, { id: "bold" }, () => "Bold"),
|
||||
]),
|
||||
h(Separator),
|
||||
h(ButtonGroup, () => h(Button, () => "Copy")),
|
||||
],
|
||||
),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('role="toolbar"');
|
||||
expect(html).toContain('aria-orientation="vertical"');
|
||||
expect(html).toContain("hv-toolbar--attached");
|
||||
expect(html).toContain('data-slot="toggle-button-group"');
|
||||
expect(html).toContain("hv-separator--horizontal");
|
||||
expect(html).toContain('data-slot="button-group"');
|
||||
});
|
||||
|
||||
it("renders NumberField in node with initial control associations and numeric submission", async () => {
|
||||
const {
|
||||
NumberField,
|
||||
NumberFieldGroup,
|
||||
NumberFieldInput,
|
||||
Label,
|
||||
Description,
|
||||
} = await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(
|
||||
NumberField,
|
||||
{ defaultValue: 12.5, name: "amount", locale: "de-DE" },
|
||||
() => [
|
||||
h(Label, {}, () => "Amount"),
|
||||
h(NumberFieldGroup, {}, () => [h(NumberFieldInput)]),
|
||||
h(Description, {}, () => "Help"),
|
||||
],
|
||||
),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('value="12,5"');
|
||||
expect(html).toContain('name="amount"');
|
||||
const inputId = html.match(/for="([^"]+)"/)?.[1];
|
||||
expect(inputId).toBeTruthy();
|
||||
expect(html).toContain(`id="${inputId}"`);
|
||||
const descriptionId = html.match(/aria-describedby="([^"]+)"/)?.[1];
|
||||
expect(descriptionId).toBeTruthy();
|
||||
expect(html).toContain(`id="${descriptionId}"`);
|
||||
});
|
||||
Reference in New Issue
Block a user