-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponents-new-gates.test.mts
More file actions
47 lines (41 loc) · 2.13 KB
/
Copy pathcomponents-new-gates.test.mts
File metadata and controls
47 lines (41 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* The gate registry after promoting `qavis-advisory` to recommended, plus `newBundledGates` — the
* pure reconcile helper `upgrade` uses to detect gates a recorded selection predates (the fix for
* `devkit upgrade` silently dropping a newly-bundled gate).
*/
import { describe, expect, it } from 'vitest';
import { GUARD_IDS, newBundledGates, RECOMMENDED_GUARD_IDS } from '../lib/components.mts';
describe('gate registry', () => {
it('qavis-advisory is recommended and GUARD_IDS carries it exactly once', () => {
expect(RECOMMENDED_GUARD_IDS).toContain('qavis-advisory');
expect(GUARD_IDS.filter((g) => g === 'qavis-advisory')).toHaveLength(1);
expect(new Set(GUARD_IDS).size).toBe(GUARD_IDS.length); // no duplicates
expect(GUARD_IDS).toContain('review'); // opt-in
});
it('sentry is offerable but NOT recommended (needs a Sentry-using product)', () => {
expect(GUARD_IDS).toContain('sentry');
expect(RECOMMENDED_GUARD_IDS).not.toContain('sentry');
});
it('coverage is offerable but NOT recommended (needs a test:run:coverage provider)', () => {
expect(GUARD_IDS).toContain('coverage');
expect(RECOMMENDED_GUARD_IDS).not.toContain('coverage');
});
});
describe('newBundledGates', () => {
it('splits gates missing from a recorded selection into recommended vs opt-in', () => {
const recorded = ['size', 'fanout', 'dup', 'clone', 'decisions']; // a pre-qavis selection
const { recommended, optIn } = newBundledGates(recorded);
expect(recommended).toEqual(['qavis-advisory']); // newly recommended, absent
expect(optIn).toEqual(['review', 'sentry', 'coverage']); // bundled but never selected
});
it('returns empty buckets when the recorded set already has every bundled gate', () => {
const { recommended, optIn } = newBundledGates([...GUARD_IDS]);
expect(recommended).toEqual([]);
expect(optIn).toEqual([]);
});
it('a fully-recommended selection leaves only the opt-in gates outstanding', () => {
const { recommended, optIn } = newBundledGates([...RECOMMENDED_GUARD_IDS]);
expect(recommended).toEqual([]);
expect(optIn).toEqual(['review', 'sentry', 'coverage']);
});
});