test(housekeeping): prove 137 route parity
CI / check (pull_request) Successful in 1m9s
CI / release (pull_request) Skipped
CI / deploy (pull_request) Skipped

This commit is contained in:
Simo committed 2026-08-30 19:11:14 +02:00
1 parent b235ce08ff
commit 8a31556d51
36 files changed
+431 -77

No files matched your search

@@ -63,6 +63,7 @@ describe("housekeeping accessibility contract", () => {
},
]}
labels={shellLabels}
search={vi.fn()}
surface="canonical"
>
<HousekeepingPageShell title="Operations" description="Daily work">
@@ -4,6 +4,7 @@ import { z } from "zod";
vi.mock("@/lib/auth", () => ({ invalidateLoginCache: vi.fn() }));
vi.mock("@/lib/auth/password", () => ({ hashPassword: vi.fn() }));
import { housekeepingCommandRegistryReady } from "../../commands";
import { COMMUNITY_COMMAND_IDS } from "../../domains/people/commands/community-commands";
import { MODERATION_COMMAND_IDS } from "../../domains/people/commands/moderation-commands";
import { SUPPORT_COMMAND_IDS } from "../../domains/people/commands/support-commands";
@@ -12,7 +13,6 @@ import { SYSTEM_COMMAND_IDS } from "../../domains/system/commands/system-command
import { anyCapability, ok } from "../contracts";
import {
defineHousekeepingCommands,
housekeepingCommandRegistryReady,
registerHousekeepingCommands,
} from "./bootstrap";
import {
@@ -1,19 +1,7 @@
import "server-only";
import { CONTENT_COMMANDS } from "../../domains/content/commands/content-commands";
import { ECONOMY_COMMANDS } from "../../domains/economy/commands/economy-commands";
import { HOTEL_COMMANDS } from "../../domains/hotel/commands/hotel-commands";
import { STUDIO_COMMANDS } from "../../domains/hotel/commands/studio-commands";
import { COMMUNITY_COMMANDS } from "../../domains/people/commands/community-commands";
import { MODERATION_COMMANDS } from "../../domains/people/commands/moderation-commands";
import { SUPPORT_COMMANDS } from "../../domains/people/commands/support-commands";
import { USER_COMMANDS } from "../../domains/people/commands/user-commands";
import { SYSTEM_COMMANDS } from "../../domains/system/commands/system-commands";
import type { HousekeepingCommand } from "./registry";
import {
registerHousekeepingCommand,
sealHousekeepingCommandRegistry,
} from "./registry";
import { registerHousekeepingCommand } from "./registry";
type PreserveHousekeepingCommand<Definition> =
Definition extends HousekeepingCommand<infer _Input, infer _Output>
@@ -42,20 +30,3 @@ export function registerHousekeepingCommands<
);
}
}
const currentHousekeepingCommands = defineHousekeepingCommands(
...CONTENT_COMMANDS,
...ECONOMY_COMMANDS,
...HOTEL_COMMANDS,
...STUDIO_COMMANDS,
...USER_COMMANDS,
...COMMUNITY_COMMANDS,
...SUPPORT_COMMANDS,
...MODERATION_COMMANDS,
...SYSTEM_COMMANDS,
);
registerHousekeepingCommands(currentHousekeepingCommands);
sealHousekeepingCommandRegistry();
export const housekeepingCommandRegistryReady = true;
@@ -28,6 +28,10 @@ const SERVER_CAPABILITY_CONTEXT =
const PERMISSIONS_ADAPTER = "src/lib/permissions";
const DOMAIN_MODULE_ROOT = "src/features/housekeeping/domains";
const approvedRuntimeImports = new Map<string, ReadonlySet<string>>([
[
"src/features/housekeeping/shell.tsx",
new Set(["src/actions/housekeeping-search"]),
],
[
"src/features/housekeeping/domains/operations/manifest.ts",
new Set([
@@ -55,10 +59,6 @@ const approvedRuntimeImports = new Map<string, ReadonlySet<string>>([
"src/features/housekeeping/domains/operations/queries",
]),
],
[
"src/features/housekeeping/foundation/shell/command-deck.tsx",
new Set(["src/actions/housekeeping-search"]),
],
[
"src/features/housekeeping/domains/hotel/commands/studio-commands.ts",
new Set(["src/features/housekeeping/domains/hotel/queries/studio"]),
@@ -932,7 +932,7 @@ const approvedRuntimeImports = new Map<string, ReadonlySet<string>>([
]),
],
[
"src/features/housekeeping/foundation/commands/bootstrap.ts",
"src/features/housekeeping/commands.ts",
new Set([
"src/features/housekeeping/domains/content/commands/content-commands",
"src/features/housekeeping/domains/economy/commands/economy-commands",
@@ -1625,6 +1625,7 @@ describe("housekeeping foundation completion contracts", () => {
partial: "HK::partial",
close: "HK::close",
},
search: vi.fn(),
surface: "preview",
});
const html = renderToStaticMarkup(trigger);
@@ -46,6 +46,7 @@ describe("housekeeping responsive contract", () => {
},
]}
labels={labels}
search={vi.fn()}
surface="canonical"
>
<div>Body</div>
@@ -72,6 +73,7 @@ describe("housekeeping responsive contract", () => {
const trigger = renderToStaticMarkup(
<CommandDeck
labels={{ ...labels.commandDeck, trigger: "Search" }}
search={vi.fn()}
surface="canonical"
/>,
);
@@ -193,7 +193,6 @@ export async function searchHousekeeping(
term: string,
context: HousekeepingCapabilityContext,
): Promise<HousekeepingSearchResponse> {
await import("../commands/bootstrap");
const [{ getTranslations }, { HOUSEKEEPING_MANIFESTS }] = await Promise.all([
import("next-intl/server"),
import("../../manifests"),
@@ -31,7 +31,7 @@ const labels = {
describe("CommandDeck", () => {
it("renders an enabled accessible cmdk trigger", () => {
const html = renderToStaticMarkup(
<CommandDeck labels={labels} surface="preview" />,
<CommandDeck labels={labels} search={vi.fn()} surface="preview" />,
);
expect(html).toContain("Search housekeeping");
expect(html).toContain('aria-haspopup="dialog"');
@@ -8,7 +8,6 @@ import {
useRef,
useState,
} from "react";
import { executeHousekeepingSearch } from "@/actions/housekeeping-search";
import {
Command,
CommandEmpty,
@@ -40,6 +39,10 @@ export interface CommandDeckLabels {
readonly close: string;
}
export type HousekeepingSearchExecutor = (
term: string,
) => Promise<HousekeepingSearchResponse>;
type CommandDeckHit =
| HousekeepingNavigationHit
| HousekeepingCommandHit
@@ -139,9 +142,11 @@ export function flattenHousekeepingSearchResults(
export function CommandDeck({
labels,
search,
surface,
}: {
readonly labels: CommandDeckLabels;
readonly search: HousekeepingSearchExecutor;
readonly surface: HousekeepingSurface;
}) {
const [open, setOpen] = useState(false);
@@ -189,7 +194,7 @@ export function CommandDeck({
let active = true;
setLoading(true);
const timer = setTimeout(() => {
executeHousekeepingSearch(term)
search(term)
.then((nextResponse) => {
if (active && sequence === requestSequence.current) {
setResponse(nextResponse);
@@ -212,7 +217,7 @@ export function CommandDeck({
active = false;
clearTimeout(timer);
};
}, [open, term]);
}, [open, search, term]);
useEffect(() => {
setSelectedIndex(entries.length === 0 ? -1 : 0);
@@ -1,18 +1,28 @@
import type { HousekeepingSurface } from "../contracts";
import { CommandDeck, type CommandDeckLabels } from "./command-deck";
import {
CommandDeck,
type CommandDeckLabels,
type HousekeepingSearchExecutor,
} from "./command-deck";
interface CommandTriggerProps {
label: string;
labels: Omit<CommandDeckLabels, "trigger">;
search: HousekeepingSearchExecutor;
surface: HousekeepingSurface;
}
export function CommandTrigger({
label,
labels,
search,
surface,
}: CommandTriggerProps) {
return (
<CommandDeck labels={{ trigger: label, ...labels }} surface={surface} />
<CommandDeck
labels={{ trigger: label, ...labels }}
search={search}
surface={surface}
/>
);
}
@@ -157,6 +157,7 @@ function renderShell(
activeDomainId={activeDomainId}
domains={availableDomains}
labels={labels}
search={vi.fn()}
surface={surface}
>
<p>Deck body</p>
@@ -3,6 +3,7 @@ import Link from "@/components/link";
import type { HousekeepingDomainId } from "../../migration/types";
import type { HousekeepingActor, HousekeepingSurface } from "../contracts";
import type { HousekeepingNavigationDomain } from "../navigation";
import type { HousekeepingSearchExecutor } from "./command-deck";
import { CommandTrigger } from "./command-trigger";
import { ContextNav } from "./context-nav";
import { DomainRail } from "./domain-rail";
@@ -15,7 +16,7 @@ export const HOUSEKEEPING_LANDMARKS = [
"main",
] as const;
interface HousekeepingShellProps {
export interface HousekeepingShellProps {
actor: HousekeepingActor;
activeDomainId: HousekeepingDomainId;
domains: readonly HousekeepingNavigationDomain[];
@@ -39,6 +40,7 @@ interface HousekeepingShellProps {
};
};
surface?: HousekeepingSurface;
search: HousekeepingSearchExecutor;
children: ReactNode;
}
@@ -47,6 +49,7 @@ export function HousekeepingShell({
activeDomainId,
domains,
labels,
search,
surface = "preview",
children,
}: HousekeepingShellProps) {
@@ -76,6 +79,7 @@ export function HousekeepingShell({
<CommandTrigger
label={labels.command}
labels={labels.commandDeck}
search={search}
surface={surface}
/>
<Link