Skip to content

Commit

Permalink
Clean up test setup and setup constants
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <[email protected]>
  • Loading branch information
RyanL1997 committed Dec 21, 2023
1 parent 2b9a2eb commit 1876d6c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
25 changes: 7 additions & 18 deletions .cypress/integration/datasources_test/datasources.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,22 @@
* SPDX-License-Identifier: Apache-2.0
*/

/// <reference types="cypress" />
import {FONTEND_BASE_PATH, DATASOURCES_API_PREFIX} from '../../utils/constants'

Check failure on line 6 in .cypress/integration/datasources_test/datasources.spec.js

View workflow job for this annotation

GitHub Actions / Lint

Replace `FONTEND_BASE_PATH,·DATASOURCES_API_PREFIX}·from·'../../utils/constants'` with `·FONTEND_BASE_PATH,·DATASOURCES_API_PREFIX·}·from·'../../utils/constants';`

const moveToDatasourcesHome = () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/datasources`);
};

// const moveToNewDatasourcesPage = () => {
// cy.visit(`${Cypress.env('opensearchDashboards')}/app/datasources#/new`);
// };

// const moveToCreatePrometheusDatasourcePage = () => {
// cy.visit(`${Cypress.env('opensearchDashboards')}/app/datasources#/configure/PROMETHEUS`);
// };
const visitDatasourcesHomePage = () => {
cy.visit(FONTEND_BASE_PATH + DATASOURCES_API_PREFIX);
}

Check failure on line 10 in .cypress/integration/datasources_test/datasources.spec.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `;`

describe('Integration tests for datasources plugin', () => {

Check failure on line 12 in .cypress/integration/datasources_test/datasources.spec.js

View workflow job for this annotation

GitHub Actions / Lint

Delete `⏎⏎`
// const testPrometheusSuffix = (Math.random() + 1).toString(36).substring(7);
// const testPrometheusInstance = `Prometheus_${testPrometheusSuffix}`;
// const testS3Suffix = (Math.random() + 1).toString(36).substring(7);
// const testS3Instance = `S3_${testS3Suffix}`;


it('Navigates to datasources plugin and expects the correct header', () => {
moveToDatasourcesHome();
visitDatasourcesHomePage();
cy.get('[data-test-subj="dataconnections-header"]').should('exist');
});

it('Tests navigation between tabs and goes to Prometheus creation flow', () => {
moveToDatasourcesHome();
visitDatasourcesHomePage();
cy.get('[data-test-subj="new"]').click();
cy.url().should('include', '/new');
cy.get('[data-test-subj="datasource_card_prometheus"]').click();
Expand Down
11 changes: 11 additions & 0 deletions .cypress/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
export const delay = 1500;
export const COMMAND_TIMEOUT_LONG = 10000;

//BASE Constants
export const BACKEND_BASE_PATH = Cypress.env('opensearch');
export const FONTEND_BASE_PATH = Cypress.env('opensearchDashboards');

//Datasources API Constants
export const DATASOURCES_API_PREFIX = '/app/datasources';
export const DATASOURCES_API = {
DATASOURCES_CREATION_BASE: `${DATASOURCES_API_PREFIX}#/new`,
DATASOURCES_CONFIG_BASE: `${DATASOURCES_API_PREFIX}#/configure`

Check failure on line 17 in .cypress/utils/constants.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `,`
}

Check failure on line 18 in .cypress/utils/constants.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `;`

// trace analytics
export const TRACE_ID = '8832ed6abbb2a83516461960c89af49d';
export const SPAN_ID = 'a673bc074b438374';
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/integration-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ jobs:
node-version: ${{ steps.versions_step.outputs.node_version }}
registry-url: 'https://registry.npmjs.org'

- name: Configure OpenSearch Dashboards
run: |
rm -rf ./config/opensearch_dashboards.yml
cat << 'EOT' > ./config/opensearch_dashboards.yml
server.host: "0.0.0.0"
home.disableWelcomeScreen: true
EOT
working-directory: OpenSearch-Dashboards

- name: Install correct yarn version for OpenSearch Dashboards
run: |
npm uninstall -g yarn
Expand Down
2 changes: 0 additions & 2 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ module.exports = defineConfig({
watch: ['common/**', 'public/**', 'server/**'],
},
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./.cypress/plugins/index.js')(on, config);
},
Expand Down

0 comments on commit 1876d6c

Please sign in to comment.