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

ESLint and Prettier updates #351

Merged
merged 7 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
44 changes: 29 additions & 15 deletions cypress/e2e/Incidents/incidents.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,7 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => {
removeColumns.map((column) => column[1]),
);

const addColumns = [
['Num Alerts', 'num_alerts'],
];
const addColumns = [['Num Alerts', 'num_alerts']];
manageIncidentTableColumns(
'add',
addColumns.map((column) => column[1]),
Expand All @@ -324,7 +322,9 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => {
.should('be.visible')
.should('contain', '1');

cy.get(`[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${incidentIdx}"]`).within(() => {
cy.get(
`[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${incidentIdx}"]`,
).within(() => {
cy.get('[aria-haspopup="dialog"]').realHover();
});

Expand All @@ -340,15 +340,19 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => {
it('Split/move alert from one incident to a new incident', () => {
const incidentIdx = 0;

cy.get(`[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${incidentIdx}"]`).within(() => {
cy.get(
`[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${incidentIdx}"]`,
).within(() => {
cy.get('[aria-haspopup="dialog"]').click();
});

selectAlert(0);

cy.get('#alerts-modal-move-btn').click();
cy.get('#alerts-modal-move-select').type('Move all selected alerts to one new incident{enter}');
cy.get('#alerts-modal-move-summary-input').clear().type('New incident created from split alert');
cy.get('#alerts-modal-move-summary-input')
.clear()
.type('New incident created from split alert');
cy.get('#alerts-modal-complete-move-btn').click();

checkActionAlertsModalContent('Alerts moved');
Expand All @@ -368,15 +372,19 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => {
waitForIncidentTable();
const incidentIdx = 0;

cy.get(`[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${incidentIdx}"]`).within(() => {
cy.get(
`[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${incidentIdx}"]`,
).within(() => {
cy.get('[aria-haspopup="dialog"]').should('be.visible').should('have.text', '2').click();
});

selectAlert(0);
selectAlert(1);

cy.get('#alerts-modal-move-btn').click();
cy.get('#alerts-modal-move-select').type('Move each selected alert to its own new incident{enter}');
cy.get('#alerts-modal-move-select').type(
'Move each selected alert to its own new incident{enter}',
);
cy.get('#alerts-modal-complete-move-btn').click();

checkActionAlertsModalContent('Alerts moved');
Expand All @@ -389,16 +397,20 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => {
selectIncident(targetIncidentIdx);

cy.get(`@selectedIncidentId_${targetIncidentIdx}`).then((incidentId) => {
cy.get(`[data-incident-header="Num Alerts"][data-incident-cell-id="${incidentId}"]`).within(() => {
cy.get('[aria-haspopup="dialog"]').should('be.visible').should('have.text', '1');
});
cy.get(`[data-incident-header="Num Alerts"][data-incident-cell-id="${incidentId}"]`).within(
() => {
cy.get('[aria-haspopup="dialog"]').should('be.visible').should('have.text', '1');
},
);

cy.get(`[data-incident-header="Title"][data-incident-cell-id="${incidentId}"]`).within(() => {
cy.get('a').invoke('text').as('targetIncidentTitle');
});
});

cy.get(`[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${sourceIncidentIdx}"]`).within(() => {
cy.get(
`[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${sourceIncidentIdx}"]`,
).within(() => {
cy.get('[aria-haspopup="dialog"]').should('be.visible').should('have.text', '1').click();
});

Expand All @@ -415,9 +427,11 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => {
waitForIncidentTable();

cy.get(`@selectedIncidentId_${targetIncidentIdx}`).then((incidentId) => {
cy.get(`[data-incident-header="Num Alerts"][data-incident-cell-id="${incidentId}"]`).within(() => {
cy.get('[aria-haspopup="dialog"]').should('be.visible').should('have.text', '2');
});
cy.get(`[data-incident-header="Num Alerts"][data-incident-cell-id="${incidentId}"]`).within(
() => {
cy.get('[aria-haspopup="dialog"]').should('be.visible').should('have.text', '2');
},
);
});

// Tidy up by resolving the incident with two alerts
Expand Down
30 changes: 22 additions & 8 deletions cypress/e2e/Search/search.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,17 @@ describe('Search Incidents', { failFast: { enabled: false } }, () => {
cy.wait(1000);
cy.get('[data-incident-header="Latest Note"]').each(($el) => {
// cy.wrap($el).should('have.text', 'foobar');
cy.wrap($el).find('*').should((subElements) => {
const elementWithFoobar = subElements.toArray().find((el) => el.textContent.includes('foobar'));
assert.isNotNull(elementWithFoobar, 'Expected to find a subelement containing "foobar"');
});
cy.wrap($el)
.find('*')
.should((subElements) => {
const elementWithFoobar = subElements
.toArray()
.find((el) => el.textContent.includes('foobar'));
assert.isNotNull(
elementWithFoobar,
'Expected to find a subelement containing "foobar"',
);
});
});
});
cy.get('#global-search-input').clear();
Expand All @@ -95,10 +102,17 @@ describe('Search Incidents', { failFast: { enabled: false } }, () => {
cy.get('#global-search-input').clear().type('foobaz');
cy.wait(1000);
cy.get('[data-incident-header="Latest Note"]').each(($el) => {
cy.wrap($el).find('*').should((subElements) => {
const elementWithFoobar = subElements.toArray().find((el) => el.textContent.includes('foobar'));
assert.isNotNull(elementWithFoobar, 'Expected to find a subelement containing "foobar"');
});
cy.wrap($el)
.find('*')
.should((subElements) => {
const elementWithFoobar = subElements
.toArray()
.find((el) => el.textContent.includes('foobar'));
assert.isNotNull(
elementWithFoobar,
'Expected to find a subelement containing "foobar"',
);
});
});
});
cy.get('#global-search-input').clear();
Expand Down
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ module.exports = {
'^.+\\.(js|jsx|ts|tsx|mjs)$': 'babel-jest',
'^.+\\.svg$': 'jest-transformer-svg',
},
transformIgnorePatterns: ['/node_modules/(?!(somePkg)|react-dnd|dnd-core|@react-dnd|jsonpath-plus)'],
transformIgnorePatterns: [
'/node_modules/(?!(somePkg)|react-dnd|dnd-core|@react-dnd|jsonpath-plus)',
],
};
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"dotenv": "^16.3.1",
"eslint": "^8.43.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.8.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-react-app": "^7.0.1",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-cypress": "^2.14.0",
Expand All @@ -138,9 +138,9 @@
"jest-environment-node": "^29.7.0",
"jest-location-mock": "^1.0.10",
"jest-transformer-svg": "^2.0.1",
"prettier": "^2.8.0",
"prettier-eslint": "^15.0.1",
"prettier-eslint-cli": "^7.1.0",
"prettier": "^3.1.0",
"prettier-eslint": "^16.1.2",
"prettier-eslint-cli": "^8.0.1",
"redux-mock-store": "^1.5.4",
"redux-saga-test-plan": "^4.0.6",
"sass": "^1.66.1",
Expand Down
13 changes: 8 additions & 5 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,14 @@ const App = () => {

// Setup log entry clearing
useEffect(() => {
const clearingInterval = setInterval(() => {
if (userAuthorized) {
cleanRecentLogEntriesAsync();
}
}, 60 * 60 * 1000);
const clearingInterval = setInterval(
() => {
if (userAuthorized) {
cleanRecentLogEntriesAsync();
}
},
60 * 60 * 1000,
);
return () => clearInterval(clearingInterval);
}, [userAuthorized]);

Expand Down
11 changes: 6 additions & 5 deletions src/components/IncidentActions/subcomponents/PriorityMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ const PriorityMenu = () => {
dispatch(updatePriorityConnected(incidents, priorityId));
};

const enabled = useMemo(() => (
selectedRows.length > 0
&& Array.isArray(abilities)
&& !abilities.includes('disable_edit_priority')
), [selectedRows]);
const enabled = useMemo(
() => selectedRows.length > 0
&& Array.isArray(abilities)
&& !abilities.includes('disable_edit_priority'),
[selectedRows],
);

return (
<Menu>
Expand Down
14 changes: 11 additions & 3 deletions src/components/IncidentTable/IncidentTableComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ import {
} from 'react-window';

import {
useTable, useSortBy, useRowSelect, useBlockLayout, useResizeColumns, useFilters,
useTable,
useSortBy,
useRowSelect,
useBlockLayout,
useResizeColumns,
useFilters,
} from 'react-table';

import {
Expand Down Expand Up @@ -290,7 +295,9 @@ const IncidentTableComponent = () => {
<Checkbox
m={0}
id="select-all"
isIndeterminate={!tableInstance.isAllRowsSelected && tableInstance.selectedFlatRows.length > 0}
isIndeterminate={
!tableInstance.isAllRowsSelected && tableInstance.selectedFlatRows.length > 0
}
isChecked={tableInstance.isAllRowsSelected}
{...getToggleAllRowsSelectedProps()}
/>
Expand Down Expand Up @@ -380,7 +387,8 @@ const IncidentTableComponent = () => {
if (inView) {
if (
!row.original.alerts
|| (Array.isArray(row.original.alerts) && row.original.alerts.length !== row.original.alert_counts?.all)
|| (Array.isArray(row.original.alerts)
&& row.original.alerts.length !== row.original.alert_counts?.all)
) {
getIncidentAlerts(row.original.id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
} from '@chakra-ui/react';

import {
IoFunnel,
IoFunnelOutline,
IoFunnel, IoFunnelOutline,
} from 'react-icons/io5';

import {
Expand Down
26 changes: 6 additions & 20 deletions src/components/IncidentTable/subcomponents/GetAllModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,19 @@ const GetAllModal = ({
const rowsFetching = useMemo(
() => rowsToExport.filter((row) => {
const {
alerts,
notes,
alerts, notes,
} = row.original;
return (
(alerts && alerts.status === 'fetching')
|| (notes && notes.status === 'fetching')
);
return (alerts && alerts.status === 'fetching') || (notes && notes.status === 'fetching');
}),
[rowsToExport],
);

const rowsDoneFetching = useMemo(
() => rowsToExport.filter((row) => {
const {
alerts,
notes,
alerts, notes,
} = row.original;
return (
(alerts && alerts instanceof Array)
&& (notes && notes instanceof Array)
);
return alerts && alerts instanceof Array && notes && notes instanceof Array;
}),
[rowsToExport],
);
Expand All @@ -79,9 +71,7 @@ const GetAllModal = ({
const fetchRows = useCallback(() => {
rowsNeedingFetch.forEach((row) => {
const {
id,
notes,
alerts,
id, notes, alerts,
} = row.original;
if (!notes) {
getIncidentNotes(id);
Expand Down Expand Up @@ -128,11 +118,7 @@ const GetAllModal = ({
<Text fontSize="sm" fontWeight="bold">
{`${rowsFetching.length} remaining`}
</Text>
<Progress
min={0}
value={rowsDoneFetching.length}
max={rowsToExport.length}
/>
<Progress min={0} value={rowsDoneFetching.length} max={rowsToExport.length} />
</Box>
<Text fontSize="sm" mt={6}>
You can close this box and continue using the app, download will continue in the
Expand Down
Loading