From ac1e4484944075badcb3f75ff5b452e4c756e91b Mon Sep 17 00:00:00 2001 From: Robb Hamilton Date: Mon, 20 Apr 2026 14:16:42 -0400 Subject: [PATCH] OCPBUGS-83816: Fix race conditions in create-namespace Cypress tests The create-namespace.cy.ts test fails intermittently with a timeout waiting for the Installation mode radio button. Investigation revealed multiple race conditions: 1. The catalog modal Install button click could fail to navigate to the install form. The button is conditionally rendered based on the useCtaLink hook, which asynchronously processes the CTA href. Clicking before the href attribute is set causes navigation to fail silently. 2. The Installation mode radio buttons re-render asynchronously after the channel/version selectors load, causing the element to be detached from the DOM before Cypress can interact with it. This fix: - Waits for catalog-details-modal-cta to have a valid href attribute before clicking to ensure navigation will succeed - Adds .should('be.visible') wait conditions before clicking/checking radio buttons to ensure elements are stable - Applies fixes to both create-namespace.cy.ts and operator.view.ts Co-Authored-By: Claude Sonnet 4.5 --- .../integration-tests/tests/create-namespace.cy.ts | 10 ++++++++-- .../integration-tests/views/operator.view.ts | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/frontend/packages/operator-lifecycle-manager/integration-tests/tests/create-namespace.cy.ts b/frontend/packages/operator-lifecycle-manager/integration-tests/tests/create-namespace.cy.ts index 07699ec83c8..45aa28f0f2b 100644 --- a/frontend/packages/operator-lifecycle-manager/integration-tests/tests/create-namespace.cy.ts +++ b/frontend/packages/operator-lifecycle-manager/integration-tests/tests/create-namespace.cy.ts @@ -26,13 +26,19 @@ describe('Create namespace from install operators', () => { cy.byTestID('search-catalog').type(operatorName); cy.url().should('include', 'keyword'); cy.byTestID(operatorSelector).click(); - cy.byTestID('catalog-details-modal-cta').click({ force: true }); + // Wait for the Install button to be visible and have a valid href before clicking. + // The button is conditionally rendered based on useCtaLink hook, which processes + // the CTA href asynchronously. Clicking before href is set causes navigation to fail. + cy.byTestID('catalog-details-modal-cta').should('be.visible').and('have.attr', 'href'); + cy.byTestID('catalog-details-modal-cta').click(); // 3scale 2.11 supports only installation mode 'A specific namespace', // so it was automatically selected. // But starting with 2.12 it also supports 'All namespaces'. // So it is required to select this radio option to specify the namespace. - cy.byTestID('A specific namespace on the cluster-radio-input').click(); + // Regression test: Wait for radio button to be visible before clicking to avoid race conditions + // where the form re-renders asynchronously after the channel/version selectors load. + cy.byTestID('A specific namespace on the cluster-radio-input').should('be.visible').click(); // configure operator install ("^=Create_"" will match "Create_Namespace" and "Create_Project") cy.byTestID('dropdown-selectbox').click().get('[data-test-dropdown-menu^="Create_"]').click(); diff --git a/frontend/packages/operator-lifecycle-manager/integration-tests/views/operator.view.ts b/frontend/packages/operator-lifecycle-manager/integration-tests/views/operator.view.ts index 9e368aefa4d..6ff8ca66408 100644 --- a/frontend/packages/operator-lifecycle-manager/integration-tests/views/operator.view.ts +++ b/frontend/packages/operator-lifecycle-manager/integration-tests/views/operator.view.ts @@ -22,7 +22,13 @@ export const operator = { cy.log('go to operator overview panel'); cy.byTestID(operatorCardTestID).click(); cy.log('go to the install form'); - cy.byTestID('catalog-details-modal-cta').click({ force: true }); + // Wait for the Install button to be visible and have a valid href before clicking. + // The button is conditionally rendered based on useCtaLink hook, which processes + // the CTA href asynchronously. Clicking before href is set causes navigation to fail. + cy.byTestID('catalog-details-modal-cta') + .should('be.visible') + .should('have.attr', 'href') + .click(); cy.log('verify the channel selection is displayed'); cy.byTestID('operator-channel-select-toggle').should('exist'); cy.log('verify the version selection is displayed'); @@ -39,7 +45,8 @@ export const operator = { */ if (installToNamespace !== GlobalInstalledNamespace) { cy.log('configure Operator install for single namespace'); - cy.byTestID('A specific namespace on the cluster-radio-input').check(); + // Wait for radio button to be visible before checking to avoid race conditions + cy.byTestID('A specific namespace on the cluster-radio-input').should('be.visible').check(); if (useOperatorRecommendedNamespace) { cy.log('configure Operator install for operator recommended namespace'); cy.byTestID('Operator recommended Namespace:-radio-input').check();