Skip to content

Commit

Permalink
Merge pull request #202 from giranm/release/v0.2.0-beta.0
Browse files Browse the repository at this point in the history
[Release] v0.2.0 beta.0
  • Loading branch information
giranm authored Aug 8, 2022
2 parents a8c2f41 + 79edf90 commit 15d1edb
Show file tree
Hide file tree
Showing 47 changed files with 3,763 additions and 2,293 deletions.
88 changes: 85 additions & 3 deletions cypress/integration/Settings/settings.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import moment from 'moment';
import 'moment/min/locales.min';

import {
faker,
} from '@faker-js/faker';

import {
acceptDisclaimer,
waitForIncidentTable,
updateUserLocale,
updateDefaultSinceDateLookback,
updateMaxIncidentsLimit,
updateAutoAcceptIncidentQuery,
manageIncidentTableColumns,
manageCustomAlertColumnDefinitions,
activateButton,
priorityNames,
} from '../../support/util/common';
Expand Down Expand Up @@ -54,15 +61,38 @@ describe('Manage Settings', { failFast: { enabled: false } }, () => {
});
});

it('Add columns to incident table', () => {
const columns = ['Teams', 'Num Alerts'];
it('Update max incidents limit', () => {
const maxIncidentsLimit = faker.datatype.number({ min: 200, max: 1000 });
updateMaxIncidentsLimit(maxIncidentsLimit);
cy.window()
.its('store')
.invoke('getState')
.then((state) => expect(
Number(state.settings.maxIncidentsLimit),
).to.equal(maxIncidentsLimit));
});

it('Update auto-accept incident query', () => {
[true, false].forEach((autoAcceptIncidentsQuery) => {
updateAutoAcceptIncidentQuery(autoAcceptIncidentsQuery);
cy.window()
.its('store')
.invoke('getState')
.then((state) => expect(
state.settings.autoAcceptIncidentsQuery,
).to.equal(autoAcceptIncidentsQuery));
});
});

it('Add standard columns to incident table', () => {
const columns = ['Teams', 'Num Alerts', 'Group', 'Component'];
manageIncidentTableColumns('add', columns);
columns.forEach((columnName) => {
cy.get(`[data-column-name="${columnName}"]`).scrollIntoView().should('be.visible');
});
});

it('Remove columns from incident table', () => {
it('Remove standard columns from incident table', () => {
const columns = ['Service', 'Latest Note'];
manageIncidentTableColumns('remove', columns);

Expand All @@ -74,6 +104,58 @@ describe('Manage Settings', { failFast: { enabled: false } }, () => {
});
});

it('Update and store incident column width correctly', () => {
const columnName = 'Status';
const targetColumn = 'Priority';
let newColumnWidth;

// Resize column by dragging header and find updated width
cy.get(`[data-column-name="${columnName}"] > div`).drag(
`[data-column-name="${targetColumn}"] > div`,
);
cy.get(`[data-column-name="${columnName}"]`)
.invoke('css', 'width')
.then((str) => {
newColumnWidth = parseInt(str, 10);
});

// Remove, re-add column, and ensure width has not been changed
manageIncidentTableColumns('remove', [columnName, targetColumn]);
manageIncidentTableColumns('add', [columnName]);
cy.get(`[data-column-name="${columnName}"]`)
.invoke('css', 'width')
.then((str) => {
expect(parseInt(str, 10)).to.equal(newColumnWidth);
});
});

it('Add valid custom alert column to incident table', () => {
const customAlertColumnDefinitions = ['Quote:details.quote'];
manageCustomAlertColumnDefinitions(customAlertColumnDefinitions);
manageIncidentTableColumns('add', customAlertColumnDefinitions);
customAlertColumnDefinitions.forEach((columnName) => {
const [header] = columnName.split(':');
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 invalid custom alert column to incident table', () => {
const customAlertColumnDefinitions = ['SOMEINVALIDCOLUMN'];
manageCustomAlertColumnDefinitions(customAlertColumnDefinitions);
manageIncidentTableColumns('add', customAlertColumnDefinitions);
customAlertColumnDefinitions.forEach((columnName) => {
const [header] = columnName.split(':');
cy.get(`[data-column-name="${header}"]`).scrollIntoView().should('be.visible');
cy.get(`[data-incident-header="${header}"][data-incident-row-cell-idx="0"]`).then(($el) => {
expect($el.text()).to.equal('Invalid JSON Path');
});
});
});

it('Clear local cache', () => {
cy.get('.settings-panel-dropdown').click();
cy.get('.dropdown-item').contains('Settings').click();
Expand Down
1 change: 1 addition & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ import './commands';
// require('./commands')

import 'cypress-fail-fast';
import '@4tw/cypress-drag-drop';
49 changes: 46 additions & 3 deletions cypress/support/util/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const runResponsePlay = (responsePlayName) => {
export const manageIncidentTableColumns = (desiredState = 'add', columns = []) => {
cy.get('.settings-panel-dropdown').click();
cy.get('.dropdown-item').contains('Settings').click();
cy.get('.nav-item').contains('Incident Table Columns').click();
cy.get('.nav-item').contains('Incident Table').click();

columns.forEach((columnName) => {
if (desiredState === 'add') {
Expand All @@ -206,8 +206,23 @@ export const manageIncidentTableColumns = (desiredState = 'add', columns = []) =
}
});

cy.get('.btn').contains('Update Columns').click();
checkActionAlertsModalContent('Updated incident table columns');
cy.get('.btn').contains('Update Incident Table').click();
checkActionAlertsModalContent('Updated incident table settings');
cy.get('.close').click();
};

export const manageCustomAlertColumnDefinitions = (customAlertColumnDefinitions) => {
cy.get('.settings-panel-dropdown').click();
cy.get('.dropdown-item').contains('Settings').click();
cy.get('.nav-item').contains('Incident Table').click();

cy.get('#alert-column-definition-select').click().type('{del}'); // Clear default example
customAlertColumnDefinitions.forEach((customAlertColumnDefinition) => {
cy.get('#alert-column-definition-select').click().type(`${customAlertColumnDefinition}{enter}`);
});

cy.get('.btn').contains('Update Incident Table').click();
checkActionAlertsModalContent('Updated incident table settings');
cy.get('.close').click();
};

Expand Down Expand Up @@ -237,6 +252,34 @@ export const updateDefaultSinceDateLookback = (tenor = '1 Day') => {
cy.reload();
};

export const updateMaxIncidentsLimit = (limit = 200) => {
cy.get('.settings-panel-dropdown').click();
cy.get('.dropdown-item').contains('Settings').click();
cy.get('.nav-item').contains('User Profile').click();

cy.get('#user-profile-max-incidents-limit-input').clear().type(`${limit}{enter}`);

cy.get('.btn').contains('Update User Profile').click();
checkActionAlertsModalContent('Updated user profile settings');
cy.get('.close').click();
};

export const updateAutoAcceptIncidentQuery = (autoAcceptIncidentsQuery = false) => {
cy.get('.settings-panel-dropdown').click();
cy.get('.dropdown-item').contains('Settings').click();
cy.get('.nav-item').contains('User Profile').click();

if (autoAcceptIncidentsQuery) {
cy.get('#user-profile-auto-accept-incident-query-checkbox').check({ force: true });
} else {
cy.get('#user-profile-auto-accept-incident-query-checkbox').uncheck({ force: true });
}

cy.get('.btn').contains('Update User Profile').click();
checkActionAlertsModalContent('Updated user profile settings');
cy.get('.close').click();
};

export const priorityNames = ['--', 'P5', 'P4', 'P3', 'P2', 'P1'];

/*
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['./cypress/'],
setupFiles: ['dotenv/config'],
setupFiles: ['dotenv/config', 'jest-canvas-mock'],
setupFilesAfterEnv: ['./setupTests.js'],
moduleDirectories: ['node_modules', 'src'],
moduleNameMapper: {
Expand Down
91 changes: 47 additions & 44 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
{
"name": "pd-live-react",
"homepage": "https://giranm.github.io/pd-live-react",
"version": "0.1.0-beta.0",
"version": "0.2.0-beta.0",
"private": true,
"dependencies": {
"@craco/craco": "7.0.0-alpha.3",
"@datadog/browser-rum": "^4.7.1",
"@fortawesome/fontawesome-svg-core": "^1.3.0",
"@fortawesome/free-brands-svg-icons": "^6.1.1",
"@fortawesome/free-regular-svg-icons": "^5.15.4",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/react-fontawesome": "^0.1.18",
"@datadog/browser-rum": "^4.16.1",
"@fortawesome/fontawesome-svg-core": "^6.1.2",
"@fortawesome/free-brands-svg-icons": "^6.1.2",
"@fortawesome/free-regular-svg-icons": "^6.1.2",
"@fortawesome/free-solid-svg-icons": "^6.1.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"@pagerduty/pdjs": "^2.2.3",
"@testing-library/jest-dom": "^5.16.3",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^12.1.5",
"@testing-library/user-event": "^14.3.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
"autoprefixer": "10.4.5",
"axios": "^0.26.0",
"autoprefixer": "10.4.8",
"axios": "^0.27.2",
"babel-eslint": "^10.1.0",
"bootstrap": "^4.6.0",
"bottleneck": "^2.19.5",
"date-fns": "^2.28.0",
"date-fns": "^2.29.1",
"enzyme": "^3.11.0",
"font-awesome": "^4.7.0",
"fuse.js": "^6.4.6",
"immer": "^9.0.6",
"fuse.js": "^6.6.2",
"immer": "^9.0.15",
"jsonpath-plus": "^7.0.0",
"lodash": "^4.17.21",
"mezr": "^0.6.2",
"moment": "^2.29.3",
"node-sass": "^6.0.1",
"moment": "^2.29.4",
"node-sass": "^7.0.1",
"react": "^17.0.2",
"react-bootstrap": "^1.6.4",
"react-datepicker": "^4.7.0",
"react-bootstrap": "^1.6.5",
"react-datepicker": "^4.8.0",
"react-dom": "^17.0.2",
"react-dual-listbox": "^2.2.0",
"react-inject-env": "^2.0.1",
"react-redux": "^7.2.8",
"react-redux": "^8.0.2",
"react-scripts": "5.0.1",
"react-select": "^4.3.1",
"react-table": "^7.7.0",
"react-window": "^1.8.6",
"redux": "^4.1.1",
"react-select": "^5.4.0",
"react-table": "^7.8.0",
"react-window": "^1.8.7",
"redux": "^4.2.0",
"redux-persist": "^6.0.0",
"redux-saga": "^1.1.3",
"styled-components": "^5.3.5",
"use-debounce": "^8.0.1",
"web-vitals": "^1.1.2"
"use-debounce": "^8.0.3",
"web-vitals": "^2.1.4"
},
"resolutions": {
"autoprefixer": "10.4.5"
Expand Down Expand Up @@ -86,36 +87,38 @@
]
},
"devDependencies": {
"@babel/preset-env": "^7.16.5",
"@4tw/cypress-drag-drop": "^2.2.1",
"@babel/preset-env": "^7.18.9",
"@babel/preset-react": "^7.16.7",
"@cypress/react": "5.12.4",
"@cypress/webpack-dev-server": "^1.8.0",
"@faker-js/faker": "^7.1.0",
"cy2": "^1.3.0",
"@cypress/webpack-dev-server": "^2.0.0",
"@faker-js/faker": "^7.3.0",
"cy2": "^2.0.0",
"cypress": "^9.2.1",
"cypress-fail-fast": "^3.4.1",
"cypress-fail-fast": "^5.0.0",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-config-react-app": "^7.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"genversion": "^3.0.2",
"gh-pages": "^3.2.3",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"genversion": "^3.1.1",
"gh-pages": "^4.0.0",
"html-webpack-plugin": "5",
"identity-obj-proxy": "^3.0.0",
"jest-canvas-mock": "^2.4.0",
"jest-location-mock": "^1.0.9",
"prettier": "^2.6.2",
"prettier-eslint": "^10.1.0",
"prettier-eslint-cli": "^5.0.1",
"prettier-eslint": "^15.0.1",
"prettier-eslint-cli": "^6.0.1",
"redux-mock-store": "^1.5.4",
"redux-saga-test-plan": "^4.0.4",
"resolve-url-loader": "^4.0.0",
"redux-saga-test-plan": "^4.0.5",
"resolve-url-loader": "^5.0.0",
"wait-on": "^6.0.1",
"yarn-audit-fix": "^9.3.1"
"yarn-audit-fix": "^9.3.3"
}
}
8 changes: 1 addition & 7 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ import {
import {
getEscalationPoliciesAsync as getEscalationPoliciesAsyncConnected,
} from 'redux/escalation_policies/actions';
import {
getExtensionsAsync as getExtensionsAsyncConnected,
} from 'redux/extensions/actions';
import {
getResponsePlaysAsync as getResponsePlaysAsyncConnected,
} from 'redux/response_plays/actions';
Expand Down Expand Up @@ -84,7 +81,6 @@ const App = ({
getPrioritiesAsync,
getUsersAsync,
getEscalationPoliciesAsync,
getExtensionsAsync,
getResponsePlaysAsync,
getLogEntriesAsync,
cleanRecentLogEntriesAsync,
Expand Down Expand Up @@ -113,10 +109,9 @@ const App = ({
getServicesAsync();
getTeamsAsync();
getEscalationPoliciesAsync();
getExtensionsAsync();
getResponsePlaysAsync();
getPrioritiesAsync();
// NB: Get Incidents and Notes are implicitly done from query now
// NB: Get incidents, notes, and alerts are implicitly done from query now
checkConnectionStatus();
}
}, [userAuthorized]);
Expand Down Expand Up @@ -204,7 +199,6 @@ const mapDispatchToProps = (dispatch) => ({
getPrioritiesAsync: () => dispatch(getPrioritiesAsyncConnected()),
getUsersAsync: () => dispatch(getUsersAsyncConnected()),
getEscalationPoliciesAsync: () => dispatch(getEscalationPoliciesAsyncConnected()),
getExtensionsAsync: () => dispatch(getExtensionsAsyncConnected()),
getResponsePlaysAsync: () => dispatch(getResponsePlaysAsyncConnected()),
getLogEntriesAsync: (since) => dispatch(getLogEntriesAsyncConnected(since)),
cleanRecentLogEntriesAsync: () => dispatch(cleanRecentLogEntriesAsyncConnected()),
Expand Down
Loading

0 comments on commit 15d1edb

Please sign in to comment.