up
This commit is contained in:
@@ -8,7 +8,7 @@ module.exports = async function previewsSmoke({ control, output, evaluate, inspe
|
||||
const root = document.querySelector(${JSON.stringify(root)});
|
||||
if (!root) return null;
|
||||
const bounds = root.getBoundingClientRect();
|
||||
return ['.background', '.cover', '.message', '.intro-waveform', '.timer h1', '.timer strong', '.results', '.results h1', '.results .empty', '.results table', ${JSON.stringify(videoSelector)}].flatMap(selector => {
|
||||
return ['.background', '.cover', '.message', '.intro-waveform', '.timer h1', '.timer strong', '.qr-scene', '.qr-caption', '.teams-scene', '.team-names', '.results', '.results h1', '.results .empty', '.results table', ${JSON.stringify(videoSelector)}].flatMap(selector => {
|
||||
const e = root.querySelector(selector); if (!e) return [];
|
||||
const r = e.getBoundingClientRect(); const s = getComputedStyle(e); if (s.display === 'none') return [];
|
||||
return [{ selector: selector.includes('video') ? 'video' : selector, text: e.textContent.trim(), x: (r.x-bounds.x)/bounds.width, y: (r.y-bounds.y)/bounds.height, width: r.width/bounds.width, height: r.height/bounds.height, font: s.fontSize, fit: s.objectFit, filter: s.filter }];
|
||||
@@ -79,11 +79,17 @@ module.exports = async function previewsSmoke({ control, output, evaluate, inspe
|
||||
{ index: 5, results: { packageKey: original.catalog.key, capturedAt: new Date().toISOString(), questions: [], teams: [] } },
|
||||
{ index: 5, results: { packageKey: original.catalog.key, capturedAt: new Date().toISOString(), questions: [{ code: 'A', text: 'Вопрос' }], teams: [{ id: 'one', name: 'Детективы', place: 1, totalScore: 5, actionsCount: 1, answers: [{ questionCode: 'A', score: 5 }] }] } },
|
||||
]
|
||||
for (const step of [
|
||||
{ mode: 9, qrUrl: 'https://example.org/join?game=7', text: 'Присоединяйтесь\nк расследованию' },
|
||||
{ mode: 9, qrUrl: 'https://example.org/join', text: '' },
|
||||
{ mode: 10, text: '' },
|
||||
]) cases.push({ index: 7, catalog: { ...original.catalog, steps: original.catalog.steps.map((old, i) => i === 7 ? { ...old, ...step } : old) }, teams: { packageKey: original.catalog.key, capturedAt: new Date().toISOString(), teams: Array.from({ length: 32 }, (_, i) => ({ id: String(i), name: `Команда ${i + 1} — Длинное название` })) } })
|
||||
cases.push({ index: 7, catalog: { ...original.catalog, steps: original.catalog.steps.map((old, i) => i === 7 ? { ...old, mode: 10 } : old) }, teams: { packageKey: original.catalog.key, capturedAt: new Date().toISOString(), teams: [] } })
|
||||
for (const item of cases) {
|
||||
const catalog = item.catalog ?? original.catalog
|
||||
const step = catalog.steps[item.index]
|
||||
const snapshot = { ...original, revision: ++revision, catalog, results: item.results ?? original.results,
|
||||
scene: { ...original.scene, revision, mode: step.mode, text: step.text, stepIndex: item.index },
|
||||
const snapshot = { ...original, revision: ++revision, catalog, results: item.results ?? original.results, teams: item.teams ?? original.teams,
|
||||
scene: { ...original.scene, revision, mode: step.mode, text: step.text, qrUrl: step.qrUrl, stepIndex: item.index },
|
||||
channels: { ...original.channels, main: { ...original.channels.main, source: catalog.media.find(m => m.kind === (step.mode === 2 ? 'audio' : 'video')) ?? null } } }
|
||||
control.webContents.send('state', snapshot)
|
||||
output.webContents.send('state', snapshot)
|
||||
@@ -91,6 +97,16 @@ module.exports = async function previewsSmoke({ control, output, evaluate, inspe
|
||||
await poll(() => evaluate(`document.querySelector('${miniature(item.index)} .scene-view').dataset.mode === '${step.mode}'`), 'fixture thumbnail')
|
||||
await new Promise(resolve => setTimeout(resolve, 50))
|
||||
await compare(item.index)
|
||||
if (step.mode === 9) {
|
||||
await poll(() => inspect("!!document.querySelector('.qr-scene canvas')"), 'QR canvas')
|
||||
assert.ok(await inspect("(() => { const c = document.querySelector('.qr-scene canvas'), r = c.getBoundingClientRect(); return r.width > 200 && r.height > 200 && r.bottom <= innerHeight && r.right <= innerWidth })()"))
|
||||
if (step.text) writeFileSync('/tmp/ed054-qr-output.png', (await output.webContents.capturePage()).toPNG())
|
||||
}
|
||||
if (step.mode === 10) {
|
||||
assert.equal(await inspect("document.querySelectorAll('.team-names p').length"), item.teams.teams.length)
|
||||
assert.ok(await inspect("Array.from(document.querySelectorAll('.team-names p')).every(e => { const r = e.getBoundingClientRect(); return r.top >= 0 && r.left >= 0 && r.bottom <= innerHeight && r.right <= innerWidth })"))
|
||||
if (item.teams.teams.length) writeFileSync('/tmp/ed054-teams-output.png', (await output.webContents.capturePage()).toPNG())
|
||||
}
|
||||
}
|
||||
console.log('SCREEN_PREVIEWS_PASS')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user