From 23309acd6a93518d3bcd11915039cccc808f9ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 9 Jul 2026 11:35:03 +0200 Subject: [PATCH] test(documents): mock the full AI-availability surface in the auto-read e2e MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- e2e/documents-auto-read.spec.ts | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/e2e/documents-auto-read.spec.ts b/e2e/documents-auto-read.spec.ts index a5f03705b..bce3a9870 100644 --- a/e2e/documents-auto-read.spec.ts +++ b/e2e/documents-auto-read.spec.ts @@ -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 { + 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,