Files

104 lines
3.3 KiB
TypeScript

import { buildEmailInboxListVM, type EmailInboxFilters, type EmailInboxListVM } from "@hivegrid/view-models";
import { EmailInboxListPage } from "./EmailInboxListPage";
export const EMAIL_INBOX_INTERIM_VISUAL_SCREENS = ["list", "empty", "no-mailbox"] as const;
export type EmailInboxInterimVisualScreen = (typeof EMAIL_INBOX_INTERIM_VISUAL_SCREENS)[number];
const FIXTURE_FILTERS: EmailInboxFilters = {
mailboxId: null,
direction: "all",
linked: "all",
read: "all",
q: "",
showArchived: false,
};
const FIXTURE_MAILBOXES = [
{ id: "mailbox-1", emailAddress: "sales@example.test" },
{ id: "mailbox-2", emailAddress: "office@example.test" },
];
/** sentAt values stay far in the past so the list renders absolute dates —
* keeps the markup snapshot independent of the test run date. */
export function createEmailInboxInterimVisualVMs(): Record<EmailInboxInterimVisualScreen, EmailInboxListVM> {
const base = {
filters: FIXTURE_FILTERS,
mailboxOptions: FIXTURE_MAILBOXES,
canWrite: true,
composeHref: "/acme/emails/new",
settingsHref: "/acme/settings/integrations/email",
};
return {
list: buildEmailInboxListVM({
...base,
hasAnyMailbox: true,
nextCursor: "2020-01-02T10:00:00.000Z~msg-2",
rows: [
{
id: "msg-1",
detailHref: "/acme/emails/msg-1",
fromName: "Erika Beispiel",
fromAddress: "erika@example.test",
subject: "Angebot für Projekt Nordlicht",
snippet: "Hallo, anbei das aktualisierte Angebot mit den besprochenen Positionen …",
sentAt: "2020-01-03T09:30:00.000Z",
direction: "inbound",
isRead: false,
hasAttachments: true,
isNewsletter: false,
mailbox: { id: "mailbox-1", emailAddress: "sales@example.test", provider: "gmail" },
links: [
{ type: "kontakt", id: "contact-1", href: "/acme/contacts/contact-1" },
{ type: "projekt", id: "project-1", href: "/acme/projects/project-1" },
],
},
{
id: "msg-2",
detailHref: "/acme/emails/msg-2",
fromName: null,
fromAddress: "newsletter@example.test",
subject: null,
snippet: null,
sentAt: "2020-01-02T10:00:00.000Z",
direction: "inbound",
isRead: true,
hasAttachments: false,
isNewsletter: true,
mailbox: { id: "mailbox-2", emailAddress: "office@example.test", provider: "microsoft" },
links: [{ type: "lead", id: "lead-1", href: "/acme/leads/lead-1" }],
},
],
}),
empty: buildEmailInboxListVM({
...base,
hasAnyMailbox: true,
nextCursor: null,
rows: [],
}),
"no-mailbox": buildEmailInboxListVM({
...base,
mailboxOptions: [],
hasAnyMailbox: false,
nextCursor: null,
rows: [],
canWrite: false,
}),
};
}
const noOp = (): void => undefined;
/** Shared ready-state fixture for the AK-UI-01 interim markup baseline. */
export function EmailInboxInterimVisualFixture({ screen }: { screen: EmailInboxInterimVisualScreen }): React.JSX.Element {
const vms = createEmailInboxInterimVisualVMs();
return (
<EmailInboxListPage
vm={vms[screen]}
actions={{ onApplyFilters: noOp, onBulk: noOp, onLoadMore: noOp, onCompose: noOp, onOpenSettings: noOp }}
/>
);
}