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 -89
View File
@@ -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>`);