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