Skip to content

switch to core platform page before test case run#837

Open
Tai-RedHat wants to merge 1 commit intoopenshift:mainfrom
Tai-RedHat:fix_perspective
Open

switch to core platform page before test case run#837
Tai-RedHat wants to merge 1 commit intoopenshift:mainfrom
Tai-RedHat:fix_perspective

Conversation

@Tai-RedHat
Copy link
Contributor

@Tai-RedHat Tai-RedHat commented Mar 12, 2026

Sometimes the displayed page will switch to others rather than the admin page. For example, acm alerting ui will switch to Fleet Management when the plugin is installed.

Summary by CodeRabbit

  • Tests
    • Enhanced test reliability by establishing proper UI context before executing alerting and operator test scenarios.

@openshift-ci openshift-ci bot requested review from etmurasaki and zhuje March 12, 2026 08:16
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 12, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Tai-RedHat
Once this PR has been reviewed and has the lgtm label, please assign etmurasaki for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

Walkthrough

Two Cypress test files are modified to add perspective switching calls. The "Core platform" UI perspective is activated before navigating to the Alerting page and before interacting with the Installed Operators page, ensuring the correct UI context is loaded prior to test execution.

Changes

Cohort / File(s) Summary
Cypress Perspective Switch
web/cypress/e2e/coo/02.acm_alerting_ui.cy.ts, web/cypress/support/commands/operator-commands.ts
Adds cy.switchPerspective('Core platform') calls before navigating to Alerting and Installed Operators pages to ensure the correct UI context is active during test execution.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding a perspective switch to the Core platform before test cases run to ensure correct UI context.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Stable And Deterministic Test Names ✅ Passed Pull request modifies Cypress test files (.cy.ts), not Ginkgo tests. Ginkgo naming guidelines do not apply.
Test Structure And Quality ✅ Passed PR modifications are Cypress E2E tests in TypeScript, not Ginkgo tests. The custom check requires Ginkgo test code review, making this check not applicable.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@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)
web/cypress/support/commands/operator-commands.ts (1)

305-310: LGTM - consider guarding against redundant perspective switches.

The perspective switch before navigating to Installed Operators correctly ensures the UI is in the expected context. This addresses the PR objective.

One minor observation: the underlying switchPerspective implementation (in auth-commands.ts) does not check if the perspective is already active before attempting to switch. If waitForCOOReady is called when already on "Core platform", the code will still open the switcher menu and click unnecessarily. This is inefficient but not breaking.

,

💡 Optional: Guard against redundant switching in the command implementation

You could enhance switchPerspective in auth-commands.ts to skip switching if already on the target perspective:

// In auth-commands.ts, inside switchPerspective
cy.get('[data-test-id="perspective-switcher-toggle"]').then(($toggle) => {
  if ($toggle.text().includes(perspectives[0])) {
    cy.log(`Already on ${perspectives[0]} perspective, skipping switch`);
    return;
  }
  // ... existing switching logic
});

This would be a broader improvement applicable to all perspective switching calls.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/cypress/support/commands/operator-commands.ts` around lines 305 - 310,
The review suggests avoiding redundant UI actions: update the switchPerspective
implementation in auth-commands.ts so it first checks whether the current
perspective already matches the target (e.g., inspect the perspective switcher
element text for the desired value) and return early if so; adjust the logic
that currently always opens the '[data-test-id="perspective-switcher-toggle"]'
and clicks options, so functions like waitForCOOReady or other callers of
switchPerspective skip unnecessary menu interactions when already on the
requested perspective.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@web/cypress/support/commands/operator-commands.ts`:
- Around line 305-310: The review suggests avoiding redundant UI actions: update
the switchPerspective implementation in auth-commands.ts so it first checks
whether the current perspective already matches the target (e.g., inspect the
perspective switcher element text for the desired value) and return early if so;
adjust the logic that currently always opens the
'[data-test-id="perspective-switcher-toggle"]' and clicks options, so functions
like waitForCOOReady or other callers of switchPerspective skip unnecessary menu
interactions when already on the requested perspective.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 84b13219-27bc-4030-82eb-4007db37d10b

📥 Commits

Reviewing files that changed from the base of the PR and between 4b2ccc0 and 54216e5.

📒 Files selected for processing (2)
  • web/cypress/e2e/coo/02.acm_alerting_ui.cy.ts
  • web/cypress/support/commands/operator-commands.ts

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 12, 2026

@Tai-RedHat: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant