import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import { fileURLToPath } from "node:url"; function read(relativePath) { return readFileSync(fileURLToPath(new URL(relativePath, import.meta.url)), "utf8"); } const profiles = `${read("../src/features/mail/MailProfileManagement.tsx")}\n${read("../src/features/mail/MailProfilePolicyEditor.tsx")}`; const mailbox = read("../src/features/mail/MailboxPage.tsx"); const mailApi = read("../src/api/mail.ts"); const bounces = read("../src/features/mail/MailBouncePage.tsx"); const legacyImport = read("../src/features/mail/MailLegacyImportPage.tsx"); const moduleSource = read("../src/module.ts"); const styles = read("../src/styles/mail-profiles.css"); const migration = read("../../docs/INTERFACE_PATTERN_MIGRATION.md"); assert.match(profiles, /ActionBlockerHint,[\s\S]*DocumentationHelpLink/); for (const sharedComponent of ["ConnectionTree", "ConfirmDialog", "Dialog", "LoadingFrame"]) { assert.match(profiles, new RegExp(`\\b${sharedComponent}\\b`)); } assert.match(profiles, /topicId: "mail\.profiles-and-policy"/); assert.match(profiles, /disabledReason: credentialMutationBlocker/); assert.match(profiles, /disabledReason=\{editorSaveBlocker\}/); assert.match(profiles, /disabledReason=\{policySaveBlocker\}/); assert.match(profiles, /smtpActionDisabledReason=\{smtpTestBlocker\}/); assert.match(profiles, /folder_mappings: draft\.imapFolderMappings/); assert.match(profiles, /listMailProfileImapFolders[\s\S]*listImapFolders/); assert.match(profiles, /onLookupImapFolders=\{\(\) => void runImapFolderLookup\(\)\}/); assert.match(profiles, /imapFolderLookupResult=\{imapFolderResult\}/); assert.match(mailbox, /ActionBlockerHint/); assert.match(mailbox, /DocumentationHelpLink/); assert.match(mailbox, /topicId: "mail\.workflow\.read-mailbox"/); assert.match(mailbox, /disabledReason=\{folderReloadBlocker\}/); assert.match(mailbox, /folder_mappings\?\.inbox/); assert.match(mailbox, /detected_folder_mappings\?\.inbox/); const openFolderNode = mailbox.slice(mailbox.indexOf(" function openFolderNode("), mailbox.indexOf(" function toggleFolderNode(")); assert.doesNotMatch(openFolderNode, /toggleFolderNode\(/, "Folder labels select; only the folder button expands or collapses."); assert.match(openFolderNode, /setSelectedFolderGroup\(\{ id: node\.id, label: node\.label \}\)/); assert.match(openFolderNode, /messageDetailRequestRef\.current \+= 1/, "Selecting a grouping invalidates pending message detail."); assert.match(mailbox, /selectedFolderGroup\?\.id \?\? findFolderNodeId/); assert.match(mailbox, /]*height="viewport"/); assert.match(mailbox, /\}\s+variant="workspace"\s+scope="workspace"[\s\S]*refreshable[\s\S]*onReload: \(\) => void reloadMailbox\(\)/); assert.ok(mailbox.indexOf(" \{[\s\S]*event\.key === "Enter" \|\| event\.key === " "/); assert.match(bounces, /DocumentationHelpLink/); assert.match(bounces, /topicId: "mail\.bounce-processing"/); assert.match(bounces, / void runImport\(\)\}/); assert.match(legacyImport, /legacy_import_enabled: false[\s\S]*is_active: false[\s\S]*createMailServerCredential[\s\S]*updateMailServerEndpoint/); assert.match(legacyImport, /expected_transport_revision: preview\.transport_revision/); assert.doesNotMatch(`${profiles}\n${mailbox}\n${bounces}\n${legacyImport}`, /window\.(?:alert|confirm)\(/); assert.doesNotMatch(`${profiles}\n${mailbox}\n${bounces}\n${legacyImport}\n${moduleSource}`, /@govoplan\/(?:campaign|files|docs|calendar)-webui|govoplan_(?:campaign|files|docs|calendar)/); assert.match(moduleSource, /"mail\.profiles"/); assert.match(styles, /@media \(max-width: 900px\)[\s\S]*\.mail-profile-transport-summary[\s\S]*grid-template-columns: 1fr/); assert.match(styles, /@media \(max-width: 1280px\)[\s\S]*\.mailbox-shell\.file-manager-shell[\s\S]*grid-template-columns:/); assert.doesNotMatch(styles, /\.mailbox-toolbar/, "Core owns workspace toolbar wrapping and action ordering."); assert.match(styles, /@media \(max-width: 760px\)[\s\S]*\.mailbox-message-row[\s\S]*grid-template-columns: 1fr/); for (const archetype of ["Directory/explorer", "Administration/configuration", "Effective-policy editor", "Evidence/reporting"]) { assert.match(migration, new RegExp(archetype.replace("/", "\\/"))); } assert.match(migration, /Shared `Dialog` owns focus entry, Escape handling, focus containment, and focus\s+return/); assert.match(migration, /Passwords are write-only[\s\S]*saved\s+state marker/); console.log("Mail surfaces satisfy the recorded interface pattern-language contract.");