mirror of
https://github.com/nexu-io/open-design.git
synced 2026-06-01 03:14:35 +07:00
* fix(web): keep Vercel static builds writing to out (#1628) Generated-By: looper 0.9.1 (runner=worker, agent=opencode) * fix(web): preserve explicit dist dir overrides Generated-By: looper 0.9.1 (runner=fixer, agent=opencode) * fix(web): preserve explicit dist dir overrides Generated-By: looper 0.9.1 (runner=fixer, agent=opencode)
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { dirname, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
import * as spaShellRoute from '../../app/[[...slug]]/page';
|
|
|
|
const WEB_ROOT = dirname(fileURLToPath(new URL('../../..', import.meta.url)));
|
|
|
|
async function loadNextConfig() {
|
|
vi.resetModules();
|
|
return (await import('../../next.config')).default;
|
|
}
|
|
|
|
afterEach(() => {
|
|
delete process.env.OD_WEB_DIST_DIR;
|
|
vi.resetModules();
|
|
});
|
|
|
|
describe('SPA shell export route', () => {
|
|
it('stays compatible with static export builds', async () => {
|
|
const nextConfig = await loadNextConfig();
|
|
expect(nextConfig.output).toBe('export');
|
|
expect(nextConfig.distDir).toBeUndefined();
|
|
expect('dynamicParams' in spaShellRoute).toBe(false);
|
|
expect(spaShellRoute.generateStaticParams()).toEqual([{ slug: [] }]);
|
|
});
|
|
|
|
it('keeps an explicit dist dir override even when static export is selected', async () => {
|
|
const configuredDistDir = resolve(WEB_ROOT, '.tmp', 'vitest-next');
|
|
process.env.OD_WEB_DIST_DIR = configuredDistDir;
|
|
|
|
const nextConfig = await loadNextConfig();
|
|
|
|
expect(nextConfig.output).toBe('export');
|
|
expect(nextConfig.distDir).toContain('vitest-next');
|
|
});
|
|
|
|
it('treats an empty dist dir override as unset for static export builds', async () => {
|
|
process.env.OD_WEB_DIST_DIR = '';
|
|
|
|
const nextConfig = await loadNextConfig();
|
|
|
|
expect(nextConfig.output).toBe('export');
|
|
expect(nextConfig.distDir).toBeUndefined();
|
|
});
|
|
});
|