Skip to content

Commit

Permalink
Merge pull request #1150 from shankari/fix_replaced_mode_regression
Browse files Browse the repository at this point in the history
🚑️ 🐛 Ensure that we do show the replaced mode when the `mode_of_inter…
  • Loading branch information
shankari authored May 5, 2024
2 parents 8a9d9b3 + 20b9e1a commit 958918d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
18 changes: 14 additions & 4 deletions www/__tests__/confirmHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ const fakeDefaultLabelOptions = {
},
},
};
const fakeInputs = {
MODE: [
{ data: { label: 'walk', start_ts: 1245, end_ts: 5678 } },
{ data: { label: 'bike', start_ts: 1245, end_ts: 5678 } },
],
PURPOSE: [
{ data: { label: 'home', start_ts: 1245, end_ts: 5678 } },
{ data: { label: 'work', start_ts: 1245, end_ts: 5678 } },
],
};

jest.mock('../js/services/commHelper', () => ({
...jest.requireActual('../js/services/commHelper'),
Expand All @@ -62,8 +72,8 @@ describe('confirmHelper', () => {

it('returns base labelInputDetails for a labelUserInput which does not have mode of study', () => {
const fakeLabelUserInput = {
MODE: fakeDefaultLabelOptions.MODE[1],
PURPOSE: fakeDefaultLabelOptions.PURPOSE[0],
MODE: fakeInputs.MODE[1],
PURPOSE: fakeInputs.PURPOSE[0],
};
const labelInputDetails = labelInputDetailsForTrip(
fakeLabelUserInput,
Expand All @@ -74,8 +84,8 @@ describe('confirmHelper', () => {

it('returns full labelInputDetails for a labelUserInput which has the mode of study', () => {
const fakeLabelUserInput = {
MODE: fakeDefaultLabelOptions.MODE[0], // 'walk' is mode of study
PURPOSE: fakeDefaultLabelOptions.PURPOSE[0],
MODE: fakeInputs.MODE[0], // 'walk' is mode of study
PURPOSE: fakeInputs.PURPOSE[0],
};
const labelInputDetails = labelInputDetailsForTrip(
fakeLabelUserInput,
Expand Down
6 changes: 3 additions & 3 deletions www/js/survey/multilabel/confirmHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ export function getLabelInputDetails(appConfigParam?) {
export function labelInputDetailsForTrip(userInputForTrip, appConfigParam?) {
if (appConfigParam) appConfig = appConfigParam;
if (appConfig.intro.mode_studied) {
if (userInputForTrip?.['MODE']?.value == appConfig.intro.mode_studied) {
logDebug(`Found trip labeled with mode of study, ${appConfig.intro.mode_studied}.
if (userInputForTrip?.['MODE']?.data?.label == appConfig.intro.mode_studied) {
logDebug(`Found trip labeled with ${userInputForTrip?.['MODE']?.data?.label}, mode of study = ${appConfig.intro.mode_studied}.
Needs REPLACED_MODE`);
return getLabelInputDetails();
} else {
logDebug(`Found trip not labeled with mode of study, ${appConfig.intro.mode_studied}.
logDebug(`Found trip labeled with ${userInputForTrip?.['MODE']?.data?.label}, not labeled with mode of study = ${appConfig.intro.mode_studied}.
Doesn't need REPLACED_MODE`);
return baseLabelInputDetails;
}
Expand Down

0 comments on commit 958918d

Please sign in to comment.