#15856 Error when creating test cases if the table contains the name COLUMN (#16195)

* #15856 Error when creating test cases if the table contains the name COLUMN

* chore: Update Cypress configuration to include all test files & fixed filter cypres
This commit is contained in:
Shailesh Parmar 2024-05-10 08:16:30 +05:30 committed by GitHub
parent e24e7cfd4b
commit fa66b55806
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 77 additions and 29 deletions

View File

@ -23,6 +23,13 @@ import {
} from '../constants/EntityConstant'; } from '../constants/EntityConstant';
import { uuid } from './common'; import { uuid } from './common';
type ColumnType = {
name: string;
description: string;
dataType: string;
dataTypeDisplay: string;
};
/** /**
* create full hierarchy of database service (service > database > schema > tables) * create full hierarchy of database service (service > database > schema > tables)
*/ */
@ -137,15 +144,19 @@ export const hardDeleteService = ({ serviceFqn, token, serviceType }) => {
}); });
}; };
export const generateRandomTable = () => { export const generateRandomTable = (
tableName?: string,
columns?: ColumnType[]
) => {
const id = uuid(); const id = uuid();
const name = `cypress-table-${id}`; const name = tableName ?? `cypress-table-${id}`;
const table = { const table = {
name, name,
description: `cypress-table-description-${id}`, description: `cypress-table-description-${id}`,
displayName: name, displayName: name,
columns: [ columns: [
...(columns ?? []),
{ {
name: `cypress-column-${id}`, name: `cypress-column-${id}`,
description: `cypress-column-description-${id}`, description: `cypress-column-description-${id}`,

View File

@ -41,6 +41,14 @@ const testCase2 = {
testSuite: testSuite.name, testSuite: testSuite.name,
}; };
const filterTable = generateRandomTable(); const filterTable = generateRandomTable();
const customTable = generateRandomTable(`cypress-table-${uuid()}-COLUMN`, [
{
name: `user_id`,
description: `cypress-column-description`,
dataType: 'STRING',
dataTypeDisplay: 'string',
},
]);
const filterTableFqn = `${filterTable.databaseSchema}.${filterTable.name}`; const filterTableFqn = `${filterTable.databaseSchema}.${filterTable.name}`;
const filterTableTestSuite = { const filterTableTestSuite = {
@ -57,6 +65,7 @@ export const DATA_QUALITY_TEST_CASE_DATA = {
testCase1, testCase1,
testCase2, testCase2,
filterTable, filterTable,
customTable,
filterTableTestCases: testCases, filterTableTestCases: testCases,
}; };

View File

@ -224,7 +224,6 @@ export const RECENT_SEARCH_TITLE = 'Recent Search Terms';
export const RECENT_VIEW_TITLE = 'Recent Views'; export const RECENT_VIEW_TITLE = 'Recent Views';
export const MY_DATA_TITLE = 'My Data'; export const MY_DATA_TITLE = 'My Data';
export const FOLLOWING_TITLE = 'Following'; export const FOLLOWING_TITLE = 'Following';
export const TEAM_ENTITY = 'alert_entity';
export const NO_SEARCHED_TERMS = 'No searched terms'; export const NO_SEARCHED_TERMS = 'No searched terms';
export const DELETE_TERM = 'DELETE'; export const DELETE_TERM = 'DELETE';
@ -251,7 +250,7 @@ export const NEW_TABLE_TEST_CASE = {
export const NEW_COLUMN_TEST_CASE = { export const NEW_COLUMN_TEST_CASE = {
name: 'id_column_value_lengths_to_be_between', name: 'id_column_value_lengths_to_be_between',
column: 'id', column: 'user_id',
type: 'columnValueLengthsToBeBetween', type: 'columnValueLengthsToBeBetween',
label: 'Column Value Lengths To Be Between', label: 'Column Value Lengths To Be Between',
min: '3', min: '3',
@ -261,7 +260,7 @@ export const NEW_COLUMN_TEST_CASE = {
export const NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE = { export const NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE = {
name: 'id_column_values_to_be_not_null', name: 'id_column_values_to_be_not_null',
column: 'id', column: 'user_id',
type: 'columnValuesToBeNotNull', type: 'columnValuesToBeNotNull',
label: 'Column Values To Be Not Null', label: 'Column Values To Be Not Null',
description: 'New table test case for columnValuesToBeNotNull', description: 'New table test case for columnValuesToBeNotNull',

View File

@ -40,18 +40,18 @@ import {
NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE, NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE,
NEW_TABLE_TEST_CASE, NEW_TABLE_TEST_CASE,
NEW_TEST_SUITE, NEW_TEST_SUITE,
TEAM_ENTITY,
} from '../../constants/constants'; } from '../../constants/constants';
import { EntityType, SidebarItem } from '../../constants/Entity.interface'; import { EntityType, SidebarItem } from '../../constants/Entity.interface';
import { DATABASE_SERVICE } from '../../constants/EntityConstant'; import { DATABASE_SERVICE } from '../../constants/EntityConstant';
import { SERVICE_CATEGORIES } from '../../constants/service.constants'; import { SERVICE_CATEGORIES } from '../../constants/service.constants';
import { GlobalSettingOptions } from '../../constants/settings.constant'; import { GlobalSettingOptions } from '../../constants/settings.constant';
const serviceName = `cypress-mysql`;
const OWNER1 = 'Aaron Johnson'; const OWNER1 = 'Aaron Johnson';
const OWNER2 = 'Cynthia Meyer'; const OWNER2 = 'Cynthia Meyer';
const { testCase1, testCase2, filterTable, filterTableTestCases } = const { testCase1, testCase2, filterTable, filterTableTestCases, customTable } =
DATA_QUALITY_TEST_CASE_DATA; DATA_QUALITY_TEST_CASE_DATA;
const TEAM_ENTITY = customTable.name;
const serviceName = DATABASE_SERVICE.service.name;
const goToProfilerTab = (data?: { service: string; entityName: string }) => { const goToProfilerTab = (data?: { service: string; entityName: string }) => {
interceptURL( interceptURL(
'GET', 'GET',
@ -111,7 +111,7 @@ describe(
createEntityTable({ createEntityTable({
token, token,
...DATABASE_SERVICE, ...DATABASE_SERVICE,
tables: [DATABASE_SERVICE.entity, filterTable], tables: [DATABASE_SERVICE.entity, filterTable, customTable],
}); });
prepareDataQualityTestCases(token); prepareDataQualityTestCases(token);
@ -143,13 +143,17 @@ describe(
}); });
it('Add Profiler ingestion', () => { it('Add Profiler ingestion', () => {
const data = {
entityName: 'alert_entity',
service: 'cypress-mysql',
};
interceptURL( interceptURL(
'POST', 'POST',
'/api/v1/services/ingestionPipelines/deploy/*', '/api/v1/services/ingestionPipelines/deploy/*',
'deployIngestion' 'deployIngestion'
); );
goToProfilerTab(); goToProfilerTab(data);
cy.get('[data-testid="no-profiler-placeholder"]').should('be.visible'); cy.get('[data-testid="no-profiler-placeholder"]').should('be.visible');
cy.clickOnLogo(); cy.clickOnLogo();
@ -162,8 +166,8 @@ describe(
'/api/v1/system/config/pipeline-service-client', '/api/v1/system/config/pipeline-service-client',
'airflow' 'airflow'
); );
searchServiceFromSettingPage(serviceName); searchServiceFromSettingPage(data.service);
cy.get(`[data-testid="service-name-${serviceName}"]`) cy.get(`[data-testid="service-name-${data.service}"]`)
.should('exist') .should('exist')
.click(); .click();
cy.get('[data-testid="tabs"]').should('exist'); cy.get('[data-testid="tabs"]').should('exist');
@ -204,16 +208,18 @@ describe(
}); });
it('Verifying profiler ingestion', () => { it('Verifying profiler ingestion', () => {
goToProfilerTab(); goToProfilerTab({
entityName: 'alert_entity',
service: 'cypress-mysql',
});
cy.get('[data-testid="no-profiler-placeholder"]').should('not.exist'); cy.get('[data-testid="no-profiler-placeholder"]').should('not.exist');
}); });
it('Add table test case', () => { it('Add table test case', () => {
const term = TEAM_ENTITY;
goToProfilerTab(); goToProfilerTab();
interceptURL( interceptURL(
'GET', 'GET',
`api/v1/tables/name/${serviceName}.*.${term}?include=all`, `api/v1/tables/name/${serviceName}.*.${TEAM_ENTITY}?include=all`,
'addTableTestPage' 'addTableTestPage'
); );
verifyResponseStatusCode('@systemProfile', 200); verifyResponseStatusCode('@systemProfile', 200);
@ -984,7 +990,7 @@ describe(
// Test case filter by test type // Test case filter by test type
interceptURL( interceptURL(
'GET', 'GET',
`/api/v1/dataQuality/testCases/search/list?*testCaseType=column*entityLink=*${filterTable.name}*`, `/api/v1/dataQuality/testCases/search/list?*testCaseType=column*`,
'testCaseTypeByColumn' 'testCaseTypeByColumn'
); );
cy.get('[data-testid="test-case-type-select-filter"]').click(); cy.get('[data-testid="test-case-type-select-filter"]').click();
@ -994,7 +1000,7 @@ describe(
interceptURL( interceptURL(
'GET', 'GET',
`/api/v1/dataQuality/testCases/search/list?*testCaseType=table*entityLink=*${filterTable.name}*`, `/api/v1/dataQuality/testCases/search/list?*testCaseType=table*`,
'testCaseTypeByTable' 'testCaseTypeByTable'
); );
cy.get('[data-testid="test-case-type-select-filter"]').click(); cy.get('[data-testid="test-case-type-select-filter"]').click();
@ -1009,7 +1015,7 @@ describe(
// Test case filter by status // Test case filter by status
interceptURL( interceptURL(
'GET', 'GET',
`/api/v1/dataQuality/testCases/search/list?*testCaseStatus=Success*entityLink=*${filterTable.name}*`, `/api/v1/dataQuality/testCases/search/list?*testCaseStatus=Success*`,
'testCaseStatusBySuccess' 'testCaseStatusBySuccess'
); );
cy.get('[data-testid="status-select-filter"]').click(); cy.get('[data-testid="status-select-filter"]').click();
@ -1019,7 +1025,7 @@ describe(
interceptURL( interceptURL(
'GET', 'GET',
`/api/v1/dataQuality/testCases/search/list?*testCaseStatus=Failed*entityLink=*${filterTable.name}*`, `/api/v1/dataQuality/testCases/search/list?*testCaseStatus=Failed*`,
'testCaseStatusByFailed' 'testCaseStatusByFailed'
); );
cy.get('[data-testid="status-select-filter"]').click(); cy.get('[data-testid="status-select-filter"]').click();
@ -1030,7 +1036,7 @@ describe(
// Test case filter by platform // Test case filter by platform
interceptURL( interceptURL(
'GET', 'GET',
`/api/v1/dataQuality/testCases/search/list?*testPlatforms=DBT*entityLink=*${filterTable.name}*`, `/api/v1/dataQuality/testCases/search/list?*testPlatforms=DBT*`,
'testCasePlatformByDBT' 'testCasePlatformByDBT'
); );
cy.get('[data-testid="platform-select-filter"]').click(); cy.get('[data-testid="platform-select-filter"]').click();
@ -1045,7 +1051,7 @@ describe(
interceptURL( interceptURL(
'GET', 'GET',
`/api/v1/dataQuality/testCases/search/list?*testPlatforms=OpenMetadata*entityLink=*${filterTable.name}*`, `/api/v1/dataQuality/testCases/search/list?*testPlatforms=OpenMetadata*`,
'testCasePlatformByOpenMetadata' 'testCasePlatformByOpenMetadata'
); );
cy.get('[data-testid="platform-select-filter"]').click(); cy.get('[data-testid="platform-select-filter"]').click();

View File

@ -18,6 +18,7 @@ const entityLinkWithColumn =
'<#E::table::sample_data.ecommerce_db.shopify.dim_address::columns::address_id::tags>'; '<#E::table::sample_data.ecommerce_db.shopify.dim_address::columns::address_id::tags>';
const entityLinkWithNestedColumn = const entityLinkWithNestedColumn =
'<#E::table::sample_data.ecommerce_db.shopify.dim_address::columns::"address_id.city"::tags>'; '<#E::table::sample_data.ecommerce_db.shopify.dim_address::columns::"address_id.city"::tags>';
const tableFqn = 'sample_data.ecommerce_db.shopify.dim_address';
describe('Test EntityLink', () => { describe('Test EntityLink', () => {
it('Should split the entityLink into parts', () => { it('Should split the entityLink into parts', () => {
@ -103,4 +104,30 @@ describe('Test EntityLink', () => {
'sample_data.ecommerce_db.shopify.dim_address."address_id.city"' 'sample_data.ecommerce_db.shopify.dim_address."address_id.city"'
); );
}); });
it('Should return the entity link for table without column name', () => {
const entityLink = EntityLink.getTableEntityLink(tableFqn);
expect(entityLink).toStrictEqual(
'<#E::table::sample_data.ecommerce_db.shopify.dim_address>'
);
});
it('Should return the entity link for table without column name, if empty string is pass', () => {
const columnName = '';
const entityLink = EntityLink.getTableEntityLink(tableFqn, columnName);
expect(entityLink).toStrictEqual(
'<#E::table::sample_data.ecommerce_db.shopify.dim_address>'
);
});
it('Should return the entity link for table with column name', () => {
const columnName = 'address_id';
const entityLink = EntityLink.getTableEntityLink(tableFqn, columnName);
expect(entityLink).toStrictEqual(
'<#E::table::sample_data.ecommerce_db.shopify.dim_address::columns::address_id>'
);
});
}); });

View File

@ -101,7 +101,7 @@ export default class EntityLink {
* @param string | undefined columnName * @param string | undefined columnName
* @returns entity link for table * @returns entity link for table
*/ */
static getTableEntityLink(tableFqn: string, columnName: string) { static getTableEntityLink(tableFqn: string, columnName?: string) {
if (columnName) { if (columnName) {
return `<#E${ENTITY_LINK_SEPARATOR}table${ENTITY_LINK_SEPARATOR}${tableFqn}${ENTITY_LINK_SEPARATOR}columns${ENTITY_LINK_SEPARATOR}${columnName}>`; return `<#E${ENTITY_LINK_SEPARATOR}table${ENTITY_LINK_SEPARATOR}${tableFqn}${ENTITY_LINK_SEPARATOR}columns${ENTITY_LINK_SEPARATOR}${columnName}>`;
} else { } else {

View File

@ -83,6 +83,7 @@ import {
getTableFQNFromColumnFQN, getTableFQNFromColumnFQN,
sortTagsCaseInsensitive, sortTagsCaseInsensitive,
} from './CommonUtils'; } from './CommonUtils';
import EntityLink from './EntityLink';
import serviceUtilClassBase from './ServiceUtilClassBase'; import serviceUtilClassBase from './ServiceUtilClassBase';
import { ordinalize } from './StringsUtils'; import { ordinalize } from './StringsUtils';
import { TableFieldsInfoCommonEntities } from './TableUtils.interface'; import { TableFieldsInfoCommonEntities } from './TableUtils.interface';
@ -410,18 +411,13 @@ export const getDataTypeString = (dataType: string): string => {
}; };
export const generateEntityLink = (fqn: string, includeColumn = false) => { export const generateEntityLink = (fqn: string, includeColumn = false) => {
const columnLink = '<#E::table::ENTITY_FQN::columns::COLUMN>';
const tableLink = '<#E::table::ENTITY_FQN>';
if (includeColumn) { if (includeColumn) {
const tableFqn = getTableFQNFromColumnFQN(fqn); const tableFqn = getTableFQNFromColumnFQN(fqn);
const columnName = getPartialNameFromTableFQN(fqn, [FqnPart.NestedColumn]); const columnName = getPartialNameFromTableFQN(fqn, [FqnPart.NestedColumn]);
return columnLink return EntityLink.getTableEntityLink(tableFqn, columnName);
.replace('ENTITY_FQN', tableFqn)
.replace('COLUMN', columnName);
} else { } else {
return tableLink.replace('ENTITY_FQN', fqn); return EntityLink.getTableEntityLink(fqn);
} }
}; };