Add end-to-end tests for TLS RPT report ingestion and WebSocket event handling

- Implemented tests for ingesting TLS RPT reports from emails and ensuring they are stored correctly in the database.
- Added tests to verify that the same report can be ingested multiple times without duplication.
- Created tests for backfilling reports that were previously delivered to the inbox.
- Developed WebSocket event handling tests to ensure events are correctly routed to subscribers based on mailbox ownership.
- Included tests for the mail API to validate session handling, mailbox isolation, and error mapping.
- Ensured that the API rejects unauthorized requests and handles malformed JSON gracefully.
This commit is contained in:
Lucas Rayan committed 2026-08-21 09:55:37 -03:00
1 parent 880dced9e4
commit f330c4324e
28 files changed
+2438 -6

No files matched your search

+1
View File
@@ -172,6 +172,7 @@
"insertUrl": "Enter the URL:",
"italic": "Italic",
"junk": "Spam",
"reports": "Reports",
"loadImages": "Load images",
"markRead": "Mark as read",
"markUnread": "Mark as unread",
+1
View File
@@ -172,6 +172,7 @@
"insertUrl": "Introduzca la URL:",
"italic": "Cursiva",
"junk": "Spam",
"reports": "Informes",
"loadImages": "Cargar imágenes",
"markRead": "Marcar como leído",
"markUnread": "Marcar como no leído",
+1
View File
@@ -172,6 +172,7 @@
"insertUrl": "Digite a URL:",
"italic": "Itálico",
"junk": "Spam",
"reports": "Relatórios",
"loadImages": "Carregar imagens",
"markRead": "Marcar como lida",
"markUnread": "Marcar como não lida",
@@ -43,6 +43,9 @@ export default function UserWebmailLayout({ children }: { children: React.ReactN
{ href: "/user/mail/archive", label: t("mail.archive"), icon: Archive, role: "archive" },
{ href: "/user/mail/junk", label: t("mail.junk"), icon: AlertTriangle, role: "junk" },
{ href: "/user/mail/trash", label: t("mail.trash"), icon: Trash2, role: "trash" },
// Where delivered DMARC and TLS-RPT reports are filed. Matched by name
// rather than a special-use role, because IMAP defines none for reports.
{ href: "/user/mail/reports", label: t("mail.reports"), icon: ShieldCheck, role: "reports" },
];
const handleLogout = () => {
@@ -306,6 +306,7 @@ export default function MailFolderPage({ params }: { params: Promise<{ folder: s
archive: t("mail.archive"),
junk: t("mail.junk"),
trash: t("mail.trash"),
reports: t("mail.reports"),
};
const folderTitle = FOLDER_LABELS[folder.toLowerCase()] ?? folder;
@@ -80,3 +80,23 @@ describe("deleting a message", () => {
expect(del.slice(0, 1200)).toMatch(/setMessages\(/);
});
});
describe("the Reports folder", () => {
// DMARC and TLS-RPT reports are parsed on arrival and filed here instead of
// the inbox. The sidebar is a fixed list, so without an entry the folder
// exists and receives mail that no screen can reach.
it("is reachable from the sidebar", () => {
const layout = code("src/app/(user)/user/layout.tsx");
expect(layout).toContain("/user/mail/reports");
});
it("is named through the translator, not hardcoded", () => {
const layout = code("src/app/(user)/user/layout.tsx");
expect(layout).toMatch(/t\("mail\.reports"\)/);
});
it("has a title on the message list too", () => {
const page = code(MAIL_PAGE);
expect(page).toMatch(/reports:\s*t\("mail\.reports"\)/);
});
});