From c72bdefaaa180d031ec300ba26e09cd97f773afe Mon Sep 17 00:00:00 2001 From: Nathan Panchout Date: Tue, 7 Apr 2026 17:36:27 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85(frontend)=20update=20e2e=20for=20item?= =?UTF-8?q?=20duplication=20with=20state=20interception?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added interception for list endpoints in the duplicate item e2e tests to override the state of duplicated items, ensuring accurate testing of upload states during the duplication process. --- .../app-drive/duplicate-item.spec.ts | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/frontend/apps/e2e/__tests__/app-drive/duplicate-item.spec.ts b/src/frontend/apps/e2e/__tests__/app-drive/duplicate-item.spec.ts index c3ce4287..4179e9b4 100644 --- a/src/frontend/apps/e2e/__tests__/app-drive/duplicate-item.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-drive/duplicate-item.spec.ts @@ -43,6 +43,29 @@ const setupDuplicateMocks = async (page: Page) => { }, ); + // Also intercept endpoints list to override the duplicated item's state + await page.route( + (url) => + url.pathname.endsWith("/api/v1.0/items/") && + !url.pathname.includes("/duplicate/"), + async (route) => { + if (route.request().method() !== "GET" || !duplicatedItemId) { + await route.continue(); + return; + } + const response = await route.fetch(); + const json = await response.json(); + if (json.results) { + for (const item of json.results) { + if (item.id === duplicatedItemId) { + item.upload_state = forcedUploadState; + } + } + } + await route.fulfill({ response, json }); + }, + ); + return { releaseDuplicating: () => { forcedUploadState = "ready"; @@ -73,8 +96,7 @@ test.describe("Duplicate item", () => { const [response] = await Promise.all([ page.waitForResponse( - (resp) => - resp.url().includes("/duplicate/") && resp.status() === 201, + (resp) => resp.url().includes("/duplicate/") && resp.status() === 201, ), triggerDuplicate(page, "TestDoc"), ]);