72 lines
2.1 KiB
TypeScript
72 lines
2.1 KiB
TypeScript
import { createChatDetailInterimFixturePage, createChatIndexInterimFixturePage } from "@hivegrid/ui-mock";
|
|
import { MemoryRouter } from "react-router";
|
|
|
|
import { ChatChannelDetailPage } from "./ChatChannelDetailPage";
|
|
import { ChatChannelListPage } from "./ChatChannelListPage";
|
|
|
|
export const CHAT_INTERIM_VISUAL_SCREENS = ["index", "detail"] as const;
|
|
|
|
export type ChatInterimVisualScreen = (typeof CHAT_INTERIM_VISUAL_SCREENS)[number];
|
|
|
|
const noOp = (): void => undefined;
|
|
|
|
/** Shared AD-28 fixture for markup snapshots and Chromium pixel baselines. */
|
|
export function ChatInterimVisualFixture({
|
|
screen,
|
|
enableNavigation = false,
|
|
}: {
|
|
readonly screen: ChatInterimVisualScreen;
|
|
readonly enableNavigation?: boolean;
|
|
}): React.JSX.Element {
|
|
if (screen === "index") {
|
|
const page = createChatIndexInterimFixturePage();
|
|
if (page.state.status !== "ready") throw new Error("chat.errors.integrityFailure");
|
|
|
|
return (
|
|
<MemoryRouter>
|
|
<ChatChannelListPage
|
|
vm={page.state.data.viewModel}
|
|
actions={{
|
|
onOpenChannel: noOp,
|
|
onQueryChange: noOp,
|
|
onViewChange: noOp,
|
|
onShowArchivedChange: noOp,
|
|
onRetry: noOp,
|
|
...(enableNavigation
|
|
? {
|
|
onCreateGroup: noOp,
|
|
onCreateDm: noOp,
|
|
onOpenMessageSearch: noOp,
|
|
onOpenMentions: noOp,
|
|
}
|
|
: {}),
|
|
}}
|
|
/>
|
|
</MemoryRouter>
|
|
);
|
|
}
|
|
|
|
const page = createChatDetailInterimFixturePage();
|
|
if (page.state.status !== "ready") throw new Error("chat.errors.integrityFailure");
|
|
|
|
return (
|
|
<MemoryRouter>
|
|
<ChatChannelDetailPage
|
|
vm={page.state.data.viewModel}
|
|
draft=""
|
|
actions={{
|
|
onBack: noOp,
|
|
onDraftChange: noOp,
|
|
onSend: noOp,
|
|
onRetryMessage: noOp,
|
|
onDiscardMessage: noOp,
|
|
onMessageVisibilityChange: noOp,
|
|
onRetryConnection: noOp,
|
|
onLoadOlder: noOp,
|
|
onOpenSettings: noOp,
|
|
}}
|
|
/>
|
|
</MemoryRouter>
|
|
);
|
|
}
|