Skip to content

Commit

Permalink
chore(ui): typescript support for cypress tests (#15239)
Browse files Browse the repository at this point in the history
* chore(ui): typescript support for cypress tests

* convert all js to ts

* fix more types

* fix more types

* updated config for ts file

* fixed failing cypress test

* fixed DQ cypress

* fixed dq flaky test

---------

Co-authored-by: Shailesh Parmar <[email protected]>
  • Loading branch information
chirag-madlani and ShaileshParmar11 authored Mar 7, 2024
1 parent 1a3ba7f commit 78d6b72
Show file tree
Hide file tree
Showing 80 changed files with 1,332 additions and 1,754 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ import {
verifyResponseStatusCode,
} from './common';

// eslint-disable-next-line spaced-comment
/// <reference types="cypress" />

export const deleteAlertSteps = (name) => {
export const deleteAlertSteps = (name: string) => {
cy.get('table').should('contain', name).click();
cy.get(`[data-testid="alert-delete-${name}"]`).click();
cy.get('.ant-modal-header').should(
Expand All @@ -38,8 +35,8 @@ export const deleteAlertSteps = (name) => {
};

export const addOwnerFilter = (
filterNumber,
ownerName,
filterNumber: number,
ownerName: string,
exclude = false,
selectId = 'Owner'
) => {
Expand Down Expand Up @@ -67,8 +64,8 @@ export const addOwnerFilter = (
};

export const addEntityFQNFilter = (
filterNumber,
entityFQN,
filterNumber: number,
entityFQN: string,
exclude = false,
selectId = 'Entity FQN'
) => {
Expand Down Expand Up @@ -96,8 +93,8 @@ export const addEntityFQNFilter = (
};

export const addEventTypeFilter = (
filterNumber,
eventType,
filterNumber: number,
eventType: string,
exclude = false
) => {
// Select event type filter
Expand Down Expand Up @@ -128,9 +125,9 @@ export const addEventTypeFilter = (
};

export const addFilterWithUsersListInput = (
filterTestId,
filterNumber,
updaterName,
filterTestId: string,
filterNumber: number,
updaterName: string,
exclude = false
) => {
// Select updater name filter
Expand All @@ -157,7 +154,11 @@ export const addFilterWithUsersListInput = (
}
};

export const addDomainFilter = (filterNumber, domainName, exclude = false) => {
export const addDomainFilter = (
filterNumber: number,
domainName: string,
exclude = false
) => {
// Select domain filter
cy.get(`[data-testid="filter-select-${filterNumber}"]`).click({
waitForAnimations: true,
Expand All @@ -179,7 +180,7 @@ export const addDomainFilter = (filterNumber, domainName, exclude = false) => {
}
};

export const addGMEFilter = (filterNumber, exclude = false) => {
export const addGMEFilter = (filterNumber: number, exclude = false) => {
// Select general metadata events filter
cy.get(`[data-testid="filter-select-${filterNumber}"]`).click({
waitForAnimations: true,
Expand All @@ -197,11 +198,11 @@ export const addGMEFilter = (filterNumber, exclude = false) => {
};

export const addInternalDestination = (
destinationNumber,
category,
type,
typeId,
searchText
destinationNumber: number,
category: string,
type: string,
typeId?: string,
searchText?: string
) => {
// Select destination category
cy.get(`[data-testid="destination-category-select-${destinationNumber}"]`)
Expand Down Expand Up @@ -258,7 +259,11 @@ export const addInternalDestination = (
);
};

export const addExternalDestination = (destinationNumber, category, input) => {
export const addExternalDestination = (
destinationNumber: number,
category: string,
input: string
) => {
// Select destination category
cy.get(`[data-testid="destination-category-select-${destinationNumber}"]`)
.scrollIntoView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// eslint-disable-next-line spaced-comment
/// <reference types="cypress" />

import { GlobalSettingOptions } from '../constants/settings.constant';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ class EntityClass {
addDomainToEntity(domainDetails1.displayName);
}

validateDomainVersionForEntity() {}

updateDomain() {
addDomainToEntity(domainDetails2.displayName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// eslint-disable-next-line spaced-comment
/// <reference types="cypress" />

import { DELETE_TERM } from '../constants/constants';
import { SidebarItem } from '../constants/Entity.interface';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ import { SERVICE_TYPE } from '../../constants/constants';
import { EntityType } from '../../constants/Entity.interface';
import {
checkServiceFieldSectionHighlighting,
handleIngestionRetry,
interceptURL,
scheduleIngestion,
verifyResponseStatusCode,
} from '../common';
import ServiceBaseClass from '../Entities/ServiceBaseClass';
import { visitServiceDetailsPage } from '../serviceUtils';
import { visitEntityDetailsPage } from '../Utils/Entity';
import { handleIngestionRetry, scheduleIngestion } from '../Utils/Ingestion';
import { Services } from '../Utils/Services';

class PostgresIngestionClass extends ServiceBaseClass {
Expand Down Expand Up @@ -137,7 +136,7 @@ class PostgresIngestionClass extends ServiceBaseClass {
verifyResponseStatusCode('@serviceDetails', 200);
verifyResponseStatusCode('@ingestionPipelines', 200);

handleIngestionRetry('database', true, 0, 'usage');
handleIngestionRetry(0, 'usage');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ import { REDSHIFT } from '../../constants/service.constants';
import { GlobalSettingOptions } from '../../constants/settings.constant';
import {
checkServiceFieldSectionHighlighting,
handleIngestionRetry,
interceptURL,
scheduleIngestion,
verifyResponseStatusCode,
} from '../common';
import ServiceBaseClass from '../Entities/ServiceBaseClass';
import { searchServiceFromSettingPage } from '../serviceUtils';
import { visitEntityDetailsPage } from '../Utils/Entity';
import { handleIngestionRetry, scheduleIngestion } from '../Utils/Ingestion';
import { Services } from '../Utils/Services';

class RedshiftWithDBTIngestionClass extends ServiceBaseClass {
Expand Down Expand Up @@ -188,7 +187,7 @@ class RedshiftWithDBTIngestionClass extends ServiceBaseClass {
verifyResponseStatusCode('@getIngestionPipelineStatus', 200);
verifyResponseStatusCode('@serviceDetails', 200);
verifyResponseStatusCode('@ingestionPipelines', 200);
handleIngestionRetry('database', true, 0, 'dbt');
handleIngestionRetry(0, 'dbt');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ const owner = 'admin';
const assignee = 'adam.matthews2';
const secondAssignee = 'aaron_johnson0';

export const verifyTaskDetails = (regexPattern) => {
export type TaskDetails = {
assignee: string;
term: string;
displayName?: string;
entity?: string;
serviceName?: string;
entityType?: string;
schemaName?: string;
};

export const verifyTaskDetails = (regexPattern: RegExp) => {
cy.get('#task-panel').should('be.visible');
cy.get('[data-testid="task-title"]')
.invoke('text')
Expand Down Expand Up @@ -61,7 +71,10 @@ export const editAssignee = () => {
cy.get(`[data-testid="${assignee}"]`).should('be.visible');
};

export const createDescriptionTask = (value, assigneeDisabled) => {
export const createDescriptionTask = (
value: TaskDetails,
assigneeDisabled?: boolean
) => {
interceptURL('POST', 'api/v1/feed', 'createTask');

cy.get('#title').should(
Expand Down Expand Up @@ -98,7 +111,7 @@ export const createDescriptionTask = (value, assigneeDisabled) => {
toastNotification('Task created successfully.');
};

export const createAndUpdateDescriptionTask = (value) => {
export const createAndUpdateDescriptionTask = (value: TaskDetails) => {
createDescriptionTask(value);

// verify the task details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@
* limitations under the License.
*/

import { SEARCH_ENTITY_TABLE } from '../constants/constants';
import { SidebarItem } from '../constants/Entity.interface';
import { SidebarItem } from '../../constants/Entity.interface';
import {
DATABASE_DETAILS,
DATABASE_SERVICE_DETAILS,
SCHEMA_DETAILS,
TABLE_DETAILS,
} from '../constants/EntityConstant';
import { USER_CREDENTIALS } from '../constants/SearchIndexDetails.constants';
import { interceptURL, uuid, verifyResponseStatusCode } from './common';
import { createEntityTable } from './EntityUtils';
import { visitEntityDetailsPage } from './Utils/Entity';
} from '../../constants/EntityConstant';
import { USER_CREDENTIALS } from '../../constants/SearchIndexDetails.constants';
import { interceptURL, uuid, verifyResponseStatusCode } from '../common';
import { createEntityTable } from '../EntityUtils';
import { visitEntityDetailsPage } from './Entity';

export const ADVANCE_SEARCH_TABLES = {
table1: TABLE_DETAILS,
Expand Down Expand Up @@ -189,10 +188,10 @@ export const OPERATOR = {
};

export const searchForField = (
condition,
fieldId,
searchCriteria,
index,
condition: string,
fieldId: string,
searchCriteria: string,
index: number,
isLocalSearch = false
) => {
if (!isLocalSearch) {
Expand Down Expand Up @@ -248,12 +247,12 @@ export const goToAdvanceSearch = () => {
};

export const checkmustPaths = (
condition,
field,
searchCriteria,
index,
responseSearch,
isLocalSearch
condition: string,
field: string,
searchCriteria: string,
index: number,
responseSearch: string,
isLocalSearch: boolean
) => {
goToAdvanceSearch();

Expand Down Expand Up @@ -309,95 +308,6 @@ export const checkmust_notPaths = (
});
};

export const removeOwner = () => {
visitEntityDetailsPage({
term: SEARCH_ENTITY_TABLE.table_1.term,
serviceName: SEARCH_ENTITY_TABLE.table_1.serviceName,
entity: SEARCH_ENTITY_TABLE.table_1.entity,
});
interceptURL(
'PATCH',
`/api/v1/${SEARCH_ENTITY_TABLE.table_1.entity}/*`,
'patchOwner'
);
cy.get('[data-testid="edit-owner"]').click();
cy.get('[data-testid="remove-owner"]').click();
verifyResponseStatusCode('@patchOwner', 200);
cy.get('[data-testid="owner-link"]').should('contain', 'No Owner');
};

export const addOwner = ({ ownerName, term, serviceName, entity }) => {
visitEntityDetailsPage({
term,
serviceName,
entity,
});

interceptURL(
'GET',
'/api/v1/search/query?q=**%20AND%20teamType:Group&from=0&size=25&index=team_search_index&sort_field=displayName.keyword&sort_order=asc',
'waitForTeams'
);

cy.get('[data-testid="edit-owner"]').click();

verifyResponseStatusCode('@waitForTeams', 200);
interceptURL('GET', '/api/v1/users?limit=25&isBot=false', 'getUsers');

cy.get('.ant-tabs [id*=tab-users]').click();
verifyResponseStatusCode('@getUsers', 200);

interceptURL(
'GET',
`api/v1/search/query?q=*${encodeURI(ownerName)}*`,
'searchOwner'
);

cy.get('[data-testid="owner-select-users-search-bar"]').type(ownerName);

verifyResponseStatusCode('@searchOwner', 200);

interceptURL('PATCH', '/api/v1/tables/*', 'tablePatch');

// Selecting the user
cy.get(`[title="${ownerName}"]`)
.should('exist')
.scrollIntoView()
.and('be.visible')
.click();

verifyResponseStatusCode('@tablePatch', 200);

cy.get('[data-testid="owner-link"]')
.scrollIntoView()
.invoke('text')
.then((text) => {
expect(text).equal(ownerName);
});
};

export const addTier = ({ term, serviceName, entity }) => {
visitEntityDetailsPage({
term,
serviceName,
entity,
});

cy.get('[data-testid="edit-tier"]')
.scrollIntoView()
.should('exist')
.should('be.visible')
.click();

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

cy.get('[data-testid="tier-dropdown"]').should('contain', 'Tier1');
};

export const addTag = ({ tag, term, serviceName, entity }) => {
visitEntityDetailsPage({
term,
Expand Down Expand Up @@ -689,7 +599,7 @@ export const checkAddRuleWithOperator = (
});
};

export const advanceSearchPreRequests = (token) => {
export const advanceSearchPreRequests = (token: string) => {
// Create Table hierarchy

createEntityTable({
Expand Down
Loading

0 comments on commit 78d6b72

Please sign in to comment.