chore: remove legacy SSR checks and consolidate migration maintenance

This commit is contained in:
maoyingjie
2026-10-26 10:32:22 +08:00
parent 52a0bef851
commit 60af6ee40b
169 changed files with 958 additions and 8422 deletions
+1 -54
View File
@@ -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}"`);
});
});