File size: 4,431 Bytes
d77bae9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { chromium } from 'playwright'
import { preview } from 'vite'
import fs from 'node:fs'

const results = {
  timestamp: '2026-07-21',
  build: null,
  runtime: { loaded: false, consoleErrors: [], pageErrors: [] },
  checks: [],
  screenshot: null,
  pageHeight: null,
}

const add = (name, pass, detail = '') => {
  results.checks.push({ name, pass, detail })
  console.log(`${pass ? 'PASS' : 'FAIL'}  ${name} ${detail}`)
}

const server = await preview({ root: '/workspace/repo', preview: { port: 4173, host: '127.0.0.1' } })
const url = 'http://127.0.0.1:4173/'

const browser = await chromium.launch()
const page = await browser.newPage({ viewport: { width: 1920, height: 1080 }, deviceScaleFactor: 1 })
page.on('pageerror', (e) => results.runtime.pageErrors.push(String(e)))
page.on('console', (m) => { if (m.type() === 'error') results.runtime.consoleErrors.push(m.text()) })

await page.goto(url, { waitUntil: 'networkidle' })
await page.waitForTimeout(1000)
results.runtime.loaded = true

// Structure checks
add('react root mounted', (await page.locator('#root > .page').count()) === 1)
for (const [name, sel] of [
  ['navbar', '.nav-bar'],
  ['hero stacked blocks', '.hero-blocks .h-block'],
  ['hero QR callout', '.h-qr img'],
  ['feature panels (4)', '.feature-panels .panel'],
  ['security green panel', '.security-panel'],
  ['getting-started cards (5)', '.step-card'],
  ['FAQ questions (6)', '.faq-questions button'],
  ['footer banner', '.cta-card'],
  ['footer', '.footer-main'],
]) {
  const n = await page.locator(sel).count()
  add(`section present: ${name}`, n > 0, `count=${n}`)
}

add('panel count = 4', (await page.locator('.feature-panels .panel').count()) === 4)
add('step cards = 5', (await page.locator('.step-card').count()) === 5)
add('faq items = 6', (await page.locator('.faq-questions button').count()) === 6)

// Text spot-checks
for (const text of ['money moves', 'SEND MONEY', 'BUY AIRTIME', 'TV SUBSCRIPTION', 'SCHEDULE',
  'Biometric chat lock', 'Frequently', 'How does OWO work?', 'Contact us', 'Flutterwave']) {
  const found = await page.getByText(text, { exact: false }).first().count()
  add(`text present: "${text}"`, found > 0)
}

// Images loaded
const badImgs = await page.evaluate(() =>
  [...document.images].filter((i) => !i.complete || i.naturalWidth === 0).map((i) => i.src),
)
add('all images loaded', badImgs.length === 0, badImgs.join(','))

// Interaction: FAQ item click adds a chat bubble
const before = await page.locator('.faq-bubbles .bubble').count()
await page.locator('.faq-questions button').first().click()
await page.waitForTimeout(300)
const after = await page.locator('.faq-bubbles .bubble').count()
add('FAQ item click adds bubble', after === before + 1, `${before} -> ${after}`)

// Interaction: hover feedback on button (computed style transition present)
const hasTransition = await page.evaluate(() => {
  const el = document.querySelector('.btn-try')
  return getComputedStyle(el).transitionDuration !== '0s'
})
add('button hover transition defined', hasTransition)
const faqTransition = await page.evaluate(() => {
  const el = document.querySelector('.faq-questions button')
  return getComputedStyle(el).transitionDuration !== '0s'
})
add('FAQ item hover transition defined', faqTransition)

// Reload clean state for the canonical screenshot
await page.goto(url, { waitUntil: 'networkidle' })
await page.waitForTimeout(1200)
results.pageHeight = await page.evaluate(() => document.documentElement.scrollHeight)
add('page height ~9255 (±5%)', Math.abs(results.pageHeight - 9255) / 9255 < 0.05, `height=${results.pageHeight}`)

fs.mkdirSync('/workspace/repo/screenshots', { recursive: true })
await page.screenshot({ path: '/workspace/repo/screenshots/full-page.png', fullPage: true })
results.screenshot = '/workspace/repo/screenshots/full-page.png'
add('screenshot captured', fs.existsSync(results.screenshot))

add('no page errors', results.runtime.pageErrors.length === 0, results.runtime.pageErrors.join(';'))
add('no console errors', results.runtime.consoleErrors.length === 0, results.runtime.consoleErrors.join(';'))

await browser.close()
await server.close()

results.allPassed = results.checks.every((c) => c.pass)
fs.mkdirSync('/workspace/artifacts', { recursive: true })
fs.writeFileSync('/workspace/artifacts/validation-results.json', JSON.stringify(results, null, 2))
console.log('\nallPassed =', results.allPassed)
process.exit(0)