105 lines
3.4 KiB
TypeScript
105 lines
3.4 KiB
TypeScript
import { buildEmailMessageDetailVM, emailMatchSourceKey, type EmailMessageDetailVM, type EmailThreadMessageVM } from "@hivegrid/view-models";
|
|
|
|
import { EmailMessageDetailPage } from "./EmailMessageDetailPage";
|
|
|
|
export const EMAIL_DETAIL_INTERIM_VISUAL_SCREENS = ["thread", "readonly"] as const;
|
|
|
|
export type EmailDetailInterimVisualScreen = (typeof EMAIL_DETAIL_INTERIM_VISUAL_SCREENS)[number];
|
|
|
|
/** sentAt values stay far in the past so the markup snapshot never depends on
|
|
* the test run date (the screen renders absolute timestamps). */
|
|
const THREAD: EmailThreadMessageVM[] = [
|
|
{
|
|
id: "msg-0",
|
|
direction: "outbound",
|
|
fromName: "Handwerk GmbH",
|
|
fromAddress: "info@handwerk.test",
|
|
toSummary: "erika@example.test",
|
|
ccSummary: null,
|
|
subject: "Angebot für Projekt Nordlicht",
|
|
safeBodyHtml: "<p>Guten Tag, anbei unser Angebot.</p>",
|
|
blockedImageCount: 0,
|
|
sentAt: "2020-01-02T09:00:00.000Z",
|
|
isRead: true,
|
|
isFocused: false,
|
|
collapsedByDefault: true,
|
|
},
|
|
{
|
|
id: "msg-1",
|
|
direction: "inbound",
|
|
fromName: "Erika Beispiel",
|
|
fromAddress: "erika@example.test",
|
|
toSummary: "info@handwerk.test",
|
|
ccSummary: "buchhaltung@example.test",
|
|
subject: "Re: Angebot für Projekt Nordlicht",
|
|
safeBodyHtml: "<p>Vielen Dank, wir prüfen das Angebot.</p>",
|
|
blockedImageCount: 3,
|
|
sentAt: "2020-01-03T09:30:00.000Z",
|
|
isRead: false,
|
|
isFocused: true,
|
|
collapsedByDefault: false,
|
|
},
|
|
];
|
|
|
|
export function createEmailDetailInterimVisualVMs(): Record<EmailDetailInterimVisualScreen, EmailMessageDetailVM> {
|
|
const base = {
|
|
focusedId: "msg-1",
|
|
subject: "Re: Angebot für Projekt Nordlicht",
|
|
mailbox: { emailAddress: "info@handwerk.test", provider: "gmail" as const },
|
|
thread: THREAD,
|
|
replyHref: "/acme/emails/new?replyTo=msg-1",
|
|
forwardHref: "/acme/emails/new?forward=msg-1",
|
|
backHref: "/acme/emails",
|
|
allowExternalImages: false,
|
|
};
|
|
|
|
return {
|
|
thread: buildEmailMessageDetailVM({
|
|
...base,
|
|
attachments: [
|
|
{ attachmentId: "att-1", filename: "angebot-nordlicht.pdf", sizeBytes: 245_760, importedFileId: null, downloadHref: null },
|
|
{ attachmentId: "att-2", filename: "aufmass.xlsx", sizeBytes: 18_432, importedFileId: "file-1", downloadHref: "/acme/files/file-1" },
|
|
],
|
|
match: {
|
|
links: [
|
|
{ type: "kontakt", id: "contact-1", href: "/acme/contacts/contact-1" },
|
|
{ type: "projekt", id: "project-1", href: "/acme/projects/project-1" },
|
|
],
|
|
confidence: "manual",
|
|
sourceKey: emailMatchSourceKey("manual"),
|
|
isManual: true,
|
|
},
|
|
canWrite: true,
|
|
}),
|
|
readonly: buildEmailMessageDetailVM({
|
|
...base,
|
|
attachments: [],
|
|
match: { links: [], confidence: "none", sourceKey: emailMatchSourceKey("none"), isManual: false },
|
|
canWrite: false,
|
|
}),
|
|
};
|
|
}
|
|
|
|
const noOp = (): void => undefined;
|
|
|
|
/** Shared ready-state fixture for the AK-UI-02 interim markup baseline. */
|
|
export function EmailDetailInterimVisualFixture({ screen }: { screen: EmailDetailInterimVisualScreen }): React.JSX.Element {
|
|
const vms = createEmailDetailInterimVisualVMs();
|
|
return (
|
|
<EmailMessageDetailPage
|
|
vm={vms[screen]}
|
|
justSent={screen === "thread"}
|
|
actions={{
|
|
onSetLink: noOp,
|
|
onClearLink: noOp,
|
|
onImportAttachment: noOp,
|
|
onToggleRead: noOp,
|
|
onLoadImages: noOp,
|
|
onReply: noOp,
|
|
onForward: noOp,
|
|
onBack: noOp,
|
|
}}
|
|
/>
|
|
);
|
|
}
|