68 lines
4.2 KiB
JavaScript
68 lines
4.2 KiB
JavaScript
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");
|
|
const mailbox = read("../src/features/mail/MailboxPage.tsx");
|
|
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/);
|
|
assert.match(mailbox, /onKeyDown=\{\(event\) => \{[\s\S]*event\.key === "Enter" \|\| event\.key === " "/);
|
|
|
|
assert.match(bounces, /DocumentationHelpLink/);
|
|
assert.match(bounces, /topicId: "mail\.bounce-processing"/);
|
|
assert.match(bounces, /<ConfirmDialog[\s\S]*confirmLabel="Remove watcher"[\s\S]*tone="danger"/);
|
|
assert.match(bounces, /disabledReason=\{saveWatcherBlocker\}/);
|
|
|
|
for (const sharedComponent of ["PageLayout", "PageActionBar", "SelectionList", "DataGrid", "Dialog", "ConfirmDialog", "ToggleSwitch", "StatusBadge"]) {
|
|
assert.match(legacyImport, new RegExp(`\\b${sharedComponent}\\b`));
|
|
}
|
|
assert.match(legacyImport, /archetype="collection"/);
|
|
assert.match(legacyImport, /variant="collection"[\s\S]*refreshable[\s\S]*reloadAction=/);
|
|
assert.match(legacyImport, /topicId: "mail\.workflow\.legacy-pop3-import"/);
|
|
assert.match(legacyImport, /<ConfirmDialog[\s\S]*tone="danger"[\s\S]*onConfirm=\{\(\) => 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.match(styles, /@media \(max-width: 760px\)[\s\S]*\.mailbox-toolbar\.file-manager-toolbar[\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.");
|