perf-budgets reports only for a project that runs Playwright (a new starter site has no e2e yet)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 14:29:17 +01:00
co-authored by Claude Opus 5.5
parent 3b32e659c5
commit 6b16b9f933
4 changed files with 13 additions and 2 deletions
+1 -1
View File
@@ -143,7 +143,7 @@ Turn off: `iapl({ doctor: false })`. Adapt: `iapl({ doctor: { tokenVar: 'MY_TOKE
| | `perf-render-blocking` | warning | no `<script src>` without `async` / `defer`, no stylesheet `<link>` or CSS `@import` from another host |
| | `perf-embeds` | warning | no `<iframe>` (map, widget) that loads with the page — a click-to-load facade, or `loading="lazy"`; YouTube is `iapl-audit`'s |
| | `perf-animations` | warning | no transition of a layout property or `transition-all`, no `scroll` listener, something honours `prefers-reduced-motion` when the site animates |
| | `perf-budgets` | info | a performance budget test in `e2e/` (the `iapl-performance` skill's template) |
| | `perf-budgets` | info | a project that runs Playwright has a performance budget test in `e2e/` (the `iapl-performance` skill's template) |
| | `perf-live` | warning | (live) the home HTML is compressed, has no blocking `<script>` in `<head>`, preloads at most four fonts, its first image in `<main>` is not lazy, and is at most 150 KB |
| | `perf-images` | warning | (deep) no stored image over 1.5 MB or 2560 px wide (`IMAGE_RULES`) |
| audit | `i18n-literals` | error / warning | from `iapl-audit`: hardcoded text in blocks (error) and components (warning), Polish literals in code (not the panel's `adminText()` / `{ en, pl }` labels in a schema file — the `iapl-audit` skill) |
+1 -1
View File
@@ -132,7 +132,7 @@ All in the `performance` group (`iapl-doctor --only performance`), warnings in 1
| `perf-render-blocking` | static | a `<script src>` without `async` / `defer`, a stylesheet or `@import` from another host | `next/script`, the plugin's script components, self-host |
| `perf-embeds` | static | an `<iframe>` (map, widget) that loads with the page (YouTube is `iapl-audit`'s) | a facade (picture + button), or `loading="lazy"` below the fold |
| `perf-animations` | static | a transition of a layout property, `transition-all`, a `scroll` listener, animations with nothing for reduced motion | `transform` / `opacity`, IntersectionObserver, `motion-reduce:` |
| `perf-budgets` | static | no performance budget test in `e2e/` | the skill's template |
| `perf-budgets` | static | the project runs Playwright but has no performance budget test in `e2e/` | the skill's template |
| `perf-live` | `--url` | the HTML is not compressed; blocking scripts in `<head>`; more than four preloaded fonts; the first image in `<main>` is lazy; the home HTML over 150 KB | proxy compression; `async`; fewer font files; `priority`; less data to client components |
| `perf-images` | `--deep` | images stored over 1.5 MB or 2560 px wide | re-upload prepared, or tick "Optimise large image" |
+4
View File
@@ -145,6 +145,10 @@ export const performanceRules: DoctorRule[] = [
// A budget nobody runs is a wish: the gate test fails when a change makes the site slower
id: 'perf-budgets',
check: (ctx) => {
// only a project that already runs browser tests: there the budget test is one file to copy (a new site from the
// starter has none yet — AGENT.md §11 and the iapl-performance skill bring it in with the first e2e tests)
const playwright = !!ctx.installed('@playwright/test') || ['playwright.config.ts', 'playwright.config.js', 'playwright.config.mjs'].some((f) => ctx.exists(f))
if (!playwright) {return []}
const dirs = ['e2e', 'tests', 'test'].filter((d) => ctx.exists(d))
const has = dirs.some((d) => ctx.list(d).some((name) => /perf/i.test(name) || /\bperfBudgets\s*\(|\boverBudget\s*\(/.test(ctx.read(`${d}/${name}`))))
return has ? [] : [{ fix: 'copy the iapl-performance skill\'s resources/performance.spec.template.ts to e2e/ (budgets from perfBudgets())', message: 'no performance budget test: nothing fails when a change makes the site slower', severity: 'info' }]
+7
View File
@@ -53,6 +53,7 @@ describe('doctor: performance group (static)', () => {
test('images config, fonts, render-blocking, embeds, animations and a missing budget test are reported', async () => {
const root = project({
'next.config.ts': 'export default { images: { remotePatterns: [] } }',
'playwright.config.ts': 'export default {}',
'src/app/(frontend)/[locale]/layout.tsx': [
"import { Fraunces, Inter, Lora } from 'next/font/google'",
"const a = Inter({ display: 'block' })",
@@ -94,6 +95,12 @@ describe('doctor: performance group (static)', () => {
})
})
test('perf-budgets: only for a project that already runs Playwright', async () => {
const files = { 'next.config.ts': 'buildImagesConfig()' }
expect(await found(project(files), ['perf-budgets'])).toEqual([])
expect(await found(project({ ...files, 'playwright.config.ts': '' }), ['perf-budgets'])).toHaveLength(1)
})
describe('doctor: performance group (deep and live)', () => {
test('perf-images: stored images over the limits', async () => {
const root = project({})