import { describe, expect, it } from 'vitest' import { MAX_UPLOAD_BYTES } from '@/entities/file' import nextConfig from '../next.config' // The upload form posts to a server action, whose body Next caps at 1 MB unless // configured (next.config `experimental.serverActions.bodySizeLimit`). The cap must // admit the largest attachment the app accepts, plus multipart overhead. function parseLimit(limit: string | number | undefined): number | undefined { if (typeof limit === 'number') return limit const match = /^(\d+)mb$/.exec(limit ?? '') return match ? Number(match[1]) * 1024 * 1024 : undefined } describe('next.config server action body limit', () => { it('admits the largest attachment the app accepts', () => { const limit = parseLimit(nextConfig.experimental?.serverActions?.bodySizeLimit) expect(limit).toBeGreaterThanOrEqual(MAX_UPLOAD_BYTES) }) })