up
This commit is contained in:
@@ -84,6 +84,7 @@ module.exports = async function previewsSmoke({ control, output, evaluate, inspe
|
||||
{ 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} — Длинное название` })) } })
|
||||
for (const count of [1, 8, 20]) 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: Array.from({ length: count }, (_, 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
|
||||
@@ -105,6 +106,12 @@ module.exports = async function previewsSmoke({ control, output, evaluate, inspe
|
||||
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 })"))
|
||||
const singleColumn = (root) => `(() => {
|
||||
const rows = Array.from(document.querySelectorAll('${root} .team-names p'), e => e.getBoundingClientRect());
|
||||
return rows.every((row, i) => Math.abs(row.left - rows[0].left) < 1 && Math.abs(row.width - rows[0].width) < 1 && (i === 0 || row.top >= rows[i - 1].bottom));
|
||||
})()`
|
||||
assert.ok(await inspect(singleColumn('.output')), 'output teams form one column')
|
||||
assert.ok(await evaluate(singleColumn(miniature(item.index))), 'preview teams form one column')
|
||||
if (item.teams.teams.length) writeFileSync('/tmp/ed054-teams-output.png', (await output.webContents.capturePage()).toPNG())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user