From 3f577d54d2f895ff63ebcfd87f55581a70d162ec Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Mon, 18 Mar 2024 18:10:24 -0400 Subject: [PATCH] Try final cleanup Signed-off-by: Derek Ho --- .../multi_datasources_enabled.spec.js | 4 +++- test/cypress/support/commands.js | 15 +++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js b/test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js index b57574134..68655f71a 100644 --- a/test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js +++ b/test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js @@ -14,7 +14,9 @@ */ const createDataSource = () => { - cy.visit('http://localhost:5601/app/management/opensearch-dashboards/dataSources/create'); + cy.visit('http://localhost:5601/app/management/opensearch-dashboards/dataSources/create', { + failOnStatusCode: false, + }); cy.get('[data-test-subj="createDataSourceFormTitleField"]').focus().type('9202'); cy.get('[data-test-subj="createDataSourceFormEndpointField"]') .focus() diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index efd021c47..487413e4c 100644 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -91,12 +91,15 @@ Cypress.Commands.add('loginWithSamlMultiauth', () => { cy.get('button[id=btn-sign-in]').should('be.visible').click(); }); -Cypress.Commands.overwrite('visit', (orig, url, options = {}) => { - if (Cypress.env('LOGIN_AS_ADMIN')) { - options.auth = ADMIN_AUTH; - } - orig(url, options); -}); +if (Cypress.env('LOGIN_AS_ADMIN')) { + // Define custom cy.visit() only if LOGIN_AS_ADMIN is true + Cypress.Commands.overwrite('visit', (orig, url, options = {}) => { + if (Cypress.env('LOGIN_AS_ADMIN')) { + options.auth = ADMIN_AUTH; + } + orig(url, options); + }); +} Cypress.Commands.add('shortenUrl', (data, tenant) => { cy.request({