Skip to content

Commit

Permalink
Fix cypress cases connectors tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Oct 2, 2023
1 parent af0df9e commit 0447625
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getServiceNowConnector, getServiceNowITSMHealthResponse } from '../../.
import { SERVICE_NOW_MAPPING } from '../../../screens/configure_cases';

import { goToEditExternalConnection } from '../../../tasks/all_cases';
import { cleanKibana, deleteCases, deleteConnectors } from '../../../tasks/common';
import { cleanKibana, deleteAllCasesItems, deleteConnectors } from '../../../tasks/common';
import {
addServiceNowConnector,
openAddNewConnectorOption,
Expand Down Expand Up @@ -54,7 +54,7 @@ describe('Cases connectors', { tags: ['@ess', '@serverless'] }, () => {

beforeEach(() => {
login();
deleteCases();
deleteAllCasesItems();
cy.intercept('GET', `${snConnector.URL}/api/x_elas2_inc_int/elastic_api/health*`, {
statusCode: 200,
body: getServiceNowITSMHealthResponse(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { TestCaseWithoutTimeline } from '../../../objects/case';
import { ALL_CASES_CREATE_NEW_CASE_BTN, ALL_CASES_NAME } from '../../../screens/all_cases';

import { goToCreateNewCase } from '../../../tasks/all_cases';
import { cleanKibana, deleteCases } from '../../../tasks/common';
import { cleanKibana, deleteAllCasesItems } from '../../../tasks/common';

import {
backToCases,
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('Cases privileges', { tags: ['@ess', '@serverless', '@brokenInServerles

beforeEach(() => {
login();
deleteCases();
deleteAllCasesItems();
});

for (const user of [secAllUser, secReadCasesAllUser, secAllCasesNoDeleteUser]) {
Expand Down
38 changes: 32 additions & 6 deletions x-pack/test/security_solution_cypress/cypress/tasks/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const resetRulesTableState = () => {
export const cleanKibana = () => {
resetRulesTableState();
deleteAlertsAndRules();
deleteCases();
deleteAllCasesItems();
deleteTimelines();
};

Expand Down Expand Up @@ -169,8 +169,8 @@ export const deleteAlertsIndex = () => {
});
};

export const deleteCases = () => {
const kibanaIndexUrl = `${Cypress.env('ELASTICSEARCH_URL')}/.kibana_\*`;
export const deleteAllCasesItems = () => {
const kibanaIndexUrl = `${Cypress.env('ELASTICSEARCH_URL')}/.kibana_alerting_cases_\*`;
rootRequest({
method: 'POST',
url: `${kibanaIndexUrl}/_delete_by_query?conflicts=proceed&refresh`,
Expand All @@ -179,8 +179,34 @@ export const deleteCases = () => {
bool: {
filter: [
{
match: {
type: 'cases',
bool: {
should: [
{
term: {
type: 'cases',
},
},
{
term: {
type: 'cases-configure',
},
},
{
term: {
type: 'cases-comments',
},
},
{
term: {
type: 'cases-user-action',
},
},
{
term: {
type: 'cases-connector-mappings',
},
},
],
},
},
],
Expand All @@ -191,7 +217,7 @@ export const deleteCases = () => {
};

export const deleteConnectors = () => {
const kibanaIndexUrl = `${Cypress.env('ELASTICSEARCH_URL')}/.kibana_\*`;
const kibanaIndexUrl = `${Cypress.env('ELASTICSEARCH_URL')}/.kibana_alerting_cases_\*`;
rootRequest({
method: 'POST',
url: `${kibanaIndexUrl}/_delete_by_query?conflicts=proceed&refresh`,
Expand Down

0 comments on commit 0447625

Please sign in to comment.