Skip to content

Commit

Permalink
Update cypress (main) (#152647)
Browse files Browse the repository at this point in the history
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [cypress](https://togithub.com/cypress-io/cypress) | [`^12.6.0` ->
`^12.10.0`](https://renovatebot.com/diffs/npm/cypress/12.6.0/12.10.0) |
[![age](https://badges.renovateapi.com/packages/npm/cypress/12.10.0/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/npm/cypress/12.10.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/npm/cypress/12.10.0/compatibility-slim/12.6.0)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/npm/cypress/12.10.0/confidence-slim/12.6.0)](https://docs.renovatebot.com/merge-confidence/)
|
| [cypress-axe](https://togithub.com/component-driven/cypress-axe) |
[`^1.3.0` ->
`^1.4.0`](https://renovatebot.com/diffs/npm/cypress-axe/1.3.0/1.4.0) |
[![age](https://badges.renovateapi.com/packages/npm/cypress-axe/1.4.0/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/npm/cypress-axe/1.4.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/npm/cypress-axe/1.4.0/compatibility-slim/1.3.0)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/npm/cypress-axe/1.4.0/confidence-slim/1.3.0)](https://docs.renovatebot.com/merge-confidence/)
|
|
[cypress-multi-reporters](https://togithub.com/you54f/cypress-multi-reporters)
| [`^1.6.2` ->
`^1.6.3`](https://renovatebot.com/diffs/npm/cypress-multi-reporters/1.6.2/1.6.3)
|
[![age](https://badges.renovateapi.com/packages/npm/cypress-multi-reporters/1.6.3/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/npm/cypress-multi-reporters/1.6.3/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/npm/cypress-multi-reporters/1.6.3/compatibility-slim/1.6.2)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/npm/cypress-multi-reporters/1.6.3/confidence-slim/1.6.2)](https://docs.renovatebot.com/merge-confidence/)
|
| [cypress-recurse](https://togithub.com/bahmutov/cypress-recurse) |
[`^1.27.0` ->
`^1.31.2`](https://renovatebot.com/diffs/npm/cypress-recurse/1.27.0/1.31.2)
|
[![age](https://badges.renovateapi.com/packages/npm/cypress-recurse/1.31.2/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/npm/cypress-recurse/1.31.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/npm/cypress-recurse/1.31.2/compatibility-slim/1.27.0)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/npm/cypress-recurse/1.31.2/confidence-slim/1.27.0)](https://docs.renovatebot.com/merge-confidence/)
|
|
[eslint-plugin-cypress](https://togithub.com/cypress-io/eslint-plugin-cypress)
| [`^2.12.1` ->
`^2.13.2`](https://renovatebot.com/diffs/npm/eslint-plugin-cypress/2.12.1/2.13.2)
|
[![age](https://badges.renovateapi.com/packages/npm/eslint-plugin-cypress/2.13.2/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/npm/eslint-plugin-cypress/2.13.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/npm/eslint-plugin-cypress/2.13.2/compatibility-slim/2.12.1)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/npm/eslint-plugin-cypress/2.13.2/confidence-slim/2.12.1)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>cypress-io/cypress</summary>

###
[`v12.10.0`](https://togithub.com/cypress-io/cypress/releases/tag/v12.10.0)

[Compare
Source](https://togithub.com/cypress-io/cypress/compare/v12.9.0...v12.10.0)

Changelog:
https://docs.cypress.io/guides/references/changelog#&#8203;12-10-0

###
[`v12.9.0`](https://togithub.com/cypress-io/cypress/releases/tag/v12.9.0)

[Compare
Source](https://togithub.com/cypress-io/cypress/compare/v12.8.1...v12.9.0)

Changelog:
https://docs.cypress.io/guides/references/changelog#&#8203;12-9-0

###
[`v12.8.1`](https://togithub.com/cypress-io/cypress/releases/tag/v12.8.1)

[Compare
Source](https://togithub.com/cypress-io/cypress/compare/v12.8.0...v12.8.1)

Changelog:
https://docs.cypress.io/guides/references/changelog#&#8203;12-8-1

###
[`v12.8.0`](https://togithub.com/cypress-io/cypress/releases/tag/v12.8.0)

[Compare
Source](https://togithub.com/cypress-io/cypress/compare/v12.7.0...v12.8.0)

Changelog:
https://docs.cypress.io/guides/references/changelog#&#8203;12.8.0

###
[`v12.7.0`](https://togithub.com/cypress-io/cypress/releases/tag/v12.7.0)

[Compare
Source](https://togithub.com/cypress-io/cypress/compare/v12.6.0...v12.7.0)

Changelog:
https://docs.cypress.io/guides/references/changelog#&#8203;12.7.0

</details>

<details>
<summary>component-driven/cypress-axe</summary>

###
[`v1.4.0`](https://togithub.com/component-driven/cypress-axe/releases/tag/v1.4.0)

[Compare
Source](https://togithub.com/component-driven/cypress-axe/compare/v1.3.0...v1.4.0)

##### Features

- retry option
([#&#8203;151](https://togithub.com/component-driven/cypress-axe/issues/151))
([682ba11](https://togithub.com/component-driven/cypress-axe/commit/682ba11d1d52a00d08a828da25f8a033b67916e0))

</details>

<details>
<summary>bahmutov/cypress-recurse</summary>

###
[`v1.31.2`](https://togithub.com/bahmutov/cypress-recurse/releases/tag/v1.31.2)

[Compare
Source](https://togithub.com/bahmutov/cypress-recurse/compare/v1.31.1...v1.31.2)

##### Bug Fixes

- compute limit from timeout and delay, closes
[#&#8203;159](https://togithub.com/bahmutov/cypress-recurse/issues/159)
([ae325c9](https://togithub.com/bahmutov/cypress-recurse/commit/ae325c9436f7318e0cd6c34dc7e11c454b09f46e))

###
[`v1.31.1`](https://togithub.com/bahmutov/cypress-recurse/releases/tag/v1.31.1)

[Compare
Source](https://togithub.com/bahmutov/cypress-recurse/compare/v1.31.0...v1.31.1)

##### Bug Fixes

- yield value on time limit
([6a8af64](https://togithub.com/bahmutov/cypress-recurse/commit/6a8af6440055f89795931a9d65d4dbcae9149b26))

###
[`v1.31.0`](https://togithub.com/bahmutov/cypress-recurse/releases/tag/v1.31.0)

[Compare
Source](https://togithub.com/bahmutov/cypress-recurse/compare/v1.30.0...v1.31.0)

##### Features

- yield the last value
([#&#8203;158](https://togithub.com/bahmutov/cypress-recurse/issues/158))
([2a089f4](https://togithub.com/bahmutov/cypress-recurse/commit/2a089f4543c688c0683166d3e9788936d43463c5))

###
[`v1.30.0`](https://togithub.com/bahmutov/cypress-recurse/releases/tag/v1.30.0)

[Compare
Source](https://togithub.com/bahmutov/cypress-recurse/compare/v1.29.0...v1.30.0)

##### Bug Fixes

- include commands in the list of files
([3ce4aad](https://togithub.com/bahmutov/cypress-recurse/commit/3ce4aad9236bc1183cbcd4a88b6ec2ba34385485))

##### Features

- add optional custom command cy.recurse
([#&#8203;156](https://togithub.com/bahmutov/cypress-recurse/issues/156))
([8cb1a6f](https://togithub.com/bahmutov/cypress-recurse/commit/8cb1a6fb3f42f7e58dc458be34cb267464e09b01))

###
[`v1.29.0`](https://togithub.com/bahmutov/cypress-recurse/releases/tag/v1.29.0)

[Compare
Source](https://togithub.com/bahmutov/cypress-recurse/compare/v1.28.0...v1.29.0)

##### Features

- print better error message
([#&#8203;148](https://togithub.com/bahmutov/cypress-recurse/issues/148))
([6dfb97e](https://togithub.com/bahmutov/cypress-recurse/commit/6dfb97e48f6aa4bebcad16daf145e98bc63fedd4))

###
[`v1.28.0`](https://togithub.com/bahmutov/cypress-recurse/releases/tag/v1.28.0)

[Compare
Source](https://togithub.com/bahmutov/cypress-recurse/compare/v1.27.1...v1.28.0)

##### Features

- add do not fail option
([#&#8203;146](https://togithub.com/bahmutov/cypress-recurse/issues/146))
([4621825](https://togithub.com/bahmutov/cypress-recurse/commit/46218259d1adefce91f2bc2c73c0276b928db7d2))

###
[`v1.27.1`](https://togithub.com/bahmutov/cypress-recurse/releases/tag/v1.27.1)

[Compare
Source](https://togithub.com/bahmutov/cypress-recurse/compare/v1.27.0...v1.27.1)

##### Bug Fixes

- put labels on the logs
([#&#8203;145](https://togithub.com/bahmutov/cypress-recurse/issues/145))
([2fa4dea](https://togithub.com/bahmutov/cypress-recurse/commit/2fa4dea883129d650a4b5730ec69cc40783fae56))

</details>

<details>
<summary>cypress-io/eslint-plugin-cypress</summary>

###
[`v2.13.2`](https://togithub.com/cypress-io/eslint-plugin-cypress/releases/tag/v2.13.2)

[Compare
Source](https://togithub.com/cypress-io/eslint-plugin-cypress/compare/v2.13.1...v2.13.2)

##### Bug Fixes

- Wait incorrectly reported as unsafe to chain
([7c20206](https://togithub.com/cypress-io/eslint-plugin-cypress/commit/7c20206))

###
[`v2.13.1`](https://togithub.com/cypress-io/eslint-plugin-cypress/releases/tag/v2.13.1)

[Compare
Source](https://togithub.com/cypress-io/eslint-plugin-cypress/compare/v2.13.0...v2.13.1)

##### Bug Fixes

- Solve unsafe to chain command does not exist
([#&#8203;126](https://togithub.com/cypress-io/eslint-plugin-cypress/issues/126))
([1fdfef7](https://togithub.com/cypress-io/eslint-plugin-cypress/commit/1fdfef7))

###
[`v2.13.0`](https://togithub.com/cypress-io/eslint-plugin-cypress/releases/tag/v2.13.0)

[Compare
Source](https://togithub.com/cypress-io/eslint-plugin-cypress/compare/v2.12.1...v2.13.0)

##### Features

- Add 'unsafe-to-chain-command' rule
([bf6a75d](https://togithub.com/cypress-io/eslint-plugin-cypress/commit/bf6a75d))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/elastic/kibana).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xNTQuNyIsInVwZGF0ZWRJblZlciI6IjM1LjU4LjIifQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Patryk Kopyciński <[email protected]>
  • Loading branch information
renovate[bot] and patrykkopycinski authored May 2, 2023
1 parent c466932 commit a16930f
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 88 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1349,14 +1349,14 @@
"cssnano": "^5.1.12",
"cssnano-preset-default": "^5.2.12",
"csstype": "^3.0.2",
"cypress": "^12.6.0",
"cypress-axe": "^1.3.0",
"cypress": "^12.10.0",
"cypress-axe": "^1.4.0",
"cypress-file-upload": "^5.0.8",
"cypress-multi-reporters": "^1.6.2",
"cypress-multi-reporters": "^1.6.3",
"cypress-pipe": "^2.0.0",
"cypress-react-selector": "^3.0.0",
"cypress-real-events": "^1.7.6",
"cypress-recurse": "^1.27.0",
"cypress-recurse": "^1.31.2",
"date-fns": "^2.29.3",
"debug": "^2.6.9",
"delete-empty": "^2.0.0",
Expand All @@ -1370,7 +1370,7 @@
"eslint-config-prettier": "^8.5.0",
"eslint-module-utils": "^2.6.2",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-cypress": "^2.13.2",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jest": "^24.5.0",
Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/osquery/cypress/e2e/all/add_integration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,11 @@ describe('ALL - Add Integration', () => {
cy.get(`[title="${policyName}"]`).click();
cy.getBySel('PackagePoliciesTableUpgradeButton').click();
cy.contains(/^Advanced$/).click();
cy.getBySel('codeEditorContainer').within(() => {
cy.contains(`"${packName}":`);
});
cy.get('.kibanaCodeEditor').should('contain', `"${packName}":`);
cy.getBySel('saveIntegration').click();
cy.get(`a[title="${integrationName}"]`).click();
cy.contains(/^Advanced$/).click();
cy.getBySel('codeEditorContainer').within(() => {
cy.contains(`"${packName}":`);
});
cy.get('.kibanaCodeEditor').should('contain', `"${packName}":`);
cy.contains('Cancel').click();
closeModalIfVisible();
cy.get(`[title="${integrationName}"]`)
Expand Down
48 changes: 28 additions & 20 deletions x-pack/plugins/osquery/cypress/e2e/all/alerts.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ describe('Alert Event Details', () => {
it('adds response actions with osquery with proper validation and form values', () => {
cy.visit('/app/security/rules');
cy.contains(ruleName).click();
cy.getBySel('editRuleSettingsLink').click({ force: true });
cy.getBySel('edit-rule-actions-tab').wait(500).click();
cy.getBySel('editRuleSettingsLink').click();
cy.getBySel('globalLoadingIndicator').should('exist');
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel('edit-rule-actions-tab').click();
cy.contains('Response actions are run on each rule execution');
cy.getBySel(OSQUERY_RESPONSE_ACTION_ADD_BUTTON).click();
cy.getBySel(RESPONSE_ACTIONS_ITEM_0).within(() => {
Expand Down Expand Up @@ -160,8 +162,10 @@ describe('Alert Event Details', () => {
cy.contains(`${ruleName} was saved`).should('exist');
closeToastIfVisible();

cy.getBySel('editRuleSettingsLink').click({ force: true });
cy.getBySel('edit-rule-actions-tab').wait(500).click();
cy.getBySel('editRuleSettingsLink').click();
cy.getBySel('globalLoadingIndicator').should('exist');
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel('edit-rule-actions-tab').click();
cy.getBySel(RESPONSE_ACTIONS_ITEM_0).within(() => {
cy.contains('select * from uptime1');
});
Expand Down Expand Up @@ -204,8 +208,10 @@ describe('Alert Event Details', () => {
cy.contains(`${ruleName} was saved`).should('exist');
closeToastIfVisible();

cy.getBySel('editRuleSettingsLink').click({ force: true });
cy.getBySel('edit-rule-actions-tab').wait(500).click();
cy.getBySel('editRuleSettingsLink').click();
cy.getBySel('globalLoadingIndicator').should('exist');
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel('edit-rule-actions-tab').click();
cy.getBySel(RESPONSE_ACTIONS_ITEM_0).within(() => {
cy.contains(packName);
cy.getBySel('comboBoxInput').type(`${multiQueryPackName}{downArrow}{enter}`);
Expand Down Expand Up @@ -268,8 +274,10 @@ describe('Alert Event Details', () => {
'You have queries in the investigation guide. Add them as response actions?';
cy.visit('/app/security/rules');
cy.contains(ruleName).click();
cy.getBySel('editRuleSettingsLink').click({ force: true });
cy.getBySel('edit-rule-actions-tab').wait(500).click();
cy.getBySel('editRuleSettingsLink').click();
cy.getBySel('globalLoadingIndicator').should('exist');
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel('edit-rule-actions-tab').click();

cy.contains(investigationGuideNote);
cy.getBySel('osqueryAddInvestigationGuideQueries').click();
Expand Down Expand Up @@ -305,9 +313,9 @@ describe('Alert Event Details', () => {
it('should be able to run live query and add to timeline (-depending on the previous test)', () => {
const TIMELINE_NAME = 'Untitled timeline';
loadRuleAlerts(ruleName);
cy.getBySel('timeline-context-menu-button').first().click({ force: true });
cy.getBySel('timeline-context-menu-button').first().click();
cy.contains('Run Osquery');
cy.getBySel('expand-event').first().click({ force: true });
cy.getBySel('expand-event').first().click();
cy.getBySel('take-action-dropdown-btn').click();
cy.getBySel('osquery-action-item').click();
cy.contains('1 agent selected.');
Expand Down Expand Up @@ -349,7 +357,7 @@ describe('Alert Event Details', () => {

it('should substitute parameters in investigation guide', () => {
loadRuleAlerts(ruleName);
cy.getBySel('expand-event').first().click({ force: true });
cy.getBySel('expand-event').first().click();
cy.contains('Get processes').click();
cy.getBySel('flyout-body-osquery').within(() => {
cy.contains("SELECT * FROM os_version where name='Ubuntu';");
Expand Down Expand Up @@ -381,7 +389,7 @@ describe('Alert Event Details', () => {

it('sees osquery results from last action and add to a case', () => {
loadRuleAlerts(ruleName);
cy.getBySel('expand-event').first().click({ force: true });
cy.getBySel('expand-event').first().click();
cy.contains('Osquery Results').click();
cy.getBySel('osquery-results').should('exist');
cy.contains('select * from users;');
Expand Down Expand Up @@ -431,7 +439,7 @@ describe('Alert Event Details', () => {
it('can visit discover from response action results', () => {
const discoverRegex = new RegExp(`action_id: ${UUID_REGEX}`);
loadRuleAlerts(ruleName);
cy.getBySel('expand-event').first().click({ force: true });
cy.getBySel('expand-event').first().click();
cy.contains('Osquery Results').click();
cy.getBySel('osquery-results').should('exist');
checkActionItemsInResults({
Expand Down Expand Up @@ -472,7 +480,7 @@ describe('Alert Event Details', () => {
it('can visit lens from response action results', () => {
const lensRegex = new RegExp(`Action ${UUID_REGEX} results`);
loadRuleAlerts(ruleName);
cy.getBySel('expand-event').first().click({ force: true });
cy.getBySel('expand-event').first().click();
cy.contains('Osquery Results').click();
cy.getBySel('osquery-results').should('exist');
checkActionItemsInResults({
Expand Down Expand Up @@ -522,7 +530,7 @@ describe('Alert Event Details', () => {
const timelineRegex = new RegExp(`Added ${UUID_REGEX} to timeline`);
const filterRegex = new RegExp(`action_id: "${UUID_REGEX}"`);
loadRuleAlerts(ruleName);
cy.getBySel('expand-event').first().click({ force: true });
cy.getBySel('expand-event').first().click();
cy.contains('Osquery Results').click();
cy.getBySel('osquery-results').should('exist');
checkActionItemsInResults({
Expand Down Expand Up @@ -565,7 +573,7 @@ describe('Alert Event Details', () => {
let initialNotificationCount: number;
let updatedNotificationCount: number;
loadRuleAlerts(ruleName);
cy.getBySel('expand-event').first().click({ force: true });
cy.getBySel('expand-event').first().click();
cy.getBySel('osquery-actions-notification')
.should('not.have.text', '0')
.then((element) => {
Expand Down Expand Up @@ -606,7 +614,7 @@ describe('Alert Event Details', () => {

it('should be able to run take action query against all enrolled agents', () => {
loadRuleAlerts(ruleName);
cy.getBySel('expand-event').first().click({ force: true });
cy.getBySel('expand-event').first().click();
cy.getBySel('take-action-dropdown-btn').click();
cy.getBySel('osquery-action-item').click();
cy.getBySel('agentSelection').within(() => {
Expand All @@ -620,8 +628,8 @@ describe('Alert Event Details', () => {
cy.wait(1000);
submitQuery();
cy.getBySel('flyout-body-osquery').within(() => {
// at least 2 agents should have responded
cy.get('[data-grid-row-index]').should('have.length.at.least', 2);
// at least 2 agents should have responded, sometimes it takes a while for the agents to respond
cy.get('[data-grid-row-index]', { timeout: 6000000 }).should('have.length.at.least', 2);
});
});
});
Expand All @@ -643,7 +651,7 @@ describe('Alert Event Details', () => {

it('should substitute params in osquery ran from timelines alerts', () => {
loadRuleAlerts(ruleName);
cy.getBySel('send-alert-to-timeline-button').first().click({ force: true });
cy.getBySel('send-alert-to-timeline-button').first().click();
cy.getBySel('query-events-table').within(() => {
cy.getBySel('expand-event').first().click();
});
Expand Down
4 changes: 1 addition & 3 deletions x-pack/plugins/osquery/cypress/tasks/live_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,5 @@ export const takeOsqueryActionWithParams = () => {
cy.getBySel('osqueryColumnValueSelect').type('platform_like{downArrow}{enter}');
cy.wait(1000);
submitQuery();
cy.getBySel('dataGridHeader').within(() => {
cy.contains('tags');
});
cy.getBySel('dataGridHeader').should('contain', 'tags', { timeout: 6000000 });
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ import { indexEndpointRuleAlerts } from '../../tasks/index_endpoint_rule_alerts'

describe('Isolate command', () => {
describe('from Manage', () => {
let endpointData: ReturnTypeFromChainable<typeof indexEndpointHosts>;
let isolatedEndpointData: ReturnTypeFromChainable<typeof indexEndpointHosts>;
let endpointData: ReturnTypeFromChainable<typeof indexEndpointHosts> | undefined;
let isolatedEndpointData: ReturnTypeFromChainable<typeof indexEndpointHosts> | undefined;
let isolatedEndpointHostnames: [string, string];
let endpointHostnames: [string, string];

before(() => {
indexEndpointHosts({
count: 2,
Expand Down Expand Up @@ -63,16 +64,15 @@ describe('Isolate command', () => {
after(() => {
if (endpointData) {
endpointData.cleanup();
// @ts-expect-error ignore setting to undefined
endpointData = undefined;
}

if (isolatedEndpointData) {
isolatedEndpointData.cleanup();
// @ts-expect-error ignore setting to undefined
isolatedEndpointData = undefined;
}
});

beforeEach(() => {
login();
});
Expand All @@ -89,35 +89,33 @@ describe('Isolate command', () => {
});

describe('from Alerts', () => {
let endpointData: ReturnTypeFromChainable<typeof indexEndpointHosts>;
let alertData: ReturnTypeFromChainable<typeof indexEndpointRuleAlerts>;
let endpointData: ReturnTypeFromChainable<typeof indexEndpointHosts> | undefined;
let alertData: ReturnTypeFromChainable<typeof indexEndpointRuleAlerts> | undefined;
let hostname: string;

before(() => {
indexEndpointHosts({ withResponseActions: false, isolation: false })
.then((indexEndpoints) => {
indexEndpointHosts({ withResponseActions: false, isolation: false }).then(
(indexEndpoints) => {
endpointData = indexEndpoints;
hostname = endpointData.data.hosts[0].host.name;
})
.then(() => {

return indexEndpointRuleAlerts({
endpointAgentId: endpointData.data.hosts[0].agent.id,
endpointHostname: endpointData.data.hosts[0].host.name,
endpointIsolated: false,
});
});
}
);
});

after(() => {
if (endpointData) {
endpointData.cleanup();
// @ts-expect-error ignore setting to undefined
endpointData = undefined;
}

if (alertData) {
alertData.cleanup();
// @ts-expect-error ignore setting to undefined
alertData = undefined;
}
});
Expand Down Expand Up @@ -192,9 +190,9 @@ describe('Isolate command', () => {
});

describe('from Cases', () => {
let endpointData: ReturnTypeFromChainable<typeof indexEndpointHosts>;
let caseData: ReturnTypeFromChainable<typeof indexNewCase>;
let alertData: ReturnTypeFromChainable<typeof indexEndpointRuleAlerts>;
let endpointData: ReturnTypeFromChainable<typeof indexEndpointHosts> | undefined;
let caseData: ReturnTypeFromChainable<typeof indexNewCase> | undefined;
let alertData: ReturnTypeFromChainable<typeof indexEndpointRuleAlerts> | undefined;
let caseAlertActions: ReturnType<typeof addAlertsToCase>;
let alertId: string;
let caseUrlPath: string;
Expand All @@ -210,41 +208,39 @@ describe('Isolate command', () => {
.then((indexEndpoints) => {
endpointData = indexEndpoints;
hostname = endpointData.data.hosts[0].host.name;
})
.then(() => {

return indexEndpointRuleAlerts({
endpointAgentId: endpointData.data.hosts[0].agent.id,
endpointHostname: endpointData.data.hosts[0].host.name,
endpointIsolated: false,
}).then((indexedAlert) => {
alertData = indexedAlert;
alertId = alertData.alerts[0]._id;
});
})
.then(() => {
caseAlertActions = addAlertsToCase({
caseId: caseData.data.id,
alertIds: [alertId],
});
.then((indexedAlert) => {
alertData = indexedAlert;
alertId = alertData.alerts[0]._id;

if (caseData) {
caseAlertActions = addAlertsToCase({
caseId: caseData.data.id,
alertIds: [alertId],
});
}
});
});

after(() => {
if (caseData) {
caseData.cleanup();
// @ts-expect-error ignore setting to undefined
caseData = undefined;
}

if (endpointData) {
endpointData.cleanup();
// @ts-expect-error ignore setting to undefined
endpointData = undefined;
}

if (alertData) {
alertData.cleanup();
// @ts-expect-error ignore setting to undefined
alertData = undefined;
}
});
Expand Down
Loading

0 comments on commit a16930f

Please sign in to comment.