buildR2Storage registered nothing without R2_* env, so `pnpm dev` / generate:importmap in dev
wrote an importMap.js without S3ClientUploadHandler — committed, the production admin (R2 on)
rendered a blank page with no console error (hit vanstev.pl). The injected s3Storage is now
always registered (enabled: false without R2 → local disk); storage-s3 still adds its client
handler, so the import map is identical in every environment. ipal-audit flags an import map
without the handler.
R2_PUBLIC_URL alone (absolute, outside production) = read-only media: URLs from the media
domain, upload/delete refused with 403 — local dev against a production database without
bucket keys. ipalEnvRules allows it in development.
Cookie Settings (MongoDB): the 1.11.1 rename buttons.save → savePreferences lost the texts on
the first save; onInit copies the old value (all locales) when the new field is missing.
getConsentTexts read the old field as a string, Mongo returns the raw { pl, en } map.
Also: context.ipalSkipAutoFill (SKIP_AUTO_FILL) — save without meta / aiSummary auto-fill;
createPageRoute redirects the homepage under its own slug (homeAlias, default 'redirect');
ipal-audit: multi-line tsconfig exclude, numeronyms (a11y) not "numbered fields",
`${prefix}/${slug}` links and slugs typed into links detected, clearer panel-language message.
Docs: fallback-on-save in i18n.md, `pnpm up --latest` and the stale-token 401 in PROGRAMISTA §1.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
37 lines
1.7 KiB
TypeScript
37 lines
1.7 KiB
TypeScript
import { describe, expect, test, vi } from 'vitest'
|
|
|
|
import { createPageRoute } from '../src/modules/frontend/pageRoute.js'
|
|
|
|
const thrower = (code: string) => vi.fn((url?: string) => { throw new Error(`${code}${url ? ` ${url}` : ''}`) }) as unknown as (url?: string) => never
|
|
|
|
const helpers = (locales = ['pl', 'en']) =>
|
|
({
|
|
getHomeSlug: vi.fn(async () => 'home'),
|
|
getPageJsonLd: vi.fn(async () => []),
|
|
getSystemLinks: vi.fn(async (locale: string) => [{ href: `/${locale}`, role: 'homepage' }]),
|
|
i18n: { defaultLocale: 'pl', locales: locales.map((code) => ({ code })) },
|
|
resolvePageRedirect: vi.fn(async () => null),
|
|
resolveRoute: vi.fn(async (_locale: string, segments: string[]) => ({
|
|
type: segments.length ? 'page' : 'home',
|
|
doc: { id: segments.length ? 'p1' : 'home', layout: [] },
|
|
})),
|
|
}) as never
|
|
|
|
const page = (segments: string[], locale = 'pl') => ({ params: Promise.resolve({ slug: segments, locale }) })
|
|
const opts = { blocks: {}, notFound: thrower('NOT_FOUND'), permanentRedirect: thrower('308') }
|
|
|
|
describe('createPageRoute homeAlias (1.12.2)', () => {
|
|
test('/pl/home → 308 /pl', async () => {
|
|
await expect(createPageRoute(helpers(), opts).Page(page(['home']))).rejects.toThrow('308 /pl')
|
|
})
|
|
|
|
test('the root and other pages render', async () => {
|
|
await expect(createPageRoute(helpers(), opts).Page(page([]))).resolves.toBeTruthy()
|
|
await expect(createPageRoute(helpers(), opts).Page(page(['kontakt']))).resolves.toBeTruthy()
|
|
})
|
|
|
|
test('homeAlias: false renders the alias', async () => {
|
|
await expect(createPageRoute(helpers(), { ...opts, homeAlias: false }).Page(page(['home']))).resolves.toBeTruthy()
|
|
})
|
|
})
|