Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add Cypress tests for dashboard and detector list #234

Merged
merged 1 commit into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .cypress/fixtures/delete_detector_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"_index": ".opendistro-anomaly-detectors",
"_type": "_doc",
"_id": "ulgqpXEBqtadYz9j2MHG",
"_version": 2,
"result": "deleted",
"forced_refresh": true,
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_seq_no": 6,
"_primary_term": 1
}
135 changes: 135 additions & 0 deletions .cypress/fixtures/multiple_detectors_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"ok": true,
"response": {
"totalDetectors": 1,
"detectorList": [
{
"id": "ulgqpXEBqtadYz7j2MHG",
"description": "test",
"indices": ["feature-required-index"],
"lastUpdateTime": 1587614056945,
"name": "feature-required-detector",
"timeField": "timestamp",
"detectionInterval": { "period": { "interval": 1, "unit": "Minutes" } },
"windowDelay": { "period": { "interval": 1, "unit": "Minutes" } },
"schemaVersion": 0,
"filterQuery": { "match_all": { "boost": 1 } },
"featureAttributes": [],
"uiMetadata": {
"features": {},
"filters": [],
"filterType": "simple_filter"
},
"enabled": false,
"totalAnomalies": 0,
"lastActiveAnomaly": 1591593056550,
"curState": "Feature required"
},
{
"id": "ulgqpXEBqtadYz6j2MHG",
"description": "test",
"indices": ["initializing-index"],
"lastUpdateTime": 1587614056945,
"name": "initializing-detector",
"timeField": "timestamp",
"detectionInterval": { "period": { "interval": 1, "unit": "Minutes" } },
"windowDelay": { "period": { "interval": 1, "unit": "Minutes" } },
"schemaVersion": 0,
"filterQuery": { "match_all": { "boost": 1 } },
"featureAttributes": [
{
"featureId": "1mMspXEBcngjFp58AS_u",
"featureName": "test-f",
"featureEnabled": true,
"aggregationQuery": { "aa": { "sum": { "field": "value" } } }
}
],
"uiMetadata": {
"features": {
"aa": {
"aggregationBy": "sum",
"aggregationOf": "value",
"featureType": "simple_aggs"
}
},
"filters": [],
"filterType": "simple_filter"
},
"enabled": true,
"totalAnomalies": 0,
"lastActiveAnomaly": 1591593056550,
"curState": "Initializing"
},
{
"id": "ulgqpXEBqtadYz8j2MHG",
"description": "test",
"indices": ["running-index"],
"lastUpdateTime": 1587614056945,
"name": "running-detector",
"timeField": "timestamp",
"detectionInterval": { "period": { "interval": 1, "unit": "Minutes" } },
"windowDelay": { "period": { "interval": 1, "unit": "Minutes" } },
"schemaVersion": 0,
"filterQuery": { "match_all": { "boost": 1 } },
"featureAttributes": [
{
"featureId": "1mMspXEBcngjFp58AS_u",
"featureName": "test-f",
"featureEnabled": true,
"aggregationQuery": { "aa": { "sum": { "field": "value" } } }
}
],
"uiMetadata": {
"features": {
"aa": {
"aggregationBy": "sum",
"aggregationOf": "value",
"featureType": "simple_aggs"
}
},
"filters": [],
"filterType": "simple_filter"
},
"enabled": true,
"totalAnomalies": 0,
"lastActiveAnomaly": 1591593056550,
"curState": "Running"
},
{
"id": "ulgqpXEBqtadYz9j2MHG",
"description": "test",
"indices": ["stopped-index"],
"lastUpdateTime": 1587614056945,
"name": "stopped-detector",
"timeField": "timestamp",
"detectionInterval": { "period": { "interval": 1, "unit": "Minutes" } },
"windowDelay": { "period": { "interval": 1, "unit": "Minutes" } },
"schemaVersion": 0,
"filterQuery": { "match_all": { "boost": 1 } },
"featureAttributes": [
{
"featureId": "1mMspXEBcngjFp58AS_u",
"featureName": "test-f",
"featureEnabled": true,
"aggregationQuery": { "aa": { "sum": { "field": "value" } } }
}
],
"uiMetadata": {
"features": {
"aa": {
"aggregationBy": "sum",
"aggregationOf": "value",
"featureType": "simple_aggs"
}
},
"filters": [],
"filterType": "simple_filter"
},
"enabled": false,
"totalAnomalies": 0,
"lastActiveAnomaly": 1591593056550,
"curState": "Stopped"
}
]
}
}
43 changes: 43 additions & 0 deletions .cypress/fixtures/single_running_detector_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"ok": true,
"response": {
"totalDetectors": 1,
"detectorList": [
{
"id": "ulgqpXEBqtadYz9j2MHG",
"description": "test",
"indices": ["test-index"],
"lastUpdateTime": 1587614056945,
"name": "running-detector",
"timeField": "timestamp",
"detectionInterval": { "period": { "interval": 1, "unit": "Minutes" } },
"windowDelay": { "period": { "interval": 1, "unit": "Minutes" } },
"schemaVersion": 0,
"filterQuery": { "match_all": { "boost": 1 } },
"featureAttributes": [
{
"featureId": "1mMspXEBcngjFp58AS_u",
"featureName": "test-f",
"featureEnabled": true,
"aggregationQuery": { "aa": { "sum": { "field": "value" } } }
}
],
"uiMetadata": {
"features": {
"aa": {
"aggregationBy": "sum",
"aggregationOf": "value",
"featureType": "simple_aggs"
}
},
"filters": [],
"filterType": "simple_filter"
},
"enabled": true,
"totalAnomalies": 0,
"lastActiveAnomaly": 1591593056550,
"curState": "Running"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"description": "test",
"indices": ["test-index"],
"lastUpdateTime": 1587614056945,
"name": "name-0",
"name": "stopped-detector",
"timeField": "timestamp",
"detectionInterval": { "period": { "interval": 1, "unit": "Minutes" } },
"windowDelay": { "period": { "interval": 1, "unit": "Minutes" } },
Expand Down
6 changes: 6 additions & 0 deletions .cypress/fixtures/start_detector_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"_id": "ulgqpXEBqtadYz9j2MHG",
"_version": 1,
"_seq_no": 1,
"_primary_term": 1
}
3 changes: 3 additions & 0 deletions .cypress/fixtures/stop_detector_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Stopped detector": "ulgqpXEBqtadYz9j2MHG"
}
43 changes: 42 additions & 1 deletion .cypress/integration/ad/dashboard/ad_dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ context('AD Dashboard', () => {
});

it('AD dashboard - single stopped detector', () => {
cy.mockGetDetectorOnAction('single_detector_response.json', () => {
cy.mockGetDetectorOnAction('single_stopped_detector_response.json', () => {
cy.visit(buildAdAppUrl(DASHBOARD));
});

Expand All @@ -56,4 +56,45 @@ context('AD Dashboard', () => {

cy.contains('h1', 'Create detector');
});

it('Filter by detector', () => {
cy.mockGetDetectorOnAction('multiple_detectors_response.json', () => {
cy.visit(buildAdAppUrl(DASHBOARD));
});

cy.contains('stopped-detector');
cy.contains('running-detector');

cy.get('[data-test-subj=comboBoxToggleListButton]')
.first()
.click({ force: true });
cy.get('.euiFilterSelectItem')
.first()
.click({ force: true });
cy.get('.euiPageSideBar').click({ force: true });

cy.contains('feature-required-detector'); // first one in the list returned by multiple_detectors_response.json
cy.contains('stopped-detector').should('not.be.visible');
cy.contains('running-detector').should('not.be.visible');
});

it('Filter by detector state', () => {
cy.mockGetDetectorOnAction('multiple_detectors_response.json', () => {
cy.visit(buildAdAppUrl(DASHBOARD));
});

cy.contains('stopped-detector');
cy.contains('running-detector');

cy.get('[data-test-subj=comboBoxToggleListButton]')
.eq(1)
.click({ force: true });
cy.get('.euiFilterSelectItem')
.first()
.click({ force: true });
cy.get('.euiPageSideBar').click({ force: true });

cy.contains('stopped-detector'); // because stopped is the first item in the detector state dropdown
cy.contains('running-detector').should('not.be.visible');
});
});
Loading