1.18.0 performance items: reference 404 placeholder and heading font without preload, lazy form and Turnstile code (eager entry /client/eager), Turnstile space kept, background video paused for reduced motion, card hover on opacity, metadata stripped on upload, MongoDB TTL indexes for the consent log and statistics, unused-media notice, version limit for the plugin's entities
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
076b3ef707
commit
d628839235
@@ -37,10 +37,8 @@ const PAGES: Array<{ budget?: { desktop?: Budget; mobile?: Budget }; name: strin
|
||||
{ name: 'form', path: '/pl/wycena' },
|
||||
// every block × variant on one page, the contact form's Turnstile included (a necessary service, before consent)
|
||||
{ budget: { desktop: { jsBytes: 230_000, thirdParty: ['https://challenges.cloudflare.com'] }, mobile: { jsBytes: 230_000, thirdParty: ['https://challenges.cloudflare.com'] } }, name: 'showcase', path: '/pl/bloki' },
|
||||
// The 404 content loads after hydration (createNotFoundPage `load`, so it is not in every page's payload): it
|
||||
// arrives late and moves the footer — measured CLS 0.32 and LCP 2.5 s on the phone. An owner decision in
|
||||
// docs/performance.md; until then the gate holds it where it is (no worse).
|
||||
{ budget: { mobile: { cls: 0.35, lcp: 3000 } }, name: '404', path: '/pl/nie-ma-takiej-strony', why: 'lazy 404 (owner decision pending)' },
|
||||
// the lazy 404: its content arrives after hydration; the placeholder in not-found.tsx keeps its height (CLS 0)
|
||||
{ budget: { mobile: { lcp: 2200 } }, name: '404', path: '/pl/nie-ma-takiej-strony', why: 'the 404 content comes from a server action after hydration' },
|
||||
]
|
||||
|
||||
let browser: Browser
|
||||
@@ -110,3 +108,34 @@ test.describe('queries per render', () => {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* MongoDB TTL index of the consent log (1.18.0, shared/ttl.ts): the database deletes records older than the retention
|
||||
* itself, also on a quiet site. The index exists with the retention's lifetime, and a new record carries the date it
|
||||
* counts from. Skipped when not MongoDB.
|
||||
*/
|
||||
test('consent log: the TTL index is there and a new record carries its date', async ({ baseURL }) => {
|
||||
const uri = process.env.DATABASE_URI
|
||||
test.skip(!uri?.startsWith('mongodb'), 'not MongoDB')
|
||||
const site = process.cwd()
|
||||
const requireFromAdapter = createRequire(createRequire(path.join(site, 'package.json')).resolve('@payloadcms/db-mongodb'))
|
||||
const mongoose = requireFromAdapter('mongoose') as typeof import('mongoose')
|
||||
const conn = await mongoose.createConnection(uri!).asPromise()
|
||||
try {
|
||||
const records = conn.db!.collection('consent-records')
|
||||
const ttl = (await records.indexes()).find((i) => i.name === 'iapl_ttl')
|
||||
expect(ttl, 'the TTL index').toMatchObject({ expireAfterSeconds: 1095 * 86_400, key: { iaplTtlFrom: 1 } })
|
||||
const id = [...crypto.getRandomValues(new Uint8Array(12))].map((b) => b.toString(16).padStart(2, '0')).join('')
|
||||
const res = await fetch(`${baseURL}/api/ipal/consent`, {
|
||||
body: JSON.stringify({ id, state: { analytics: false, functional: false, marketing: false, necessary: true }, version: 1 }),
|
||||
headers: { 'content-type': 'application/json', origin: baseURL! },
|
||||
method: 'POST',
|
||||
})
|
||||
expect(res.status).toBe(201)
|
||||
const record = await records.findOne({ consentId: id })
|
||||
expect(record?.iaplTtlFrom, 'the date the TTL counts from').toBeInstanceOf(Date)
|
||||
await records.deleteOne({ consentId: id })
|
||||
} finally {
|
||||
await conn.close()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { expect, test } from '@playwright/test'
|
||||
|
||||
import { editorTestAccount, totp } from './totp'
|
||||
|
||||
/**
|
||||
* `iapl({ unusedMedia: true })` (1.18.0; docs/media.md): above the Media list, how many files nothing uses, with a
|
||||
* link to Payload's own list filtered to them. An image uploaded here and used nowhere must be listed; it is deleted
|
||||
* by this test afterwards, never by the panel. Signs in as the test editor (the admins' 2FA attempts stay for the
|
||||
* other specs).
|
||||
*/
|
||||
test('Media: the unused-files notice lists a file nothing uses and links to the filtered list', async ({ baseURL, page }) => {
|
||||
const { E2E_ADMIN_EMAIL: email, E2E_ADMIN_PASSWORD: password, E2E_TOTP_SECRET: secret } = process.env
|
||||
test.skip(!email || !password || !secret, 'E2E_* test admin not configured')
|
||||
await page.goto('/admin/login')
|
||||
await page.fill('#field-email', editorTestAccount(email!))
|
||||
await page.fill('#field-password', password!)
|
||||
await page.click('.form-submit button')
|
||||
await page.waitForURL(/verify-totp|\/admin(\?|$)/, { waitUntil: 'commit' })
|
||||
if (page.url().includes('verify-totp')) {
|
||||
await page.getByRole('textbox').first().click()
|
||||
await page.keyboard.type(totp(secret!))
|
||||
}
|
||||
await expect(page).toHaveTitle(/Dashboard|Pulpit/, { timeout: 20_000 })
|
||||
|
||||
// a 1×1 PNG nobody points at
|
||||
const png = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=', 'base64')
|
||||
// the session cookie counts only with the site's own Origin (Payload's CSRF rule)
|
||||
const origin = { origin: new URL(baseURL!).origin }
|
||||
const created = await page.request.post('/api/media', {
|
||||
headers: origin,
|
||||
multipart: { _payload: JSON.stringify({ alt: 'unused-media e2e' }), file: { buffer: png, mimeType: 'image/png', name: 'unused-media-e2e.png' } },
|
||||
})
|
||||
expect(created.status(), await created.text()).toBe(201)
|
||||
const id = ((await created.json()) as { doc: { id: string } }).doc.id
|
||||
try {
|
||||
await page.goto('/admin/collections/media')
|
||||
const notice = page.locator('[data-iapl="unused-media"]')
|
||||
await expect(notice).toBeVisible()
|
||||
const href = await notice.locator('a').getAttribute('href')
|
||||
expect(href).toContain(`=${id}`)
|
||||
await notice.locator('a').click()
|
||||
await expect(page.getByText('unused-media-e2e', { exact: false }).first()).toBeVisible()
|
||||
} finally {
|
||||
await page.request.delete(`/api/media/${id}`, { headers: origin })
|
||||
}
|
||||
})
|
||||
@@ -15,7 +15,9 @@ import '../styles.css'
|
||||
|
||||
// Fixed slot names from the token standard: --font-family-body / --font-family-heading (design-tokens.md)
|
||||
const body = Inter({ display: 'swap', subsets: ['latin', 'latin-ext'], variable: '--font-family-body' })
|
||||
const heading = Fraunces({ display: 'swap', subsets: ['latin', 'latin-ext'], variable: '--font-family-heading' })
|
||||
// The heading font is not preloaded: the stylesheet and the hero image get the first round trips (measured on a
|
||||
// phone: first paint and LCP 36–52 ms sooner; headings swap in with fallback metrics, CLS stays < 0.1 — docs/performance.md)
|
||||
const heading = Fraunces({ display: 'swap', preload: false, subsets: ['latin', 'latin-ext'], variable: '--font-family-heading' })
|
||||
|
||||
type Props = { children: React.ReactNode; params: Promise<{ locale: string }> }
|
||||
|
||||
|
||||
@@ -4,4 +4,9 @@ import * as content from '@/lib/content'
|
||||
|
||||
import { loadNotFoundView } from './notFoundView'
|
||||
|
||||
export default createNotFoundPage(content, { load: loadNotFoundView })
|
||||
// The lazy 404 content arrives after hydration: a block as tall as it keeps the footer still (no layout shift).
|
||||
// Measured for this site's 404 content: 282 px at 360 px wide to 432 px at 1920 — change it with that content.
|
||||
export default createNotFoundPage(content, {
|
||||
load: loadNotFoundView,
|
||||
placeholder: <div aria-hidden style={{ minHeight: 'max(290px, calc(212px + 11.5vw))' }} />,
|
||||
})
|
||||
|
||||
@@ -28,6 +28,7 @@ import { MetaDescriptionComponent as MetaDescriptionComponent_a8a977ebc872c5d5ea
|
||||
import { MetaDescriptionCheck as MetaDescriptionCheck_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { MetaImageComponent as MetaImageComponent_a8a977ebc872c5d5ea7ee689724c0860 } from '@payloadcms/plugin-seo/client'
|
||||
import { PreviewComponent as PreviewComponent_a8a977ebc872c5d5ea7ee689724c0860 } from '@payloadcms/plugin-seo/client'
|
||||
import { UnusedMediaNotice as UnusedMediaNotice_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { MaskedField as MaskedField_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { TOTPField as TOTPField_3eb2cc20d1a2569c2ccbafcee15bd128 } from '@clocklimited/payload-2fa/rsc'
|
||||
import { TwoFactorStatusField as TwoFactorStatusField_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
@@ -84,6 +85,7 @@ export const importMap = {
|
||||
"@intecion/ipal-kit/admin#MetaDescriptionCheck": MetaDescriptionCheck_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@payloadcms/plugin-seo/client#MetaImageComponent": MetaImageComponent_a8a977ebc872c5d5ea7ee689724c0860,
|
||||
"@payloadcms/plugin-seo/client#PreviewComponent": PreviewComponent_a8a977ebc872c5d5ea7ee689724c0860,
|
||||
"@intecion/ipal-kit/admin#UnusedMediaNotice": UnusedMediaNotice_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#MaskedField": MaskedField_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@clocklimited/payload-2fa/rsc#TOTPField": TOTPField_3eb2cc20d1a2569c2ccbafcee15bd128,
|
||||
"@intecion/ipal-kit/admin#TwoFactorStatusField": TwoFactorStatusField_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
|
||||
@@ -1372,6 +1372,7 @@ export interface ConsentRecord {
|
||||
analytics?: boolean | null;
|
||||
marketing?: boolean | null;
|
||||
};
|
||||
iaplTtlFrom?: string | null;
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
}
|
||||
@@ -2442,6 +2443,7 @@ export interface ConsentRecordsSelect<T extends boolean = true> {
|
||||
analytics?: T;
|
||||
marketing?: T;
|
||||
};
|
||||
iaplTtlFrom?: T;
|
||||
updatedAt?: T;
|
||||
createdAt?: T;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,8 @@ export default buildConfig({
|
||||
// @starter:else
|
||||
//: forms: { redirectRelationships: ['pages'], emailLayout: true }, // files on forms: add `attachments: true` (forms.md "Files")
|
||||
// @starter:endif
|
||||
// Media → above the list: files no page, entry or setting uses, with a link to review and delete them by hand
|
||||
unusedMedia: true,
|
||||
// @starter:if twoFactor
|
||||
twoFactor: { issuer: 'Example Studio', plugin: payloadTotp },
|
||||
// @starter:else
|
||||
|
||||
Reference in New Issue
Block a user