🔧 Make mockAsset to accept an array of asset ids too

This commit is contained in:
Belén Albeza 2025-06-09 16:45:36 +02:00
parent 479406b884
commit 971b92a75b
2 changed files with 21 additions and 22 deletions

View file

@ -24,15 +24,19 @@ export class BasePage {
} }
static async mockAsset(page, assetId, assetFilename, options) { static async mockAsset(page, assetId, assetFilename, options) {
const url = `**/assets/by-file-media-id/${assetId}`; const ids = Array.isArray(assetId) ? assetId : [assetId];
return page.route(url, (route) => for (const id of ids) {
route.fulfill({ const url = `**/assets/by-file-media-id/${id}`;
path: `playwright/data/${assetFilename}`,
status: 200, await page.route(url, (route) =>
...options, route.fulfill({
}), path: `playwright/data/${assetFilename}`,
); status: 200,
...options,
}),
);
}
} }
static async mockConfigFlags(page, flags) { static async mockConfigFlags(page, flags) {

View file

@ -31,11 +31,10 @@ test("Renders a file with solid, gradient and image fills", async ({
const workspace = new WasmWorkspacePage(page); const workspace = new WasmWorkspacePage(page);
await workspace.setupEmptyFile(); await workspace.setupEmptyFile();
await workspace.mockAsset( await workspace.mockAsset(
"1ebcea38-f1bf-8101-8006-4c8fd68e7c84", [
"render-wasm/assets/penguins.jpg", "1ebcea38-f1bf-8101-8006-4c8fd68e7c84",
); "1ebcea38-f1bf-8101-8006-4c8f579da49c",
await workspace.mockAsset( ],
"1ebcea38-f1bf-8101-8006-4c8f579da49c",
"render-wasm/assets/penguins.jpg", "render-wasm/assets/penguins.jpg",
); );
await workspace.mockGetFile("render-wasm/get-file-shapes-fills.json"); await workspace.mockGetFile("render-wasm/get-file-shapes-fills.json");
@ -53,15 +52,11 @@ test("Renders a file with strokes", async ({ page }) => {
const workspace = new WasmWorkspacePage(page); const workspace = new WasmWorkspacePage(page);
await workspace.setupEmptyFile(); await workspace.setupEmptyFile();
await workspace.mockAsset( await workspace.mockAsset(
"202c1104-9385-81d3-8006-5074e4682cac", [
"render-wasm/assets/penguins.jpg", "202c1104-9385-81d3-8006-5074e4682cac",
); "202c1104-9385-81d3-8006-5074c50339b6",
await workspace.mockAsset( "202c1104-9385-81d3-8006-507560ce29e3",
"202c1104-9385-81d3-8006-5074c50339b6", ],
"render-wasm/assets/penguins.jpg",
);
await workspace.mockAsset(
"202c1104-9385-81d3-8006-507560ce29e3",
"render-wasm/assets/penguins.jpg", "render-wasm/assets/penguins.jpg",
); );
await workspace.mockGetFile("render-wasm/get-file-shapes-strokes.json"); await workspace.mockGetFile("render-wasm/get-file-shapes-strokes.json");