Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move over remaining AD tests; clean up cypress run scripts #89

Merged
merged 3 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix baseUrl in constants; pass correct fixture path to AD tests
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
  • Loading branch information
ohltyler committed Feb 10, 2022
commit e9c576c7ff1c39b9bd73bb9f52b1ede03fb21ef3
2 changes: 2 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"defaultCommandTimeout": 60000,
"requestTimeout": 60000,
"responseTimeout": 60000,
"baseUrl": "http://localhost:5601",
"reporter": "cypress-multi-reporters",
"reporterOptions": {
Expand Down
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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"ok": true,
"response": {
"name": "detector-name",
"description": "",
"timeField": "timestamp",
"indices": ["e2e-test-index"],
"detectionInterval": { "period": { "interval": 10, "unit": "Minutes" } },
"windowDelay": { "period": { "interval": 1, "unit": "Minutes" } },
"schemaVersion": 0,
"id": "MiSon3IBq0Ub5wDcgBII",
"primaryTerm": 3,
"seqNo": 41,
"filterQuery": { "match_all": { "boost": 1 } },
"featureAttributes": [],
"uiMetadata": {
"features": {},
"filters": [],
"filterType": "simple_filter"
},
"enabled": false
}
}
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": "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"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"_id": "ulgqpXEBqtadYz9j2MHG",
"_version": 1,
"_seq_no": 1,
"_primary_term": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Stopped detector": "ulgqpXEBqtadYz9j2MHG"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,87 +3,111 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { BASE_AD_DASHBOARDS_PATH } from "../../../utils/constants";
import {
AD_FIXTURE_BASE_PATH,
BASE_AD_DASHBOARDS_PATH,
} from '../../../utils/constants';

// Contains basic sanity tests on AD Dashboards page
describe("AD Dashboard page", () => {
describe('AD Dashboard page', () => {
// start a server so that server responses can be mocked via fixtures
// in all of the below test cases
before(() => {
cy.server();
});

it("empty - no detector index", () => {
cy.mockGetDetectorOnAction("no_detector_index_response.json", () => {
cy.visit(BASE_AD_DASHBOARDS_PATH);
});
cy.contains("h2", "You have no detectors");
it('empty - no detector index', () => {
cy.mockGetDetectorOnAction(
AD_FIXTURE_BASE_PATH + 'no_detector_index_response.json',
() => {
cy.visit(BASE_AD_DASHBOARDS_PATH);
}
);
cy.contains('h2', 'You have no detectors');
});

it("empty - empty detector index", () => {
cy.mockGetDetectorOnAction("empty_detector_index_response.json", () => {
cy.visit(BASE_AD_DASHBOARDS_PATH);
});
cy.contains("h2", "You have no detectors");
it('empty - empty detector index', () => {
cy.mockGetDetectorOnAction(
AD_FIXTURE_BASE_PATH + 'empty_detector_index_response.json',
() => {
cy.visit(BASE_AD_DASHBOARDS_PATH);
}
);
cy.contains('h2', 'You have no detectors');
});

it("non-empty - single running detector", () => {
cy.mockGetDetectorOnAction("single_running_detector_response.json", () => {
cy.visit(BASE_AD_DASHBOARDS_PATH);
});
it('non-empty - single running detector', () => {
cy.mockGetDetectorOnAction(
AD_FIXTURE_BASE_PATH + 'single_running_detector_response.json',
() => {
cy.visit(BASE_AD_DASHBOARDS_PATH);
}
);

cy.contains("h3", "Live anomalies");
cy.contains("a", "running-detector");
cy.contains('h3', 'Live anomalies');
cy.contains('a', 'running-detector');
});

it("redirect to create detector page", () => {
cy.mockGetDetectorOnAction("no_detector_index_response.json", () => {
cy.visit(BASE_AD_DASHBOARDS_PATH);
});

cy.mockSearchIndexOnAction("search_index_response.json", () => {
cy.get('a[data-test-subj="createDetectorButton"]').click({
force: true,
});
});

cy.contains("span", "Create detector");
it('redirect to create detector page', () => {
cy.mockGetDetectorOnAction(
AD_FIXTURE_BASE_PATH + 'no_detector_index_response.json',
() => {
cy.visit(BASE_AD_DASHBOARDS_PATH);
}
);

cy.mockSearchIndexOnAction(
AD_FIXTURE_BASE_PATH + 'search_index_response.json',
() => {
cy.get('a[data-test-subj="createDetectorButton"]').click({
force: true,
});
}
);

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

it("filter by detector", () => {
cy.mockGetDetectorOnAction("multiple_detectors_response.json", () => {
cy.visit(BASE_AD_DASHBOARDS_PATH);
});
it('filter by detector', () => {
cy.mockGetDetectorOnAction(
AD_FIXTURE_BASE_PATH + 'multiple_detectors_response.json',
() => {
cy.visit(BASE_AD_DASHBOARDS_PATH);
}
);

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

cy.get("[data-test-subj=comboBoxToggleListButton]")
cy.get('[data-test-subj=comboBoxToggleListButton]')
.first()
.click({ force: true });
cy.get(".euiFilterSelectItem").first().click({ force: true });
cy.get(".euiPageSideBar").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");
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(BASE_AD_DASHBOARDS_PATH);
});
it('filter by detector state', () => {
cy.mockGetDetectorOnAction(
AD_FIXTURE_BASE_PATH + 'multiple_detectors_response.json',
() => {
cy.visit(BASE_AD_DASHBOARDS_PATH);
}
);

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

cy.get("[data-test-subj=comboBoxToggleListButton]")
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.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");
cy.contains('stopped-detector'); // because stopped is the first item in the detector state dropdown
cy.contains('running-detector').should('not.be.visible');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,46 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { BASE_AD_CREATE_AD_PATH } from '../../../utils/constants';
import {
AD_FIXTURE_BASE_PATH,
BASE_AD_CREATE_AD_PATH,
} from '../../../utils/constants';

context('Create detector', () => {
it.skip('Create detector - from dashboard', () => {
cy.mockSearchIndexOnAction('search_index_response.json', () => {
cy.visit(BASE_AD_CREATE_AD_PATH);
});
cy.mockSearchIndexOnAction(
AD_FIXTURE_BASE_PATH + 'search_index_response.json',
() => {
cy.visit(BASE_AD_CREATE_AD_PATH);
}
);

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

const detectorName = 'detector-name';
cy.get('input[name="detectorName"]').type(detectorName, { force: true });

cy.mockGetIndexMappingsOnAction('index_mapping_response.json', () => {
cy.get('input[role="textbox"]').first().type('e2e-test-index{enter}', {
force: true,
});
});
cy.mockGetIndexMappingsOnAction(
AD_FIXTURE_BASE_PATH + 'index_mapping_response.json',
() => {
cy.get('input[role="textbox"]').first().type('e2e-test-index{enter}', {
force: true,
});
}
);

cy.get('input[role="textbox"]').last().type('timestamp{enter}', {
force: true,
});

cy.mockCreateDetectorOnAction('post_detector_response.json', () => {
cy.get('[data-test-subj=createOrSaveDetectorButton]').click({
force: true,
});
});
cy.mockCreateDetectorOnAction(
AD_FIXTURE_BASE_PATH + 'post_detector_response.json',
() => {
cy.get('[data-test-subj=createOrSaveDetectorButton]').click({
force: true,
});
}
);

cy.contains('h1', detectorName);
cy.contains('h3', 'Detector configuration');
Expand Down
Loading