Skip to content

Commit 661bddc

Browse files
authored
Merge pull request #80 from coder13/fix/issue-79-worldsassignments
Fix worlds assignment schedule rendering
2 parents dbb2fc7 + 02306f1 commit 661bddc

2 files changed

Lines changed: 70 additions & 10 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { Competition, Person } from '@wca/helpers';
2+
import { parseActivityCodeFlexible } from '@/lib/activityCodes';
3+
import { formatBriefActivityName, getAllAssignments, getGroupedAssignmentsByDate } from './utils';
4+
5+
jest.mock('@/i18n', () => ({
6+
__esModule: true,
7+
default: {
8+
t: (key: string) => key,
9+
},
10+
t: (key: string) => key,
11+
}));
12+
13+
const wcif = {
14+
id: 'WC2025',
15+
schedule: {
16+
venues: [
17+
{
18+
id: 1,
19+
name: 'Venue',
20+
timezone: 'America/Los_Angeles',
21+
rooms: [],
22+
},
23+
],
24+
},
25+
events: [],
26+
} as unknown as Competition;
27+
28+
const worldsAssignmentsPerson = {
29+
registrantId: 215,
30+
assignments: [],
31+
registration: {
32+
eventIds: [],
33+
},
34+
extensions: [
35+
{
36+
id: 'com.competitiongroups.worldsassignments',
37+
data: {
38+
assignments: [
39+
{
40+
staff: 'Stage Stream - Main',
41+
startTime: '2025-07-03T18:00:00Z',
42+
endTime: '2025-07-03T19:00:00Z',
43+
},
44+
],
45+
},
46+
},
47+
],
48+
} as unknown as Person;
49+
50+
describe('PersonalSchedule utils', () => {
51+
it('creates parse-safe activities for worlds assignments with free-form staff names', () => {
52+
const [assignment] = getAllAssignments(wcif, worldsAssignmentsPerson);
53+
54+
expect(assignment.activity).toBeDefined();
55+
const activity = assignment.activity!;
56+
57+
expect(activity.activityCode).toBe('other-misc');
58+
expect(() => parseActivityCodeFlexible(activity.activityCode)).not.toThrow();
59+
expect(formatBriefActivityName(activity)).toBe('Stage Stream - Main');
60+
});
61+
62+
it('includes days that only have worlds assignments', () => {
63+
const [scheduleDay] = getGroupedAssignmentsByDate(wcif, worldsAssignmentsPerson);
64+
65+
expect(scheduleDay.date).toBe('Thursday, 7/3/2025');
66+
expect(scheduleDay.assignments).toHaveLength(1);
67+
expect(scheduleDay.assignments[0].assignment.assignmentCode).toBe('Stage Stream - Main');
68+
});
69+
});

src/containers/PersonalSchedule/utils.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const getExtraAssignments = (person: Person) => {
5353
activityId: -1,
5454
stationNumber: null,
5555
activity: {
56-
activityCode: 'other-' + assignment.staff,
56+
activityCode: 'other-misc',
5757
startTime: assignment.startTime,
5858
endTime: assignment.endTime,
5959
childActivities: [],
@@ -148,15 +148,6 @@ export const getGroupedAssignmentsByDate = (wcif: Competition, person: Person) =
148148

149149
const scheduledDays = allAssignments
150150
.map((a) => {
151-
if (a.type === 'extra') {
152-
return {
153-
approxDateTime: 0,
154-
date: '',
155-
dateParts: [],
156-
assignments: [],
157-
};
158-
}
159-
160151
if (!a.activity) {
161152
return {
162153
approxDateTime: 0,

0 commit comments

Comments
 (0)