From 72477bfec88eb75cff3ec5ce8eb8fd6754a8a032 Mon Sep 17 00:00:00 2001 From: brendan colloran Date: Tue, 12 Sep 2023 17:31:31 -0700 Subject: [PATCH] update tests to look for comparison API --- web-local/test/ui/dashboards.spec.ts | 5 +++-- web-local/test/ui/utils/dashboardHelpers.ts | 25 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/web-local/test/ui/dashboards.spec.ts b/web-local/test/ui/dashboards.spec.ts index f0d87c3bd0f..6b6f70d03ac 100644 --- a/web-local/test/ui/dashboards.spec.ts +++ b/web-local/test/ui/dashboards.spec.ts @@ -7,6 +7,7 @@ import { createDashboardFromModel, createDashboardFromSource, metricsViewRequestFilterMatcher, + waitForComparisonTopLists, waitForTimeSeries, waitForTopLists, } from "./utils/dashboardHelpers"; @@ -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); @@ -62,7 +63,7 @@ test.describe("dashboard", () => { ); await Promise.all([ waitForTimeSeries(page, "AdBids_model_dashboard", domainFilterMatcher), - waitForTopLists( + waitForComparisonTopLists( page, "AdBids_model_dashboard", ["domain"], diff --git a/web-local/test/ui/utils/dashboardHelpers.ts b/web-local/test/ui/utils/dashboardHelpers.ts index e7f45743525..3470c721575 100644 --- a/web-local/test/ui/utils/dashboardHelpers.ts +++ b/web-local/test/ui/utils/dashboardHelpers.ts @@ -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, + 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 }; /**