Skip to content

Commit ea15869

Browse files
[Backport 2.x] Add functional test for datasources at observability dashboards plugin (#1024)
* Add functional test for datasources at observability dashboards plugin (#987) * Add functional test for datasources at observability dashboards plugin Signed-off-by: Ryan Liang <[email protected]> * Extend the header locating to 2 mins Signed-off-by: Ryan Liang <[email protected]> * Fix lint Signed-off-by: Ryan Liang <[email protected]> --------- Signed-off-by: Ryan Liang <[email protected]> * Change the assertions check for urls Signed-off-by: Ryan Liang <[email protected]> * Fix lint Signed-off-by: Ryan Liang <[email protected]> --------- Signed-off-by: Ryan Liang <[email protected]> Co-authored-by: Hailong Cui <[email protected]>
1 parent 684b84b commit ea15869

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/// <reference types="cypress" />
7+
8+
import { BASE_PATH } from '../../../utils/base_constants';
9+
10+
import {
11+
DATASOURCES_API_PREFIX,
12+
DATASOURCES_PATH,
13+
} from '../../../utils/plugins/observability-dashboards/constants';
14+
15+
const manageDataSourcesTag = 'button[data-test-subj="manage"]';
16+
const newDataSourcesTag = 'button[data-test-subj="new"]';
17+
const createS3Button = '[data-test-subj="datasource_card_s3glue"]';
18+
const createPrometheusButton = '[data-test-subj="datasource_card_prometheus"]';
19+
20+
const visitDatasourcesHomePage = () => {
21+
cy.visit(BASE_PATH + DATASOURCES_API_PREFIX);
22+
};
23+
24+
const visitDatasourcesCreationPage = () => {
25+
cy.visit(BASE_PATH + DATASOURCES_PATH.DATASOURCES_CREATION_BASE);
26+
};
27+
28+
describe('Integration tests for datasources plugin', () => {
29+
it('Navigates to datasources plugin and expects the correct header', () => {
30+
visitDatasourcesHomePage();
31+
cy.get('[data-test-subj="dataconnections-header"]', {
32+
timeout: 120000,
33+
}).should('exist');
34+
});
35+
36+
it('Tests navigation between tabs', () => {
37+
visitDatasourcesHomePage();
38+
39+
cy.get(manageDataSourcesTag)
40+
.should('have.class', 'euiTab-isSelected')
41+
.and('have.attr', 'aria-selected', 'true');
42+
cy.get(manageDataSourcesTag).click();
43+
cy.url().should('include', '/manage');
44+
45+
cy.get(newDataSourcesTag).click();
46+
cy.get(newDataSourcesTag)
47+
.should('have.class', 'euiTab-isSelected')
48+
.and('have.attr', 'aria-selected', 'true');
49+
cy.url().should('include', '/new');
50+
51+
cy.get(createS3Button).should('be.visible');
52+
cy.get(createPrometheusButton).should('be.visible');
53+
});
54+
55+
it('Tests navigation of S3 datasources creation page with hash', () => {
56+
visitDatasourcesCreationPage();
57+
58+
cy.get(createS3Button).should('be.visible').click();
59+
cy.url().should('include', 'configure/AmazonS3AWSGlue');
60+
61+
cy.get('h1.euiTitle.euiTitle--medium')
62+
.should('be.visible')
63+
.and('contain', 'Configure Amazon S3 data source');
64+
});
65+
66+
it('Tests navigation of Prometheus datasources creation page with hash', () => {
67+
visitDatasourcesCreationPage();
68+
69+
cy.get(createPrometheusButton).should('be.visible').click();
70+
cy.url().should('include', 'configure/Prometheus');
71+
72+
cy.get('h4.euiTitle.euiTitle--medium')
73+
.should('be.visible')
74+
.and('contain', 'Configure Prometheus data source');
75+
});
76+
});

cypress/utils/plugins/observability-dashboards/constants.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ import { BASE_PATH } from '../../base_constants';
66

77
export const delayTime = 1500;
88

9+
//Datasources API Constants
10+
export const DATASOURCES_API_PREFIX = '/app/datasources';
11+
export const DATASOURCES_PATH = {
12+
DATASOURCES_CREATION_BASE: `${DATASOURCES_API_PREFIX}#/new`,
13+
DATASOURCES_CONFIG_BASE: `${DATASOURCES_API_PREFIX}#/configure`,
14+
};
15+
916
// trace analytics
1017
export const TRACE_ID = '8832ed6abbb2a83516461960c89af49d';
1118
export const SPAN_ID = 'a673bc074b438374';

0 commit comments

Comments
 (0)