test(documents): mock the full AI-availability surface in the auto-read e2e

The auto-read vault specs mocked only the document capability probe, leaving
the usage endpoint (assist + content-index flags) unmocked — so the read
action rendered but stayed disabled and the click timed out. Mock the same
three endpoints the working document-AI e2e does (usage, labs OCR capability,
document capability) so the action is enabled.
This commit is contained in:
Marc-André Bombeck committed 2026-07-09 11:35:03 +02:00
1 parent 1a43880ab4
commit 23309acd6a
1 file changed
+29 -2
+29 -2
View File
@@ -35,18 +35,45 @@ async function fulfilJson(
});
}
/** Mock the document capability probe so the vault AI section renders. */
/**
* Mock the FULL AI-availability surface the vault section probes so the read
* action renders AND is enabled: `usage` (assist + content-index flags — this is
* what un-disables the action), the labs OCR capability, and the document-scoped
* capability (provider order + vendor-blind egress class). Mirrors
* `mockAiEnabled` in documents-ai.spec.ts; egress-specific tests set the class.
*/
async function mockDocumentCapability(
page: Page,
opts: { egress: "local" | "external"; pdfSupported?: boolean },
): Promise<void> {
const pdfSupported = opts.pdfSupported ?? true;
await page.route("**/api/documents/inbound/usage", (route) =>
fulfilJson(route, {
data: {
usedBytes: 4096,
quotaBytes: 1_073_741_824,
maxFileBytes: 26_214_400,
acceptedExtensions: [".pdf", ".png", ".jpg", ".jpeg", ".webp"],
linkedEpisodes: [],
assistAvailable: true,
contentIndex: { enabled: true, indexedCount: 0, totalCount: 1 },
},
error: null,
}),
);
await page.route("**/api/labs/ocr/capability", (route) =>
fulfilJson(route, {
data: { available: true, mode: "vision", reason: null, pdfSupported },
error: null,
}),
);
await page.route("**/api/documents/inbound/capability", (route) =>
fulfilJson(route, {
data: {
available: true,
mode: "vision",
reason: null,
pdfSupported: opts.pdfSupported ?? true,
pdfSupported,
egress: opts.egress,
},
error: null,