From 8ac81b9461c11e272f3b2c1940ea1d9face5cd01 Mon Sep 17 00:00:00 2001 From: Pier-Jean Malandrino Date: Thu, 7 May 2026 11:09:19 +0200 Subject: [PATCH] test(#256): Karate UI regression for Doc tab chunk mode Setup via API (upload + analyse + wait COMPLETED), then drive the UI to the chunks tab and assert the chunk list renders. Includes a direct HTTP probe on /api/documents/{id}/chunks so an API-only regression fails the test even if the UI somehow swallows it. Tagged @critical so it runs in the smoke suite. --- .../documents/doc-tab-chunk-mode.feature | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 e2e/ui/src/test/resources/documents/doc-tab-chunk-mode.feature diff --git a/e2e/ui/src/test/resources/documents/doc-tab-chunk-mode.feature b/e2e/ui/src/test/resources/documents/doc-tab-chunk-mode.feature new file mode 100644 index 0000000..a232928 --- /dev/null +++ b/e2e/ui/src/test/resources/documents/doc-tab-chunk-mode.feature @@ -0,0 +1,53 @@ +@ui @critical +Feature: UI — Doc tab chunk mode renders canonical chunks (#256) + + # Regression coverage for the bug where opening the chunks tab on a + # document returned 404 because /api/documents/{id}/chunks was not + # implemented backend-side. Setup is API-driven (upload + analyse) so + # the test is fast and deterministic; the UI portion only exercises + # navigation + chunk rendering, not the parse pipeline. + + Background: + * url baseUrl + + Scenario: Open the chunks tab and see the canonical chunkset (no 404) + # 1. Setup via API: upload + run an analysis (with chunking) and wait + # until the doc-centric chunkset gets promoted by the analysis hook. + * def upload = call read('classpath:common/helpers/upload.feature') { file: 'small.pdf' } + * def docId = upload.docId + + Given url baseUrl + And path '/api/analyses' + And request { documentId: '#(docId)', chunkingOptions: { chunkerType: 'hybrid', maxTokens: 256, mergePeers: true, repeatTableHeader: true } } + When method POST + Then status 200 + * def analysisId = response.id + + # Poll until the analysis is COMPLETED (chunks get promoted in the + # same step via AnalysisService → ChunkService.promote_from_analysis). + Given url baseUrl + And path '/api/analyses', analysisId + And retry until response.status == 'COMPLETED' || response.status == 'FAILED' + When method GET + Then status 200 + And match response.status == 'COMPLETED' + + # 2. Sanity-check the new endpoint over HTTP — proves the 404 is gone. + Given url baseUrl + And path '/api/documents', docId, 'chunks' + When method GET + Then status 200 + And assert karate.sizeOf(response) > 0 + + # 3. Drive the UI: open the workspace page and click the chunks tab. + * driver uiBaseUrl + '/docs/' + docId + * waitFor('[data-e2e=tab-strip]') + * click('[data-e2e=tab-chunks]') + + # 4. Verify the chunks list rendered (no 404 banner, chunk-list visible). + * waitFor('[data-e2e=chunks-editor]') + * waitFor('[data-e2e=chunk-list]') + * assert karate.sizeOf(locateAll('[data-e2e=chunk-list] .chunk-card')) > 0 + + # 5. Cleanup via API. + * call read('classpath:common/helpers/cleanup-by-name.feature') { filename: 'small.pdf' }