diff --git a/cypress.config.ts b/cypress.config.ts index 39bc969dc6cc..982a249cd2b5 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -34,7 +34,7 @@ module.exports = defineConfig({ WAIT_FOR_LOADER_BUFFER_MS: 0, }, e2e: { - baseUrl: 'http://localhost:5601', + baseUrl: 'http://localhost:5602', specPattern: 'cypress/integration/**/*.spec.{js,jsx,ts,tsx}', testIsolation: false, setupNodeEvents, diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/query_enhancements/a_check.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/query_enhancements/a_check.spec.js index 2f3578179cbf..bbc86cfd1f25 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/query_enhancements/a_check.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/query_enhancements/a_check.spec.js @@ -9,10 +9,11 @@ import { SECONDARY_ENGINE } from '../../../../../utils/constants'; const miscUtils = new MiscUtils(cy); -describe('Workspace Commands / API Test', () => { +describe('No Index Pattern Check Test', () => { before(() => { // Load test data cy.setupTestData( + SECONDARY_ENGINE.url, [ 'cypress/fixtures/query_enhancements/data-logs-1/data_logs_small_time_1.mapping.json', 'cypress/fixtures/query_enhancements/data-logs-2/data_logs_small_time_2.mapping.json', diff --git a/cypress/lib/test-fixture-handler.js b/cypress/lib/test_fixture_handler.js similarity index 92% rename from cypress/lib/test-fixture-handler.js rename to cypress/lib/test_fixture_handler.js index e653aa6ad17b..09cc15fddbc9 100644 --- a/cypress/lib/test-fixture-handler.js +++ b/cypress/lib/test_fixture_handler.js @@ -3,8 +3,10 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { BASE_ENGINE } from '../utils/constants'; + export class TestFixtureHandler { - constructor(inputTestRunner, openSearchUrl = 'localhost:9200') { + constructor(inputTestRunner, openSearchUrl = BASE_ENGINE.url) { this.testRunner = inputTestRunner; this.openSearchUrl = openSearchUrl; } diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js index 5d4afd2fc55f..9176a4029b6c 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -7,26 +7,3 @@ import '../utils/commands'; import '../utils/apps/commands'; import '../utils/dashboards/workspace-plugin/commands'; import '../utils/dashboards/commands'; - -import { TestFixtureHandler } from '../lib/test-fixture-handler'; - -Cypress.Commands.add('setupTestData', (mappingFiles, dataFiles) => { - if (!Array.isArray(mappingFiles) || !Array.isArray(dataFiles)) { - throw new Error('Both mappingFiles and dataFiles must be arrays'); - } - - if (mappingFiles.length !== dataFiles.length) { - throw new Error('The number of mapping files must match the number of data files'); - } - - const handler = new TestFixtureHandler(cy, 'http://localhost:9200'); - - let chain = cy.wrap(null); - mappingFiles.forEach((mappingFile, index) => { - chain = chain - .then(() => handler.importMapping(mappingFile)) - .then(() => handler.importData(dataFiles[index])); - }); - - return chain; -}); diff --git a/cypress/utils/commands.js b/cypress/utils/commands.js index 499ea9c1f338..93d9d4b3d7d8 100644 --- a/cypress/utils/commands.js +++ b/cypress/utils/commands.js @@ -8,6 +8,7 @@ */ import { BASE_PATH } from './constants'; +import { TestFixtureHandler } from '../lib/test_fixture_handler'; // This function does not delete all indices Cypress.Commands.add('deleteAllIndices', () => { @@ -332,3 +333,24 @@ Cypress.Commands.add('openWorkspaceDashboard', (workspaceName) => { .find('a.euiLink') .click(); }); + +Cypress.Commands.add('setupTestData', (endpoint, mappingFiles, dataFiles) => { + if (!Array.isArray(mappingFiles) || !Array.isArray(dataFiles)) { + throw new Error('Both mappingFiles and dataFiles must be arrays'); + } + + if (mappingFiles.length !== dataFiles.length) { + throw new Error('The number of mapping files must match the number of data files'); + } + + const handler = new TestFixtureHandler(cy, endpoint); + + let chain = cy.wrap(null); + mappingFiles.forEach((mappingFile, index) => { + chain = chain + .then(() => handler.importMapping(mappingFile)) + .then(() => handler.importData(dataFiles[index])); + }); + + return chain; +});