Skip to content

Commit 7cf008f

Browse files
committed
evidence: one-off Chrome stills run for #14182 (not for merge)
1 parent 0a228d6 commit 7cf008f

4 files changed

Lines changed: 163 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type {Meta, StoryObj} from '@storybook/react';
2+
3+
import UseLongPressHookUsage from '../../../packages/cli/assets/templates/blocks/components/Hooks/useLongPressHookUsage';
4+
5+
const meta: Meta = {title: 'Tmp/UseLongPressBlock'};
6+
export default meta;
7+
type Story = StoryObj;
8+
9+
export const Narrow: Story = {
10+
render: () => (
11+
<div style={{width: 240, padding: 8}}>
12+
<UseLongPressHookUsage />
13+
</div>
14+
),
15+
};
16+
17+
export const Wide: Story = {
18+
render: () => (
19+
<div style={{width: 360, padding: 8}}>
20+
<UseLongPressHookUsage />
21+
</div>
22+
),
23+
};
24+
25+
export const NarrowRtl: Story = {
26+
render: () => (
27+
<div dir="rtl" style={{width: 240, padding: 8}}>
28+
<UseLongPressHookUsage />
29+
</div>
30+
),
31+
};

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
// One-off evidence capture for pull request 14182. Not for merge.
3+
import {writeFile} from 'node:fs/promises';
4+
import path from 'node:path';
5+
import {chromium} from 'playwright';
6+
import {serve, settle} from './common.mjs';
7+
8+
const temp = process.argv[2];
9+
const out = path.join(temp, 'stills');
10+
const CELLS = [
11+
['narrow', 'tmp-uselongpressblock--narrow', 320],
12+
['narrow-rtl', 'tmp-uselongpressblock--narrow-rtl', 320],
13+
['wide', 'tmp-uselongpressblock--wide', 800],
14+
];
15+
const browser = await chromium.launch({channel: 'chrome'});
16+
const report = [`browser ${browser.version()}`];
17+
for (const side of ['base', 'head']) {
18+
const server = await serve(path.join(temp, `sb-${side}`));
19+
const origin = `http://127.0.0.1:${server.address().port}`;
20+
for (const [key, story, width] of CELLS) {
21+
const context = await browser.newContext({viewport: {width, height: 700}, deviceScaleFactor: 2});
22+
const page = await context.newPage();
23+
await page.goto(`${origin}/iframe.html?id=${story}&viewMode=story`);
24+
const root = page.locator('#storybook-root > *').first();
25+
await root.waitFor();
26+
await settle(page);
27+
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`)});
29+
report.push(`${side} ${key}: hint "${hint}"`);
30+
await context.close();
31+
}
32+
server.close();
33+
}
34+
await browser.close();
35+
await writeFile(path.join(out, 'report.txt'), report.join('\n') + '\n');
36+
console.log(report.join('\n'));

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
// One-off evidence capture helpers. Not for merge.
3+
import {createServer} from 'node:http';
4+
import {readFile} from 'node:fs/promises';
5+
import path from 'node:path';
6+
7+
const TYPES = {'.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.json': 'application/json', '.svg': 'image/svg+xml', '.woff2': 'font/woff2', '.png': 'image/png'};
8+
9+
export function serve(root) {
10+
const base = path.resolve(root);
11+
return new Promise(resolve => {
12+
const server = createServer(async (req, res) => {
13+
const url = new URL(req.url, 'http://x');
14+
const file = path.resolve(base, '.' + decodeURIComponent(url.pathname === '/' ? '/index.html' : url.pathname));
15+
if (file !== base && !file.startsWith(base + path.sep)) {
16+
res.writeHead(404);
17+
res.end();
18+
return;
19+
}
20+
try {
21+
const body = await readFile(file);
22+
res.writeHead(200, {'content-type': TYPES[path.extname(file)] ?? 'application/octet-stream'});
23+
res.end(body);
24+
} catch {
25+
res.writeHead(404);
26+
res.end();
27+
}
28+
});
29+
server.listen(0, '127.0.0.1', () => resolve(server));
30+
});
31+
}
32+
33+
export async function settle(page) {
34+
await page.evaluate(async () => {
35+
await document.fonts.ready;
36+
await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)));
37+
});
38+
}
39+
40+
// A clip around the side nav and any open menu, with a margin.
41+
export async function navClip(page) {
42+
return page.evaluate(() => {
43+
const boxes = [...document.querySelectorAll('nav, [role="navigation"], .astryx-side-nav, [role="menu"]')]
44+
.map(e => e.getBoundingClientRect())
45+
.filter(r => r.width > 0 && r.height > 0);
46+
const left = Math.max(0, Math.min(...boxes.map(r => r.left)) - 24);
47+
const top = Math.max(0, Math.min(...boxes.map(r => r.top)) - 24);
48+
const right = Math.min(innerWidth, Math.max(...boxes.map(r => r.right)) + 24);
49+
const bottom = Math.min(innerHeight, Math.max(...boxes.map(r => r.bottom)) + 24);
50+
return {x: left, y: top, width: right - left, height: bottom - top};
51+
});
52+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# One-off evidence run for pull request 14182. Not for merge.
3+
name: scratch chrome stills 14182
4+
on:
5+
push:
6+
branches: [scratch/chrome-stills-14182]
7+
permissions:
8+
contents: read
9+
jobs:
10+
stills:
11+
runs-on: macos-15
12+
timeout-minutes: 75
13+
steps:
14+
- uses: actions/checkout@v7
15+
with:
16+
fetch-depth: 0
17+
persist-credentials: false
18+
- uses: ./.github/actions/setup
19+
- name: Build Storybook at the head
20+
run: |
21+
cp .github/scratch-14182/TmpUlp.stories.tsx apps/storybook/stories/TmpUlp.stories.tsx
22+
pnpm build
23+
pnpm -F @astryxdesign/storybook build
24+
mv apps/storybook/dist "$RUNNER_TEMP/sb-head"
25+
- name: Build Storybook at the merge base
26+
run: |
27+
git worktree add "$RUNNER_TEMP/base" 841322a245ba1e6a3539044605d37b28ee1116f7
28+
cp .github/scratch-14182/TmpUlp.stories.tsx "$RUNNER_TEMP/base/apps/storybook/stories/TmpUlp.stories.tsx"
29+
cd "$RUNNER_TEMP/base"
30+
pnpm install --frozen-lockfile
31+
pnpm build
32+
pnpm -F @astryxdesign/storybook build
33+
mv apps/storybook/dist "$RUNNER_TEMP/sb-base"
34+
- name: Capture in Google Chrome
35+
run: |
36+
mkdir -p "$RUNNER_TEMP/stills"
37+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --version | tee "$RUNNER_TEMP/stills/chrome-version.txt"
38+
echo "head 0a228d67b167f8c21722a0197e4825ccefdf1a8b base 841322a245ba1e6a3539044605d37b28ee1116f7" >> "$RUNNER_TEMP/stills/chrome-version.txt"
39+
node .github/scratch-14182/capture.mjs "$RUNNER_TEMP"
40+
- uses: actions/upload-artifact@v7
41+
with:
42+
name: pr-14182-chrome-stills
43+
path: ${{ runner.temp }}/stills
44+
retention-days: 7

0 commit comments

Comments
 (0)