Skip to content

Commit

Permalink
cypress: fixed AUT failure part 5 (#13940)
Browse files Browse the repository at this point in the history
* cypress: fixed AUT failure part 5

* fixed cypress failure

* fixed team cypress

* fixed errorplace holder

(cherry picked from commit 48fd4f9)
  • Loading branch information
ShaileshParmar11 authored and chirag-madlani committed Nov 10, 2023
1 parent 5c5763a commit fc94db7
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 59 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 @@ -65,7 +65,7 @@ describe('Alerts page should work properly', () => {
.should('exist')
.and('be.visible')
.click();
interceptURL('GET', '/api/v1/events/subscriptions', 'alertsPage');
interceptURL('GET', '/api/v1/events/subscriptions?*', 'alertsPage');
cy.get('[data-testid="global-setting-left-panel"]')
.contains('Alerts')
.scrollIntoView()
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 @@ -437,7 +466,7 @@ describe('Data Quality and Profiler should work properly', () => {
const testCaseName = 'column_value_max_to_be_between';
interceptURL(
'GET',
'/api/v1/dataQuality/testSuites?fields=*&testSuiteType=logical',
'/api/v1/dataQuality/testSuites?*testSuiteType=logical*',
'testSuite'
);
interceptURL(
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 @@ -296,7 +296,7 @@ describe('Teams flow should work properly', () => {
cy.get('[data-testid="leave-team-button"]').click();

// //Click on confirm button
cy.get('[data-testid="save-button"]').should('be.visible').click();
cy.get('.ant-modal-footer').contains('Confirm').click();

toastNotification('Left the team successfully');

Expand All @@ -319,17 +319,11 @@ describe('Teams flow should work properly', () => {
cy.get('[data-testid="team-heading"]')
.should('be.visible')
.contains(TEAM_DETAILS.updatedName);
cy.get('[data-testid="manage-button"]')
.should('exist')
.should('be.visible')
.click();
cy.get('[data-testid="manage-button"]').click();

cy.get('[data-menu-id*="delete-button"]').should('be.visible');

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

cy.get('[data-testid="confirm-button"]')
.should('exist')
Expand All @@ -345,16 +339,15 @@ describe('Teams flow should work properly', () => {

interceptURL('DELETE', '/api/v1/teams/*', 'softDeleteTeam');

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

verifyResponseStatusCode('@softDeleteTeam', 200);

// Verify the toast message
toastNotification('Team deleted successfully!');

cy.get('[data-testid="settings-left-panel"]').contains('Teams').click();

// Check if soft deleted team is shown when 'Deleted Teams' switch is on
cy.get('table').should('not.contain', TEAM_DETAILS.name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ describe('RedShift Ingestion', () => {
// Verify DBT tags
interceptURL(
'GET',
`/api/v1/tags?fields=usageCount&parent=${DBT.classification}&limit=10`,
`/api/v1/tags?*parent=${DBT.classification}*`,
'getTagList'
);
cy.get('[data-testid="governance"]')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,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 @@ -96,6 +97,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 fc94db7

Please sign in to comment.