Skip to content

Commit fcdf766

Browse files
committed
fix test
1 parent b3814c6 commit fcdf766

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ function LargeScreenLayout({ query, route, map, error, mapOptions, encodedValues
178178
</PlainButton>
179179
<RoutingProfiles
180180
routingProfiles={query.profiles}
181-
profileGroupMapping={query.profileGroupMapping}
182181
selectedProfile={query.routingProfile}
183182
showCustomModelBox={showCustomModelBox}
184183
toggleCustomModelBox={() => setShowCustomModelBox(!showCustomModelBox)}

src/sidebar/MobileSidebar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export default function ({ query, route, error, encodedValues, drawAreas, map }:
6060
</div>
6161
<RoutingProfiles
6262
routingProfiles={query.profiles}
63-
profileGroupMapping={query.profileGroupMapping}
6463
selectedProfile={query.routingProfile}
6564
showCustomModelBox={showCustomModelBox}
6665
toggleCustomModelBox={() => setShowCustomModelBox(!showCustomModelBox)}

src/sidebar/search/routingProfiles/RoutingProfiles.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@ import Chevron from './chevron.svg'
88
import { tr } from '@/translation/Translation'
99
import CustomModelBoxSVG from '@/sidebar/open_custom_model.svg'
1010
import { icons } from '@/sidebar/search/routingProfiles/profileIcons'
11-
import { ProfileGroup, ProfileGroupMap } from '@/stores/QueryStore'
11+
import { ProfileGroupMap } from '@/stores/QueryStore'
12+
import * as config from 'config'
1213

1314
export default function ({
1415
routingProfiles,
15-
profileGroupMapping,
1616
selectedProfile,
1717
showCustomModelBox,
1818
toggleCustomModelBox,
1919
customModelBoxEnabled,
2020
}: {
2121
routingProfiles: RoutingProfile[]
22-
profileGroupMapping: Record<string, ProfileGroup>
2322
selectedProfile: RoutingProfile
2423
showCustomModelBox: boolean
2524
toggleCustomModelBox: () => void
@@ -83,7 +82,7 @@ export default function ({
8382
if (!icons[p.name]) customProfiles[key] = [...(customProfiles[key] || []), p.name]
8483
})
8584

86-
let profileToGroup = ProfileGroupMap.create(profileGroupMapping)
85+
let profileToGroup = ProfileGroupMap.create(config.profile_group_mapping)
8786
return (
8887
<div className={styles.profilesParent}>
8988
<PlainButton

src/stores/QueryStore.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ export function getBBoxFromCoord(c: Coordinate, offset: number = 0.005): Bbox {
3535
export class ProfileGroupMap {
3636
public static create(map: Record<string, ProfileGroup>): Record<string, string> {
3737
let res: Record<string, string> = {}
38-
for (const [key, value] of Object.entries(map)) {
39-
for (const option of value.options) {
40-
res[option.profile] = key
38+
if (map)
39+
for (const [key, value] of Object.entries(map)) {
40+
for (const option of value.options) {
41+
res[option.profile] = key
42+
}
4143
}
42-
}
4344
return res
4445
}
4546
}
@@ -50,7 +51,6 @@ export interface ProfileGroup {
5051

5152
export interface QueryStoreState {
5253
readonly profiles: RoutingProfile[]
53-
readonly profileGroupMapping: Record<string, ProfileGroup>
5454
readonly lastProfiles: Record<string, string>
5555
readonly queryPoints: QueryPoint[]
5656
readonly nextQueryPointId: number
@@ -117,7 +117,6 @@ export default class QueryStore extends Store<QueryStoreState> {
117117

118118
return {
119119
profiles: [],
120-
profileGroupMapping: {},
121120
lastProfiles: {},
122121
queryPoints: [
123122
QueryStore.getEmptyPoint(0, QueryPointType.From),
@@ -278,7 +277,6 @@ export default class QueryStore extends Store<QueryStoreState> {
278277
{
279278
...state,
280279
profiles,
281-
profileGroupMapping: config.profile_group_mapping,
282280
routingProfile: profile,
283281
},
284282
true
@@ -300,7 +298,7 @@ export default class QueryStore extends Store<QueryStoreState> {
300298

301299
const newState: QueryStoreState = {
302300
...state,
303-
routingProfile: { name: name },
301+
routingProfile: { ...action.profile, name: name },
304302
lastProfiles: { ...state.lastProfiles, [key]: value },
305303
}
306304
return this.routeIfReady(newState, true)

test/stores/QueryStore.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,11 @@ describe('QueryStore', () => {
268268
})
269269
)
270270

271-
expect(newState).toEqual({ ...state, profiles: [{ name: 'some-other-profile' }] })
271+
expect(newState).toEqual({
272+
...state,
273+
profileGroupMapping: undefined,
274+
profiles: [{ name: 'some-other-profile' }],
275+
})
272276
})
273277
it('should use the first profile received from info endpoint', () => {
274278
const expectedProfile = {

0 commit comments

Comments
 (0)