diff --git a/cypress/scripts/dynamic_config.ts b/cypress/scripts/dynamic_config.ts index a3ef5345e4c5..96a1611b8028 100644 --- a/cypress/scripts/dynamic_config.ts +++ b/cypress/scripts/dynamic_config.ts @@ -20,8 +20,9 @@ const CONNECTION_RETRY_INTERVAL = 15000; const checkSecurity = async (config: Cypress.PluginConfigOptions) => { const startTime = Date.now(); do { + const apiStatusUrl = new URL('/api/status', config.baseUrl); // Not catching to allow Cypress to fail - const resp = await fetch(config.baseUrl, { timeout: CONNECTION_TIMEOUT }); + const resp = await fetch(apiStatusUrl, { timeout: CONNECTION_TIMEOUT }); if (resp.status === 200) { console.log('OpenSearch Dashboards is configured without security.'); @@ -80,6 +81,8 @@ const checkPlugins = async (config: Cypress.PluginConfigOptions) => { .replace(/([A-Z])/g, '_$1') .toUpperCase(); config.env[`${envName}_ENABLED`] = true; + + console.log(`${envName} is enabled.`); }); return; diff --git a/cypress/support/conditional_describers.js b/cypress/support/conditional_describers.js index 7efb1fbe0374..cfed413d53d4 100644 --- a/cypress/support/conditional_describers.js +++ b/cypress/support/conditional_describers.js @@ -6,13 +6,13 @@ /** * Helper function to describe conditional test suites, based on features enabled in OSD * - * @param {string} featureName - The name of feature to be checked. + * @param {string[] | string} featureNames - The name of feature to be checked. * Based on the status of the feature, the suite will be described. * * @returns {Mocha.SuiteFunction & { describe: Mocha.SuiteFunction, not: Mocha.SuiteFunction & { describe: Mocha.SuiteFunction }}} */ -const ifEnabled = (featureName) => { +const ifEnabled = (featureNames) => { /** * Describes a "suite" that should be executed if the feature is enabled. * @type {Mocha.SuiteFunction & { not: Mocha.SuiteFunction & {describe: Mocha.SuiteFunction}}} @@ -20,12 +20,17 @@ const ifEnabled = (featureName) => { const describer = (name, fn, options = {}) => { const { skip = false, only = false, condition = true, not = false } = options; - if ( - skip || - !condition || - (!not && !Cypress.env(`${featureName}_ENABLED`)) || - (not && Cypress.env(`${featureName}_ENABLED`)) - ) { + let shouldSkip = skip || !condition; + if (!shouldSkip) { + const allFeaturesAreEnabled = (Array.isArray(featureNames) + ? featureNames + : [featureNames] + ).every((name) => Cypress.env(`${name}_ENABLED`)); + + shouldSkip = not ? !allFeaturesAreEnabled : allFeaturesAreEnabled; + } + + if (shouldSkip) { describe.skip(name, fn); } else if (only) { // eslint-disable-next-line mocha/no-exclusive-tests