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]>
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import { afterEach, describe, expect, test, vi } from 'vitest'
|
|
|
|
import { assertEnv } from '../src/modules/env/assertEnv.js'
|
|
import { ipalEnvRules } from '../src/modules/env/ipalEnvRules.js'
|
|
|
|
const base = { DATABASE_URI: 'mongodb://db/x', NEXT_PUBLIC_SERVER_URL: 'http://localhost:3000', PAYLOAD_SECRET: 's' }
|
|
const r2 = {
|
|
R2_ACCESS_KEY_ID: 'k',
|
|
R2_BUCKET: 'b',
|
|
R2_ENDPOINT: 'https://acc.r2.cloudflarestorage.com',
|
|
R2_PUBLIC_URL: 'https://media.acme.pl',
|
|
R2_SECRET_ACCESS_KEY: 's',
|
|
}
|
|
|
|
function check(env: Record<string, string>) {
|
|
vi.unstubAllEnvs()
|
|
for (const [k, v] of Object.entries(env)) {vi.stubEnv(k, v)}
|
|
return () => assertEnv(ipalEnvRules({ storage: true }), { env })
|
|
}
|
|
|
|
afterEach(() => vi.unstubAllEnvs())
|
|
|
|
describe('ipalEnvRules({ storage })', () => {
|
|
test('production: every R2_* is required', () => {
|
|
expect(check({ ...base, NODE_ENV: 'production' })).toThrow(/R2_BUCKET is required/)
|
|
expect(check({ ...base, ...r2, NODE_ENV: 'production' })).not.toThrow()
|
|
})
|
|
|
|
test('development: no R2 at all is fine (local disk)', () => {
|
|
expect(check({ ...base, NODE_ENV: 'development' })).not.toThrow()
|
|
})
|
|
|
|
test('development: R2_PUBLIC_URL alone is the read-only media mode', () => {
|
|
expect(check({ ...base, NODE_ENV: 'development', R2_PUBLIC_URL: 'https://media.acme.pl' })).not.toThrow()
|
|
})
|
|
|
|
test('development: a partial R2 set is an error (all or nothing)', () => {
|
|
expect(check({ ...base, NODE_ENV: 'development', R2_BUCKET: 'b' })).toThrow(/R2_ACCESS_KEY_ID is required/)
|
|
})
|
|
})
|