Skip to content

Commit

Permalink
Fixed cypress tests.
Browse files Browse the repository at this point in the history
Signed-off-by: AWSHurneyt <[email protected]>
  • Loading branch information
AWSHurneyt committed Oct 12, 2023
1 parent fe21de1 commit 8cdaae3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
8 changes: 4 additions & 4 deletions cypress/integration/1_detectors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import sample_windows_index_settings from '../fixtures/sample_windows_index_sett
import sample_dns_index_settings from '../fixtures/sample_dns_index_settings.json';
import dns_name_rule_data from '../fixtures/integration_tests/rule/create_dns_rule_with_name_selection.json';
import dns_type_rule_data from '../fixtures/integration_tests/rule/create_dns_rule_with_type_selection.json';
import dns_mapping_fields from '../fixtures/integration_tests/rule/sample_dns_field_mappings.json';
import _ from 'lodash';
import { getMappingFields } from '../../public/pages/Detectors/utils/helpers';
import { getLogTypeLabel } from '../../public/pages/LogTypes/utils/helpers';

const cypressIndexDns = 'cypress-index-dns';
const cypressIndexWindows = 'cypress-index-windows';
Expand Down Expand Up @@ -115,9 +115,9 @@ const validatePendingFieldMappingsPanel = (mappings) => {
const fillDetailsForm = (detectorName, dataSource) => {
getNameField().type(detectorName);
getDataSourceField().selectComboboxItem(dataSource);
getDataSourceField().blur();
getLogTypeField().selectComboboxItem(cypressLogTypeDns);
getLogTypeField().blur();
getDataSourceField().focus().blur();
getLogTypeField().selectComboboxItem(getLogTypeLabel(cypressLogTypeDns));
getLogTypeField().focus().blur();
};

const createDetector = (detectorName, dataSource, expectFailure) => {
Expand Down
15 changes: 10 additions & 5 deletions cypress/integration/2_rules.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { OPENSEARCH_DASHBOARDS_URL } from '../support/constants';
import { getLogTypeLabel } from '../../public/pages/LogTypes/utils/helpers';

const uniqueId = Cypress._.random(0, 1e6);
const SAMPLE_RULE = {
Expand Down Expand Up @@ -55,7 +56,9 @@ const checkRulesFlyout = () => {
cy.get('[data-test-subj="rule_flyout_rule_name"]').contains(SAMPLE_RULE.name);

// Validate log type
cy.get('[data-test-subj="rule_flyout_rule_log_type"]').contains(SAMPLE_RULE.logType);
cy.get('[data-test-subj="rule_flyout_rule_log_type"]').contains(
getLogTypeLabel(SAMPLE_RULE.logType)
);

// Validate description
cy.get('[data-test-subj="rule_flyout_rule_description"]').contains(SAMPLE_RULE.description);
Expand Down Expand Up @@ -161,7 +164,7 @@ const fillCreateForm = () => {
getAuthorField().type(`${SAMPLE_RULE.author}`);

// rule details
getLogTypeField().selectComboboxItem(SAMPLE_RULE.logType);
getLogTypeField().selectComboboxItem(getLogTypeLabel(SAMPLE_RULE.logType));
getRuleLevelField().selectComboboxItem(SAMPLE_RULE.severity);

// rule detection
Expand Down Expand Up @@ -284,7 +287,7 @@ describe('Rules', () => {
getLogTypeField().focus().blur();
getLogTypeField().containsError('Log type is required');

getLogTypeField().selectComboboxItem(SAMPLE_RULE.logType);
getLogTypeField().selectComboboxItem(getLogTypeLabel(SAMPLE_RULE.logType));
getLogTypeField().focus().blur().shouldNotHaveError();
});

Expand Down Expand Up @@ -425,7 +428,7 @@ describe('Rules', () => {
// log field
getLogTypeField().clearCombobox();
toastShouldExist();
getLogTypeField().selectComboboxItem(SAMPLE_RULE.logType);
getLogTypeField().selectComboboxItem(getLogTypeLabel(SAMPLE_RULE.logType));

// severity field
getRuleLevelField().clearCombobox();
Expand Down Expand Up @@ -551,7 +554,9 @@ describe('Rules', () => {
YAML_RULE_LINES[2] = `product: ${SAMPLE_RULE.logType}`;
YAML_RULE_LINES[3] = `title: ${SAMPLE_RULE.name}`;
getLogTypeField().selectComboboxItem(SAMPLE_RULE.logType);
getLogTypeField().containsValue(SAMPLE_RULE.logType).contains(SAMPLE_RULE.logType);
getLogTypeField()
.containsValue(SAMPLE_RULE.logType)
.contains(getLogTypeLabel(SAMPLE_RULE.logType));

SAMPLE_RULE.description += ' edited';
YAML_RULE_LINES[4] = `description: ${SAMPLE_RULE.description}`;
Expand Down

0 comments on commit 8cdaae3

Please sign in to comment.