fix(campaign): query reports before pagination
This commit is contained in:
43
webui/tests/report-grid-query.test.ts
Normal file
43
webui/tests/report-grid-query.test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { campaignJobsQueryParams } from "../src/features/campaigns/utils/jobListQuery";
|
||||
|
||||
declare function require(name: string): {
|
||||
readFileSync(path: string, encoding: string): string;
|
||||
};
|
||||
|
||||
const { readFileSync } = require("node:fs");
|
||||
|
||||
function assert(condition: unknown, message: string): void {
|
||||
if (!condition) throw new Error(message);
|
||||
}
|
||||
|
||||
const params = campaignJobsQueryParams({
|
||||
versionId: "version-1",
|
||||
page: 2,
|
||||
pageSize: 25,
|
||||
query: " recipient ",
|
||||
sortBy: "recipient",
|
||||
sortDirection: "desc",
|
||||
filters: {
|
||||
recipient: "target",
|
||||
send: 'list:["failed_temporary","outcome_unknown"]',
|
||||
attempts: "gte:2",
|
||||
unsupported: "must-not-leak"
|
||||
}
|
||||
});
|
||||
|
||||
assert(params.get("version_id") === "version-1", "the selected Campaign version is retained");
|
||||
assert(params.get("page") === "2" && params.get("page_size") === "25", "server pagination is serialized");
|
||||
assert(params.get("q") === "recipient", "the deep-link search query is normalized");
|
||||
assert(params.get("sort_by") === "recipient" && params.get("sort_direction") === "desc", "DataGrid sorting is server-owned");
|
||||
assert(params.get("filter_recipient") === "target", "text filters are sent to the backend");
|
||||
assert(params.get("filter_send") === 'list:["failed_temporary","outcome_unknown"]', "stable list selections are sent intact");
|
||||
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 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("setPage((value) => Math.max(1, value - 1))"), "the one-off report pager is removed in favor of the central DataGrid pager");
|
||||
Reference in New Issue
Block a user