Skip to content

Commit da08066

Browse files
committed
Refactor datasources test and disable security config
Signed-off-by: Ryan Liang <[email protected]>
1 parent 2115daf commit da08066

File tree

4 files changed

+73
-29
lines changed

4 files changed

+73
-29
lines changed

.cypress/integration/datasources_test/datasources.spec.js

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

.cypress/utils/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const FONTEND_BASE_PATH = Cypress.env('opensearchDashboards');
1212

1313
//Datasources API Constants
1414
export const DATASOURCES_API_PREFIX = '/app/datasources';
15-
export const DATASOURCES_API = {
15+
export const DATASOURCES_PATH = {
1616
DATASOURCES_CREATION_BASE: `${DATASOURCES_API_PREFIX}#/new`,
1717
DATASOURCES_CONFIG_BASE: `${DATASOURCES_API_PREFIX}#/configure`
1818
}

cypress.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = defineConfig({
1818
env: {
1919
opensearch: 'localhost:9200',
2020
opensearchDashboards: 'localhost:5601',
21-
security_enabled: true,
21+
security_enabled: false,
2222
},
2323
'cypress-watch-and-reload': {
2424
watch: ['common/**', 'public/**', 'server/**'],

0 commit comments

Comments
 (0)