Skip to content

Commit

Permalink
Add E2E tests to the enviroment (#1810)
Browse files Browse the repository at this point in the history
* Add the test environment

* Add the first functional test

* Add two services to test the visualizations

* Add two tests for the alerts visualizations

* Refactoring and cleaning code

* Create two new services to test pie charts

* Create two tests for charts pie

* should top 5 agent chart pie values are correct
* should top 5 rule groups chart pie values are correct

* Add test and fix sort problem

* should alerts evolution - top 5 agents chart values are correct

* Add the missing ID property

* Fix problem with the sort function

* Add two classes to test visualization tables

* Add new test for alert summary table

`should alerts summary table values are correct`

* Refactoring duplicate code in `setTodayRange`

* Add 14 tests to cover query bar and filters

* should `alertStats` values ​​are correct when add the filter ` rule.level: 7`
* should `alert level evolution` chart values are correct when add the filter ` rule.level: 7`
* should `alert` chart values are correct when add the filter ` rule.level: 7`
* should `top 5 agent` chart pie values are correct when add the filter ` rule.level: 7`
* should `top 5 rule groups` chart pie values are correct when add the filter ` rule.level: 7`
* should `alerts evolution - top 5 agents` chart values are correct when add the filter ` rule.level: 7`
* should `alerts summary` table values are correct when add the filter ` rule.level: 7`
* should `alertStats` values ​​are correct when add to the query bar ` rule.level: 7`
* should `alert level evolution` chart values are correct when add to the query bar ` rule.level: 7`
* should `alert` chart values are correct when add to the query bar ` rule.level: 7`
* should `top 5 agent` chart pie values are correct when add to the query bar ` rule.level: 7`
* should `top 5 rule groups` chart pie values are correct when add to the query bar ` rule.level: 7`
* should `alerts evolution - top 5 agents` chart values are correct when add to the query bar ` rule.level: 7`
* should `alerts summary` table values are correct when add to the query bar ` rule.level: 7`

* Fix the problem with summary alerts test

* Fix expect problem with alert summary table

* Change the value of a param in visualization

The aggregation type of the visualization is `sum`

I change the value to `count`

* Add missing id properties to visualizations

* Create a new method to navigate to the FIM view

* Add a `beforeEach` method to remove duplicate code

* Add the tests for FIM Dashboard

* Add test for the filters and query bar in FIM

* Add documentation to the code

* Fix problem when comparing objects

* Set index pattern

* Fix the problem with the expected test result

* Removed discover from wz-menu
  • Loading branch information
jsanchez91 authored and adri9valle committed Oct 9, 2019
1 parent 04b6265 commit 15a0ef4
Show file tree
Hide file tree
Showing 23 changed files with 3,229 additions and 10 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"lint": "eslint . --ext .js -c .eslintrc.json --color",
"prebuild": "tsc; find . -name \"*.ts*\" -type f -not -path \"./node_modules/*\" -delete",
"build": "plugin-helpers build",
"test": "_mocha test/**/*"
"test": "_mocha test/**/*",
"test:ui:runner": "node ../../scripts/functional_test_runner.js"
},
"dependencies": {
"angular-animate": "1.7.8",
Expand Down
5 changes: 5 additions & 0 deletions public/controllers/overview/components/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { StringsTools } from '../../../utils/strings-tools';
import {
EuiCard,
EuiIcon,
Expand All @@ -32,6 +33,7 @@ import { TabDescription } from '../../../../server/reporting/tab-description';
export class WelcomeScreen extends Component {
constructor(props) {
super(props);
this.strtools = new StringsTools();

this.state = {
extensions: this.props.extensions
Expand Down Expand Up @@ -70,6 +72,7 @@ export class WelcomeScreen extends Component {
icon={<EuiIcon size="xl" type={icon} />}
title={TabDescription[tab].title}
onClick={() => this.props.switchTab(tab)}
data-test-subj={`overviewWelcome${this.strtools.capitalize(tab)}`}
description={TabDescription[tab].description}
/>
</EuiFlexItem>
Expand All @@ -83,6 +86,7 @@ export class WelcomeScreen extends Component {
<EuiSwitch
label={`${TabDescription[extension].title} extension`}
checked={this.state.extensions[extension]}
data-test-subj={`switch${this.strtools.capitalize(extension)}`}
onChange={() => this.toggleExtension(extension)}
/>
</EuiFormRow>
Expand All @@ -96,6 +100,7 @@ export class WelcomeScreen extends Component {
<EuiButtonIcon
aria-label="Extensions"
iconType="eye"
data-test-subj={`eye${this.strtools.toUpperCamelCase(popoverName)}`}
onClick={() => this.onButtonClick(popoverName)}
/>
}
Expand Down
10 changes: 6 additions & 4 deletions public/directives/wz-menu/wz-menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@
<!-- Main Wazuh app navigation buttons -->
<md-button class="wz-menu-button" ng-href="#/overview" ng-click="setMenuNavItem('overview')"
ng-class="{'wz-menu-active': menuNavItem === 'overview' || menuNavItem === 'health-check' }"
aria-label="Overview tab">
aria-label="Overview tab" data-test-subj="wzMenuOverview">
<react-component name="EuiIcon" class="kbnGlobalNavLink__euiIcon" props="{type:'visualizeApp'}" /> Overview
</md-button>

<md-button class="wz-menu-button" ng-href="#/manager" ng-click="setMenuNavItem('manager')"
ng-class="{'wz-menu-active': menuNavItem === 'manager' }" aria-label="Cluster tab">
ng-class="{'wz-menu-active': menuNavItem === 'manager' }" aria-label="Cluster tab"
data-test-subj="wzMenuManagement">
<react-component name="EuiIcon" class="kbnGlobalNavLink__euiIcon" props="{type:'infraApp'}" /> Management
</md-button>

<md-button class="wz-menu-button" ng-href="#/agents-preview" ng-click="setMenuNavItem('agents-preview')"
ng-class="{'wz-menu-active': menuNavItem === 'agents-preview' || menuNavItem === 'agents' }"
aria-label="Agents tab">
aria-label="Agents tab" data-test-subj="wzMenuAgents">
<i class="fa fa-fw fa-tv" aria-hidden="true"></i> Agents
</md-button>

<md-button class="wz-menu-button" ng-href="#/wazuh-dev" ng-click="setMenuNavItem('wazuh-dev')"
ng-class="{'wz-menu-active': menuNavItem === 'wazuh-dev' }" aria-label="Dev Tools tab">
ng-class="{'wz-menu-active': menuNavItem === 'wazuh-dev' }" aria-label="Dev Tools tab"
data-test-subj="wzMenuDevTools">
<react-component name="EuiIcon" class="kbnGlobalNavLink__euiIcon" props="{type:'console'}" /> Dev tools
</md-button>

Expand Down
6 changes: 3 additions & 3 deletions public/templates/overview/overview-fim.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</span>
</md-card-actions>
<md-card-content class="wazuh-column">
<kbn-vis vis-id="'Wazuh-App-Overview-FIM-Top-5-rules'"></kbn-vis>
<kbn-vis id="Wazuh-App-Overview-FIM-Top-5-rules" vis-id="'Wazuh-App-Overview-FIM-Top-5-rules'"></kbn-vis>
</md-card-content>
</md-card>

Expand All @@ -78,7 +78,7 @@
</span>
</md-card-actions>
<md-card-content class="wazuh-column">
<kbn-vis class="sca-vis table-scrollable" vis-id="'Wazuh-App-Overview-FIM-top-agents-user'"></kbn-vis>
<kbn-vis class="sca-vis table-scrollable" id="Wazuh-App-Overview-FIM-top-agents-user" vis-id="'Wazuh-App-Overview-FIM-top-agents-user'"></kbn-vis>
</md-card-content>
</md-card>
</div>
Expand All @@ -92,7 +92,7 @@
</span>
</md-card-actions>
<md-card-content class="wazuh-column">
<kbn-vis vis-id="'Wazuh-App-Overview-FIM-Alerts-summary'"></kbn-vis>
<kbn-vis id="Wazuh-App-Overview-FIM-Alerts-summary"vis-id="'Wazuh-App-Overview-FIM-Alerts-summary'"></kbn-vis>
</md-card-content>
</md-card>
</div>
Expand Down
2 changes: 1 addition & 1 deletion public/templates/overview/overview-general.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
</span>
</md-card-actions>
<md-card-content class="wazuh-column">
<kbn-vis vis-id="'Wazuh-App-Overview-General-Alerts-summary'"></kbn-vis>
<kbn-vis id="Wazuh-App-Overview-General-Alerts-summary" vis-id="'Wazuh-App-Overview-General-Alerts-summary'"></kbn-vis>
</md-card-content>
</md-card>
</div>
Expand Down
43 changes: 43 additions & 0 deletions public/utils/strings-tools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Wazuh app - Strings tools class
* Copyright (C) 2015-2019 Wazuh, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Find more information about this on the LICENSE file.
*/

export class StringsTools {
constructor () {}
/**
* Set the first letter to upper case
*
* @param {*} str
* @returns capitalized str
* @memberof StringsTools
*/
capitalize (str) {
return str[0].toUpperCase() + str.slice(1);
}


/**
* Remove all white spaces from str
*
* @param {*} str
* @returns striped str
* @memberof StringsTools
*/
strip (str) {
return str.replace(/\s+/g, '');
}

toUpperCamelCase (str) {
const capitalizeStrs = str.split(' ').map((s) => this.capitalize(s));
return capitalizeStrs.join('');
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default [
_source: {
title: 'Top 5 rules',
visState:
'{"title":"Export rule distr","type":"pie","params":{"type":"pie","addTooltip":true,"addLegend":true,"legendPosition":"right","isDonut":true,"labels":{"show":false,"values":true,"last_level":true,"truncate":100}},"aggs":[{"id":"1","enabled":true,"type":"sum","schema":"metric","params":{"field":"rule.level"}},{"id":"2","enabled":true,"type":"terms","schema":"segment","params":{"field":"rule.description","size":5,"order":"desc","orderBy":"1","otherBucket":false,"otherBucketLabel":"Other","missingBucket":false,"missingBucketLabel":"Missing"}}]}',
'{"title":"Export rule distr","type":"pie","params":{"type":"pie","addTooltip":true,"addLegend":true,"legendPosition":"right","isDonut":true,"labels":{"show":false,"values":true,"last_level":true,"truncate":100}},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric","params":{"field":"rule.level"}},{"id":"2","enabled":true,"type":"terms","schema":"segment","params":{"field":"rule.description","size":5,"order":"desc","orderBy":"1","otherBucket":false,"otherBucketLabel":"Other","missingBucket":false,"missingBucketLabel":"Missing"}}]}',
uiStateJSON: '{}',
description: '',
version: 1,
Expand Down
Loading

0 comments on commit 15a0ef4

Please sign in to comment.