feat(deploy): 接入全自动生产发布校验
This commit is contained in:
34
apps/web/lib/runtime-version.test.ts
Normal file
34
apps/web/lib/runtime-version.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import test from 'node:test';
|
||||
import { getClientRuntimeVersion, shouldPromptForNewRuntimeVersion } from './runtime-version';
|
||||
|
||||
test('getClientRuntimeVersion reads web build metadata from public environment variables', () => {
|
||||
const result = getClientRuntimeVersion({
|
||||
NEXT_PUBLIC_APP_VERSION: 'commit-789',
|
||||
NEXT_PUBLIC_APP_BUILD_TIME: '2026-07-06T15:00:00.000Z',
|
||||
});
|
||||
|
||||
assert.deepEqual(result, {
|
||||
service: 'web',
|
||||
version: 'commit-789',
|
||||
buildTime: '2026-07-06T15:00:00.000Z',
|
||||
});
|
||||
});
|
||||
|
||||
test('getClientRuntimeVersion uses stable fallback values without build metadata', () => {
|
||||
const result = getClientRuntimeVersion({});
|
||||
|
||||
assert.deepEqual(result, {
|
||||
service: 'web',
|
||||
version: 'unknown',
|
||||
buildTime: '',
|
||||
});
|
||||
});
|
||||
|
||||
test('shouldPromptForNewRuntimeVersion only prompts when both versions are known and different', () => {
|
||||
assert.equal(shouldPromptForNewRuntimeVersion('commit-a', 'commit-b'), true);
|
||||
assert.equal(shouldPromptForNewRuntimeVersion('commit-a', 'commit-a'), false);
|
||||
assert.equal(shouldPromptForNewRuntimeVersion('unknown', 'commit-b'), false);
|
||||
assert.equal(shouldPromptForNewRuntimeVersion('commit-a', 'unknown'), false);
|
||||
assert.equal(shouldPromptForNewRuntimeVersion('', 'commit-b'), false);
|
||||
});
|
||||
Reference in New Issue
Block a user