Skip to content
Merged
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
11 changes: 7 additions & 4 deletions web/src/components/courtlist/CourtListSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
async (newVal) => {
judgeId.value = newVal;
selectedCourtLocation.value = getJudgeHomeLocation();
selectedCourtRoom.value = '';
searchForCourtList();
}
);
Expand All @@ -184,6 +185,11 @@
};

const getJudgeHomeLocation = () => {
// Judge Home Location is only applicable for ROOM_SCHEDULE
if (schedule.value === MY_SCHEDULE) {
return null;
}

return (
locationsAndCourtRooms.value?.find(
(l) =>
Expand Down Expand Up @@ -217,10 +223,7 @@
setupAutoRefresh();
};
const scheduleChanged = () => {
selectedCourtLocation.value = null;
if (schedule.value === ROOM_SCHEDULE) {
selectedCourtLocation.value = getJudgeHomeLocation();
}
selectedCourtLocation.value = getJudgeHomeLocation();
selectedCourtRoom.value = '';
errors.isMissingLocation = false;
errors.isMissingRoom = false;
Expand Down
24 changes: 24 additions & 0 deletions web/tests/components/courtList/CourtListSearch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ describe('CourtListSearch.vue', () => {
judgeId: 123,
};

wrapper.vm.schedule = 'room_schedule';
const result = wrapper.vm.getJudgeHomeLocation();

expect(result).toEqual({
Expand Down Expand Up @@ -342,6 +343,7 @@ describe('CourtListSearch.vue', () => {
judgeId: 123,
};

wrapper.vm.schedule = 'room_schedule';
const result = wrapper.vm.getJudgeHomeLocation();

expect(result).toEqual({
Expand All @@ -352,5 +354,27 @@ describe('CourtListSearch.vue', () => {
courtRooms: [{ room: 'Room 42' }],
});
});

it('correctly converts judgeHomeLocationId to string for comparison', () => {
wrapper.vm.locationsAndCourtRooms = [
{
locationId: '42',
name: 'String Location',
shortName: 'SL',
code: 'SL',
courtRooms: [{ room: 'Room 42' }],
},
];

commonStore.userInfo = {
judgeHomeLocationId: 42, // Number
judgeId: 123,
};

wrapper.vm.schedule = 'my_schedule';
const result = wrapper.vm.getJudgeHomeLocation();

expect(result).toBeNull();
});
});
});
Loading