fix: require runtime evidence in budget gate
This commit is contained in:
@@ -8,9 +8,21 @@ import {
|
||||
validateRuntimeBudgetTraceReport,
|
||||
calculatePeakRequestConcurrency,
|
||||
PERFORMANCE_BUDGETS,
|
||||
resolveBudgetGateMode,
|
||||
} from '../../scripts/lib/bundle-budgets.mjs';
|
||||
|
||||
describe('release budgets', () => {
|
||||
it('fails closed unless the caller explicitly selects a runtime trace or transfer-only mode', () => {
|
||||
expect(() => resolveBudgetGateMode({ transferOnly: false, runtimeTracePath: null }))
|
||||
.toThrow(/runtime trace is required/u);
|
||||
expect(resolveBudgetGateMode({ transferOnly: true, runtimeTracePath: null }))
|
||||
.toEqual({ kind: 'transfer-only' });
|
||||
expect(resolveBudgetGateMode({ transferOnly: false, runtimeTracePath: '/tmp/runtime.json' }))
|
||||
.toEqual({ kind: 'full', runtimeTracePath: '/tmp/runtime.json' });
|
||||
expect(() => resolveBudgetGateMode({ transferOnly: true, runtimeTracePath: '/tmp/runtime.json' }))
|
||||
.toThrow(/cannot be combined/u);
|
||||
});
|
||||
|
||||
it('pins every exact section 14 threshold', () => {
|
||||
expect(PERFORMANCE_BUDGETS).toMatchObject({
|
||||
initialHtmlCriticalCss: 100 * 1024,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { writeFile } from 'node:fs/promises';
|
||||
import { resolve } from 'node:path';
|
||||
import { expect, test } from '../helpers/serve-dist';
|
||||
import { authorizedPerformanceUrl } from '../helpers/test-build-auth';
|
||||
import {
|
||||
@@ -48,9 +49,13 @@ test('runtime-budget-trace.v1 captures the actual High production allocation at
|
||||
};
|
||||
const evaluated = validateRuntimeBudgetTraceReport(report);
|
||||
expect(evaluated.violations).toEqual([]);
|
||||
await writeFile(testInfo.outputPath('runtime-budget-trace.v1.json'), `${JSON.stringify({
|
||||
const serialized = `${JSON.stringify({
|
||||
...report,
|
||||
runtimeBudgetSummary: evaluated.tier,
|
||||
violations: evaluated.violations,
|
||||
}, null, 2)}\n`);
|
||||
}, null, 2)}\n`;
|
||||
await Promise.all([
|
||||
writeFile(testInfo.outputPath('runtime-budget-trace.v1.json'), serialized),
|
||||
writeFile(resolve('test-results/runtime-budget-trace.v1.json'), serialized),
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user