Skip to content

Commit d32c01e

Browse files
committed
Fixed build
1 parent 9164a60 commit d32c01e

4 files changed

Lines changed: 92 additions & 54 deletions

File tree

src/lib/assignments.test.ts

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,34 +37,52 @@ describe('createGroupAssignment', () => {
3737

3838
describe('isStaffAssignment', () => {
3939
it('returns true for staff assignments', () => {
40-
expect(isStaffAssignment({ assignmentCode: 'staff-judge', activityId: 1 })).toBe(true);
41-
expect(isStaffAssignment({ assignmentCode: 'staff-scrambler', activityId: 1 })).toBe(true);
42-
expect(isStaffAssignment({ assignmentCode: 'staff-runner', activityId: 1 })).toBe(true);
40+
expect(
41+
isStaffAssignment({ assignmentCode: 'staff-judge', activityId: 1, stationNumber: null })
42+
).toBe(true);
43+
expect(
44+
isStaffAssignment({ assignmentCode: 'staff-scrambler', activityId: 1, stationNumber: null })
45+
).toBe(true);
46+
expect(
47+
isStaffAssignment({ assignmentCode: 'staff-runner', activityId: 1, stationNumber: null })
48+
).toBe(true);
4349
});
4450

4551
it('returns false for non-staff assignments', () => {
46-
expect(isStaffAssignment({ assignmentCode: 'competitor', activityId: 1 })).toBe(false);
52+
expect(
53+
isStaffAssignment({ assignmentCode: 'competitor', activityId: 1, stationNumber: null })
54+
).toBe(false);
4755
});
4856
});
4957

5058
describe('isCompetitorAssignment', () => {
51-
it('returns true for competitor assignment', () => {
52-
expect(isCompetitorAssignment({ assignmentCode: 'competitor', activityId: 1 })).toBe(true);
59+
it('returns true for competitor assignments', () => {
60+
expect(
61+
isCompetitorAssignment({ assignmentCode: 'competitor', activityId: 1, stationNumber: null })
62+
).toBe(true);
5363
});
5464

55-
it('returns false for staff assignments', () => {
56-
expect(isCompetitorAssignment({ assignmentCode: 'staff-judge', activityId: 1 })).toBe(false);
65+
it('returns false for non-competitor assignments', () => {
66+
expect(
67+
isCompetitorAssignment({ assignmentCode: 'staff-judge', activityId: 1, stationNumber: null })
68+
).toBe(false);
5769
});
5870
});
5971

6072
describe('isJudgeAssignment', () => {
61-
it('returns true for judge assignment', () => {
62-
expect(isJudgeAssignment({ assignmentCode: 'staff-judge', activityId: 1 })).toBe(true);
73+
it('returns true for judge assignments', () => {
74+
expect(
75+
isJudgeAssignment({ assignmentCode: 'staff-judge', activityId: 1, stationNumber: null })
76+
).toBe(true);
6377
});
6478

65-
it('returns false for other assignments', () => {
66-
expect(isJudgeAssignment({ assignmentCode: 'staff-scrambler', activityId: 1 })).toBe(false);
67-
expect(isJudgeAssignment({ assignmentCode: 'competitor', activityId: 1 })).toBe(false);
79+
it('returns false for non-judge assignments', () => {
80+
expect(
81+
isJudgeAssignment({ assignmentCode: 'staff-scrambler', activityId: 1, stationNumber: null })
82+
).toBe(false);
83+
expect(
84+
isJudgeAssignment({ assignmentCode: 'competitor', activityId: 1, stationNumber: null })
85+
).toBe(false);
6886
});
6987
});
7088

@@ -79,13 +97,14 @@ describe('hasAssignment', () => {
7997
birthdate: '2000-01-01',
8098
email: 'test@example.com',
8199
assignments: [
82-
{ assignmentCode: 'competitor', activityId: 100 },
83-
{ assignmentCode: 'staff-judge', activityId: 200 },
100+
{ assignmentCode: 'competitor', activityId: 100, stationNumber: null },
101+
{ assignmentCode: 'staff-judge', activityId: 200, stationNumber: null },
84102
],
85103
avatar: null,
86104
roles: [],
87105
registration: null,
88106
personalBests: [],
107+
extensions: [],
89108
};
90109

91110
it('checks person assignments when no filters provided', () => {
@@ -117,7 +136,7 @@ describe('hasAssignment', () => {
117136
it('returns false when person has no matching assignments', () => {
118137
const personWithoutStaff: Person = {
119138
...mockPerson,
120-
assignments: [{ assignmentCode: 'competitor', activityId: 100 }],
139+
assignments: [{ assignmentCode: 'competitor', activityId: 100, stationNumber: null }],
121140
};
122141

123142
const hasStaff = hasAssignment(isStaffAssignment)({});
@@ -135,11 +154,12 @@ describe('doesNotHaveAssignment', () => {
135154
gender: 'm',
136155
birthdate: '2000-01-01',
137156
email: 'test@example.com',
138-
assignments: [{ assignmentCode: 'competitor', activityId: 100 }],
157+
assignments: [{ assignmentCode: 'competitor', activityId: 100, stationNumber: null }],
139158
avatar: null,
140159
roles: [],
141160
registration: null,
142161
personalBests: [],
162+
extensions: [],
143163
};
144164

145165
it('returns true when person does not have assignment', () => {
@@ -164,14 +184,15 @@ describe('filterAssignments', () => {
164184
birthdate: '2000-01-01',
165185
email: 'test@example.com',
166186
assignments: [
167-
{ assignmentCode: 'competitor', activityId: 100 },
168-
{ assignmentCode: 'staff-judge', activityId: 200 },
169-
{ assignmentCode: 'staff-scrambler', activityId: 300 },
187+
{ assignmentCode: 'competitor', activityId: 100, stationNumber: null },
188+
{ assignmentCode: 'staff-judge', activityId: 200, stationNumber: null },
189+
{ assignmentCode: 'staff-scrambler', activityId: 300, stationNumber: null },
170190
],
171191
avatar: null,
172192
roles: [],
173193
registration: null,
174194
personalBests: [],
195+
extensions: [],
175196
};
176197

177198
it('filters person assignments by test', () => {
@@ -225,19 +246,20 @@ describe('helper functions', () => {
225246
birthdate: '2000-01-01',
226247
email: 'test@example.com',
227248
assignments: [
228-
{ assignmentCode: 'competitor', activityId: 100 },
229-
{ assignmentCode: 'staff-judge', activityId: 200 },
249+
{ assignmentCode: 'competitor', activityId: 100, stationNumber: null },
250+
{ assignmentCode: 'staff-judge', activityId: 200, stationNumber: null },
230251
],
231252
avatar: null,
232253
roles: [],
233254
registration: null,
234255
personalBests: [],
256+
extensions: [],
235257
};
236258

237259
const mockPersonCompetitorOnly: Person = {
238260
...mockPersonWithStaff,
239261
registrantId: 2,
240-
assignments: [{ assignmentCode: 'competitor', activityId: 100 }],
262+
assignments: [{ assignmentCode: 'competitor', activityId: 100, stationNumber: null }],
241263
};
242264

243265
describe('hasStaffAssignment', () => {
@@ -275,7 +297,7 @@ describe('helper functions', () => {
275297
it('returns true when person lacks competitor assignment', () => {
276298
const personNoCompeting: Person = {
277299
...mockPersonWithStaff,
278-
assignments: [{ assignmentCode: 'staff-judge', activityId: 200 }],
300+
assignments: [{ assignmentCode: 'staff-judge', activityId: 200, stationNumber: null }],
279301
};
280302
expect(missingCompetitorAssignments({})(personNoCompeting)).toBe(true);
281303
});
@@ -301,7 +323,7 @@ describe('helper functions', () => {
301323
it('returns empty array when no competing assignments', () => {
302324
const personNoCompeting: Person = {
303325
...mockPersonWithStaff,
304-
assignments: [{ assignmentCode: 'staff-judge', activityId: 200 }],
326+
assignments: [{ assignmentCode: 'staff-judge', activityId: 200, stationNumber: null }],
305327
};
306328
expect(findCompetingAssignment({})(personNoCompeting)).toEqual([]);
307329
});

src/lib/events.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ describe('roundFormatById', () => {
9999
describe('sortWcifEvents', () => {
100100
it('sorts events in canonical order', () => {
101101
const wcifEvents: Event[] = [
102-
{ id: 'minx', rounds: [] },
103-
{ id: '333', rounds: [] },
104-
{ id: '222', rounds: [] },
105-
{ id: '444', rounds: [] },
102+
{ id: 'minx', rounds: [], extensions: [] },
103+
{ id: '333', rounds: [], extensions: [] },
104+
{ id: '222', rounds: [], extensions: [] },
105+
{ id: '444', rounds: [], extensions: [] },
106106
];
107107

108108
const sorted = sortWcifEvents(wcifEvents);
@@ -111,9 +111,9 @@ describe('sortWcifEvents', () => {
111111

112112
it('maintains order for events not in the standard list', () => {
113113
const wcifEvents: Event[] = [
114-
{ id: 'pyram', rounds: [] },
115-
{ id: 'clock', rounds: [] },
116-
{ id: 'skewb', rounds: [] },
114+
{ id: 'pyram', rounds: [], extensions: [] },
115+
{ id: 'clock', rounds: [], extensions: [] },
116+
{ id: 'skewb', rounds: [], extensions: [] },
117117
];
118118

119119
const sorted = sortWcifEvents(wcifEvents);

src/lib/persons.test.ts

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ const createMockPerson = (overrides: Partial<Person> = {}): Person => ({
3737
status: 'accepted',
3838
guests: 0,
3939
comments: '',
40+
isCompeting: true,
4041
},
4142
personalBests: [],
43+
extensions: [],
4244
...overrides,
4345
});
4446

@@ -156,6 +158,7 @@ describe('shouldBeInRound', () => {
156158
{ personId: 1, ranking: 1, attempts: [], best: 0, average: 0 },
157159
{ personId: 2, ranking: 2, attempts: [], best: 0, average: 0 },
158160
],
161+
extensions: [],
159162
};
160163

161164
const test = shouldBeInRound(round);
@@ -172,6 +175,7 @@ describe('shouldBeInRound', () => {
172175
advancementCondition: null,
173176
scrambleSetCount: 1,
174177
results: [],
178+
extensions: [],
175179
};
176180

177181
const test = shouldBeInRound(round);
@@ -195,6 +199,7 @@ describe('shouldBeInRound', () => {
195199
advancementCondition: null,
196200
scrambleSetCount: 1,
197201
results: [],
202+
extensions: [],
198203
};
199204

200205
const test = shouldBeInRound(round);
@@ -212,6 +217,7 @@ describe('personsShouldBeInRound', () => {
212217
advancementCondition: null,
213218
scrambleSetCount: 1,
214219
results: [],
220+
extensions: [],
215221
};
216222

217223
const persons = [
@@ -406,8 +412,8 @@ describe('addAssignmentsToPerson', () => {
406412
it('adds assignments to person', () => {
407413
const person = createMockPerson({ assignments: [] });
408414
const newAssignments = [
409-
{ assignmentCode: 'competitor', activityId: 100 },
410-
{ assignmentCode: 'staff-judge', activityId: 200 },
415+
{ assignmentCode: 'competitor', activityId: 100, stationNumber: null },
416+
{ assignmentCode: 'staff-judge', activityId: 200, stationNumber: null },
411417
];
412418

413419
const updated = addAssignmentsToPerson(person, newAssignments);
@@ -417,9 +423,11 @@ describe('addAssignmentsToPerson', () => {
417423

418424
it('appends to existing assignments', () => {
419425
const person = createMockPerson({
420-
assignments: [{ assignmentCode: 'competitor', activityId: 100 }],
426+
assignments: [{ assignmentCode: 'competitor', activityId: 100, stationNumber: null }],
421427
});
422-
const newAssignments = [{ assignmentCode: 'staff-judge', activityId: 200 }];
428+
const newAssignments = [
429+
{ assignmentCode: 'staff-judge', activityId: 200, stationNumber: null },
430+
];
423431

424432
const updated = addAssignmentsToPerson(person, newAssignments);
425433
expect(updated.assignments).toHaveLength(2);
@@ -430,8 +438,8 @@ describe('removeAssignmentsFromPerson', () => {
430438
it('removes assignments for specific activity', () => {
431439
const person = createMockPerson({
432440
assignments: [
433-
{ assignmentCode: 'competitor', activityId: 100 },
434-
{ assignmentCode: 'staff-judge', activityId: 200 },
441+
{ assignmentCode: 'competitor', activityId: 100, stationNumber: null },
442+
{ assignmentCode: 'staff-judge', activityId: 200, stationNumber: null },
435443
],
436444
});
437445

@@ -451,26 +459,30 @@ describe('upsertAssignmentsOnPerson', () => {
451459
it('replaces existing assignment for same activity', () => {
452460
const person = createMockPerson({
453461
assignments: [
454-
{ assignmentCode: 'competitor', activityId: 100 },
455-
{ assignmentCode: 'staff-judge', activityId: 200 },
462+
{ assignmentCode: 'competitor', activityId: 100, stationNumber: null },
463+
{ assignmentCode: 'staff-judge', activityId: 200, stationNumber: null },
456464
],
457465
});
458466

459-
const newAssignments = [{ assignmentCode: 'staff-scrambler', activityId: 100 }];
467+
const newAssignments = [
468+
{ assignmentCode: 'staff-scrambler', activityId: 100, stationNumber: null },
469+
];
460470

461471
const updated = upsertAssignmentsOnPerson(person, newAssignments);
462472
expect(updated.assignments).toHaveLength(2);
463-
expect(updated.assignments.find((a) => a.activityId === 100)?.assignmentCode).toBe(
473+
expect(updated.assignments!.find((a) => a.activityId === 100)?.assignmentCode).toBe(
464474
'staff-scrambler'
465475
);
466476
});
467477

468478
it('adds new assignment when activity not present', () => {
469479
const person = createMockPerson({
470-
assignments: [{ assignmentCode: 'competitor', activityId: 100 }],
480+
assignments: [{ assignmentCode: 'competitor', activityId: 100, stationNumber: null }],
471481
});
472482

473-
const newAssignments = [{ assignmentCode: 'staff-judge', activityId: 200 }];
483+
const newAssignments = [
484+
{ assignmentCode: 'staff-judge', activityId: 200, stationNumber: null },
485+
];
474486

475487
const updated = upsertAssignmentsOnPerson(person, newAssignments);
476488
expect(updated.assignments).toHaveLength(2);
@@ -487,6 +499,7 @@ describe('mayMakeTimeLimit', () => {
487499
advancementCondition: null,
488500
scrambleSetCount: 1,
489501
results: [],
502+
extensions: [],
490503
};
491504

492505
const persons = [
@@ -532,6 +545,7 @@ describe('mayMakeTimeLimit', () => {
532545
advancementCondition: null,
533546
scrambleSetCount: 1,
534547
results: [],
548+
extensions: [],
535549
};
536550

537551
expect(mayMakeTimeLimit('333', round, [])).toEqual([]);
@@ -548,6 +562,7 @@ describe('mayMakeCutoff', () => {
548562
advancementCondition: null,
549563
scrambleSetCount: 1,
550564
results: [],
565+
extensions: [],
551566
};
552567

553568
const persons = [
@@ -593,6 +608,7 @@ describe('mayMakeCutoff', () => {
593608
advancementCondition: null,
594609
scrambleSetCount: 1,
595610
results: [],
611+
extensions: [],
596612
};
597613

598614
expect(mayMakeCutoff('333', round, [])).toEqual([]);

src/lib/utils.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export const updateIn = (object, [property, ...properyChain]: string[], updater)
1212
properyChain.length === 0
1313
? { ...object, [property]: updater(object[property]) }
1414
: {
15-
...object,
16-
[property]: updateIn(object[property], properyChain, updater),
17-
};
15+
...object,
16+
[property]: updateIn(object[property], properyChain, updater),
17+
};
1818

1919
/**
2020
* Returns a copy of the object with the value at the specified path set to the given one.
@@ -59,7 +59,7 @@ export const mapIn = (object, properyChain, mapper) =>
5959
* @param {*} defaultValue
6060
* @returns {*}
6161
*/
62-
export const getIn = (object, [property, ...propertyChain]: string[], defaultValue = null) =>
62+
export const getIn = (object, [property, ...propertyChain]: string[], defaultValue: any = null) =>
6363
object
6464
? propertyChain.length === 0
6565
? object.hasOwnProperty(property)
@@ -95,7 +95,7 @@ export const isPresentDeep = (value) =>
9595
* @param {string} plural
9696
* @returns {string}
9797
*/
98-
export const pluralize = (count, singular, plural) =>
98+
export const pluralize = (count, singular, plural?) =>
9999
`${count} ${count === 1 ? singular : plural || singular + 's'}`;
100100

101101
/**
@@ -107,7 +107,7 @@ export const pluralize = (count, singular, plural) =>
107107
* @param {string} plural
108108
* @returns {string}
109109
*/
110-
export const pluralizeWord = (count, singular, plural) =>
110+
export const pluralizeWord = (count, singular, plural?) =>
111111
`${count === 1 ? singular : plural || singular + 's'}`;
112112

113113
/**
@@ -181,10 +181,10 @@ export const pick = (obj, keys) =>
181181
keys.reduce((newObj, key) => ({ ...newObj, [key]: obj[key] }), {});
182182

183183
export const omit = <T extends object, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K> => {
184-
const _ = { ...obj }
185-
keys.forEach((key) => delete _[key])
186-
return _
187-
}
184+
const _ = { ...obj };
185+
keys.forEach((key) => delete _[key]);
186+
return _;
187+
};
188188

189189
// Date utils
190190

0 commit comments

Comments
 (0)