fix(housekeeping): address task 14 review round 1
This commit is contained in:
1 parent
fd68819d9b
commit
d09eaa33d6
23 files changed
+2503
-488
No files matched your search
@@ -7,7 +7,16 @@ import {
|
||||
type ContentQueryInput,
|
||||
createContentQuery,
|
||||
} from "./content-queries";
|
||||
import { CONTENT_QUERY_DEFINITIONS } from "./content-queries-production";
|
||||
import {
|
||||
CONTENT_QUERY_DEFINITIONS,
|
||||
loadProductionContentQuery,
|
||||
} from "./content-queries-production";
|
||||
|
||||
const queryMocks = vi.hoisted(() => ({ execute: vi.fn() }));
|
||||
vi.mock("drizzle-orm", () => ({
|
||||
sql: { raw: (statement: string) => statement },
|
||||
}));
|
||||
vi.mock("@/lib/db", () => ({ db: { execute: queryMocks.execute } }));
|
||||
|
||||
function context(granted: readonly string[]): HousekeepingCapabilityContext {
|
||||
const permissions = new Set(granted);
|
||||
@@ -35,6 +44,25 @@ const ready: ContentQueryData = {
|
||||
};
|
||||
|
||||
describe("Content query", () => {
|
||||
it("reports totals beyond the former 500-row adapter cap", async () => {
|
||||
const allRows = Array.from({ length: 600 }, (_, index) => ({
|
||||
id: index + 1,
|
||||
title: `Article ${index + 1}`,
|
||||
status: "published",
|
||||
updated_at: null,
|
||||
}));
|
||||
queryMocks.execute.mockImplementationOnce(async (statement: string) => [
|
||||
statement.includes("LIMIT 500") ? allRows.slice(0, 500) : allRows,
|
||||
]);
|
||||
const result = await loadProductionContentQuery({
|
||||
routeId: "content.editorial.articles",
|
||||
params: {},
|
||||
list: { search: "", pageSize: 25, offset: 0 },
|
||||
});
|
||||
expect(result.total).toBe(600);
|
||||
expect(result.items).toHaveLength(25);
|
||||
});
|
||||
|
||||
it("never selects email template bodies into summary query results", () => {
|
||||
const emailTemplates =
|
||||
CONTENT_QUERY_DEFINITIONS["content.help.email-templates"];
|
||||
|
||||
Reference in new issue
Block a user