chore: remove legacy SSR checks and consolidate migration maintenance
This commit is contained in:
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user