Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaHegde committed Jan 17, 2025
1 parent 79ada46 commit a0dddab
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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/",
},
Expand All @@ -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",
},

{
Expand Down

0 comments on commit a0dddab

Please sign in to comment.