mirror of
https://github.com/suitenumerique/drive.git
synced 2026-09-30 13:35:14 +02:00
✅(frontend) update e2e for item duplication with state interception
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.
This commit is contained in:
@@ -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"),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user