Skip to content

Commit

Permalink
Update for category switch
Browse files Browse the repository at this point in the history
  • Loading branch information
tmoitie committed Mar 6, 2024
1 parent dd60339 commit 88b3177
Show file tree
Hide file tree
Showing 20 changed files with 186 additions and 166 deletions.
2 changes: 2 additions & 0 deletions build/api/getSeason.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const trackTypeToCatId = {
road: 2,
dirt_oval: 3,
dirt_road: 4,
sports_car: 5,
formula_car: 6,
};

const licenceGroupToMinlicenselevel: {[key: string]: number} = {
Expand Down
22 changes: 19 additions & 3 deletions src/__tests__/__snapshots__/App.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -336,16 +336,32 @@ exports[`components/App renders correctly 1`] = `
className="checkbox"
>
<label
htmlFor="checkbox-type-road"
htmlFor="checkbox-type-road-sports"
>
<input
checked={true}
disabled={false}
id="checkbox-type-road"
id="checkbox-type-road-sports"
onChange={[Function]}
type="checkbox"
/>
Road
Sports Car
</label>
</div>
<div
className="checkbox"
>
<label
htmlFor="checkbox-type-road-formula"
>
<input
checked={true}
disabled={false}
id="checkbox-type-road-formula"
onChange={[Function]}
type="checkbox"
/>
Formula Car
</label>
</div>
<div
Expand Down
15 changes: 11 additions & 4 deletions src/components/Filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,18 @@ export default function Filters(): React.Node {
{t('Oval')}
</Checkbox>
<Checkbox
id="checkbox-type-road"
checked={currentFilters.type.indexOf('Road') !== -1}
onChange={getCheckboxFilterHandler('type', 'Road')}
id="checkbox-type-road-sports"
checked={currentFilters.type.indexOf('Sports Car') !== -1}
onChange={getCheckboxFilterHandler('type', 'Sports Car')}
>
{t('Road')}
{t('Sports Car')}
</Checkbox>
<Checkbox
id="checkbox-type-road-formula"
checked={currentFilters.type.indexOf('Formula Car') !== -1}
onChange={getCheckboxFilterHandler('type', 'Formula Car')}
>
{t('Formula Car')}
</Checkbox>
<Checkbox
id="checkbox-type-dirt"
Expand Down
112 changes: 96 additions & 16 deletions src/components/__tests__/__snapshots__/Filters.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,32 @@ exports[`components/Filters correctly click a filter item checkbox 1`] = `
className="checkbox"
>
<label
htmlFor="checkbox-type-road"
htmlFor="checkbox-type-road-sports"
>
<input
checked={true}
checked={false}
disabled={false}
id="checkbox-type-road"
id="checkbox-type-road-sports"
onChange={[Function]}
type="checkbox"
/>
Road
Sports Car
</label>
</div>
<div
className="checkbox"
>
<label
htmlFor="checkbox-type-road-formula"
>
<input
checked={false}
disabled={false}
id="checkbox-type-road-formula"
onChange={[Function]}
type="checkbox"
/>
Formula Car
</label>
</div>
<div
Expand Down Expand Up @@ -378,16 +394,32 @@ exports[`components/Filters correctly click a true/false checkbox 1`] = `
className="checkbox"
>
<label
htmlFor="checkbox-type-road"
htmlFor="checkbox-type-road-sports"
>
<input
checked={true}
disabled={false}
id="checkbox-type-road-sports"
onChange={[Function]}
type="checkbox"
/>
Sports Car
</label>
</div>
<div
className="checkbox"
>
<label
htmlFor="checkbox-type-road-formula"
>
<input
checked={true}
disabled={false}
id="checkbox-type-road"
id="checkbox-type-road-formula"
onChange={[Function]}
type="checkbox"
/>
Road
Formula Car
</label>
</div>
<div
Expand Down Expand Up @@ -725,16 +757,32 @@ exports[`components/Filters not synced user 1`] = `
className="checkbox"
>
<label
htmlFor="checkbox-type-road"
htmlFor="checkbox-type-road-sports"
>
<input
checked={true}
disabled={false}
id="checkbox-type-road"
id="checkbox-type-road-sports"
onChange={[Function]}
type="checkbox"
/>
Road
Sports Car
</label>
</div>
<div
className="checkbox"
>
<label
htmlFor="checkbox-type-road-formula"
>
<input
checked={true}
disabled={false}
id="checkbox-type-road-formula"
onChange={[Function]}
type="checkbox"
/>
Formula Car
</label>
</div>
<div
Expand Down Expand Up @@ -1080,16 +1128,32 @@ exports[`components/Filters renders correctly 1`] = `
className="checkbox"
>
<label
htmlFor="checkbox-type-road"
htmlFor="checkbox-type-road-sports"
>
<input
checked={true}
disabled={false}
id="checkbox-type-road"
id="checkbox-type-road-sports"
onChange={[Function]}
type="checkbox"
/>
Road
Sports Car
</label>
</div>
<div
className="checkbox"
>
<label
htmlFor="checkbox-type-road-formula"
>
<input
checked={true}
disabled={false}
id="checkbox-type-road-formula"
onChange={[Function]}
type="checkbox"
/>
Formula Car
</label>
</div>
<div
Expand Down Expand Up @@ -1427,16 +1491,32 @@ exports[`components/Filters synced user 1`] = `
className="checkbox"
>
<label
htmlFor="checkbox-type-road"
htmlFor="checkbox-type-road-sports"
>
<input
checked={true}
disabled={false}
id="checkbox-type-road-sports"
onChange={[Function]}
type="checkbox"
/>
Sports Car
</label>
</div>
<div
className="checkbox"
>
<label
htmlFor="checkbox-type-road-formula"
>
<input
checked={true}
disabled={false}
id="checkbox-type-road"
id="checkbox-type-road-formula"
onChange={[Function]}
type="checkbox"
/>
Road
Formula Car
</label>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ exports[`components/modal/FavouriteSeriesModal renders with checkbox saving 1`]
className="container-fluid"
>
<h3>
Road
Oval
</h3>
<div
className="row"
Expand All @@ -86,36 +86,43 @@ exports[`components/modal/FavouriteSeriesModal renders with checkbox saving 1`]
className="checkbox"
>
<label
htmlFor="favourite-series-374"
htmlFor="favourite-series-245"
>
<input
checked={false}
checked={true}
disabled={false}
id="favourite-series-374"
id="favourite-series-245"
onChange={[Function]}
type="checkbox"
/>
IndyCar iRacing Series
13th Week iRacing Figure GR8
</label>
</div>
</div>
</div>
<h3>
Road
</h3>
<div
className="row"
>
<div
className="col-md-6"
>
<div
className="checkbox"
>
<label
htmlFor="favourite-series-245"
htmlFor="favourite-series-374"
>
<input
checked={true}
checked={false}
disabled={false}
id="favourite-series-245"
id="favourite-series-374"
onChange={[Function]}
type="checkbox"
/>
13th Week iRacing Figure GR8
IndyCar iRacing Series
</label>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/data/__mocks__/season.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
"race_time_limit": null
}
],
"catid": 2,
"catid": 5,
"isOfficial": true,
"licnceGroup": 3,
"licnceGroupName": "Class C",
Expand Down Expand Up @@ -557,7 +557,7 @@
"race_time_limit": null
}
],
"catid": 2,
"catid": 1,
"isOfficial": false,
"licnceGroup": 1,
"licnceGroupName": "Rookie",
Expand Down
5 changes: 5 additions & 0 deletions src/data/changelog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import moment from 'moment';

export default [{
date: moment('2024-03-06 00:00:00').utc(),
items: [
'Update with new categories',
],
}, {
date: moment('2024-03-05 00:00:00').utc(),
items: [
'Update to 2024S1W13',
Expand Down
2 changes: 2 additions & 0 deletions src/lib/races.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ categoryMap.set(1, 'Oval');
categoryMap.set(2, 'Road');
categoryMap.set(3, 'Dirt');
categoryMap.set(4, 'RX');
categoryMap.set(5, 'Sports Car');
categoryMap.set(6, 'Formula Car');

const getType = (catId: number): ?string => categoryMap.get(catId);

Expand Down
14 changes: 6 additions & 8 deletions src/reducers/__tests__/settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ describe('reducers/settings', () => {
expect(state.ownedTracks.length).toBe(22);
});

test('set up legacy state', () => {
window.localStorage.setItem('iracing-state', JSON.stringify({ sort: { key: 'class', order: 'desc' } }));
const state = settingsReducer(undefined, {});
expect(state.sort).toEqual({ key: 'class', order: 'desc' });
expect(window.localStorage.getItem('iracing-state')).toEqual(null);
});

test('localStorageActionTypes.INIT', async () => {
const state = settingsReducer(
undefined,
Expand All @@ -34,12 +27,17 @@ describe('reducers/settings', () => {
settings: {
ownedCars: [5],
ownedTracks: [34, 165],
filters: {
type: ['Road', 'Oval'],
}
},
},
},
);
expect(state.ownedCars.length).toBe(17);
expect(state.ownedTracks.length).toBe(23);
expect(state.filters.type).toInclude('Sports Car');
expect(state.filters.type.length).toBe(3);
const stateNoPayload = settingsReducer(
undefined,
{
Expand Down Expand Up @@ -69,7 +67,7 @@ describe('reducers/settings', () => {
type: RESET_FILTERS,
},
);
expect(state.filters.type).toEqual(['Road', 'Oval', 'Dirt', 'RX']);
expect(state.filters.type).toEqual(['Sports Car', 'Formula Car', 'Oval', 'Dirt', 'RX']);
expect(state.firebaseSynced).toBe(false);
});

Expand Down
Loading

0 comments on commit 88b3177

Please sign in to comment.