diff --git a/packages/sit-onyx/src/playwright/screenshots.tsx b/packages/sit-onyx/src/playwright/screenshots.tsx index 53d0ade2e7..1f99adeb81 100644 --- a/packages/sit-onyx/src/playwright/screenshots.tsx +++ b/packages/sit-onyx/src/playwright/screenshots.tsx @@ -58,7 +58,7 @@ type TestArgs = Parameters[2]>[0]; export const executeMatrixScreenshotTest = async ( options: MatrixScreenshotTestOptions, ) => { - test(`${options.name}`, async ({ mount, page, browserName, makeAxeBuilder }) => { + test(`${options.name}`, async ({ mount, page, browserName, makeAxeBuilder, context }) => { // limit the max timeout per permutation const timeoutPerScreenshot = 25 * 1000; test.setTimeout(options.columns.length * options.rows.length * timeoutPerScreenshot); @@ -93,18 +93,14 @@ export const executeMatrixScreenshotTest = async - ); + return { + box, + id, + screenshot, + }; }; - const screenshots: JSX.Element[] = []; + const screenshotMap = new Map>>(); for (const row of options.rows) { for (const column of options.columns) { @@ -122,11 +118,32 @@ export const executeMatrixScreenshotTest = async ); - const screenshot = await getScreenshot(wrappedElement, column, row); - screenshots.push(screenshot); + const data = await getScreenshot(wrappedElement, column, row); + screenshotMap.set(data.id, data); } } + await context.route("/_playwright-matrix-screenshot*", (route, request) => { + const url = new URL(request.url()); + const wantedId = url.searchParams.get("id") ?? ""; + + return route.fulfill({ + status: 200, + contentType: "image/png", + body: screenshotMap.get(wantedId)?.screenshot, + }); + }); + + const screenshots = Array.from(screenshotMap.values()).map(({ box, id }) => ( + {id} + )); + const component = await mount(