From 05deb14b0f4d435bf499e79598724b96447d7304 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 4 Oct 2023 17:32:17 -0400 Subject: [PATCH 1/3] fix(util/ui): Display itins as list items of no itin active and url param is full. --- __tests__/util/ui.ts | 22 ++++++++++++++++++---- lib/util/ui.ts | 4 ++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/__tests__/util/ui.ts b/__tests__/util/ui.ts index 0dfadfbf1..a36473017 100644 --- a/__tests__/util/ui.ts +++ b/__tests__/util/ui.ts @@ -11,15 +11,29 @@ describe('util > ui', () => { ItineraryView.LIST ) }) - it('returns a full itinerary view if URL contains ui_activeItinerary', () => { + it('returns a full itinerary view if URL contains ui_activeItinerary that is not -1', () => { expect(getItineraryView({ ui_activeItinerary: 2 })).toBe( ItineraryView.FULL ) }) - it('returns the specified view mode when set in URL', () => { - expect(getItineraryView({ ui_itineraryView: 'leg' })).toBe( - ItineraryView.LEG + it('returns an itinerary list view if URL contains ui_activeItinerary=-1 regardless of ui_itineraryView', () => { + expect(getItineraryView({ ui_activeItinerary: -1 })).toBe( + ItineraryView.LIST ) + expect( + getItineraryView({ + ui_activeItinerary: -1, + ui_itineraryView: ItineraryView.FULL + }) + ).toBe(ItineraryView.LIST) + }) + it('returns the specified view mode when set in URL', () => { + expect( + getItineraryView({ + ui_activeItinerary: 0, + ui_itineraryView: ItineraryView.LEG + }) + ).toBe(ItineraryView.LEG) }) }) }) diff --git a/lib/util/ui.ts b/lib/util/ui.ts index 60e1d4b0a..54dba6d99 100644 --- a/lib/util/ui.ts +++ b/lib/util/ui.ts @@ -110,6 +110,10 @@ export function getItineraryView({ ui_itineraryView }: UrlParams): ItineraryView { return ( + ((ui_activeItinerary === null || + ui_activeItinerary === undefined || + `${ui_activeItinerary}` === '-1') && + ItineraryView.LIST) || ui_itineraryView || (isDefinedAndNotEqual(ui_activeItinerary, -1) && ItineraryView.FULL) || ItineraryView.LIST From 50ade14667b150e35a86c39b3255eb69fd6844d4 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:00:12 -0400 Subject: [PATCH 2/3] fix(lib/api): Reset ui_itineraryView when settin active itin to -1. --- lib/actions/api.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/actions/api.js b/lib/actions/api.js index c4b0aad28..7a1b8b433 100644 --- a/lib/actions/api.js +++ b/lib/actions/api.js @@ -137,6 +137,8 @@ export function updateOtpUrlParams(state, searchId) { params.ui_activeSearch = searchId // Assumes this is a new search and the active itinerary should be reset. params.ui_activeItinerary = -1 + // At the same time, reset/delete the ui_itineraryView param. + params.ui_itineraryView = undefined if (config.itinerary?.showFirstResultByDefault) { dispatch(setVisibleItinerary({ index: 0 })) } From 391a36a0f3907bb87e29749bd38114009efbc488 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Thu, 5 Oct 2023 10:39:37 -0400 Subject: [PATCH 3/3] test(util/ui): Improve unit test. --- __tests__/util/ui.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/__tests__/util/ui.ts b/__tests__/util/ui.ts index a36473017..813f90d2e 100644 --- a/__tests__/util/ui.ts +++ b/__tests__/util/ui.ts @@ -17,15 +17,18 @@ describe('util > ui', () => { ) }) it('returns an itinerary list view if URL contains ui_activeItinerary=-1 regardless of ui_itineraryView', () => { - expect(getItineraryView({ ui_activeItinerary: -1 })).toBe( - ItineraryView.LIST - ) expect( getItineraryView({ ui_activeItinerary: -1, ui_itineraryView: ItineraryView.FULL }) ).toBe(ItineraryView.LIST) + expect( + getItineraryView({ + ui_activeItinerary: -1, + ui_itineraryView: ItineraryView.LEG + }) + ).toBe(ItineraryView.LIST) }) it('returns the specified view mode when set in URL', () => { expect(