Skip to content

CONSOLE-5196: Fix flaky Playwright e2e tests caused by OAuth redirect timing#16740

Open
rhamilto wants to merge 1 commit into
openshift:mainfrom
rhamilto:CONSOLE-5196
Open

CONSOLE-5196: Fix flaky Playwright e2e tests caused by OAuth redirect timing#16740
rhamilto wants to merge 1 commit into
openshift:mainfrom
rhamilto:CONSOLE-5196

Conversation

@rhamilto

@rhamilto rhamilto commented Jul 8, 2026

Copy link
Copy Markdown
Member

Analysis / Root cause:

Several Playwright e2e tests fail intermittently in CI because they interact with the page before the OAuth redirect chain (/ → /oauth/authorize → /auth/callback → /) completes. Tests using bare page.goto('/') without waiting for the SPA to fully render attempt to find elements that don't exist yet, causing timeout failures.

Five flaky tests were identified:

  • quotas.spec.ts — ClusterResourceQuota visibility assertions use default 5s timeout, too tight for cluster-scoped resource propagation
  • masthead.spec.ts — bare page.goto('/') without waiting for OAuth flow
  • favorites.spec.ts — bare page.goto('/') without waiting for OAuth flow
  • web-terminal-admin.spec.tsBasePage.goTo('/') doesn't verify the SPA rendered; console never fully loads
  • base-page.ts (warmupSPA) — default 5s toBeVisible timeout too tight for OAuth redirects in CI

Additionally, an accessibility bug was identified in the other-routes.spec.ts test — a PatternFly DataViewFilters MenuToggle has no accessible name. This is an upstream bug filed as patternfly/react-data-view#680.

Solution description:

  • warmupSPA (base-page.ts): Increase page.goto('/') timeout to 60s with waitUntil: 'domcontentloaded' and toBeVisible timeout to 30s to accommodate OAuth redirects in CI
  • quotas.spec.ts: Increase ClusterResourceQuota toBeVisible timeout to 30s (lines 93, 116) for cluster-scoped resource propagation
  • masthead.spec.ts: Add warmupSPA in beforeEach and remove redundant bare page.goto('/') from each test
  • favorites.spec.ts: Replace bare page.goto('/') with warmupSPA
  • web-terminal-admin.spec.ts / web-terminal-page.ts: Replace this.goTo('/') with warmupSPA in waitForTerminalIconVisible so the console fully loads before looking for the terminal icon

Screenshots / screen recording:

Test setup:
Run the affected Playwright e2e tests in CI to verify they no longer flake.

Test cases:

  • quotas.spec.ts — "All Projects shows ClusterResourceQuotas" and "project namespace shows AppliedClusterResourceQuotas" should pass reliably
  • masthead.spec.ts — "quick create should open Deploy Image" and all other masthead tests should pass reliably
  • favorites.spec.ts — "adds, displays, removes, and limits favorites" should pass reliably
  • web-terminal-admin.spec.ts — "open and close multiple terminal tabs" should pass reliably

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:
Upstream PatternFly issue for the DataViewFilters a11y bug: patternfly/react-data-view#680

Summary by CodeRabbit

  • Bug Fixes (E2E Reliability)
    • Standardized SPA warm-up/navigation across Web Terminal, Masthead, and Favorites E2E flows.
    • Added explicit readiness waits during warm-up to ensure the main page is ready before assertions.
    • Increased stability of quota-related UI checks by adding longer element visibility timeouts.
    • Added a pre-check to confirm the expected cluster resource exists before running later quota list tests.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 8, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@rhamilto: This pull request references CONSOLE-5196 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Analysis / Root cause:

Several Playwright e2e tests fail intermittently in CI because they interact with the page before the OAuth redirect chain (/ → /oauth/authorize → /auth/callback → /) completes. Tests using bare page.goto('/') without waiting for the SPA to fully render attempt to find elements that don't exist yet, causing timeout failures.

Five flaky tests were identified:

  • quotas.spec.ts — ClusterResourceQuota visibility assertions use default 5s timeout, too tight for cluster-scoped resource propagation
  • masthead.spec.ts — bare page.goto('/') without waiting for OAuth flow
  • favorites.spec.ts — bare page.goto('/') without waiting for OAuth flow
  • web-terminal-admin.spec.tsBasePage.goTo('/') doesn't verify the SPA rendered; console never fully loads
  • base-page.ts (warmupSPA) — default 5s toBeVisible timeout too tight for OAuth redirects in CI

Additionally, an accessibility bug was identified in the other-routes.spec.ts test — a PatternFly DataViewFilters MenuToggle has no accessible name. This is an upstream bug filed as patternfly/react-data-view#680.

Solution description:

  • warmupSPA (base-page.ts): Increase page.goto('/') timeout to 60s with waitUntil: 'domcontentloaded' and toBeVisible timeout to 30s to accommodate OAuth redirects in CI
  • quotas.spec.ts: Increase ClusterResourceQuota toBeVisible timeout to 30s (lines 93, 116) for cluster-scoped resource propagation
  • masthead.spec.ts: Add warmupSPA in beforeEach and remove redundant bare page.goto('/') from each test
  • favorites.spec.ts: Replace bare page.goto('/') with warmupSPA
  • web-terminal-admin.spec.ts / web-terminal-page.ts: Replace this.goTo('/') with warmupSPA in waitForTerminalIconVisible so the console fully loads before looking for the terminal icon

Screenshots / screen recording:

Test setup:
Run the affected Playwright e2e tests in CI to verify they no longer flake.

Test cases:

  • quotas.spec.ts — "All Projects shows ClusterResourceQuotas" and "project namespace shows AppliedClusterResourceQuotas" should pass reliably
  • masthead.spec.ts — "quick create should open Deploy Image" and all other masthead tests should pass reliably
  • favorites.spec.ts — "adds, displays, removes, and limits favorites" should pass reliably
  • web-terminal-admin.spec.ts — "open and close multiple terminal tabs" should pass reliably

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:
Upstream PatternFly issue for the DataViewFilters a11y bug: patternfly/react-data-view#680

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

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ab100474-404b-4987-be12-ebb7a084f28d

📥 Commits

Reviewing files that changed from the base of the PR and between 25eeceb and f36dc10.

📒 Files selected for processing (7)
  • frontend/e2e/clients/kubernetes-client.ts
  • frontend/e2e/pages/base-page.ts
  • frontend/e2e/pages/web-terminal-page.ts
  • frontend/e2e/tests/console/app/masthead.spec.ts
  • frontend/e2e/tests/console/crud/quotas.spec.ts
  • frontend/e2e/tests/console/favorites/favorites.spec.ts
  • frontend/e2e/tests/webterminal/web-terminal-admin.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • frontend/e2e/tests/webterminal/web-terminal-admin.spec.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • frontend/e2e/tests/console/favorites/favorites.spec.ts
  • frontend/e2e/pages/base-page.ts
  • frontend/e2e/pages/web-terminal-page.ts
  • frontend/e2e/tests/console/app/masthead.spec.ts

Walkthrough

Playwright E2E setup now uses shared SPA warmup behavior with explicit navigation and visibility timeouts. Quota tests verify cluster resource creation through the Kubernetes client and extend list visibility waits.

Changes

E2E warmup and quota readiness

Layer / File(s) Summary
Shared SPA warmup integration
frontend/e2e/pages/base-page.ts, frontend/e2e/pages/web-terminal-page.ts, frontend/e2e/tests/console/app/masthead.spec.ts, frontend/e2e/tests/console/favorites/favorites.spec.ts, frontend/e2e/tests/webterminal/web-terminal-admin.spec.ts
warmupSPA uses explicit navigation and heading visibility timeouts; affected page objects and specs use the shared helper for SPA setup.
Quota resource readiness validation
frontend/e2e/clients/kubernetes-client.ts, frontend/e2e/tests/console/crud/quotas.spec.ts
Adds a cluster-scoped custom resource getter, waits for ClusterResourceQuota creation, and applies 30-second visibility timeouts to quota list assertions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: component/dev-console

Suggested reviewers: spadgett, sg00dwin

🚥 Pre-merge checks | ✅ 12 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Structure And Quality ⚠️ Warning favorites.spec.ts still crams add/display/remove/limit favorites into one It block, so the PR doesn’t meet the single-responsibility test-structure requirement. Split the favorites scenarios into separate It blocks and add explicit failure messages to the new waits/assertions.
Microshift Test Compatibility ⚠️ Warning quotas.spec.ts still uses quota.openshift.io ClusterResourceQuota/AppliedClusterResourceQuota without MicroShift skip or apigroup tagging. Guard it with [Skipped:MicroShift] or [apigroup:quota.openshift.io], or rewrite the test to avoid ClusterResourceQuota/AppliedClusterResourceQuota.
✅ Passed checks (12 passed)
Check name Status Explanation
Title check ✅ Passed The title is specific and matches the main change: fixing flaky Playwright e2e tests from OAuth redirect timing.
Description check ✅ Passed The description includes the required root cause, solution, testing, browser conformance, and extra info sections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed Changed test titles are static strings; only runtime-generated names appear in test bodies, not in It/Describe/Context titles.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo tests or SNO-sensitive multi-node assumptions were introduced; the changed Playwright specs only adjust waits/navigation and use single-cluster APIs.
Topology-Aware Scheduling Compatibility ✅ Passed Diff only touches e2e tests/page objects and a client helper; no manifests/controllers/operator scheduling constraints or topology-aware node/affinity logic were changed.
Ote Binary Stdout Contract ✅ Passed Touched files only adjust navigation/timeouts and add a client method; no process-level stdout writes or logging were introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Touched tests only add warmup/timeouts; no hardcoded IPv4, IPv4-only parsing, or external/public connectivity was introduced.
No-Weak-Crypto ✅ Passed No MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret/token comparisons appear in the touched diff.
Container-Privileges ✅ Passed No container/K8s manifest files were changed, and the diff contains no privileged/hostPID/hostNetwork/hostIPC/SYS_ADMIN/allowPrivilegeEscalation fields.
No-Sensitive-Data-In-Logs ✅ Passed The diff adds no console/logger calls or sensitive-data log statements; targeted scans of all touched files and the patch found none.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot requested review from cajieh and fsgreco July 8, 2026 15:12
@openshift-ci

openshift-ci Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 8, 2026
@rhamilto

rhamilto commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

/retest backend

@rhamilto

rhamilto commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

/test backend

1 similar comment
@rhamilto

rhamilto commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

/test backend

@rhamilto

rhamilto commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@rhamilto

rhamilto commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@rhamilto

rhamilto commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

/test e2e-playwright

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
frontend/e2e/tests/console/crud/quotas.spec.ts (1)

93-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract duplicated retry-and-reload logic into a shared helper.

The same 3-attempt retry/reload/re-filter pattern is duplicated verbatim in both tests. Consider extracting it into a reusable helper (e.g., in list-page.ts) to avoid drift if the retry strategy needs tuning later. Also consider logging or narrowing the caught error so unrelated failures (e.g., wrong selector) aren't silently retried and masked.

♻️ Proposed helper extraction
+// in list-page.ts (or a shared e2e util)
+async function waitForCellVisibleWithRetry(
+  page: Page,
+  listPage: ListPage,
+  resourceName: string,
+  attempts = 3,
+  timeout = 10_000,
+): Promise<void> {
+  for (let attempt = 0; attempt < attempts; attempt++) {
+    try {
+      await expect(listPage.getCell(resourceName)).toBeVisible({ timeout });
+      return;
+    } catch (err) {
+      if (attempt === attempts - 1) throw err;
+      await page.reload({ waitUntil: 'domcontentloaded' });
+      await listPage.filterByName(resourceName);
+    }
+  }
+}
-    for (let attempt = 0; attempt < 3; attempt++) {
-      try {
-        await expect(listPage.getCell(clusterQuotaName)).toBeVisible({ timeout: 10_000 });
-        break;
-      } catch {
-        await page.reload({ waitUntil: 'domcontentloaded' });
-        await listPage.filterByName(clusterQuotaName);
-      }
-    }
-    await expect(listPage.getCell(clusterQuotaName)).toBeVisible({ timeout: 10_000 });
+    await waitForCellVisibleWithRetry(page, listPage, clusterQuotaName);

Also applies to: 125-134

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/e2e/tests/console/crud/quotas.spec.ts` around lines 93 - 102, The
3-attempt retry, reload, and re-filter flow is duplicated in the quota CRUD
tests and should be extracted into a shared helper to keep the behavior
consistent. Move the repeated logic into a reusable utility such as a method on
listPage in list-page.ts, then update both tests to call that helper instead of
inlining the loop. While refactoring, avoid catching everything silently: narrow
or log the caught error so only the intended transient failures are retried and
unrelated selector/test issues are not masked.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@frontend/e2e/tests/console/crud/quotas.spec.ts`:
- Around line 93-102: The 3-attempt retry, reload, and re-filter flow is
duplicated in the quota CRUD tests and should be extracted into a shared helper
to keep the behavior consistent. Move the repeated logic into a reusable utility
such as a method on listPage in list-page.ts, then update both tests to call
that helper instead of inlining the loop. While refactoring, avoid catching
everything silently: narrow or log the caught error so only the intended
transient failures are retried and unrelated selector/test issues are not
masked.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4175aa4d-a6a2-4dce-a4da-36b32d40ebcf

📥 Commits

Reviewing files that changed from the base of the PR and between 61f7b81 and 25eeceb.

📒 Files selected for processing (6)
  • frontend/e2e/pages/base-page.ts
  • frontend/e2e/pages/web-terminal-page.ts
  • frontend/e2e/tests/console/app/masthead.spec.ts
  • frontend/e2e/tests/console/crud/quotas.spec.ts
  • frontend/e2e/tests/console/favorites/favorites.spec.ts
  • frontend/e2e/tests/webterminal/web-terminal-admin.spec.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • frontend/e2e/tests/console/favorites/favorites.spec.ts
  • frontend/e2e/pages/base-page.ts
  • frontend/e2e/tests/webterminal/web-terminal-admin.spec.ts
  • frontend/e2e/pages/web-terminal-page.ts
  • frontend/e2e/tests/console/app/masthead.spec.ts

… timing

Several e2e tests fail intermittently because they interact with the page
before the OAuth redirect chain completes. The SPA navigates through
/oauth/authorize and /auth/callback before rendering, and tests using bare
page.goto('/') without waiting for the app to load hit elements that don't
exist yet.

- warmupSPA: increase goto timeout to 60s and toBeVisible to 30s to
  accommodate OAuth redirects in CI
- quotas: increase ClusterResourceQuota visibility timeout to 30s for
  cluster-scoped resource propagation
- masthead: use warmupSPA in beforeEach instead of bare page.goto('/')
- favorites: use warmupSPA instead of bare page.goto('/')
- web-terminal: use warmupSPA in waitForTerminalIconVisible so the
  console fully loads before looking for the terminal icon

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rhamilto

Copy link
Copy Markdown
Member Author

/test backend

2 similar comments
@rhamilto

Copy link
Copy Markdown
Member Author

/test backend

@rhamilto

Copy link
Copy Markdown
Member Author

/test backend

@rhamilto

Copy link
Copy Markdown
Member Author

/test e2e-playwright
/test backend

@openshift-ci

openshift-ci Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

@rhamilto: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/backend f36dc10 link true /test backend

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

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants