Skip to content

Commit

Permalink
Add e2e test for adding computed columns
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Reynolds <[email protected]>
  • Loading branch information
gsreynolds committed Jul 12, 2024
1 parent 87e3b65 commit 0c355ed
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
23 changes: 18 additions & 5 deletions cypress/e2e/Settings/settings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
updateDarkMode,
updateRelativeDates,
manageIncidentTableColumns,
manageCustomAlertColumnDefinitions,
manageCustomColumnDefinitions,
checkIncidentCellContentAllRows,
checkActionAlertsModalContent,
} from '../../support/util/common';
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('Manage Settings', { failFast: { enabled: true } }, () => {

it('Add valid custom alert column to incident table', () => {
const customAlertColumnDefinitions = ['Quote:details.quote'];
manageCustomAlertColumnDefinitions(customAlertColumnDefinitions);
manageCustomColumnDefinitions(customAlertColumnDefinitions);
customAlertColumnDefinitions.forEach((columnName) => {
const header = columnName.split(':')[0];
cy.get(`[data-column-name="${header}"]`).scrollIntoView().should('be.visible');
Expand All @@ -154,9 +154,22 @@ describe('Manage Settings', { failFast: { enabled: true } }, () => {
});

it('Add valid custom alert column with JSON path containing spaces to incident table', () => {
const customAlertColumnDefinitions = ["Fav Flavour:details.['favorite ice cream flavor']"];
manageCustomAlertColumnDefinitions(customAlertColumnDefinitions);
customAlertColumnDefinitions.forEach((columnName) => {
const customColumnDefinitions = ["Fav Flavour:details.['favorite ice cream flavor']"];
manageCustomColumnDefinitions(customColumnDefinitions);
customColumnDefinitions.forEach((columnName) => {
const header = columnName.split(':')[0];
cy.get(`[data-column-name="${header}"]`).scrollIntoView().should('be.visible');
cy.get(`[data-incident-header="${header}"][data-incident-row-cell-idx="0"]`).then(($el) => {
// eslint-disable-next-line no-unused-expressions
expect($el.text()).to.exist;
});
});
});

it('Add valid custom computed column to incident table', () => {
const customColumnDefinitions = ['CI:first_trigger_log_entry.channel.details:(.*.example.com)'];
manageCustomColumnDefinitions(customColumnDefinitions, 'computed');
customColumnDefinitions.forEach((columnName) => {
const header = columnName.split(':')[0];
cy.get(`[data-column-name="${header}"]`).scrollIntoView().should('be.visible');
cy.get(`[data-incident-header="${header}"][data-incident-row-cell-idx="0"]`).then(($el) => {
Expand Down
10 changes: 7 additions & 3 deletions cypress/support/util/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,22 @@ export const manageIncidentTableColumns = (desiredState = 'add', columns = []) =
checkActionAlertsModalContent('Incident table columns saved');
};

export const manageCustomAlertColumnDefinitions = (customAlertColumnDefinitions) => {
export const manageCustomColumnDefinitions = (customColumnDefinitions, type = 'alert') => {
cy.get('.settings-panel-dropdown').click();
cy.get('.dropdown-item').contains('Columns').click();

cy.get('#custom-columns-card-body .chakra-icon').each(($el) => {
cy.wrap($el).click();
});

customAlertColumnDefinitions.forEach((customAlertColumnDefinition) => {
const [header, accessorPath] = customAlertColumnDefinition.split(':');
customColumnDefinitions.forEach((customAlertColumnDefinition) => {
const [header, accessorPath, expression] = customAlertColumnDefinition.split(':');
cy.get('#column-type-select').select(type);
cy.get('input[placeholder="Header"]').type(header);
cy.get('input[placeholder="JSON Path"]').type(accessorPath);
if (type === 'computed') {
cy.get('input[placeholder="Regex"]').type(expression);
}
cy.get('button[aria-label="Add custom column"]').click();
// Need to escape special characters in accessorPath
// https://docs.cypress.io/faq/questions/using-cypress-faq#How-do-I-use-special-characters-with-cyget
Expand Down

0 comments on commit 0c355ed

Please sign in to comment.