Datasets:
File size: 4,518 Bytes
148f3c7 | 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | import { chromium } from 'playwright'
import fs from 'node:fs'
const url = process.env.APP_URL || 'http://localhost:4173/'
const results = {
timestamp: new Date().toISOString(),
url,
checks: [],
consoleErrors: [],
}
const add = (name, passed, detail) => results.checks.push({ name, passed, detail })
const browser = await chromium.launch()
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } })
page.on('console', (msg) => {
if (msg.type() === 'error') results.consoleErrors.push(msg.text())
})
page.on('pageerror', (err) => results.consoleErrors.push(String(err)))
await page.goto(url, { waitUntil: 'networkidle' })
await page.evaluate(() => document.fonts.ready)
// 1. App mounted via React root
const rootChildren = await page.evaluate(() => document.getElementById('root').children.length)
add('react-root-renders', rootChildren > 0, `#root has ${rootChildren} child(ren)`)
// 2. Section order present
const sectionsOk = await page.evaluate(() => {
const order = ['.site-header', '.locations', '.studio-section', '.mission', '.cta-band-wrap', '.site-footer']
const tops = order.map((sel) => {
const el = document.querySelector(sel)
return el ? el.getBoundingClientRect().top + window.scrollY : null
})
return tops.every((t, i) => t !== null && (i === 0 || t >= tops[i - 1]))
})
add('section-order', sectionsOk, 'header → locations → studio(dark) → mission → cta → footer')
// 3. Page height close to source (5055px)
const height = await page.evaluate(() => document.documentElement.scrollHeight)
add('page-height', Math.abs(height - 5055) <= 160, `rendered ${height}px vs source 5055px`)
// 4. Menu toggle interaction
await page.click('.menu-toggle')
const menuVisible = await page.isVisible('#main-menu')
add('menu-opens', menuVisible, 'menu panel appears after clicking Menu')
await page.click('#main-menu a')
const menuClosed = !(await page.isVisible('#main-menu'))
add('menu-closes-on-link', menuClosed, 'menu panel closes after clicking a link')
// 5. Video play button toggles
const playBtn = page.locator('.play-btn').first()
await playBtn.scrollIntoViewIfNeeded()
await playBtn.click()
const pressed = await playBtn.getAttribute('aria-pressed')
add('play-button-toggles', pressed === 'true', `aria-pressed=${pressed} after click`)
await playBtn.click()
// 6. Email form submit shows confirmation
await page.fill('.cta-field input', 'test@example.com')
await page.click('.cta-submit')
const confirm = (await page.textContent('.cta-confirm'))?.trim()
add('form-submit-feedback', !!confirm && confirm.includes('test@example.com'), `confirmation: "${confirm}"`)
// 7. Images all load
const badImages = await page.evaluate(() =>
Array.from(document.images)
.filter((img) => !img.complete || img.naturalWidth === 0)
.map((img) => img.src),
)
add('images-load', badImages.length === 0, badImages.length ? `broken: ${badImages.join(', ')}` : 'all <img> loaded')
// 8. Key text content present
const texts = [
'Gros Horloge',
'Vieux Marché',
'Des bureaux fermés privatifs',
'Xavier Leboulanger',
'Julien Hesry',
'Bien plus qu\'un coworking',
'Testez gratuitement',
'06 22 25 78 97',
]
const body = await page.textContent('body')
const missing = texts.filter((t) => !body.includes(t))
add('key-copy-present', missing.length === 0, missing.length ? `missing: ${missing.join('; ')}` : 'all key strings found')
// 9. Responsive layouts render without horizontal overflow
for (const [w, h, label] of [[900, 900, 'tablet'], [480, 900, 'mobile']]) {
await page.setViewportSize({ width: w, height: h })
await page.waitForTimeout(250)
const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)
add(`responsive-${label}`, overflow <= 1, `${w}px viewport, horizontal overflow ${overflow}px`)
}
await page.setViewportSize({ width: 1440, height: 900 })
await page.waitForTimeout(250)
add('no-console-errors', results.consoleErrors.length === 0, results.consoleErrors.join(' | ') || 'clean console')
results.passed = results.checks.filter((c) => c.passed).length
results.failed = results.checks.filter((c) => !c.passed).length
results.allPassed = results.failed === 0
fs.mkdirSync('/workspace/artifacts', { recursive: true })
fs.writeFileSync('/workspace/artifacts/validation-results.json', JSON.stringify(results, null, 2))
console.log(JSON.stringify({ passed: results.passed, failed: results.failed, allPassed: results.allPassed }))
await browser.close()
|