Files
core2026/app/game-frontend/test/viteConfig.test.ts
T
Hide_D 5549f0c1e8 feat: profile 새 버전 안내 toast를 추가한다
배포 bundle과 같은 commit의 정적 버전 문서를 생성하고, 열린 탭이 DB mutation 없이 변경을 감지하도록 한다. 동일 버전은 tab session에서 한 번만 안내하며 강제 새로고침은 하지 않는다.
2026-08-22 05:11:50 +00:00

68 lines
2.6 KiB
TypeScript

import assert from 'node:assert/strict';
import path from 'node:path';
import { describe, it } from 'node:test';
import { loadConfigFromFile } from 'vite';
import { mergeViteEnv } from '../src/config/viteEnv.ts';
void describe('game frontend Vite config', () => {
void it('prefers managed runtime values over values loaded from env files', () => {
const env = mergeViteEnv(
{ VITE_APP_BASE_PATH: '/gateway', VITE_GAME_API_URL: '/gateway/api/trpc' },
{ VITE_APP_BASE_PATH: '/hwe', VITE_GAME_API_URL: '/hwe/api/trpc' }
);
assert.equal(env.VITE_APP_BASE_PATH, '/hwe');
assert.equal(env.VITE_GAME_API_URL, '/hwe/api/trpc');
});
void it('keeps production source maps enabled', async () => {
const configPath = path.resolve(import.meta.dirname, '../vite.config.ts');
const loaded = await loadConfigFromFile(
{ command: 'build', mode: 'production' },
configPath,
path.dirname(configPath),
undefined,
undefined,
'runner'
);
assert.equal(loaded?.config.build?.sourcemap, true);
});
void it('uses the deployment-pinned full commit SHA as the displayed build version', async () => {
const commitSha = 'ABCDEF0123456789ABCDEF0123456789ABCDEF01';
const previousCommitSha = process.env.VITE_BUILD_COMMIT_SHA;
process.env.VITE_BUILD_COMMIT_SHA = commitSha;
try {
const configPath = path.resolve(import.meta.dirname, '../vite.config.ts');
const loaded = await loadConfigFromFile(
{ command: 'build', mode: 'production' },
configPath,
path.dirname(configPath),
undefined,
undefined,
'runner'
);
assert.equal(
loaded?.config.define?.['import.meta.env.VITE_BUILD_COMMIT_SHA'],
JSON.stringify(commitSha.toLowerCase())
);
assert.equal(
loaded?.config.plugins?.some(
(plugin) =>
plugin !== null &&
typeof plugin === 'object' &&
!Array.isArray(plugin) &&
'name' in plugin &&
plugin.name === 'sammo-deployment-version'
),
true
);
} finally {
if (previousCommitSha === undefined) delete process.env.VITE_BUILD_COMMIT_SHA;
else process.env.VITE_BUILD_COMMIT_SHA = previousCommitSha;
}
});
});