BS-004 Build approved homepage composition with explicit asset placeholders

This commit is contained in:
rob
2026-11-10 14:17:14 +00:00
parent 2a4ffe1b00
commit 4f3b75b2b4
14 changed files with 290 additions and 98 deletions
+30
View File
@@ -0,0 +1,30 @@
import { expect, test } from '@playwright/test'
for (const width of [320, 768, 1440]) {
test(`homepage composition at ${width}px`, async ({ page }) => {
await page.setViewportSize({ width, height: 900 })
const errors = []
const failedRequests = []
page.on('pageerror', error => errors.push(error.message))
page.on('requestfailed', request => failedRequests.push(request.url()))
await page.emulateMedia({ reducedMotion: 'reduce' })
await page.goto('/')
const hero = page.getByRole('region', { name: /software solutions/i })
await expect(hero.getByRole('link')).toHaveCount(1)
await expect(page.getByRole('region', { name: 'What we do' }).getByRole('link')).toHaveCount(4)
await expect(page.getByRole('region', { name: 'Featured project' }).getByRole('img')).toHaveCount(1)
await expect(page.getByText('Featured project pending')).toBeVisible()
await expect(page.getByRole('region', { name: 'Why BortStack' }).getByRole('heading', { level: 3 })).toHaveCount(3)
expect(await page.locator('html').evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true)
for (const heading of await page.getByRole('heading').all()) {
const box = await heading.boundingBox()
expect(box.x).toBeGreaterThanOrEqual(0)
expect(box.x + box.width).toBeLessThanOrEqual(width + 1)
}
await hero.getByRole('link', { name: 'Discuss a Project' }).click()
await expect(page).toHaveURL(/\/contact$/)
await expect(page.getByRole('heading', { name: 'Contact', exact: true })).toBeVisible()
expect(errors).toEqual([])
expect(failedRequests).toEqual([])
})
}
+1 -1
View File
@@ -2,7 +2,7 @@ import AxeBuilder from '@axe-core/playwright'
import { expect, test } from '@playwright/test'
for (const [path, heading] of [
['/', 'Software development for real-world needs'], ['/services', 'Services'],
['/', /Software solutions\s*for real-world use\./], ['/services', 'Services'],
['/projects', 'Projects'], ['/projects/example', 'Project details'],
['/about', 'About BortStack'], ['/contact', 'Contact'], ['/privacy', 'Privacy policy'],
['/login', 'Page not found'], ['/dashboard', 'Page not found'],
+2 -1
View File
@@ -40,11 +40,12 @@ test('storage denied does not break initial page or theme toggle', async ({ page
})
for (const theme of ['dark', 'light']) {
test(`${theme} shell contrast and layout`, async ({ page }) => {
test(`${theme} shell contrast and layout`, async ({ page }, testInfo) => {
await page.addInitScript(theme => localStorage.setItem('bortstack-theme', theme), theme)
await page.goto('/')
expect((await new AxeBuilder({ page }).analyze()).violations).toEqual([])
expect(await page.locator('html').evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true)
await page.screenshot({ path: testInfo.outputPath(`homepage-${theme}.png`), fullPage: true })
await page.getByRole('button', { name: `Switch to ${theme === 'dark' ? 'light' : 'dark'} mode` }).focus()
await page.keyboard.press('Enter')
await expect(page.locator('html')).toHaveAttribute('data-bs-theme', theme === 'dark' ? 'light' : 'dark')