Files
KoalaSync/scripts/release-local-gate.test.mjs
T
2026-08-25 02:26:13 +02:00

42 lines
1.8 KiB
JavaScript

import { describe, expect, it } from 'vitest';
import {
linuxGateCommand,
parseGateArgs,
parseRemoteMain,
playwrightImageFromLock
} from './release-local-gate.mjs';
describe('local release gate contract', () => {
it('requires one exact version and makes candidate mode explicit', () => {
expect(parseGateArgs(['3.1.5'])).toEqual({ version: '3.1.5', candidate: false });
expect(parseGateArgs(['3.1.5', '--candidate'])).toEqual({ version: '3.1.5', candidate: true });
expect(() => parseGateArgs([])).toThrow('Usage: npm run release:gate');
expect(() => parseGateArgs(['3.1'])).toThrow('Release tag must match vMAJOR.MINOR.PATCH');
});
it('derives an exact official Playwright Linux image from the lockfile', () => {
expect(playwrightImageFromLock({
packages: { 'node_modules/@playwright/test': { version: '1.62.0' } }
})).toBe('mcr.microsoft.com/playwright:v1.62.0-noble');
expect(() => playwrightImageFromLock({ packages: {} })).toThrow('must pin');
});
it('extracts main only from the exact remote branch record', () => {
const sha = '0123456789abcdef0123456789abcdef01234567';
expect(parseRemoteMain(`${sha}\trefs/heads/main\n`)).toBe(sha);
expect(() => parseRemoteMain('')).toThrow('could not resolve origin main');
expect(() => parseRemoteMain(`${sha}\trefs/heads/not-main`)).toThrow('could not resolve origin main');
});
it('runs the complete CI-equivalent dependency, verify, and browser sequence', () => {
expect(linuxGateCommand()).toBe([
'git clone --no-local /src /work',
'cd /work',
'npm ci',
'npm ci --prefix server',
'npm run verify',
'npm run test:e2e'
].join(' && '));
});
});