volleyballsimtypes 0.0.485 → 0.0.486
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -23,12 +23,17 @@ function fatigueCondition(band) {
|
|
|
23
23
|
function convertLegacySetSubConfig(raw) {
|
|
24
24
|
if (!isRecord(raw))
|
|
25
25
|
return raw;
|
|
26
|
-
// Derive the mode for the oldest (pre-mode) generation; a unified shape has none of these keys.
|
|
26
|
+
// Derive the mode for the oldest (pre-mode) generation; a unified shape has none of these keys. Test the
|
|
27
|
+
// isPinchServer VALUE, not key presence: the sim read path (transformToObject) spreads `isPinchServer:
|
|
28
|
+
// d.isPinchServer` onto every row, so a unified row carries an `isPinchServer: undefined` key. `'isPinchServer'
|
|
29
|
+
// in raw` would then misread that unified row as a legacy FATIGUE sub and overwrite its real conditions /
|
|
30
|
+
// pinchServer flag. A genuine legacy isPinchServer-era row always has a boolean flag (true handled above), so
|
|
31
|
+
// the only remaining legacy case is an explicit `=== false`.
|
|
27
32
|
const mode = raw.mode ?? (raw.isPinchServer === true
|
|
28
33
|
? 'PINCH'
|
|
29
34
|
: raw.fatigueBand === 'NEVER'
|
|
30
35
|
? 'NEVER'
|
|
31
|
-
: raw.fatigueBand != null ||
|
|
36
|
+
: raw.fatigueBand != null || raw.isPinchServer === false ? 'FATIGUE' : null);
|
|
32
37
|
if (mode == null)
|
|
33
38
|
return raw;
|
|
34
39
|
const { mode: _m, fatigueBand, isPinchServer: _p, ...rest } = raw;
|
|
@@ -12,6 +12,25 @@ const sub_config_convert_1 = require("./sub-config-convert");
|
|
|
12
12
|
const unified = { bench: 'X', conditions: [{ type: pinch_condition_1.PinchConditionType.ASAP }], pinchServer: true };
|
|
13
13
|
(0, globals_1.expect)((0, sub_config_convert_1.convertLegacySetSubConfig)(unified)).toBe(unified);
|
|
14
14
|
});
|
|
15
|
+
(0, globals_1.it)('keeps a unified pinch server intact when a caller injects isPinchServer: undefined (sim read path)', () => {
|
|
16
|
+
// The sim read path (transformToObject) spreads `isPinchServer: d.isPinchServer` onto every row, so a
|
|
17
|
+
// unified row arrives carrying an `isPinchServer: undefined` key. Detecting the legacy shape by key
|
|
18
|
+
// PRESENCE misread it as a FATIGUE sub and wiped its real conditions + pinchServer flag; the value check
|
|
19
|
+
// (=== false) keeps the unified shape. Regression for the "pinch server never serves" prod bug.
|
|
20
|
+
const out = (0, sub_config_convert_1.convertLegacySetSubConfig)({
|
|
21
|
+
bench: 'X',
|
|
22
|
+
conditions: [{ type: pinch_condition_1.PinchConditionType.AFTER_ROTATIONS, rotations: 1 }],
|
|
23
|
+
conditionLogic: 'ANY',
|
|
24
|
+
pinchServer: true,
|
|
25
|
+
subBackMode: 'FATIGUE',
|
|
26
|
+
isPinchServer: undefined,
|
|
27
|
+
mode: undefined,
|
|
28
|
+
fatigueBand: undefined
|
|
29
|
+
});
|
|
30
|
+
(0, globals_1.expect)(out.pinchServer).toBe(true);
|
|
31
|
+
(0, globals_1.expect)(out.conditions).toEqual([{ type: pinch_condition_1.PinchConditionType.AFTER_ROTATIONS, rotations: 1 }]);
|
|
32
|
+
(0, globals_1.expect)(out.conditionLogic).toBe('ANY');
|
|
33
|
+
});
|
|
15
34
|
(0, globals_1.it)('converts mode NEVER to an explicit empty condition list, dropping every other field', () => {
|
|
16
35
|
(0, globals_1.expect)((0, sub_config_convert_1.convertLegacySetSubConfig)({ mode: 'NEVER', bench: 'X' })).toEqual({ conditions: [] });
|
|
17
36
|
});
|
|
@@ -17,12 +17,17 @@ function fatigueCondition(band) {
|
|
|
17
17
|
export function convertLegacySetSubConfig(raw) {
|
|
18
18
|
if (!isRecord(raw))
|
|
19
19
|
return raw;
|
|
20
|
-
// Derive the mode for the oldest (pre-mode) generation; a unified shape has none of these keys.
|
|
20
|
+
// Derive the mode for the oldest (pre-mode) generation; a unified shape has none of these keys. Test the
|
|
21
|
+
// isPinchServer VALUE, not key presence: the sim read path (transformToObject) spreads `isPinchServer:
|
|
22
|
+
// d.isPinchServer` onto every row, so a unified row carries an `isPinchServer: undefined` key. `'isPinchServer'
|
|
23
|
+
// in raw` would then misread that unified row as a legacy FATIGUE sub and overwrite its real conditions /
|
|
24
|
+
// pinchServer flag. A genuine legacy isPinchServer-era row always has a boolean flag (true handled above), so
|
|
25
|
+
// the only remaining legacy case is an explicit `=== false`.
|
|
21
26
|
const mode = raw.mode ?? (raw.isPinchServer === true
|
|
22
27
|
? 'PINCH'
|
|
23
28
|
: raw.fatigueBand === 'NEVER'
|
|
24
29
|
? 'NEVER'
|
|
25
|
-
: raw.fatigueBand != null ||
|
|
30
|
+
: raw.fatigueBand != null || raw.isPinchServer === false ? 'FATIGUE' : null);
|
|
26
31
|
if (mode == null)
|
|
27
32
|
return raw;
|
|
28
33
|
const { mode: _m, fatigueBand, isPinchServer: _p, ...rest } = raw;
|
|
@@ -10,6 +10,25 @@ describe('convertLegacySetSubConfig', () => {
|
|
|
10
10
|
const unified = { bench: 'X', conditions: [{ type: PinchConditionType.ASAP }], pinchServer: true };
|
|
11
11
|
expect(convertLegacySetSubConfig(unified)).toBe(unified);
|
|
12
12
|
});
|
|
13
|
+
it('keeps a unified pinch server intact when a caller injects isPinchServer: undefined (sim read path)', () => {
|
|
14
|
+
// The sim read path (transformToObject) spreads `isPinchServer: d.isPinchServer` onto every row, so a
|
|
15
|
+
// unified row arrives carrying an `isPinchServer: undefined` key. Detecting the legacy shape by key
|
|
16
|
+
// PRESENCE misread it as a FATIGUE sub and wiped its real conditions + pinchServer flag; the value check
|
|
17
|
+
// (=== false) keeps the unified shape. Regression for the "pinch server never serves" prod bug.
|
|
18
|
+
const out = convertLegacySetSubConfig({
|
|
19
|
+
bench: 'X',
|
|
20
|
+
conditions: [{ type: PinchConditionType.AFTER_ROTATIONS, rotations: 1 }],
|
|
21
|
+
conditionLogic: 'ANY',
|
|
22
|
+
pinchServer: true,
|
|
23
|
+
subBackMode: 'FATIGUE',
|
|
24
|
+
isPinchServer: undefined,
|
|
25
|
+
mode: undefined,
|
|
26
|
+
fatigueBand: undefined
|
|
27
|
+
});
|
|
28
|
+
expect(out.pinchServer).toBe(true);
|
|
29
|
+
expect(out.conditions).toEqual([{ type: PinchConditionType.AFTER_ROTATIONS, rotations: 1 }]);
|
|
30
|
+
expect(out.conditionLogic).toBe('ANY');
|
|
31
|
+
});
|
|
13
32
|
it('converts mode NEVER to an explicit empty condition list, dropping every other field', () => {
|
|
14
33
|
expect(convertLegacySetSubConfig({ mode: 'NEVER', bench: 'X' })).toEqual({ conditions: [] });
|
|
15
34
|
});
|