Skip to content

Commit 7721a68

Browse files
committed
test(dq-dashboard): apply review feedback on CertificationFilter spec
1 parent 85d0973 commit 7721a68

2 files changed

Lines changed: 35 additions & 31 deletions

File tree

openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/DataQuality/CertificationFilter.spec.ts

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,27 @@
1010
* See the License for the specific language governing permissions and
1111
* limitations under the License.
1212
*/
13-
import test, { expect, Page, Request } from '@playwright/test';
13+
import test, { expect } from '@playwright/test';
1414
import { TableClass } from '../../../support/entity/TableClass';
1515
import { TagClass } from '../../../support/tag/TagClass';
1616
import { createNewPage } from '../../../utils/common';
17-
import { goToDataQualityDashboard } from '../../../utils/dataQuality';
17+
import {
18+
captureReports,
19+
goToDataQualityDashboard,
20+
} from '../../../utils/dataQuality';
1821
import { waitForAllLoadersToDisappear } from '../../../utils/entity';
1922

2023
test.use({
2124
storageState: 'playwright/.auth/admin.json',
2225
});
2326

24-
const certTable = new TableClass();
25-
const cert = new TagClass({ classification: 'Certification' });
27+
let certTable: TableClass;
28+
let cert: TagClass;
2629

2730
test.beforeAll('setup', async ({ browser }) => {
31+
certTable = new TableClass();
32+
cert = new TagClass({ classification: 'Certification' });
33+
2834
const { apiContext, afterAction } = await createNewPage(browser);
2935

3036
await cert.create(apiContext);
@@ -60,33 +66,6 @@ test.beforeAll('setup', async ({ browser }) => {
6066
await afterAction();
6167
});
6268

63-
test.afterAll('cleanup', async ({ browser }) => {
64-
const { apiContext, afterAction } = await createNewPage(browser);
65-
66-
await certTable.delete(apiContext);
67-
await cert.delete(apiContext);
68-
69-
await afterAction();
70-
});
71-
72-
function captureReports(
73-
page: Page
74-
): { url: string; q: string; index: string }[] {
75-
const captured: { url: string; q: string; index: string }[] = [];
76-
page.on('request', (req: Request) => {
77-
const url = req.url();
78-
if (url.includes('/dataQualityReport')) {
79-
const u = new URL(url);
80-
captured.push({
81-
url,
82-
q: u.searchParams.get('q') ?? '',
83-
index: u.searchParams.get('index') ?? '',
84-
});
85-
}
86-
});
87-
return captured;
88-
}
89-
9069
test('Certification filter is rendered between Tier and Tag in the filter row', async ({
9170
page,
9271
}) => {

openmetadata-ui/src/main/resources/ui/playwright/utils/dataQuality.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,3 +386,28 @@ export const verifyBundleSuitePageLoaded = async (
386386
)
387387
.toBe(expectedTestCaseCount);
388388
};
389+
390+
/** A `dataQualityReport` call captured for assertion in tests. */
391+
export type CapturedReport = { url: string; q: string; index: string };
392+
393+
/**
394+
* Subscribes to every `/dataQualityReport` request fired by the page and
395+
* returns a live array of (url, q, index). Useful for asserting which
396+
* indices were queried and what filter the dashboard sent.
397+
*/
398+
export function captureReports(page: Page): CapturedReport[] {
399+
const captured: CapturedReport[] = [];
400+
page.on('request', (req) => {
401+
const url = req.url();
402+
if (!url.includes('/dataQualityReport')) {
403+
return;
404+
}
405+
const u = new URL(url);
406+
captured.push({
407+
url,
408+
q: u.searchParams.get('q') ?? '',
409+
index: u.searchParams.get('index') ?? '',
410+
});
411+
});
412+
return captured;
413+
}

0 commit comments

Comments
 (0)