feat(campaign): filter reports from outcome counts
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { campaignJobsQueryParams } from "../src/features/campaigns/utils/jobListQuery";
|
||||
import {
|
||||
activeReportGridShortcut,
|
||||
reportGridQueryForShortcut,
|
||||
toggleReportGridShortcut
|
||||
} from "../src/features/campaigns/utils/reportGridShortcuts";
|
||||
|
||||
declare function require(name: string): {
|
||||
readFileSync(path: string, encoding: string): string;
|
||||
@@ -34,12 +39,47 @@ assert(params.get("filter_send") === 'list:["failed_temporary","outcome_unknown"
|
||||
assert(params.get("filter_attempts") === "gte:2", "typed number filters retain their operator");
|
||||
assert(!params.toString().includes("unsupported") && !params.toString().includes("must-not-leak"), "only the declared backend filter contract is serialized");
|
||||
|
||||
const shortcutFilters = {
|
||||
smtp_accepted: { send: 'list:["smtp_accepted","sent"]' },
|
||||
failed: { send: 'list:["failed_temporary","failed_permanent"]' },
|
||||
outcome_unknown: { send: 'list:["outcome_unknown"]' },
|
||||
not_attempted: { send: 'list:["not_queued"]' },
|
||||
smtp_skipped: { send: 'list:["skipped"]' },
|
||||
cancelled: { send: 'list:["cancelled"]' },
|
||||
imap_appended: { imap: 'list:["appended"]' },
|
||||
imap_failed: { imap: 'list:["failed"]' },
|
||||
imap_skipped: { imap: 'list:["skipped"]' }
|
||||
} as const;
|
||||
|
||||
for (const [shortcutId, filters] of Object.entries(shortcutFilters)) {
|
||||
const shortcut = reportGridQueryForShortcut(shortcutId as keyof typeof shortcutFilters);
|
||||
assert(JSON.stringify(shortcut.filters) === JSON.stringify(filters), `${shortcutId} uses the exact backend list filter`);
|
||||
assert(shortcut.sort?.columnId === "number" && shortcut.sort.direction === "asc", `${shortcutId} restores stable report ordering`);
|
||||
}
|
||||
|
||||
const failedShortcut = toggleReportGridShortcut({
|
||||
sort: { columnId: "updated", direction: "desc" },
|
||||
filters: { recipient: "old search", imap: 'list:["appended"]' }
|
||||
}, "failed");
|
||||
assert(JSON.stringify(failedShortcut.filters) === JSON.stringify(shortcutFilters.failed), "a shortcut clears unrelated filters");
|
||||
assert(activeReportGridShortcut(failedShortcut) === "failed", "the exact shortcut query is recognized as active");
|
||||
const toggledBack = toggleReportGridShortcut(failedShortcut, "failed");
|
||||
assert(Object.keys(toggledBack.filters).length === 0, "selecting an active count returns to all jobs");
|
||||
assert(activeReportGridShortcut(toggledBack) === "all", "the cleared query activates the all-jobs shortcut");
|
||||
const sortedFailedShortcut = { ...failedShortcut, sort: { columnId: "recipient", direction: "desc" as const } };
|
||||
assert(Object.keys(toggleReportGridShortcut(sortedFailedShortcut, "failed").filters).length === 0, "the active shortcut toggles to all even after the user changes sorting");
|
||||
|
||||
const reportSource = readFileSync("src/features/campaigns/CampaignReportPage.tsx", "utf8");
|
||||
assert(reportSource.includes('mode: "server"'), "the report DataGrid declares server query ownership");
|
||||
assert(reportSource.includes("totalRows: jobs.total"), "the shared pagination count uses the filtered backend total");
|
||||
assert(reportSource.includes("onQueryChange={handleJobGridQuery}"), "header sort and filter changes drive the backend query");
|
||||
assert(reportSource.includes("initialReportGridFilters()"), "status deep links initialize the DataGrid filters");
|
||||
assert(reportSource.includes("initialReportQuery()"), "q deep links initialize the report search");
|
||||
assert(reportSource.includes("query={jobGridQuery}"), "external count shortcuts synchronize the visible DataGrid query");
|
||||
assert(reportSource.includes('setQuery("");') && reportSource.includes('setAppliedQuery("");'), "count shortcuts clear both visible and applied search terms");
|
||||
assert(reportSource.includes("deliveryOutcomeShortcuts.map") && reportSource.includes("imapOutcomeShortcuts.map"), "top-level delivery counts use one coherent shortcut model");
|
||||
assert(reportSource.includes('<Button type="button" variant={active ? "primary" : "ghost"}'), "count shortcuts render the central Button directly");
|
||||
assert(reportSource.includes('aria-pressed={active}'), "count shortcuts expose their selected state accessibly");
|
||||
assert(reportSource.includes('"skipped",\n"queued"'), "SMTP skipped is a first-class report filter option");
|
||||
assert(reportSource.includes("i18n:govoplan-campaign.excluded_rows_are_intentionally_omitted_from_del.421a1f00"), "the report explains excluded transport semantics through the bilingual catalog");
|
||||
assert(reportSource.includes('return status === "skipped" ? "i18n:govoplan-campaign.skipped.5a000ad7"'), "the new skipped filter and status badges use the localized label");
|
||||
|
||||
Reference in New Issue
Block a user