프로필 배포가 고정한 전체 커밋 SHA를 프론트 빌드와 Turbo 캐시 입력에 전달한다. 게임 정보 대화상자와 데스크톱·모바일 Chromium 검증을 함께 보강한다.
57 lines
2.2 KiB
TypeScript
57 lines
2.2 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())
|
|
);
|
|
} finally {
|
|
if (previousCommitSha === undefined) delete process.env.VITE_BUILD_COMMIT_SHA;
|
|
else process.env.VITE_BUILD_COMMIT_SHA = previousCommitSha;
|
|
}
|
|
});
|
|
});
|