import assert from 'node:assert/strict'
|
import { readFile } from 'node:fs/promises'
|
import path from 'node:path'
|
import test from 'node:test'
|
|
const projectRoot = path.resolve(import.meta.dirname, '..')
|
|
async function readProjectFile(relativePath) {
|
return readFile(path.join(projectRoot, relativePath), 'utf8')
|
}
|
|
test('development env routes API requests through the rsf-server context path', async () => {
|
const envContent = await readProjectFile('.env.development')
|
|
assert.match(envContent, /VITE_API_URL\s*=\s*\/rsf-server\b/)
|
assert.match(envContent, /VITE_API_PROXY_URL\s*=\s*http:\/\/127\.0\.0\.1:8085\b/)
|
})
|
|
test('production env keeps the rsf-server context path as the API base', async () => {
|
const envContent = await readProjectFile('.env.production')
|
|
assert.match(envContent, /VITE_API_URL\s*=\s*\/rsf-server\b/)
|
})
|
|
test('vite dev server proxies the rsf-server context path to the backend target', async () => {
|
const viteConfig = await readProjectFile('vite.config.js')
|
|
assert.match(viteConfig, /'\/rsf-server'\s*:\s*\{/)
|
assert.match(viteConfig, /target:\s*VITE_API_PROXY_URL/)
|
})
|