Use one instance count for all beta games
This commit is contained in:
@@ -15,15 +15,26 @@ describe('beta draft and plan recovery', () => {
|
||||
expect(readBetaDraft('{bad')).toBeNull();
|
||||
expect(readBetaDraft(JSON.stringify({ version: 1, picks: [{ scriptId: '12', versionId: 45 }] }))).toBeNull();
|
||||
});
|
||||
it('restores automatic selection and incomplete counts without substituting manual selections', () => {
|
||||
it('restores the shared count and incomplete input without substituting manual selections', () => {
|
||||
const raw = { version: 1, savedAt: '', step: 1, picks: [{ scriptId: 12, versionId: 45 }],
|
||||
servers: ['previous-manual-choice'], selectionMode: 'automatic', instancesPerGame: { t5: 2, t6: null }, testPlan: defaultPlan() };
|
||||
expect(readBetaDraft(JSON.stringify(raw))).toMatchObject({ selectionMode: 'automatic', instancesPerGame: { t5: 2, t6: null } });
|
||||
expect(readBetaDraft(JSON.stringify({ ...raw, instancesPerGame: { t5: 1.5, t6: -1 } }))?.instancesPerGame).toEqual({ t5: 1.5, t6: -1 });
|
||||
expect(readBetaDraft(JSON.stringify({ ...raw, instancesPerGame: { t5: '2' } }))).toBeNull();
|
||||
expect(readBetaDraft(JSON.stringify({ ...raw, instancesPerGame: { unknown: 2 } }))).toBeNull();
|
||||
servers: ['previous-manual-choice'], selectionMode: 'automatic', instanceCount: 2, testPlan: defaultPlan() };
|
||||
expect(readBetaDraft(JSON.stringify(raw))).toMatchObject({ selectionMode: 'automatic', instanceCount: 2 });
|
||||
for (const instanceCount of [null, 1.5, -1]) {
|
||||
expect(readBetaDraft(JSON.stringify({ ...raw, instanceCount }))?.instanceCount).toBe(instanceCount);
|
||||
}
|
||||
expect(readBetaDraft(JSON.stringify({ ...raw, instanceCount: '2' }))).toBeNull();
|
||||
expect(readBetaDraft(JSON.stringify({ ...raw, selectionMode: 'unknown' }))).toBeNull();
|
||||
});
|
||||
it('migrates per-game drafts without reducing coverage and revisits unequal counts', () => {
|
||||
const raw = { version: 1, savedAt: '', step: 3, picks: [{ scriptId: 12, versionId: 45 }],
|
||||
servers: [], selectionMode: 'automatic', instancesPerGame: { t5: 2, t6: 3 }, testPlan: defaultPlan() };
|
||||
expect(readBetaDraft(JSON.stringify(raw))).toMatchObject({ instanceCount: 3, step: 1 });
|
||||
expect(readBetaDraft(JSON.stringify({ ...raw, instancesPerGame: { t5: 2, t6: 2 } }))).toMatchObject({ instanceCount: 2, step: 3 });
|
||||
expect(readBetaDraft(JSON.stringify({ ...raw, instancesPerGame: { t5: 2, t6: null } }))?.instanceCount).toBeNull();
|
||||
expect(readBetaDraft(JSON.stringify({ ...raw, instancesPerGame: {} }))?.instanceCount).toBe(1);
|
||||
expect(readBetaDraft(JSON.stringify({ ...raw, selectionMode: 'manual' }))?.step).toBe(3);
|
||||
expect(readBetaDraft(JSON.stringify({ ...raw, instancesPerGame: { t5: '2' } }))).toBeNull();
|
||||
});
|
||||
it('defaults a legacy draft with no server choices to automatic selection', () => {
|
||||
expect(readBetaDraft(JSON.stringify({ version: 1, picks: [{ scriptId: 12, versionId: 45 }], servers: [], testPlan: defaultPlan() }))?.selectionMode).toBe('automatic');
|
||||
});
|
||||
@@ -56,12 +67,13 @@ describe('multi-game beta setup', () => {
|
||||
expect(betaCandidateServers([], servers)).toEqual([]);
|
||||
expect(betaApplicableGames([], servers)).toEqual([]);
|
||||
});
|
||||
it('keeps explicitly scoped games visible without fleet matches and preserves zero or incomplete counts', () => {
|
||||
it('uses the shared count for every applicable game, including games without fleet matches', () => {
|
||||
const files = [{ scope_type: 'game' as const, scope_value: 't5' }, { scope_type: 'game' as const, scope_value: 't6' }];
|
||||
expect(betaApplicableGames(files, [])).toEqual(['t5', 't6']);
|
||||
expect(betaInstanceCounts(['t5', 't6'], {})).toEqual({ t5: 1, t6: 1 });
|
||||
expect(betaInstanceCounts(['t5', 't6'], { t5: 0, t6: null })).toEqual({ t5: 0, t6: null });
|
||||
expect(betaInstanceCounts(['t6'], { t5: 3, t6: 2 })).toEqual({ t6: 2 });
|
||||
expect(betaInstanceCounts(betaApplicableGames(files, []), 2)).toEqual({ t5: 2, t6: 2 });
|
||||
expect(betaInstanceCounts(betaApplicableGames([files[1]], servers), 3)).toEqual({ t6: 3 });
|
||||
for (const count of [null, 0, -1, 1.5, 1001]) expect(betaInstanceCounts(['t5', 't6'], count)).toEqual({});
|
||||
expect(betaInstanceCounts([], 2)).toEqual({});
|
||||
});
|
||||
});
|
||||
describe('beta evidence explanations', () => {
|
||||
|
||||
Reference in New Issue
Block a user