|
| 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 | +}); |
0 commit comments