Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: Add cypress tests for data observability and notification alerts #14900

Merged
merged 5 commits into from
Jan 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add cypress tests for observability alert CRUD flow
aniketkatkar97 committed Jan 28, 2024
commit 71b07a5a11fd93526e275309075b46d2daf1d229
128 changes: 100 additions & 28 deletions openmetadata-ui/src/main/resources/ui/cypress/common/AlertUtils.js
Original file line number Diff line number Diff line change
@@ -38,12 +38,19 @@ export const deleteAlertSteps = (name) => {
toastNotification(`"${name}" deleted successfully!`);
};

export const addOwnerFilter = (filterNumber, ownerName, exclude = false) => {
export const addOwnerFilter = (
filterNumber,
ownerName,
exclude = false,
selectId = 'Owner'
) => {
// Select owner filter
cy.get(`[data-testid="filter-select-${filterNumber}"]`).click({
waitForAnimations: true,
});
cy.get('[data-testid="Owner-filter-option"]').filter(':visible').click();
cy.get(`[data-testid="${selectId}-filter-option"]`)
.filter(':visible')
.click();

// Search and select owner
cy.get('[data-testid="owner-name-select"]').click().type(ownerName);
@@ -62,13 +69,16 @@ export const addOwnerFilter = (filterNumber, ownerName, exclude = false) => {
export const addEntityFQNFilter = (
filterNumber,
entityFQN,
exclude = false
exclude = false,
selectId = 'Entity FQN'
) => {
// Select entity FQN filter
cy.get(`[data-testid="filter-select-${filterNumber}"]`).click({
waitForAnimations: true,
});
cy.get('[data-testid="Entity FQN-filter-option"]').filter(':visible').click();
cy.get(`[data-testid="${selectId}-filter-option"]`)
.filter(':visible')
.click();

// Search and select entity
cy.get('[data-testid="fqn-list-select"]').click().type(entityFQN);
@@ -216,30 +226,7 @@ export const addInternalDestination = (
);
};

export const verifyAlertDetails = (alertDetails) => {
const { name, description, filteringRules, input, destinations } =
alertDetails;

const triggerName = filteringRules.resources[0];
const filters = input.filters;

// Check created alert details
cy.get('[data-testid="alert-details-container"]').should('exist');

// Check alert name
cy.get('[data-testid="alert-name"]').should('contain', name);

if (description) {
// Check alert name
cy.get('[data-testid="alert-description"]').should('contain', description);
}

// Check trigger name
cy.get('[data-testid="resource-name"]').should(
'contain',
startCase(triggerName)
);

const checkActionOrFilterDetails = (filters) => {
if (!isEmpty(filters)) {
filters.forEach((filter) => {
// Check filter
@@ -269,6 +256,44 @@ export const verifyAlertDetails = (alertDetails) => {
}
});
}
};

export const verifyAlertDetails = (
alertDetails,
isObservabilityAlert = false
) => {
const { name, description, filteringRules, input, destinations } =
alertDetails;

const triggerName = filteringRules.resources[0];
const filters = input.filters;

// Check created alert details
cy.get('[data-testid="alert-details-container"]').should('exist');

// Check alert name
cy.get('[data-testid="alert-name"]').should('contain', name);

if (description) {
// Check alert name
cy.get('[data-testid="alert-description"]').should('contain', description);
}

// Check trigger name
cy.get('[data-testid="resource-name"]').should(
'contain',
startCase(triggerName)
);

// Check filter details
checkActionOrFilterDetails(filters);

if (isObservabilityAlert) {
const actions = input.actions;

// Check action details
checkActionOrFilterDetails(actions);
}

if (!isEmpty(destinations)) {
destinations.forEach((destination) => {
@@ -291,3 +316,50 @@ export const verifyAlertDetails = (alertDetails) => {
});
}
};

export const addGetSchemaChangesAction = (filterNumber, exclude = false) => {
// Select owner filter
cy.get(`[data-testid="action-select-${filterNumber}"]`).click({
waitForAnimations: true,
});
cy.get(`[data-testid="Get Schema Changes-filter-option"]`)
.filter(':visible')
.click();

if (exclude) {
// Change filter effect
cy.get(`[data-testid="filter-switch-${filterNumber}"]`)
.scrollIntoView()
.click();
}
};

export const addPipelineStatusUpdatesAction = (
filterNumber,
statusName,
exclude = false
) => {
// Select domain filter
cy.get(`[data-testid="action-select-${filterNumber}"]`).click({
waitForAnimations: true,
});
cy.get('[data-testid="Get Pipeline Status Updates-filter-option"]')
.filter(':visible')
.click();

// Search and select domain
cy.get('[data-testid="pipeline-status-select"]').click().type(statusName);
cy.get(`[title="${statusName}"]`).filter(':visible').scrollIntoView().click();
cy.get('[data-testid="pipeline-status-select"]').should(
'contain',
statusName
);
cy.clickOutside();

if (exclude) {
// Change filter effect
cy.get(`[data-testid="filter-switch-${filterNumber}"]`)
.scrollIntoView()
.click();
}
};
Original file line number Diff line number Diff line change
@@ -291,9 +291,11 @@ export const DASHBOARD_DATA_MODEL_DETAILS = {
],
dataModelType: 'SupersetDataModel',
};
const PIPELINE_NAME = `cypress-pipeline-${uuid()}`;

export const PIPELINE_DETAILS = {
name: `cypress-pipeline-${uuid()}`,
name: PIPELINE_NAME,
displayName: PIPELINE_NAME,
service: PIPELINE_SERVICE_DETAILS.name,
tasks: [{ name: 'snowflake_task' }],
};
Loading