From 3a9e0973fe27125da9ba6335ec66825926646e03 Mon Sep 17 00:00:00 2001 From: Shailesh Parmar Date: Wed, 10 Jul 2024 16:33:59 +0530 Subject: [PATCH] Minor: fixed edit test suite pipeline issue (#16984) --- .../Features/TestSuiteMultiPipeline.spec.ts | 69 ++++++++++++++++ .../playwright/support/entity/TableClass.ts | 82 +++++++++++++++---- .../AddTestCaseList.component.tsx | 5 +- .../TestSuiteIngestionPage.tsx | 2 +- 4 files changed, 139 insertions(+), 19 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/TestSuiteMultiPipeline.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/TestSuiteMultiPipeline.spec.ts index a3bacfdeef2..3848344d369 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/TestSuiteMultiPipeline.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/TestSuiteMultiPipeline.spec.ts @@ -151,3 +151,72 @@ test('TestSuite multi pipeline support', async ({ page }) => { await table.delete(apiContext); await afterAction(); }); + +test("Edit the pipeline's test case", async ({ page }) => { + test.slow(true); + + await redirectToHomePage(page); + const { apiContext, afterAction } = await getApiContext(page); + const table = new TableClass(); + await table.create(apiContext); + for (let index = 0; index < 4; index++) { + await table.createTestCase(apiContext); + } + const testCaseNames = [ + table.testCasesResponseData[0]?.['name'], + table.testCasesResponseData[1]?.['name'], + ]; + const pipeline = await table.createTestSuitePipeline( + apiContext, + testCaseNames + ); + await table.visitEntityPage(page); + await page.getByText('Profiler & Data Quality').click(); + await page.getByRole('menuitem', { name: 'Data Quality' }).click(); + + await page.getByRole('tab', { name: 'Pipeline' }).click(); + await page + .getByRole('row', { + name: new RegExp(pipeline?.['name']), + }) + .getByTestId('edit') + .click(); + + for (const testCaseName of testCaseNames) { + await expect(page.getByTestId(`checkbox-${testCaseName}`)).toBeChecked(); + } + + await page.getByTestId(`checkbox-${testCaseNames[0]}`).click(); + + await expect( + page.getByTestId(`checkbox-${testCaseNames[0]}`) + ).not.toBeChecked(); + + await page.getByTestId('submit').click(); + await page.getByTestId('deploy-button').click(); + await page.waitForSelector('[data-testid="body-text"]', { + state: 'detached', + }); + + await expect(page.getByTestId('success-line')).toContainText( + /has been updated and deployed successfully/ + ); + + await page.getByTestId('view-service-button').click(); + + await page.getByRole('tab', { name: 'Pipeline' }).click(); + await page + .getByRole('row', { + name: new RegExp(pipeline?.['name']), + }) + .getByTestId('edit') + .click(); + + await expect( + page.getByTestId(`checkbox-${testCaseNames[0]}`) + ).not.toBeChecked(); + await expect(page.getByTestId(`checkbox-${testCaseNames[1]}`)).toBeChecked(); + + await table.delete(apiContext); + await afterAction(); +}); diff --git a/openmetadata-ui/src/main/resources/ui/playwright/support/entity/TableClass.ts b/openmetadata-ui/src/main/resources/ui/playwright/support/entity/TableClass.ts index 38f7167f0b5..8130f043742 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/support/entity/TableClass.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/support/entity/TableClass.ts @@ -99,6 +99,9 @@ export class TableClass extends EntityClass { databaseResponseData: unknown; schemaResponseData: unknown; entityResponseData: unknown; + testSuiteResponseData: unknown; + testSuitePipelineResponseData: unknown[] = []; + testCasesResponseData: unknown[] = []; constructor(name?: string) { super(EntityTypeEndpoint.Table); @@ -160,7 +163,7 @@ export class TableClass extends EntityClass { async createTestSuiteAndPipelines(apiContext: APIRequestContext) { if (!this.entityResponseData) { - return Promise.reject('Entity not created'); + return this.create(apiContext); } const testSuiteData = await apiContext @@ -174,24 +177,69 @@ export class TableClass extends EntityClass { }) .then((res) => res.json()); - await apiContext.post(`/api/v1/services/ingestionPipelines`, { - data: { - airflowConfig: {}, - name: `${this.entityResponseData['fullyQualifiedName']}_test_suite`, - pipelineType: 'TestSuite', - service: { - id: testSuiteData.id, - type: 'testSuite', - }, - sourceConfig: { - config: { - type: 'TestSuite', - entityFullyQualifiedName: - this.entityResponseData['fullyQualifiedName'], + this.testSuiteResponseData = testSuiteData; + + const pipeline = await this.createTestSuitePipeline(apiContext); + + return { + testSuiteData, + pipeline, + }; + } + + async createTestSuitePipeline( + apiContext: APIRequestContext, + testCases?: string[] + ) { + const pipelineData = await apiContext + .post(`/api/v1/services/ingestionPipelines`, { + data: { + airflowConfig: {}, + name: `pw-test-suite-pipeline-${uuid()}`, + pipelineType: 'TestSuite', + service: { + id: this.testSuiteResponseData?.['id'], + type: 'testSuite', + }, + sourceConfig: { + config: { + type: 'TestSuite', + entityFullyQualifiedName: + this.entityResponseData?.['fullyQualifiedName'], + testCases, + }, }, }, - }, - }); + }) + .then((res) => res.json()); + this.testSuitePipelineResponseData.push(pipelineData); + + return pipelineData; + } + + async createTestCase(apiContext: APIRequestContext) { + if (!this.testSuiteResponseData) { + await this.createTestSuiteAndPipelines(apiContext); + } + + const testCase = await apiContext + .post('/api/v1/dataQuality/testCases', { + data: { + name: `pw-test-case-${uuid()}`, + entityLink: `<#E::table::${this.entityResponseData?.['fullyQualifiedName']}>`, + testDefinition: 'tableRowCountToBeBetween', + testSuite: this.testSuiteResponseData?.['fullyQualifiedName'], + parameterValues: [ + { name: 'minValue', value: 12 }, + { name: 'maxValue', value: 34 }, + ], + }, + }) + .then((res) => res.json()); + + this.testCasesResponseData.push(testCase); + + return testCase; } async delete(apiContext: APIRequestContext) { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/AddTestCaseList/AddTestCaseList.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/AddTestCaseList/AddTestCaseList.component.tsx index 059723a4981..1db8330ca6e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/AddTestCaseList/AddTestCaseList.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/AddTestCaseList/AddTestCaseList.component.tsx @@ -201,7 +201,10 @@ export const AddTestCaseList = ({ {getEntityName(test)} - + { const handleAddTestSubmit = (testCases: TestCase[]) => { const testCaseNames = testCases.map((testCase) => testCase.name); - setTestCases((pre) => uniq([...pre, ...testCaseNames])); + setTestCases(uniq(testCaseNames)); setActiveServiceStep(2); };