-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathoverflow-586-gif.spec.ts
More file actions
66 lines (57 loc) · 2.19 KB
/
Copy pathoverflow-586-gif.spec.ts
File metadata and controls
66 lines (57 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { test } from '@playwright/test'
import { loginAsStudent } from '../utils/auth'
import { BASE, LOCALE } from '../utils/constants'
import fs from 'node:fs'
/**
* Frame capture for the issue #586 GIF. Sweeps the viewport across the broken
* band (700 → 1024) and holds a few frames at each end, then opens the avatar
* dropdown at 820px to show the gamification card is still reachable there.
*
* Run with SHOT_LABEL=before / SHOT_LABEL=after; stitch the frames with ffmpeg.
*/
const LABEL = process.env.SHOT_LABEL || 'after'
const DIR = `${process.env.FRAME_DIR || '/tmp/586-frames'}/${LABEL}`
const WIDTHS = [
700, 700, 720, 740, 768, 768, 768, 790, 810, 830, 850, 870, 890, 910, 940,
970, 1000, 1024, 1024, 1024,
]
test('capture #586 gif frames', async ({ page }) => {
test.setTimeout(240_000)
fs.mkdirSync(DIR, { recursive: true })
await loginAsStudent(page)
await page.setViewportSize({ width: 1024, height: 820 })
await page.goto(`${BASE}/${LOCALE}/dashboard/student`)
await page.waitForLoadState('networkidle').catch(() => {})
await page.waitForTimeout(2000)
let i = 0
const shot = async () => {
await page.screenshot({
path: `${DIR}/frame-${String(i).padStart(4, '0')}.png`,
})
i++
}
for (const width of WIDTHS) {
await page.setViewportSize({ width, height: 820 })
await page.waitForTimeout(320)
const m = await page.evaluate(() => ({
c: document.documentElement.clientWidth,
s: document.documentElement.scrollWidth,
}))
console.log(`${LABEL} @${width}: overflow=${m.s - m.c}`)
await shot()
}
// The "before" recording is only about the sideways scroll; the dropdown
// segment below shows the post-fix trade and would be misleading there.
if (LABEL === 'before') return
// Hold at 820 and open the avatar menu — the gamification card lives here
// below `lg`, which is the trade this change makes.
await page.setViewportSize({ width: 820, height: 820 })
await page.waitForTimeout(500)
await shot()
await shot()
await page.evaluate(() => {
document.querySelector<HTMLElement>('[data-testid="user-nav-trigger"]')?.click()
})
await page.waitForTimeout(900)
for (let k = 0; k < 8; k++) await shot()
})