Skip to content

OCPBUGS-83816: Fix race conditions in create-namespace Cypress tests#16306

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
rhamilto:OCPBUGS-83816-fix-create-namespace-test-flake
Apr 22, 2026
Merged

OCPBUGS-83816: Fix race conditions in create-namespace Cypress tests#16306
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
rhamilto:OCPBUGS-83816-fix-create-namespace-test-flake

Conversation

@rhamilto
Copy link
Copy Markdown
Member

@rhamilto rhamilto commented Apr 20, 2026

What is this PR about?

Fixes intermittent failures in the create-namespace.cy.ts Cypress test caused by race conditions.

Root Cause Analysis

Investigation revealed two distinct race conditions:

  1. Install button navigation failure: The catalog modal Install button (catalog-details-modal-cta) is conditionally rendered based on the useCtaLink hook, which asynchronously processes the CTA href by parsing query parameters. Clicking the button before the href attribute is fully set causes navigation to the install form to fail silently.

  2. Radio button detachment: The Installation mode radio buttons re-render asynchronously after the channel/version selectors load their data, causing the DOM element to be detached before Cypress can interact with it.

Changes

  • catalog-details-modal-cta clicks: Added .should('have.attr', 'href') assertion to wait for the href attribute to be set before clicking, ensuring navigation will succeed
  • Radio button interactions: Added .should('be.visible') wait conditions before clicking/checking to ensure elements are stable after async re-renders
  • Scope: Applied fixes to both create-namespace.cy.ts and operator.view.ts for consistency

Testing

  • Verified test passes locally
  • Verified fix addresses both race conditions
  • No changes to production code, test-only fix

Related Issues

🤖 Generated with Claude Code

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 20, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-83816, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Analysis / Root cause:
The create-namespace.cy.ts Cypress test fails intermittently in CI with a timeout error when attempting to click the "A specific namespace on the cluster" radio button. The test times out after 40 seconds waiting for the element to be found.

Root cause: The operator install form's Installation mode radio buttons can re-render asynchronously after the OperatorChannelSelect and OperatorVersionSelect components load their data. This causes the radio button element to be temporarily unavailable or detached from the DOM when Cypress attempts to interact with it, leading to intermittent test failures.

Solution description:
Added .should('be.visible') wait conditions before interacting with the radio button in two locations:

  1. create-namespace.cy.ts line 37: Changed from .click() to .should('be.visible').click()
  2. operator.view.ts line 42: Changed from .check() to .should('be.visible').check()

This ensures Cypress waits for the element to be visible and stable before attempting to interact with it, preventing race conditions caused by asynchronous form re-renders. This follows the same pattern used in OCPBUGS-83813 for fixing similar race conditions in debug pod tests.

Screenshots / screen recording:
N/A - This is a test-only fix with no visual changes to the UI.

Test setup:
No special setup required.

Test cases:

  • Run cd frontend && yarn test:integration tests/create-namespace.cy.ts - test should pass consistently
  • Run the test multiple times to verify it no longer flakes
  • Verify the operator install flow works correctly in the UI (manual smoke test)

Browser conformance:
N/A - This is a Cypress test fix, not a UI change.

Additional info:

🤖 Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Apr 20, 2026
@openshift-ci openshift-ci Bot requested review from Leo6Leo and jhadvig April 20, 2026 18:17
@openshift-ci openshift-ci Bot added component/olm Related to OLM approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 20, 2026
@rhamilto
Copy link
Copy Markdown
Member Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Apr 20, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-83816, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-83816, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

Analysis / Root cause:
The create-namespace.cy.ts Cypress test fails intermittently in CI with a timeout error when attempting to click the "A specific namespace on the cluster" radio button. The test times out after 40 seconds waiting for the element to be found.

Root cause: The operator install form's Installation mode radio buttons can re-render asynchronously after the OperatorChannelSelect and OperatorVersionSelect components load their data. This causes the radio button element to be temporarily unavailable or detached from the DOM when Cypress attempts to interact with it, leading to intermittent test failures.

Solution description:
Added .should('be.visible') wait conditions before interacting with the radio button in two locations:

  1. create-namespace.cy.ts line 37: Changed from .click() to .should('be.visible').click()
  2. operator.view.ts line 42: Changed from .check() to .should('be.visible').check()

This ensures Cypress waits for the element to be visible and stable before attempting to interact with it, preventing race conditions caused by asynchronous form re-renders. This follows the same pattern used in OCPBUGS-83813 for fixing similar race conditions in debug pod tests.

Screenshots / screen recording:
N/A - This is a test-only fix with no visual changes to the UI.

Test setup:
No special setup required.

Test cases:

  • Run cd frontend && yarn test:integration tests/create-namespace.cy.ts - test should pass consistently
  • Run the test multiple times to verify it no longer flakes
  • Verify the operator install flow works correctly in the UI (manual smoke test)

Browser conformance:
N/A - This is a Cypress test fix, not a UI change.

Additional info:

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
  • Improved stability of namespace selection tests by adding explicit visibility assertions before UI element interactions, reducing timing-related test failures.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 2026

📝 Walkthrough

Walkthrough

These changes introduce explicit visibility assertions to the "A specific namespace" radio option interactions across two integration test files. The test file now asserts visibility before clicking the radio option, while the view file adds a visibility check before calling .check() on the radio input. Both modifications follow the same pattern of waiting for the DOM element to be rendered and visible before proceeding with user interactions, addressing timing-related failures that occur during asynchronous UI updates.

🚥 Pre-merge checks | ✅ 10
✅ Passed checks (10 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the main change: fixing race conditions in Cypress tests for create-namespace, with clear reference to the specific issue identifier.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Stable And Deterministic Test Names ✅ Passed Check not applicable; PR modifies Cypress (TypeScript) tests, not Ginkgo (Go) tests which this check targets.
Test Structure And Quality ✅ Passed Custom Ginkgo test check is not applicable to Cypress e2e tests which use different framework patterns and language.
Microshift Test Compatibility ✅ Passed PR modifies only Cypress integration tests (.cy.ts), not Ginkgo e2e tests. No new Ginkgo test constructs (It, Describe, Context, When) are introduced.
Single Node Openshift (Sno) Test Compatibility ✅ Passed SNO test compatibility check not applicable; PR modifies Cypress UI tests for OpenShift Console frontend, not Go-based Ginkgo e2e tests.
Topology-Aware Scheduling Compatibility ✅ Passed Pull request modifies only test files in integration-tests/ directory, adding visibility assertions to reduce flakiness. No deployment manifests, operator code, or controllers affected.
Ote Binary Stdout Contract ✅ Passed The PR modifies only Cypress integration tests (TypeScript frontend test files), not Go-based OpenShift Tests Extension binaries. The OTE Binary Stdout Contract is inapplicable.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR modifies only Cypress integration tests, not Ginkgo e2e tests. Check targets Ginkgo patterns and is not applicable.
Description check ✅ Passed PR description includes root cause analysis, solution details, testing notes, and Jira reference, but lacks Browser conformance checkboxes and incomplete Test setup/cases sections.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
frontend/packages/operator-lifecycle-manager/integration-tests/tests/create-namespace.cy.ts (1)

35-37: Consider asserting the radio is selected after the click.

A post-click be.checked assertion makes this step more deterministic if a late re-render happens.

Suggested tweak
-cy.byTestID('A specific namespace on the cluster-radio-input').should('be.visible').click();
+cy.byTestID('A specific namespace on the cluster-radio-input')
+  .should('be.visible')
+  .click()
+  .should('be.checked');
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/packages/operator-lifecycle-manager/integration-tests/tests/create-namespace.cy.ts`
around lines 35 - 37, After ensuring the radio button is visible and clicking it
via cy.byTestID('A specific namespace on the cluster-radio-input'), add a
post-click assertion to confirm selection (e.g., assert it is checked) so late
re-renders can't leave the radio unselected; update the test around the
cy.byTestID(...).should('be.visible').click() step to follow the click with a
.should('be.checked') assertion targeting the same test id.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@frontend/packages/operator-lifecycle-manager/integration-tests/tests/create-namespace.cy.ts`:
- Around line 35-37: After ensuring the radio button is visible and clicking it
via cy.byTestID('A specific namespace on the cluster-radio-input'), add a
post-click assertion to confirm selection (e.g., assert it is checked) so late
re-renders can't leave the radio unselected; update the test around the
cy.byTestID(...).should('be.visible').click() step to follow the click with a
.should('be.checked') assertion targeting the same test id.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 754df77f-5576-4cf6-a975-99b34a2abde9

📥 Commits

Reviewing files that changed from the base of the PR and between 4cc53f8 and 990a6ff.

📒 Files selected for processing (2)
  • frontend/packages/operator-lifecycle-manager/integration-tests/tests/create-namespace.cy.ts
  • frontend/packages/operator-lifecycle-manager/integration-tests/views/operator.view.ts
📜 Review details
🔇 Additional comments (1)
frontend/packages/operator-lifecycle-manager/integration-tests/views/operator.view.ts (1)

42-43: Solid flake fix for the single-namespace radio interaction.

This is a good stability improvement for async form re-renders before selection.

@rhamilto
Copy link
Copy Markdown
Member Author

/retest

2 similar comments
@rhamilto
Copy link
Copy Markdown
Member Author

/retest

@rhamilto
Copy link
Copy Markdown
Member Author

/retest

@rhamilto rhamilto force-pushed the OCPBUGS-83816-fix-create-namespace-test-flake branch from 990a6ff to 51d2b6c Compare April 21, 2026 14:49
@Leo6Leo
Copy link
Copy Markdown
Contributor

Leo6Leo commented Apr 21, 2026

/retest-required

@rhamilto
Copy link
Copy Markdown
Member Author

/retest

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 <noreply@anthropic.com>
@rhamilto rhamilto force-pushed the OCPBUGS-83816-fix-create-namespace-test-flake branch from 51d2b6c to ac1e448 Compare April 22, 2026 16:37
Copy link
Copy Markdown
Member

@logonoff logonoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 22, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 22, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: logonoff, rhamilto

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@logonoff
Copy link
Copy Markdown
Member

/verified by CI

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Apr 22, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@logonoff: This PR has been marked as verified by CI.

Details

In response to this:

/verified by CI

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 22, 2026

@rhamilto: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot Bot merged commit 095e60f into openshift:main Apr 22, 2026
8 checks passed
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@rhamilto: Jira Issue Verification Checks: Jira Issue OCPBUGS-83816
✔️ This pull request was pre-merge verified.
✔️ All associated pull requests have merged.
✔️ All associated, merged pull requests were pre-merge verified.

Jira Issue OCPBUGS-83816 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓

Details

In response to this:

What is this PR about?

Fixes intermittent failures in the create-namespace.cy.ts Cypress test caused by race conditions.

Root Cause Analysis

Investigation revealed two distinct race conditions:

  1. Install button navigation failure: The catalog modal Install button (catalog-details-modal-cta) is conditionally rendered based on the useCtaLink hook, which asynchronously processes the CTA href by parsing query parameters. Clicking the button before the href attribute is fully set causes navigation to the install form to fail silently.

  2. Radio button detachment: The Installation mode radio buttons re-render asynchronously after the channel/version selectors load their data, causing the DOM element to be detached before Cypress can interact with it.

Changes

  • catalog-details-modal-cta clicks: Added .should('have.attr', 'href') assertion to wait for the href attribute to be set before clicking, ensuring navigation will succeed
  • Radio button interactions: Added .should('be.visible') wait conditions before clicking/checking to ensure elements are stable after async re-renders
  • Scope: Applied fixes to both create-namespace.cy.ts and operator.view.ts for consistency

Testing

  • Verified test passes locally
  • Verified fix addresses both race conditions
  • No changes to production code, test-only fix

Related Issues

🤖 Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@rhamilto rhamilto deleted the OCPBUGS-83816-fix-create-namespace-test-flake branch April 23, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/olm Related to OLM jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants