🔧 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) {
const url = `**/assets/by-file-media-id/${assetId}`;
const ids = Array.isArray(assetId) ? assetId : [assetId];
return page.route(url, (route) =>
route.fulfill({
path: `playwright/data/${assetFilename}`,
status: 200,
...options,
}),
);
for (const id of ids) {
const url = `**/assets/by-file-media-id/${id}`;
await page.route(url, (route) =>
route.fulfill({
path: `playwright/data/${assetFilename}`,
status: 200,
...options,
}),
);
}
}
static async mockConfigFlags(page, flags) {