Skip to content

Commit

Permalink
[Backport 4.4-1.2-wzd] Test Fixed, change decoder/rule tittle for cor…
Browse files Browse the repository at this point in the history
…rect execution (#4498)

Test Fixed, change decoder/rule tittle for correct execution (#4496)

* Test Fixed, change decoder tittle for correct execution

* Adding random name based on timestamp

* Add new writing behaviour, same as decoder

(cherry picked from commit ec3e4f6)

Co-authored-by: Mayons95 <[email protected]>
  • Loading branch information
github-actions[bot] and Mayons95 authored Sep 12, 2022
1 parent 2268d64 commit 023274c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { When } from 'cypress-cucumber-preprocessor/steps';
import { fillField, elementIsVisible, getSelector } from '../../../utils/driver';
import { fillField, elementIsVisible, getSelector, generateRandomName } from '../../../utils/driver';
import { DECODERS_PAGE as pageName} from '../../../utils/pages-constants';
const decoderTitleSelector = getSelector('decoderTitleSelector', pageName);
const codeEditorSelector = getSelector('codeEditorSelector', pageName);
const testXmlText = '<decoder name="json"><prematch>^{\s*"</prematch><plugin_decoder>JSON_Decoder</plugin_decoder></decoder>';
const testXmlText = '<decoder name="wazuh"><prematch>^wazuh2: </prematch></decoder>';

When('The user writes a new decoder', () => {
elementIsVisible(decoderTitleSelector);
fillField(decoderTitleSelector,'Test');
fillField(decoderTitleSelector,generateRandomName());
fillField(codeEditorSelector,testXmlText);
})
});
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { When } from 'cypress-cucumber-preprocessor/steps';
import { elementIsVisible, getSelector, fillField } from '../../../utils/driver';
import { elementIsVisible, getSelector, fillField, generateRandomName } from '../../../utils/driver';
import { RULES_PAGE as pageName} from '../../../utils/pages-constants';
const codeEditorSelector = getSelector('codeEditorSelector', pageName);
const rulesTitleSelector = getSelector('rulesTitleSelector', pageName);
const testXmlText = '<group name="windows,"><rule id="6" level="0" noalert="1"> <category>windows</category> <description>Generic template for all windows rules.</description></rule></group>';

When('The user writes a new rule', () => {
elementIsVisible(rulesTitleSelector);
fillField(rulesTitleSelector,'Test')
fillField(rulesTitleSelector,generateRandomName())
elementIsVisible(codeEditorSelector);
fillField(codeEditorSelector,'Test');
fillField(codeEditorSelector,testXmlText);
});
6 changes: 6 additions & 0 deletions test/cypress/cypress/integration/utils/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ export const xpathElementIsVisible = (xpathSelector) => {
return getElementByXpath(xpathSelector).should('exist').should('be.visible');
};

export const generateRandomName = () => {
const uniqueSeed = Date.now().toString();
const getUniqueId = () => Cypress._.uniqueId(uniqueSeed);
return 'Test-'+getUniqueId();
};

export const timestampToDate = (e) => {
let newDates = e.getDate() + "/" + (e.getMonth() + 1) + "/" + e.getFullYear() + " " + e.getHours() + ":" + e.getMinutes() + ":" + e.getSeconds();
return newDates;
Expand Down

0 comments on commit 023274c

Please sign in to comment.