Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
Signed-off-by: Jovan Cvetkovic <[email protected]>
  • Loading branch information
jovancvetkovic3006 committed Feb 22, 2023
1 parent 0075e93 commit 9cfa754
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
35 changes: 17 additions & 18 deletions cypress/integration/1_detectors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ const testMappings = {
const cypressDNSRule = dns_rule_data.title;

describe('Detectors', () => {
const indexName = 'cypress-test-dns';
const cypressIndexDns = 'cypress-index-dns';
const cypressIndexWindows = 'cypress-index-windows';
const detectorName = 'test detector';

before(() => {
cy.cleanUpTests();

cy.createIndex(cypressIndexWindows, sample_index_settings);

// Create test index
cy.createIndex(indexName, sample_index_settings).then(() =>
cy.createIndex(cypressIndexDns, sample_index_settings).then(() =>
cy
.request('POST', '_plugins/_security_analytics/rules/_search?prePackaged=true', {
from: 0,
Expand Down Expand Up @@ -58,11 +61,6 @@ describe('Detectors', () => {
});

it('...should show mappings warning', () => {
const indexName = 'cypress-index-windows';
const dnsName = 'cypress-index-dns';
cy.createIndex(indexName, sample_index_settings);
cy.createIndex(dnsName, sample_dns_settings);

// Locate Create detector button click to start
cy.get('.euiButton').filter(':contains("Create detector")').click({ force: true });

Expand All @@ -71,23 +69,25 @@ describe('Detectors', () => {
contains: 'Define detector',
});

// Select our pre-seeded data source (check indexName)
// Select our pre-seeded data source (check cypressIndexDns)
cy.get(`[data-test-subj="define-detector-select-data-source"]`)
.find('input')
.focus()
.realType(indexName);
.realType(cypressIndexDns);

// Select threat detector type (Windows logs)
cy.get(`input[id="dns"]`).click({ force: true });

// Select our pre-seeded data source (check indexName)
// Select our pre-seeded data source (check cypressIndexDns)
cy.get(`[data-test-subj="define-detector-select-data-source"]`)
.find('input')
.focus()
.realType(dnsName)
.realType(cypressIndexWindows)
.realPress('Enter');

cy.get('.euiCallOut').should('be.visible').contains('Detector configuration warning');
cy.get('.euiCallOut')
.should('be.visible')
.contains('The selected log sources contain different types of logs');
});

it('...can be created', () => {
Expand All @@ -102,11 +102,11 @@ describe('Detectors', () => {
// Enter a name for the detector in the appropriate input
cy.get(`input[placeholder="Enter a name for the detector."]`).focus().realType('test detector');

// Select our pre-seeded data source (check indexName)
// Select our pre-seeded data source (check cypressIndexDns)
cy.get(`[data-test-subj="define-detector-select-data-source"]`)
.find('input')
.focus()
.realType(indexName);
.realType(cypressIndexDns);

cy.intercept({
pathname: '/_plugins/_security_analytics/rules/_search',
Expand Down Expand Up @@ -198,7 +198,7 @@ describe('Detectors', () => {
cy.contains('Detector details');
cy.contains(detectorName);
cy.contains('dns');
cy.contains(indexName);
cy.contains(cypressIndexDns);
cy.contains('Alert on test_trigger');

// Create the detector
Expand Down Expand Up @@ -252,8 +252,7 @@ describe('Detectors', () => {
.find('input')
.ospClear()
.focus()
.realType('.opensearch-notifications-config')
.realPress('Enter');
.realType(cypressIndexWindows);

// Change detector scheduling
cy.get(`[data-test-subj="detector-schedule-number-select"]`).ospClear().focus().realType('10');
Expand All @@ -271,7 +270,7 @@ describe('Detectors', () => {
cy.contains('test detector edited');
cy.contains('Every 10 hours');
cy.contains('Edited description');
cy.contains('.opensearch-notifications-config');
cy.contains(cypressIndexWindows);
});

it('...rules can be edited', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,11 @@ export const UpdateDetectorBasicDetails: React.FC<UpdateDetectorBasicDetailsProp

<DetectorDataSource
isEdit={true}
detector_type={detector.detector_type}
notifications={props.notifications}
indexService={services?.indexService as IndexService}
detectorIndices={inputs[0].detector_input.indices}
filedMappingService={services?.fieldMappingService}
onDetectorInputIndicesChange={onDetectorInputIndicesChange}
/>
<EuiSpacer size={'xl'} />
Expand Down

0 comments on commit 9cfa754

Please sign in to comment.