Aniket Katkar c101c7cf30
Minor: Auto classification UI (#18785)
* Add the auto classification pipeline option in the service ingestion

* Localization changes for other languages

* Improve the logic for getSupportedPipelineTypes function and add unit tests for newly added logic

* Add playwright tests for the auto classification feature

* Improve the getSupportedPipelineTypes function logic to reduce the cognitive complexity

* update md docs

* Add classificationFilterPattern in the UI schema form order

* fix logs from backend for auto classification

* Changes to view the auto classification logs

* Fix the sonar errors

---------

Co-authored-by: Pere Miquel Brull <peremiquelbrull@gmail.com>
2024-11-27 14:51:59 +05:30

89 lines
2.9 KiB
TypeScript

/*
* Copyright 2024 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Page } from '@playwright/test';
import MysqlIngestionClass from '../support/entity/ingestion/MySqlIngestionClass';
import { getApiContext, toastNotification } from './common';
import { visitServiceDetailsPage } from './service';
export const addAndTriggerAutoClassificationPipeline = async (
page: Page,
mysqlService: MysqlIngestionClass
) => {
const { apiContext } = await getApiContext(page);
await visitServiceDetailsPage(
page,
{
type: mysqlService.category,
name: mysqlService.name,
displayName: mysqlService.name,
},
true
);
// Add auto classification ingestion
await page.click('[data-testid="ingestions"]');
await page.click('[data-testid="add-new-ingestion-button"]');
await page.waitForSelector('[data-menu-id*="autoClassification"]');
await page.click('[data-menu-id*="autoClassification"]');
// Fill the auto classification form details
await page.waitForSelector('#root\\/tableFilterPattern\\/includes');
await mysqlService.fillIngestionDetails(page);
await page.click('#root\\/enableAutoClassification');
await page.click('[data-testid="submit-btn"]');
// Make sure we create ingestion with None schedule to avoid conflict between Airflow and Argo behavior
await mysqlService.scheduleIngestion(page);
await page.click('[data-testid="view-service-button"]');
// Header available once page loads
await page.getByTestId('loader').waitFor({ state: 'detached' });
await page.getByTestId('ingestions').click();
await page
.getByLabel('Ingestions')
.getByTestId('loader')
.waitFor({ state: 'detached' });
const response = await apiContext
.get(
`/api/v1/services/ingestionPipelines?service=${encodeURIComponent(
mysqlService.name
)}&pipelineType=autoClassification&serviceType=databaseService&limit=1`
)
.then((res) => res.json());
// need manual wait to settle down the deployed pipeline, before triggering the pipeline
await page.waitForTimeout(3000);
await page.click(
`[data-row-key*="${response.data[0].name}"] [data-testid="more-actions"]`
);
await page.getByTestId('run-button').click();
await toastNotification(page, `Pipeline triggered successfully!`);
// need manual wait to make sure we are awaiting on latest run results
await page.waitForTimeout(2000);
await mysqlService.handleIngestionRetry('autoClassification', page);
};