diff --git a/web-common/src/features/dashboards/stores/test-data/data.ts b/web-common/src/features/dashboards/stores/test-data/data.ts index 79a329a1d99..78b67a82ab8 100644 --- a/web-common/src/features/dashboards/stores/test-data/data.ts +++ b/web-common/src/features/dashboards/stores/test-data/data.ts @@ -242,7 +242,7 @@ export const AD_BIDS_PRESET: V1ExplorePreset = { compareTimeRange: "rill-PP", measures: [AD_BIDS_IMPRESSIONS_MEASURE], dimensions: [AD_BIDS_PUBLISHER_DIMENSION], - exploreSortBy: AD_BIDS_BID_PRICE_MEASURE, + exploreSortBy: AD_BIDS_IMPRESSIONS_MEASURE, exploreSortAsc: true, exploreSortType: V1ExploreSortType.EXPLORE_SORT_TYPE_PERCENT, }; diff --git a/web-common/src/features/dashboards/stores/test-data/store-mutations.ts b/web-common/src/features/dashboards/stores/test-data/store-mutations.ts index d42319cb9cd..ff526992a59 100644 --- a/web-common/src/features/dashboards/stores/test-data/store-mutations.ts +++ b/web-common/src/features/dashboards/stores/test-data/store-mutations.ts @@ -147,11 +147,20 @@ export const AD_BIDS_SORT_DESC_BY_IMPRESSIONS: TestDashboardMutation = ( setLeaderboardMeasureName(mut, AD_BIDS_IMPRESSIONS_MEASURE); setSortDescending(mut); }; +export const AD_BIDS_SORT_ASC_BY_IMPRESSIONS: TestDashboardMutation = (mut) => { + setLeaderboardMeasureName(mut, AD_BIDS_IMPRESSIONS_MEASURE); + setSortDescending(mut); + toggleSort(mut, mut.dashboard.dashboardSortType); +}; export const AD_BIDS_SORT_ASC_BY_BID_PRICE: TestDashboardMutation = (mut) => { setLeaderboardMeasureName(mut, AD_BIDS_BID_PRICE_MEASURE); setSortDescending(mut); toggleSort(mut, mut.dashboard.dashboardSortType); }; +export const AD_BIDS_SORT_DESC_BY_BID_PRICE: TestDashboardMutation = (mut) => { + setLeaderboardMeasureName(mut, AD_BIDS_BID_PRICE_MEASURE); + setSortDescending(mut); +}; export const AD_BIDS_SORT_BY_VALUE: TestDashboardMutation = (mut) => { toggleSort(mut, DashboardState_LeaderboardSortType.VALUE); }; diff --git a/web-common/src/features/dashboards/url-state/convertURLToExplorePreset.ts b/web-common/src/features/dashboards/url-state/convertURLToExplorePreset.ts index e73504f3da0..8546eb4107e 100644 --- a/web-common/src/features/dashboards/url-state/convertURLToExplorePreset.ts +++ b/web-common/src/features/dashboards/url-state/convertURLToExplorePreset.ts @@ -390,7 +390,10 @@ function fromExploreUrlParams( if (searchParams.has(ExploreStateURLParams.SortBy)) { const sortBy = searchParams.get(ExploreStateURLParams.SortBy) as string; if (measures.has(sortBy)) { - if (preset.measures && preset.measures.includes(sortBy)) { + if ( + (preset.measures && preset.measures.includes(sortBy)) || + !preset.measures + ) { preset.exploreSortBy = sortBy; } else { errors.push( diff --git a/web-common/src/features/dashboards/url-state/url-state-variations.spec.ts b/web-common/src/features/dashboards/url-state/url-state-variations.spec.ts index 745e5e70f5c..39a14236842 100644 --- a/web-common/src/features/dashboards/url-state/url-state-variations.spec.ts +++ b/web-common/src/features/dashboards/url-state/url-state-variations.spec.ts @@ -29,9 +29,11 @@ import { AD_BIDS_SET_PREVIOUS_PERIOD_COMPARE_TIME_RANGE_FILTER, AD_BIDS_SET_PREVIOUS_WEEK_COMPARE_TIME_RANGE_FILTER, AD_BIDS_SORT_ASC_BY_BID_PRICE, + AD_BIDS_SORT_ASC_BY_IMPRESSIONS, AD_BIDS_SORT_BY_DELTA_ABS_VALUE, AD_BIDS_SORT_BY_PERCENT_VALUE, AD_BIDS_SORT_BY_VALUE, + AD_BIDS_SORT_DESC_BY_BID_PRICE, AD_BIDS_SORT_DESC_BY_IMPRESSIONS, AD_BIDS_SORT_PIVOT_BY_IMPRESSIONS_DESC, AD_BIDS_SORT_PIVOT_BY_TIME_DAY_ASC, @@ -198,7 +200,7 @@ const TestCases: { { title: "Leaderboard configs with preset and leaderboard sort measure in state same as preset", - mutations: [AD_BIDS_SORT_BY_PERCENT_VALUE, AD_BIDS_SORT_ASC_BY_BID_PRICE], + mutations: [AD_BIDS_SORT_BY_PERCENT_VALUE, AD_BIDS_SORT_ASC_BY_IMPRESSIONS], preset: AD_BIDS_PRESET, expectedUrl: "http://localhost/", }, @@ -207,11 +209,11 @@ const TestCases: { "Leaderboard configs with preset and leaderboard sort measure in state different than preset", mutations: [ AD_BIDS_SORT_BY_DELTA_ABS_VALUE, - AD_BIDS_SORT_DESC_BY_IMPRESSIONS, + AD_BIDS_SORT_DESC_BY_BID_PRICE, ], preset: AD_BIDS_PRESET, expectedUrl: - "http://localhost/?sort_by=impressions&sort_type=delta_abs&sort_dir=DESC", + "http://localhost/?sort_by=bid_price&sort_type=delta_abs&sort_dir=DESC", }, {