Skip to content

Commit d128703

Browse files
committed
evidence: clip the card instead of an element screenshot (not for merge)
1 parent 7cf008f commit d128703

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎.github/scratch-14182/capture.mjs‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,21 @@ for (const side of ['base', 'head']) {
1818
const server = await serve(path.join(temp, `sb-${side}`));
1919
const origin = `http://127.0.0.1:${server.address().port}`;
2020
for (const [key, story, width] of CELLS) {
21-
const context = await browser.newContext({viewport: {width, height: 700}, deviceScaleFactor: 2});
21+
const context = await browser.newContext({viewport: {width, height: 700}, deviceScaleFactor: 2, reducedMotion: 'reduce'});
2222
const page = await context.newPage();
2323
await page.goto(`${origin}/iframe.html?id=${story}&viewMode=story`);
2424
const root = page.locator('#storybook-root > *').first();
2525
await root.waitFor();
2626
await settle(page);
2727
const hint = await page.evaluate(() => [...document.querySelectorAll('p, span')].map(e => e.textContent.trim()).find(t => t.startsWith('Touch press-and-hold')) ?? 'none');
28-
await root.screenshot({path: path.join(out, `${side}-${key}.png`)});
28+
// A clip, not an element screenshot: the example's long-press ring keeps
29+
// the element from ever reading as stable.
30+
const box = await root.boundingBox();
31+
await page.screenshot({
32+
path: path.join(out, `${side}-${key}.png`),
33+
clip: {x: Math.max(0, box.x - 8), y: Math.max(0, box.y - 8), width: Math.min(width, box.width + 16), height: box.height + 16},
34+
animations: 'disabled',
35+
});
2936
report.push(`${side} ${key}: hint "${hint}"`);
3037
await context.close();
3138
}

0 commit comments

Comments
 (0)