Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/danielroe/roe.dev. This is the code and content for my personal website, built in Nuxt. roe.dev
Something went wrong. Try again.
TypeScript
at feat/nuxt-v5
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182import process from 'node:process'import type { Locator, Page } from '@playwright/test'import { test, expect } from '@playwright/test'import { joinURL, withTrailingSlash } from 'ufo'
async function waitForImages (page: Page) { await page.evaluate(() => { for (const img of document.images) img.loading = 'eager' }) await page.evaluate(() => Promise.all( Array.from(document.images) .filter(img => !img.complete) .map(img => new Promise(resolve => { img.addEventListener('load', () => resolve(null), { once: true }) img.addEventListener('error', () => resolve(null), { once: true }) })), ))}
async function removeSections (page: Page, headings: string[]) { await page.evaluate(headings => { for (const h2 of document.querySelectorAll('section > h2')) { if (!headings.includes(h2.textContent!.trim())) continue const section = h2.parentElement! if (section.previousElementSibling?.tagName === 'HR') section.previousElementSibling.remove() section.remove() } }, headings)}
const baseURL = process.env.BASE_URL || 'https://roe.dev/'
const url = (path: string) => joinURL(baseURL, path)
const pages = [ '/', '/talks', '/uses', '/projects', '/blog', '/blog/introduction', '/blog/serverless-functions-nuxt-zeit-now', '/blog/good-ux-and-giving-birth', '/blog/building-your-own-vue-rich-text-component', '/blog/creating-your-own-sitemap-module', '/blog/open-invitation', '/blog/contributing-to-nuxt',]
test.describe(`pages`, () => { for (const path of pages) { test(`renders ${path}`, async ({ page }) => { await page.goto(url(path))
const title = page.locator('title') expect(await title.textContent()).toContain('Daniel Roe')
await waitForImages(page)
const mask: Locator[] = [ page.locator('img[src*="s2/favicons"]'), ] if (path === '/') { await removeSections(page, ['some recent streams', 'upcoming talks']) mask.push(page.locator('section:has(h2:text("recent talks")) ul')) }
await expect(page).toHaveScreenshot({ maxDiffPixelRatio: 0.05, mask }) })
test(`image for ${path}`, async ({ page }) => { await page.goto(url(path))
const ogImage = page.locator('[property="og:image"]').first() const ogURL = await ogImage.getAttribute('content') await page.goto(ogURL!.replace('https://roe.dev/', withTrailingSlash(baseURL))) await waitForImages(page) await expect(page).toHaveScreenshot() }) }})