import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import { dirname, resolve } from "node:path"; import { fileURLToPath } from "node:url"; const here = dirname(fileURLToPath(import.meta.url)); const source = readFileSync(resolve(here, "../src/features/operator/OperatorQueuePage.tsx"), "utf8"); const campaignModulePage = readFileSync(resolve(here, "../src/features/campaigns/CampaignModulePage.tsx"), "utf8"); const moduleSource = readFileSync(resolve(here, "../src/module.ts"), "utf8"); const translations = readFileSync(resolve(here, "../src/i18n/generatedTranslations.ts"), "utf8"); const jobQueries = readFileSync(resolve(here, "../../src/govoplan_campaign/backend/services/job_queries.py"), "utf8"); const responseSecurity = readFileSync(resolve(here, "../../src/govoplan_campaign/backend/response_security.py"), "utf8"); assert.match(source, / `\$\{row\.campaign\.id\}:\$\{rowVersionId\(row\)/); assert.match(source, /row\.campaign\.id === selectedCampaignId && rowVersionId\(row\) === selectedVersionParam/); assert.match(source, /retryCampaignJobs[\s\S]*version_id: rowVersionId\(row\)/); assert.match(source, /sendUnattemptedCampaignJobs[\s\S]*version_id: rowVersionId\(row\)/); assert.match(source, /report\?version=\$\{encodeURIComponent\(rowVersionId\(row\)\)\}&send_status=outcome_unknown/); for (const count of ["queued", "claimed", "sending", "completed"]) { assert.match(source, new RegExp(`row\\.${count}`)); assert.match(source, new RegExp(`totals\\.${count}`)); } for (const field of ["campaign_version_id", "entry_id", "entry_index", "queue_status", "send_status", "imap_status", "attempt_count", "queued_at", "sent_at", "updated_at", "last_error"]) { assert.match(source, new RegExp(field)); } assert.match(source, /deliveryResultSummary[\s\S]*send_status[\s\S]*imap_status/); assert.match(source, /durableResultText[\s\S]*slice\(0, 239\)/); assert.match(source, /permissions\.canOpenReport[\s\S]*you_do_not_have_permission/); assert.doesNotMatch(source, /claim_token|eml_local_path|storage_key|smtp_transport_revision|eml_sha256|message_id_header|smtp_response|provider_response|resolved_attachments/); assert.match(jobQueries, /"last_error": public_delivery_result_message\([\s\S]*last_error=job\.last_error/); assert.match(responseSecurity, /Map persisted provider text to a stable business-safe explanation/); assert.match(responseSecurity, /SMTP delivery failed; an operator can inspect restricted diagnostics\./); assert.doesNotMatch(source, /window\.alert\s*\(/); assert.doesNotMatch(source, /function QueuePressureGrid|function OperatorJob/); assert.doesNotMatch(source, /humanize\(/); assert.match(campaignModulePage, /