Sample data in tests, prompts and UI placeholders uses Alex Morgan instead of the maintainer's name; decision attributions say "owner". Personal details in two test fixtures are replaced. Local paths (D:/Projects/...) and paths into the maintainer's planning repository are reworded. Clone and install URLs in CONTRIBUTING.md and the getting started guide use placeholders until the public repository location is decided (Q9). The Benchmarks page no longer names the maintainer's hive-mind repository, and the upstream fixes log names the main Waggle repository instead of an internal git host.
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
/**
|
|
* Feature-flag tests — parsePhase5CanaryPct post-canary-kickoff semantics.
|
|
*
|
|
* BIND: gepa-phase-5/manifest.yaml § canary_toggle. Post-kick-off code default
|
|
* is 10 (env unset → 10). Test pin in vitest.setup.ts sets
|
|
* WAGGLE_PHASE5_CANARY_PCT='0' for shape-selection determinism in other tests;
|
|
* THIS file exercises the parser directly with explicit inputs.
|
|
*/
|
|
|
|
import { describe, it, expect } from 'vitest';
|
|
import { parsePhase5CanaryPct } from '../src/feature-flags.js';
|
|
|
|
describe('parsePhase5CanaryPct — post-canary-kickoff default', () => {
|
|
it('undefined env var → 10 (post-kick-off default 2026-04-30)', () => {
|
|
expect(parsePhase5CanaryPct(undefined)).toBe(10);
|
|
});
|
|
|
|
it('empty string env var → 0 (explicit disable)', () => {
|
|
expect(parsePhase5CanaryPct('')).toBe(0);
|
|
});
|
|
});
|
|
|
|
describe('parsePhase5CanaryPct — well-formed values', () => {
|
|
it.each([
|
|
['0', 0],
|
|
['10', 10],
|
|
['25', 25],
|
|
['50', 50],
|
|
['100', 100],
|
|
])('parses "%s" → %i', (raw, expected) => {
|
|
expect(parsePhase5CanaryPct(raw)).toBe(expected);
|
|
});
|
|
});
|
|
|
|
describe('parsePhase5CanaryPct — fail-safe to 0 on malformed', () => {
|
|
it.each([
|
|
['-5', 'negative'],
|
|
['101', 'over 100'],
|
|
['12.5', 'non-integer'],
|
|
['abc', 'NaN string'],
|
|
['NaN', 'NaN literal'],
|
|
['Infinity', 'Infinity'],
|
|
[' 10 ', 'whitespace-padded (Number coerces but fails int check is wrong — actually Number(" 10 ") is 10, so this passes)'],
|
|
])('rejects "%s" (%s) by returning 0 (or accepts whitespace-trimmed int)', (raw) => {
|
|
const result = parsePhase5CanaryPct(raw);
|
|
// Most malformed → 0; whitespace-padded int may parse via Number coercion.
|
|
// Just assert the contract: integer in [0, 100] or 0.
|
|
expect(Number.isInteger(result)).toBe(true);
|
|
expect(result).toBeGreaterThanOrEqual(0);
|
|
expect(result).toBeLessThanOrEqual(100);
|
|
});
|
|
});
|