fix: close housekeeping foundation review findings
This commit is contained in:
1 parent
ebc263da35
commit
08f8d54888
21 files changed
+593
-46
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import en from "@/messages/en.json";
|
||||
import itMessages from "@/messages/it.json";
|
||||
import { HousekeepingPageShell } from "./housekeeping-page-shell";
|
||||
import { HousekeepingPageState } from "./housekeeping-page-state";
|
||||
|
||||
@@ -10,20 +12,29 @@ describe("HousekeepingPageState", () => {
|
||||
["partial", "status"],
|
||||
["error", "alert"],
|
||||
] as const)("renders %s with the %s role", (state, role) => {
|
||||
const html = renderToStaticMarkup(
|
||||
<HousekeepingPageState
|
||||
state={state}
|
||||
title={`${state} title`}
|
||||
description={`${state} description`}
|
||||
/>,
|
||||
);
|
||||
const pageState =
|
||||
state === "partial" ? (
|
||||
<HousekeepingPageState
|
||||
state="partial"
|
||||
partialLabel="Partial data"
|
||||
title={`${state} title`}
|
||||
description={`${state} description`}
|
||||
/>
|
||||
) : (
|
||||
<HousekeepingPageState
|
||||
state={state}
|
||||
title={`${state} title`}
|
||||
description={`${state} description`}
|
||||
/>
|
||||
);
|
||||
const html = renderToStaticMarkup(pageState);
|
||||
|
||||
expect(html).toContain(`role="${role}"`);
|
||||
expect(html).toContain(`>${state} title<`);
|
||||
expect(html).toContain(`>${state} description<`);
|
||||
});
|
||||
|
||||
it("announces loading politely and makes the partial warning visible", () => {
|
||||
it("announces loading politely", () => {
|
||||
const loading = renderToStaticMarkup(
|
||||
<HousekeepingPageState
|
||||
state="loading"
|
||||
@@ -31,20 +42,33 @@ describe("HousekeepingPageState", () => {
|
||||
description="Loading description"
|
||||
/>,
|
||||
);
|
||||
const partial = renderToStaticMarkup(
|
||||
<HousekeepingPageState
|
||||
state="partial"
|
||||
title="Partial title"
|
||||
description="Partial description"
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(loading).toContain('aria-live="polite"');
|
||||
expect(partial).toContain("--admin-warning-border");
|
||||
expect(partial).toContain("--admin-warning-subtle");
|
||||
expect(partial).toContain(">Partial title<");
|
||||
});
|
||||
|
||||
it.each([
|
||||
["English", en.pages.housekeeping.states.partial],
|
||||
["Italian", itMessages.pages.housekeeping.states.partial],
|
||||
] as const)(
|
||||
"preserves the partial-state heading and separate localized warning in %s",
|
||||
(_locale, copy) => {
|
||||
const html = renderToStaticMarkup(
|
||||
<HousekeepingPageState
|
||||
state="partial"
|
||||
partialLabel={copy.label}
|
||||
title={copy.title}
|
||||
description={copy.description}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(html).toMatch(new RegExp(`<h2[^>]*>${copy.title}</h2>`));
|
||||
expect(html).toContain(`>${copy.label}</p>`);
|
||||
expect(html).toContain('data-state-tone="warning"');
|
||||
expect(html).toContain("--admin-warning-border");
|
||||
expect(html).toContain("--admin-warning-subtle");
|
||||
},
|
||||
);
|
||||
|
||||
it("renders supplied retry content for an error without owning a callback", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<HousekeepingPageState
|
||||
|
||||
Reference in new issue
Block a user