Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ on:

jobs:
test:
runs-on: ubuntu-latest
# Keep the test OS compatible with the locked Playwright/browser dependencies.
runs-on: ubuntu-24.04

steps:
- name: Checkout code
Expand Down Expand Up @@ -41,7 +42,8 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

e2e:
runs-on: ubuntu-latest
# Keep the test OS compatible with the locked Playwright/browser dependencies.
runs-on: ubuntu-24.04

steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/*
24
104 changes: 104 additions & 0 deletions e2e/fto.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { readFile } from 'node:fs/promises';
import { test, expect } from '@playwright/test';
import type { Competition } from '@wca/helpers';
import { fixtures } from './fixtures';
import { createWcaApiState, registerWcaApiRoutes, seedAuth } from './mocks/wcaApi';

test('official FTO groups, assignments, persistence, display and CSV exports', async ({ page }) => {
test.setTimeout(60_000);
// Reuse the small two-person fixture, retaining official WCIF identifiers throughout.
const wcif = JSON.parse(
JSON.stringify(fixtures.wcif)
.replaceAll('333', 'fto')
.replaceAll('3x3x3 Cube', 'Face-Turning Octahedron')
) as Competition;
// Exports read the required WCIF room extensions, omitted by the base UI fixture.
wcif.schedule.venues[0].rooms[0].extensions = [];
wcif.persons[0].email = 'alex@example.com';
const state = createWcaApiState({ wcif });
await seedAuth(page);
await registerWcaApiRoutes(page, state, fixtures);
const errors: string[] = [];
page.on('pageerror', (error) => errors.push(error.message));

await page.goto('/competitions/TestComp2026');
await expect(page.getByText('Events:').locator('..')).toHaveText('Events: FTO (1)');
const roundLink = page.getByText('Face-Turning Octahedron, Round 1', { exact: true });
await expect(roundLink).toBeVisible();
const icon = page.locator('.cubing-icon.event-fto').first();
await expect(icon).toBeVisible();
expect(await icon.evaluate((element) => getComputedStyle(element, '::before').content)).toBe(
'"\uf135"'
);
await roundLink.click();
await expect(page).toHaveURL(/\/events\/fto-r1$/);

await page.getByRole('button', { name: 'Configure Group Counts' }).click();
const counts = page.getByRole('dialog', { name: 'Configuring Group Counts For fto-r1' });
await counts.getByLabel('Groups').fill('2');
await counts.getByRole('button', { name: 'Save And Create Groups' }).click();
await expect(page.getByText('Main Room: Group 2')).toBeVisible();
await page.getByRole('button', { name: 'Assign Competitor and Judging Assignments' }).click();
const stats = page.getByRole('table').filter({ hasText: 'Round Size' }).getByRole('row').last();
await expect(stats.getByRole('cell').nth(2)).toHaveText('2');
await expect(stats.getByRole('cell').nth(3)).toHaveText('2');

await page.getByRole('button', { name: 'Configure Assignments', exact: true }).click();
const assignments = page.getByRole('dialog', {
name: 'Configuring Assignments For Face-Turning Octahedron, Round 1',
});
await assignments.getByRole('switch').first().click();
await expect(assignments.getByRole('row', { name: /Alex Example/ })).toBeVisible();
await expect(assignments.getByRole('row', { name: /Jamie Example/ })).toBeVisible();
await assignments.getByRole('button', { name: 'Close' }).click();

await page.getByRole('button', { name: 'SAVE', exact: true }).click();
await expect(page.getByText('Saved!', { exact: true })).toBeVisible();
const saved = state.wcifById.TestComp2026 as Competition;
expect(saved.events[0].id).toBe('fto');
expect(
saved.schedule.venues[0].rooms[0].activities[0].childActivities.map(
(group) => group.activityCode
)
).toEqual(['fto-r1-g1', 'fto-r1-g2']);
for (const person of saved.persons) {
expect(person.registration?.eventIds).toEqual(['fto']);
expect(person.assignments?.map((a) => a.assignmentCode).sort()).toEqual([
'competitor',
'staff-judge',
]);
}

await page.goto('/competitions/TestComp2026/assignments');
const eventFilter = page.getByRole('button', { name: 'Face-Turning Octahedron', exact: true });
await expect(eventFilter).toHaveAttribute('aria-pressed', 'true');
await eventFilter.click();
await expect(eventFilter).toHaveAttribute('aria-pressed', 'false');
await eventFilter.click();

await page.goto('/competitions/TestComp2026/export');
for (const [button, expected] of [
[
'Generate Nametags CSV',
['fto', 'fto_station_number', 'fto_staff', 'Alex Example', 'Jamie Example'],
],
['Generate Scorecard CSV', ['Face-Turning Octahedron', 'ao5', 'Alex Example', 'Jamie Example']],
['Generate Registration CSV', ['alex@example.com', 'jamie@example.com']],
[
'Generate Nametags for publisher CSV',
['fto-0', 'fto_staff-0', 'Alex Example', 'Jamie Example'],
],
] as const) {
await test.step(button, async () => {
const downloadPromise = page.waitForEvent('download');
await page.getByRole('button', { name: button, exact: true }).click();
expect(errors).toEqual([]);
const download = await downloadPromise;
expect(await download.failure()).toBeNull();
const csv = await readFile((await download.path())!, 'utf8');
for (const value of expected) expect(csv).toContain(value);
expect(csv).not.toContain('undefined');
});
}
expect(errors).toEqual([]);
});
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"test:e2e": "playwright test",
"test:e2e:headed": "playwright test --headed",
"prepare": "husky install",
"prettier": "prettier \"src/**/*.js\" --write"
"prettier": "prettier \"src/**/*.js\" --write",
"postinstall": "patch-package --error-on-fail"
},
"dependencies": {
"@codemirror/lang-json": "6.0.2",
Expand All @@ -36,7 +37,7 @@
"@types/react-dom": "19.2.3",
"@uiw/react-codemirror": "^4.25.4",
"@vitejs/plugin-react": "^5.1.2",
"@wca/helpers": "^1.1.6",
"@wca/helpers": "1.1.6",
"clsx": "^2.1.1",
"country-flag-icons": "^1.6.8",
"date-fns": "^4.1.0",
Expand All @@ -50,6 +51,7 @@
"lodash.debounce": "^4.0.8",
"material-ui-confirm": "^4.0.0",
"notistack": "^3.0.1",
"patch-package": "^8.0.1",
"prop-types": "^15.8.1",
"react": "19.2.3",
"react-dom": "19.2.3",
Expand Down Expand Up @@ -109,5 +111,8 @@
"singleQuote": true,
"bracketSpacing": true,
"bracketSameLine": true
},
"resolutions": {
"@wca/helpers": "1.1.6"
}
}
21 changes: 21 additions & 0 deletions patches/@wca+helpers+1.1.6.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/node_modules/@wca/helpers/lib/helpers/event.js b/node_modules/@wca/helpers/lib/helpers/event.js
index 87b4f87..78c7846 100644
--- a/node_modules/@wca/helpers/lib/helpers/event.js
+++ b/node_modules/@wca/helpers/lib/helpers/event.js
@@ -2,6 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEventResultType = exports.getEventName = void 0;
var eventDataById = {
+ fto: { resultType: 'time', name: 'Face-Turning Octahedron' },
'333': { resultType: 'time', name: '3x3x3 Cube' },
'222': { resultType: 'time', name: '2x2x2 Cube' },
'444': { resultType: 'time', name: '4x4x4 Cube' },
diff --git a/node_modules/@wca/helpers/lib/models/eventId.d.ts b/node_modules/@wca/helpers/lib/models/eventId.d.ts
index f676817..f872d26 100644
--- a/node_modules/@wca/helpers/lib/models/eventId.d.ts
+++ b/node_modules/@wca/helpers/lib/models/eventId.d.ts
@@ -1,3 +1,3 @@
-export type CurrentEventId = '222' | '333' | '444' | '555' | '666' | '777' | '333bf' | '333fm' | '333oh' | 'clock' | 'minx' | 'pyram' | 'skewb' | 'sq1' | '444bf' | '555bf' | '333mbf';
+export type CurrentEventId = '222' | '333' | '444' | '555' | '666' | '777' | '333bf' | '333fm' | '333oh' | 'clock' | 'minx' | 'pyram' | 'skewb' | 'sq1' | '444bf' | '555bf' | '333mbf' | 'fto';
export type DeprecatedEventId = 'magic' | 'mmagic' | '333mbo' | '333ft';
export type EventId = CurrentEventId | DeprecatedEventId;
16 changes: 16 additions & 0 deletions patches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# FTO compatibility

`@wca/helpers` 1.1.6 is pinned and patched at install time to add the official
`fto` event ID, display name and timed-result type. The patch applies to the
shared dependency used by both this app and `wca-group-generators`; changing
only the app registry leaves upstream activity naming and group creation broken.

The 1.1.9 release still lacks FTO. Version 2.0.0 includes the ID type but not the
runtime event metadata, and also changes the WCIF schema. Remove this patch and
pin/resolution when a compatible upstream release supplies both pieces.
Install with Yarn lifecycle scripts enabled. `postinstall` fails if the patch
cannot apply. The FTO workflow test exercises the actual upstream functions.

`@cubing/icons` 3.0.5 includes the FTO glyph as `unofficial-fto`. The CSS alias in
`src/assets/index.css` lets every existing `event-fto` consumer display it while
keeping the official WCIF identifier throughout registrations and assignments.
6 changes: 6 additions & 0 deletions src/assets/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@
display: flex;
flex-shrink: 1;
}

/* @cubing/icons 3.0.5 ships the FTO glyph as unofficial-fto.
* Alias the official WCIF event ID for all event icon consumers. */
.cubing-icon.event-fto::before {
content: "\f135";
}
3 changes: 3 additions & 0 deletions src/components/EventSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { eventNameById } from '../lib/domain/events';
import { IconButton } from '@mui/material';
import { type EventId } from '@wca/helpers';

Expand Down Expand Up @@ -25,6 +26,8 @@ const EventSelector = ({ eventIds, value, onChange, styleOverrides }: EventSelec
{eventIds.map((eventId) => (
<IconButton
key={eventId}
aria-label={eventNameById(eventId)}
aria-pressed={value.includes(eventId)}
className={`cubing-icon event-${eventId}`}
style={{ fontSize: '1.5em' }}
sx={(theme) => ({
Expand Down
4 changes: 2 additions & 2 deletions src/components/_tests_/CompetitionSummaryCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('CompetitionSummaryCard', () => {
id: 'Comp',
name: 'Summary Competition',
schedule: { startDate: '2024-01-01', numberOfDays: 1, venues: [] },
events: [{ id: '333' }, { id: '222' }],
events: [{ id: '333' }, { id: '222' }, { id: 'fto' }],
persons: [{ registration: { status: 'accepted' } }, { registration: { status: 'pending' } }],
};

Expand All @@ -26,6 +26,6 @@ describe('CompetitionSummaryCard', () => {

expect(getByText('Summary Competition')).toBeInTheDocument();
expect(getByText('Competitors:').parentElement).toHaveTextContent('Competitors: 1');
expect(getByText('Events:').parentElement).toHaveTextContent('Events: 3x3, 2x2 (2)');
expect(getByText('Events:').parentElement).toHaveTextContent('Events: 3x3, 2x2, FTO (3)');
});
});
147 changes: 147 additions & 0 deletions src/lib/domain/_tests_/fto.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import { describe, expect, it } from 'vitest';
import {
activityCodeToName as helperActivityName,
getEventName,
getEventResultType,
type EventId,
} from '@wca/helpers';
import { createGroupActivity as generatorGroupActivity } from 'wca-group-generators';
import {
buildActivity,
buildEvent,
buildPerson,
buildRound,
buildWcifWithEvents,
} from '../../../store/reducers/_tests_/helpers';
import { events, eventNameById, shortEventNameById, sortWcifEvents } from '../events';
import { activityCodeToName, hasDistributedAttempts, parseActivityCode } from '../activities';
import { personsRegistered, personsShouldBeInRound } from '../persons';
import { generateCompetingGroupActitivitesForEveryone } from '../../assignmentGenerators/generateCompetingGroupActitivitesForEveryone';
import { generateJudgeAssignmentsFromCompetingAssignments } from '../../assignmentGenerators/generateJudgeAssignmentsFromCompetingAssignments';
import {
determineMissingGroupActivities,
generateAssignments,
generateMissingGroupActivities,
upsertCompetitorAssignments,
validate,
} from '../../importExport/import';
import { formatSeedResult } from '../../../dialogs/ConfigureAssignmentsDialog/formatSeedResult';

const eventId: EventId = 'fto';
const round = buildRound({ id: 'fto-r1' });
const event = buildEvent({ id: eventId, rounds: [round] });
const registered = (
registrantId: number,
status: 'accepted' | 'pending' = 'accepted',
eventIds: EventId[] = [eventId]
) =>
buildPerson({
registrantId,
email: `${registrantId}@example.com`,
registration: {
wcaRegistrationId: registrantId,
status,
eventIds,
isCompeting: true,
},
});

const buildFtoWcif = () =>
buildWcifWithEvents(
[
buildActivity({
activityCode: 'fto-r1',
childActivities: [
buildActivity({ id: 2, activityCode: 'fto-r1-g1' }),
buildActivity({ id: 3, activityCode: 'fto-r1-g2' }),
],
}),
],
[event],
[registered(1), registered(2), registered(3, 'pending'), registered(4, 'accepted', ['333'])]
);

describe('official FTO workflow', () => {
it('uses the official ID, names, time results and deterministic event order', () => {
expect(events.filter(({ id }) => id === eventId)).toHaveLength(1);
expect(eventNameById(eventId)).toBe('Face-Turning Octahedron');
expect(shortEventNameById(eventId)).toBe('FTO');
expect(getEventName(eventId)).toBe(eventNameById(eventId));
expect(getEventResultType(eventId)).toBe('time');
expect(
sortWcifEvents([event, buildEvent(), buildEvent({ id: 'clock' })]).map(({ id }) => id)
).toEqual(['333', 'clock', 'fto']);
expect(formatSeedResult(eventId, 'average', 1234)).toBe('12.34');
expect(formatSeedResult(eventId, 'single', -1)).toBe('DNF');
expect(formatSeedResult(eventId, 'average')).toBe('-');
});

it('names and creates ordinary round/group activities in both helper implementations', () => {
expect(parseActivityCode('fto-r1-g2')).toMatchObject({
eventId,
roundNumber: 1,
groupNumber: 2,
});
expect(hasDistributedAttempts('fto-r1')).toBe(false);
expect(activityCodeToName('fto-r1-g2')).toBe('Face-Turning Octahedron, Round 1, Group 2');
expect(helperActivityName('fto-r1-g2')).toBe(activityCodeToName('fto-r1-g2'));
const activity = generatorGroupActivity(
2,
buildActivity({ activityCode: 'fto-r1' }),
1,
null,
null
);
expect(activity).toMatchObject({
activityCode: 'fto-r1-g1',
name: 'Face-Turning Octahedron, Round 1, Group 1',
});
});

it('generates competing and judging assignments only for accepted FTO registrants', () => {
const wcif = buildFtoWcif();
expect(personsRegistered(wcif.persons, eventId).map((p) => p.registrantId)).toEqual([1, 2]);
expect(personsShouldBeInRound(round)(wcif.persons).map((p) => p.registrantId)).toEqual([1, 2]);
expect(personsShouldBeInRound(buildRound({ id: 'fto-r2' }))(wcif.persons)).toEqual([]);
const competing = generateCompetingGroupActitivitesForEveryone(wcif, round.id)!([]);
expect(competing).toHaveLength(2);
expect(competing.map((a) => a.registrantId).sort()).toEqual([1, 2]);
expect(new Set(competing.map((a) => a.assignment.activityId))).toEqual(new Set([2, 3]));
const judging = generateJudgeAssignmentsFromCompetingAssignments(wcif, round.id)!(competing);
expect(judging).toHaveLength(2);
for (const assignment of judging) {
expect(assignment.assignment.assignmentCode).toBe('staff-judge');
expect(assignment.assignment.activityId).not.toBe(
competing.find((a) => a.registrantId === assignment.registrantId)!.assignment.activityId
);
}
});

it('imports official FTO competitor and staff columns and creates missing groups', () => {
const wcif = buildWcifWithEvents(
[buildActivity({ activityCode: 'fto-r1' })],
[event],
[registered(1)]
);
const data = {
meta: { fields: ['email', 'fto', 'fto-staff'] },
data: [{ email: '1@example.com', fto: '1', 'fto-staff': 'S2' }],
};
expect(validate(wcif)(data).every((check) => check.passed)).toBe(true);
const assignments = generateAssignments(wcif, data);
expect(assignments.map((a) => a.activityCode)).toEqual(['fto-r1-g1', 'fto-r1-g2']);
const missing = determineMissingGroupActivities(wcif, assignments);
const withGroups = generateMissingGroupActivities(wcif, missing);
const updated = upsertCompetitorAssignments(withGroups, assignments);
expect(updated.persons[0].assignments?.map((a) => a.assignmentCode).sort()).toEqual([
'competitor',
'staff-scrambler',
]);
expect(
updated.schedule.venues[0].rooms[0].activities[0].childActivities.map((a) => a.name)
).toEqual([
'Face-Turning Octahedron, Round 1, Group 1',
'Face-Turning Octahedron, Round 1, Group 2',
]);
});
});
1 change: 1 addition & 0 deletions src/lib/domain/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const events: EventInfo[] = [
{ id: '444bf', name: '4x4x4 Blindfolded', shortName: '4BLD' },
{ id: '555bf', name: '5x5x5 Blindfolded', shortName: '5BLD' },
{ id: '333mbf', name: '3x3x3 Multi-Blind', shortName: 'MBLD' },
{ id: 'fto', name: 'Face-Turning Octahedron', shortName: 'FTO' },
];

export const eventNameById = (eventId: EventId): string => propertyById('name', eventId);
Expand Down
Loading
Loading