Skip to content

Commit

Permalink
cypress: fixed AUT failure part 5
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaileshParmar11 committed Nov 10, 2023
1 parent ba35e1e commit 89976a9
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {
DATABASE_DETAILS,
DATABASE_SERVICE_DETAILS,
SCHEMA_DETAILS,
} from '../constants/entityConstant';
import { uuid } from './common';

/**
* create full hierarchy of database service (service > database > schema > tables)
*/
Expand Down Expand Up @@ -112,3 +120,25 @@ export const hardDeleteService = ({ serviceFqn, token, serviceType }) => {
});
});
};

export const generateRandomTable = () => {
const id = uuid();
const name = `cypress-table-${id}`;

const table = {
name,
description: `cypress-table-description-${id}`,
displayName: name,
columns: [
{
name: `cypress-column-${id}`,
description: `cypress-column-description-${id}`,
dataType: 'NUMERIC',
dataTypeDisplay: 'numeric',
},
],
databaseSchema: `${DATABASE_SERVICE_DETAILS.name}.${DATABASE_DETAILS.name}.${SCHEMA_DETAILS.name}`,
};

return table;
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,64 @@ import {
verifyResponseStatusCode,
visitEntityDetailsPage,
} from '../../common/common';
import { SEARCH_ENTITY_TABLE } from '../../constants/constants';
import {
createEntityTable,
generateRandomTable,
hardDeleteService,
} from '../../common/entityUtils';
import { MYDATA_SUMMARY_OPTIONS } from '../../constants/constants';
import { DATABASE_SERVICE } from '../../constants/entityConstant';
import { SERVICE_CATEGORIES } from '../../constants/service.constants';

const queryTable = {
term: DATABASE_SERVICE.tables.name,
displayName: DATABASE_SERVICE.tables.name,
entity: MYDATA_SUMMARY_OPTIONS.tables,
serviceName: DATABASE_SERVICE.service.name,
entityType: 'Table',
};
const table1 = generateRandomTable();
const table2 = generateRandomTable();

const DATA = {
...SEARCH_ENTITY_TABLE.table_5,
query: `select * from table ${SEARCH_ENTITY_TABLE.table_5.term}`,
...queryTable,
query: `select * from table ${queryTable.term}`,
description: 'select all the field from table',
owner: 'Aaron Johnson',
tag: 'Personal',
queryUsedIn: {
table1: 'dim_address_clean',
table2: 'raw_product_catalog',
table1: table1.name,
table2: table2.name,
},
};

describe('Query Entity', () => {
before(() => {
cy.login();
cy.getAllLocalStorage().then((data) => {
const token = Object.values(data)[0].oidcIdToken;

createEntityTable({
token,
...DATABASE_SERVICE,
tables: [DATABASE_SERVICE.tables, table1, table2],
});
});
});

after(() => {
cy.login();
cy.getAllLocalStorage().then((data) => {
const token = Object.values(data)[0].oidcIdToken;

hardDeleteService({
token,
serviceFqn: DATABASE_SERVICE.service.name,
serviceType: SERVICE_CATEGORIES.DATABASE_SERVICES,
});
});
});

beforeEach(() => {
cy.login();
cy.get("[data-testid='welcome-screen-close-btn']").click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
verifyResponseStatusCode,
visitEntityDetailsPage,
} from '../../common/common';
import { searchServiceFromSettingPage } from '../../common/serviceUtils';
import {
API_SERVICE,
DATA_QUALITY_SAMPLE_DATA_TABLE,
Expand Down Expand Up @@ -59,6 +60,33 @@ const goToProfilerTab = () => {

cy.get('[data-testid="profiler"]').should('be.visible').click();
};
const clickOnTestSuite = (testSuiteName) => {
cy.get('[data-testid="test-suite-container"]').then(($body) => {
if ($body.find(`[data-testid="${testSuiteName}"]`).length) {
cy.get(`[data-testid="${testSuiteName}"]`).scrollIntoView().click();
} else {
if ($body.find('[data-testid="next"]').length) {
cy.get('[data-testid="next"]').click();
verifyResponseStatusCode('@testSuite', 200);
clickOnTestSuite(testSuiteName);
} else {
throw new Error('Test Suite not found');
}
}
});
};
const visitTestSuiteDetailsPage = (testSuiteName) => {
interceptURL(
'GET',
'/api/v1/dataQuality/testSuites?*testSuiteType=logical*',
'testSuite'
);
interceptURL('GET', '/api/v1/dataQuality/testCases?fields=*', 'testCase');
cy.get('[data-testid="app-bar-item-data-quality"]').click();
cy.get('[data-testid="by-test-suites"]').click();
verifyResponseStatusCode('@testSuite', 200);
clickOnTestSuite(testSuiteName);
};

describe('Data Quality and Profiler should work properly', () => {
beforeEach(() => {
Expand Down Expand Up @@ -108,6 +136,7 @@ describe('Data Quality and Profiler should work properly', () => {
'/api/v1/system/config/pipeline-service-client',
'airflow'
);
searchServiceFromSettingPage(serviceName);
cy.get(`[data-testid="service-name-${serviceName}"]`)
.should('exist')
.click();
Expand Down Expand Up @@ -474,23 +503,14 @@ describe('Data Quality and Profiler should work properly', () => {
'/api/v1/search/query?q=*&index=test_case_search_index*',
'searchTestCase'
);
interceptURL(
'GET',
'/api/v1/dataQuality/testSuites?fields=*&testSuiteType=logical',
'testSuite'
);
interceptURL('GET', '/api/v1/dataQuality/testCases?fields=*', 'testCase');
interceptURL(
'PUT',
'/api/v1/dataQuality/testCases/logicalTestCases',
'putTestCase'
);
cy.get('[data-testid="app-bar-item-data-quality"]').click();
cy.get('[data-testid="by-test-suites"]').click();
verifyResponseStatusCode('@testSuite', 200);
cy.get('[data-testid="test-suite-container"]')
.contains(NEW_TEST_SUITE.name)
.click();

visitTestSuiteDetailsPage(NEW_TEST_SUITE.name);

cy.get('[data-testid="add-test-case-btn"]').click();
verifyResponseStatusCode('@testCase', 200);
Expand All @@ -506,11 +526,6 @@ describe('Data Quality and Profiler should work properly', () => {
});

it('Remove test case from logical test suite', () => {
interceptURL(
'GET',
'/api/v1/dataQuality/testSuites?fields=*&testSuiteType=logical',
'testSuite'
);
interceptURL('GET', '/api/v1/dataQuality/testCases?fields=*', 'testCase');
interceptURL(
'GET',
Expand All @@ -522,12 +537,7 @@ describe('Data Quality and Profiler should work properly', () => {
'/api/v1/dataQuality/testCases/logicalTestCases/*/*',
'removeTestCase'
);
cy.get('[data-testid="app-bar-item-data-quality"]').click();
cy.get('[data-testid="by-test-suites"]').click();
verifyResponseStatusCode('@testSuite', 200);
cy.get('[data-testid="test-suite-container"]')
.contains(NEW_TEST_SUITE.name)
.click();
visitTestSuiteDetailsPage(NEW_TEST_SUITE.name);
verifyResponseStatusCode('@testSuitePermission', 200);
verifyResponseStatusCode('@testCase', 200);

Expand All @@ -541,17 +551,7 @@ describe('Data Quality and Profiler should work properly', () => {
});

it('Delete test suite', () => {
interceptURL(
'GET',
'/api/v1/dataQuality/testSuites?fields=*&testSuiteType=logical',
'testSuite'
);
cy.get('[data-testid="app-bar-item-data-quality"]').click();
cy.get('[data-testid="by-test-suites"]').click();
verifyResponseStatusCode('@testSuite', 200);
cy.get('[data-testid="test-suite-container"]')
.contains(NEW_TEST_SUITE.name)
.click();
visitTestSuiteDetailsPage(NEW_TEST_SUITE.name);

cy.get('[data-testid="manage-button"]').should('be.visible').click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Object.entries(SERVICE_DETAILS_FOR_VERSION_TEST).map(

interceptURL(
'GET',
`/api/v1/services/${serviceDetails.serviceCategory}/name/${serviceDetails.serviceName}`,
`/api/v1/services/${serviceDetails.serviceCategory}/name/${serviceDetails.serviceName}?*`,
`getServiceDetails`
);
interceptURL(
Expand Down Expand Up @@ -206,7 +206,7 @@ Object.entries(SERVICE_DETAILS_FOR_VERSION_TEST).map(

interceptURL(
'GET',
`/api/v1/services/${serviceDetails.serviceCategory}/name/${serviceDetails.serviceName}`,
`/api/v1/services/${serviceDetails.serviceCategory}/name/${serviceDetails.serviceName}?*`,
`get${serviceType}Details`
);
interceptURL(
Expand Down Expand Up @@ -266,7 +266,7 @@ Object.entries(SERVICE_DETAILS_FOR_VERSION_TEST).map(

interceptURL(
'GET',
`/api/v1/services/${serviceDetails.serviceCategory}/name/${serviceDetails.serviceName}`,
`/api/v1/services/${serviceDetails.serviceCategory}/name/${serviceDetails.serviceName}?*`,
`get${serviceType}Details`
);
interceptURL(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ export const TestSuites = ({ summaryPanel }: { summaryPanel: ReactNode }) => {
title: t('label.name'),
dataIndex: 'name',
key: 'name',
render: (_, record) => {
render: (name, record) => {
return record.executable ? (
<Link
data-testid={name}
to={{
pathname: getTableTabPath(
encodeURIComponent(
Expand All @@ -91,6 +92,7 @@ export const TestSuites = ({ summaryPanel }: { summaryPanel: ReactNode }) => {
</Link>
) : (
<Link
data-testid={name}
to={getTestSuitePath(
encodeURIComponent(record.fullyQualifiedName ?? record.name)
)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ const TagsForm = ({
pattern: ENTITY_NAME_REGEX,
message: t('message.entity-name-validation'),
},
{ type: 'string', min: 2, max: 64 },
{
type: 'string',
min: 2,
max: 64,
message: t('message.entity-size-must-be-between-2-and-64', {
entity: t('label.name'),
}),
},
],
props: {
'data-testid': 'name',
Expand Down

0 comments on commit 89976a9

Please sign in to comment.