Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions test/browser/website.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
import { test, expect } from '@playwright/test'
import AxeBuilder from '@axe-core/playwright'

for (const initialWidth of [320, 1440]) {
test(`homepage fits 320px after loading at ${initialWidth}px`, async ({
page,
}) => {
await page.setViewportSize({ width: initialWidth, height: 1000 })
await page.goto('/')
const support = page.getByRole('region', {
name: 'Useful in your project?',
exact: true,
})
await support.scrollIntoViewIfNeeded()
for (const name of ['Star on GitHub', 'Explore NIPE Open Source']) {
await support.getByRole('link', { name, exact: true }).focus()
}
await page.setViewportSize({ width: 320, height: 1000 })
await support.scrollIntoViewIfNeeded()
for (const name of ['Star on GitHub', 'Explore NIPE Open Source']) {
await support.getByRole('link', { name, exact: true }).focus()
}
const layout = await page.evaluate(() => ({
viewport: document.documentElement.clientWidth,
scroll: document.documentElement.scrollWidth,
}))
expect(layout.viewport).toBe(320)
expect(layout.scroll).toBeLessThanOrEqual(layout.viewport)
if (process.env.CTA_SCREENSHOT_DIR) {
await page.locator('.onward').screenshot({
path: `${process.env.CTA_SCREENSHOT_DIR}/onward-${initialWidth}-to-320-${test.info().project.name}.png`,
})
}
})
}

for (const width of [1280, 390, 320]) {
test(`homepage support links remain usable at ${width}px`, async ({
page,
Expand Down
3 changes: 3 additions & 0 deletions website/story.css
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,9 @@ footer nav {
.hero {
grid-template-columns: 1fr;
}
.onward .hero-links {
flex-wrap: wrap;
}
.hero h1 {
font-size: clamp(38px, 9vw, 52px);
}
Expand Down