Minor: fixed edit test suite pipeline issue (#16984)

This commit is contained in:
Shailesh Parmar 2024-07-10 16:33:59 +05:30 committed by GitHub
parent e736324e4d
commit 3a9e0973fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 139 additions and 19 deletions

View File

@ -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();
});

View File

@ -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`, {
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: `${this.entityResponseData['fullyQualifiedName']}_test_suite`,
name: `pw-test-suite-pipeline-${uuid()}`,
pipelineType: 'TestSuite',
service: {
id: testSuiteData.id,
id: this.testSuiteResponseData?.['id'],
type: 'testSuite',
},
sourceConfig: {
config: {
type: 'TestSuite',
entityFullyQualifiedName:
this.entityResponseData['fullyQualifiedName'],
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) {

View File

@ -201,7 +201,10 @@ export const AddTestCaseList = ({
{getEntityName(test)}
</Typography.Paragraph>
<Checkbox checked={selectedItems?.has(test.id ?? '')} />
<Checkbox
checked={selectedItems?.has(test.id ?? '')}
data-testid={`checkbox-${test.name}`}
/>
</Space>
<Typography.Paragraph
className="m-0 w-max-500"

View File

@ -120,7 +120,7 @@ const TestSuiteIngestionPage = () => {
const handleAddTestSubmit = (testCases: TestCase[]) => {
const testCaseNames = testCases.map((testCase) => testCase.name);
setTestCases((pre) => uniq([...pre, ...testCaseNames]));
setTestCases(uniq(testCaseNames));
setActiveServiceStep(2);
};