Skip to content

Commit

Permalink
update tests to look for comparison API
Browse files Browse the repository at this point in the history
  • Loading branch information
bcolloran committed Sep 13, 2023
1 parent 0903622 commit 72477bf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
5 changes: 3 additions & 2 deletions web-local/test/ui/dashboards.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
createDashboardFromModel,
createDashboardFromSource,
metricsViewRequestFilterMatcher,
waitForComparisonTopLists,
waitForTimeSeries,
waitForTopLists,

Check failure on line 12 in web-local/test/ui/dashboards.spec.ts

View workflow job for this annotation

GitHub Actions / build

'waitForTopLists' is defined but never used
} from "./utils/dashboardHelpers";
Expand Down Expand Up @@ -48,7 +49,7 @@ test.describe("dashboard", () => {
true
),
waitForTimeSeries(page, "AdBids_model_dashboard"),
waitForTopLists(page, "AdBids_model_dashboard", ["domain"]),
waitForComparisonTopLists(page, "AdBids_model_dashboard", ["domain"]),
createDashboardFromModel(page, "AdBids_model"),
]);
await assertAdBidsDashboard(page);
Expand All @@ -62,7 +63,7 @@ test.describe("dashboard", () => {
);
await Promise.all([
waitForTimeSeries(page, "AdBids_model_dashboard", domainFilterMatcher),
waitForTopLists(
waitForComparisonTopLists(
page,
"AdBids_model_dashboard",
["domain"],
Expand Down
25 changes: 25 additions & 0 deletions web-local/test/ui/utils/dashboardHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,31 @@ export async function waitForTopLists(
);
}

/**
* Waits for a set of top list queries to end.
* Optionally takes a filter matcher: {@link metricsViewRequestFilterMatcher}.
*/
export async function waitForComparisonTopLists(
page: Page,
metricsView: string,
dimensions: Array<string>,
filterMatcher?: RequestMatcher
) {
const topListUrlRegex = new RegExp(
`/metrics-views/${metricsView}/compare-toplist`
);
await Promise.all(
dimensions.map((dimension) =>
page.waitForResponse(
(response) =>
topListUrlRegex.test(response.url()) &&
response.request().postDataJSON().dimensionName === dimension &&
(filterMatcher ? filterMatcher(response) : true)
)
)
);
}

export type RequestMatcherFilter = { label: string; values: Array<unknown> };

/**
Expand Down

0 comments on commit 72477bf

Please sign in to comment.