Skip to content

OLS-3197: Migrate e2e tests from Cypress to Playwright#2004

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
kyoto:tests-playwright
Jun 1, 2026
Merged

OLS-3197: Migrate e2e tests from Cypress to Playwright#2004
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
kyoto:tests-playwright

Conversation

@kyoto
Copy link
Copy Markdown
Member

@kyoto kyoto commented Jun 1, 2026

Manual cherry pick of #1997

Summary by CodeRabbit

  • New Features

    • Replace Cypress with Playwright for end-to-end testing and add a comprehensive Playwright test suite for the Lightspeed UI.
  • Documentation

    • Updated test guides and commands to use Playwright, updated tag-filtering and artifact instructions.
  • Chores

    • CI/CD and developer scripts switched to Playwright; removed legacy Cypress tooling and adjusted ignore rules for test auth artifacts.
  • Tests

    • Removed legacy Cypress test/support files and added Playwright fixtures, global setup/teardown, and test helpers.

@kyoto kyoto added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 1, 2026
@openshift-ci openshift-ci Bot requested review from JoaoFula and syedriko June 1, 2026 03:03
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Jun 1, 2026

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

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

1 similar comment
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Jun 1, 2026

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e7369d51-067a-4268-ac62-68f10918bdc6

📥 Commits

Reviewing files that changed from the base of the PR and between b913797 and cc7511d.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (27)
  • .ai/spec/how/project-structure.md
  • .claude/commands/test.md
  • .claude/settings.json
  • .cursor/skills/test/SKILL.md
  • .dockerignore
  • .gitignore
  • .tekton/integration-tests/lightspeed-console-pre-commit.yaml
  • AGENTS.md
  • cypress.config.ts
  • cypress/OWNERS
  • cypress/support/commands.ts
  • cypress/support/e2e.js
  • cypress/tsconfig.json
  • package.json
  • playwright.config.ts
  • renovate.json
  • tests/.eslintrc.yml
  • tests/README.md
  • tests/support/fixtures.ts
  • tests/support/global-setup.ts
  • tests/support/global-teardown.ts
  • tests/tests/lightspeed-install.cy.ts
  • tests/tests/lightspeed.spec.ts
  • tests/tsconfig.json
  • tests/views/operator-hub-page.ts
  • tests/views/pages.ts
  • tests/views/utils.ts
💤 Files with no reviewable changes (11)
  • tests/views/utils.ts
  • tests/.eslintrc.yml
  • cypress/support/e2e.js
  • tests/views/pages.ts
  • cypress/tsconfig.json
  • tests/views/operator-hub-page.ts
  • cypress/OWNERS
  • cypress/support/commands.ts
  • cypress.config.ts
  • tests/tests/lightspeed-install.cy.ts
  • .dockerignore
✅ Files skipped from review due to trivial changes (5)
  • .gitignore
  • .cursor/skills/test/SKILL.md
  • .claude/settings.json
  • tests/tsconfig.json
  • .ai/spec/how/project-structure.md
🚧 Files skipped from review as they are similar to previous changes (9)
  • AGENTS.md
  • .claude/commands/test.md
  • playwright.config.ts
  • tests/support/global-teardown.ts
  • tests/README.md
  • tests/support/fixtures.ts
  • package.json
  • .tekton/integration-tests/lightspeed-console-pre-commit.yaml
  • tests/support/global-setup.ts

📝 Walkthrough

Walkthrough

This PR completes a comprehensive migration from Cypress to Playwright for end-to-end testing. The changes introduce Playwright configuration, global setup/teardown scaffolding for OpenShift cluster preparation and auth state capture, a new comprehensive test suite covering UI functionality and API integration, removal of all Cypress artifacts, and updated CI/CD pipelines and documentation.

Changes

End-to-End Test Framework Migration

Layer / File(s) Summary
Playwright Configuration & Test Foundation
playwright.config.ts
Playwright config with baseURL derivation, auth state persistence via tests/.auth/state.json, conditional global setup/teardown based on SKIP_OLS_SETUP, and reporter/artifact output to gui_test_screenshots/.
Test Fixtures & API Route Interception
tests/support/fixtures.ts
Mock streaming response bodies, interceptQuery and interceptFeedback route helpers, oc CLI wrapper for kubeconfig, and custom Playwright fixture for console error/warning capture.
Global Setup: Cluster Prep & Auth State
tests/support/global-setup.ts
OpenShift RBAC setup, conditional lightspeed-operator installation with CSV image patching, OLSConfig/secret management, and browser-based login with storage state persistence.
Global Teardown: Cluster Cleanup
tests/support/global-teardown.ts
Conditional cleanup of OLSConfig, namespace, and cluster role bindings when SKIP_OLS_SETUP is unset.
Comprehensive Playwright Test Suite
tests/tests/lightspeed.spec.ts
Full e2e coverage: core UI (popover/prompt/rendering), streamed responses, HITL tool approval, user feedback, clipboard, attachment menu (YAML/events/logs/uploads), ACM stubs, and MCP iframe rendering with mocked APIs.
Package Dependencies & npm Scripts
package.json
Add @playwright/test, remove Cypress/grep deps; update test and test-headless scripts to npx playwright test [--ui]; remove ./cypress from lint paths.
Test Configuration Updates
tests/tsconfig.json, tests/.eslintrc.yml
Remove Cypress/grep from TypeScript types; remove unused-expressions eslint rule.
Tekton Pipeline Migration
.tekton/integration-tests/lightspeed-console-pre-commit.yaml
Switch container image to mcr.microsoft.com/playwright:v1.60.0-noble; replace CYPRESS_* env vars with non-prefixed equivalents; run npx playwright test and capture exit code to /workspace/playwright-exit-code; update assertion step.
Dependency Management
renovate.json
Add @playwright/* to test package grouping.
Docker & Git Configuration
.gitignore, .dockerignore
Add tests/.auth/ to .gitignore; remove cypress from .dockerignore.
Documentation & CLI Integration
AGENTS.md, tests/README.md, .claude/commands/test.md, .claude/settings.json, .cursor/skills/test/SKILL.md, .ai/spec/how/project-structure.md
Update all docs and CLI tool config to use Playwright: replace Cypress install/run commands with npx playwright install and npx playwright test; change env var prefix and tag filter syntax.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • openshift/lightspeed-console#1997: Part of the same Cypress→Playwright migration effort; overlaps in updating test-selection command docs and Playwright support fixtures like interceptQuery and interceptFeedback.

Suggested labels

lgtm

Suggested reviewers

  • JoaoFula
  • xrajesh

Poem

🐰 Hopping from Cypress to Playwright so bright,
The tests now run with dynamic delight.
Global setup hums and storage state persists,
Mocked APIs chatter while console logs hiss.
One bunny cheer for tests that finally fit.

🚥 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 clearly and specifically summarizes the main change: migrating the end-to-end testing framework from Cypress to Playwright, which is the primary focus of the entire changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ 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

@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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/support/fixtures.ts (1)

67-71: 💤 Low value

Consider adding a guard for missing KUBECONFIG_PATH.

The non-null assertion on process.env.KUBECONFIG_PATH! will cause a cryptic error at runtime if the environment variable is not set. A clearer error message would help debugging.

💡 Suggested improvement
-export const oc = (args: string[]): string =>
-  execFileSync('oc', [...args, '--kubeconfig', process.env.KUBECONFIG_PATH!], {
+export const oc = (args: string[]): string => {
+  if (!process.env.KUBECONFIG_PATH) {
+    throw new Error('KUBECONFIG_PATH environment variable is not set');
+  }
+  return execFileSync('oc', [...args, '--kubeconfig', process.env.KUBECONFIG_PATH], {
     encoding: 'utf-8',
     timeout: 180_000,
   });
+};
🤖 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 `@tests/support/fixtures.ts` around lines 67 - 71, The oc helper uses
process.env.KUBECONFIG_PATH! with a non-null assertion which will throw a
cryptic error when KUBECONFIG_PATH is missing; update the oc function to first
read and validate process.env.KUBECONFIG_PATH (referencing the oc function and
process.env.KUBECONFIG_PATH) and, if it's undefined or empty, throw a
descriptive Error (e.g., "KUBECONFIG_PATH environment variable is required for
tests") or return a clear failure before calling execFileSync so callers get a
helpful message rather than a runtime null assertion.
🤖 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.

Inline comments:
In `@tests/support/global-setup.ts`:
- Around line 246-247: Add an explicit runtime check for the LOGIN_PASSWORD
environment variable before using the non-null assertion: read
process.env.LOGIN_PASSWORD into a local (e.g., password) and if it is undefined
or empty, throw an Error or call process.exit with a clear message like
"LOGIN_PASSWORD environment variable must be set" so the code in
tests/support/global-setup.ts fails fast instead of crashing at runtime when
using the password variable; update the block where idp and password are set to
validate password and provide actionable guidance.
- Around line 201-204: The execSync call that builds a shell string using
interpolated variables (execSync(...`timeout 180 bash -c 'until ! oc get
${OLS_CONFIG_KIND} ${OLS_CONFIG_NAME} --kubeconfig ${KUBECONFIG} ...'`)) is
vulnerable to command injection; replace it with a safe execFileSync-based
invocation (require('child_process').execFileSync) or equivalent that passes the
binary ("timeout" or "bash") and each argument as an array instead of a single
interpolated shell string, or explicitly validate/escape OLS_CONFIG_KIND,
OLS_CONFIG_NAME, and KUBECONFIG beforehand; locate the call to execSync in
tests/support/global-setup.ts and change it to use execFileSync with args array
(or validated values) and preserve the timeout option passed via the options
object.

---

Nitpick comments:
In `@tests/support/fixtures.ts`:
- Around line 67-71: The oc helper uses process.env.KUBECONFIG_PATH! with a
non-null assertion which will throw a cryptic error when KUBECONFIG_PATH is
missing; update the oc function to first read and validate
process.env.KUBECONFIG_PATH (referencing the oc function and
process.env.KUBECONFIG_PATH) and, if it's undefined or empty, throw a
descriptive Error (e.g., "KUBECONFIG_PATH environment variable is required for
tests") or return a clear failure before calling execFileSync so callers get a
helpful message rather than a runtime null assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 29016ee3-69c2-4fcc-9e14-c2a780e25315

📥 Commits

Reviewing files that changed from the base of the PR and between 163e863 and b913797.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (27)
  • .ai/spec/how/project-structure.md
  • .claude/commands/test.md
  • .claude/settings.json
  • .cursor/skills/test/SKILL.md
  • .dockerignore
  • .gitignore
  • .tekton/integration-tests/lightspeed-console-pre-commit.yaml
  • AGENTS.md
  • cypress.config.ts
  • cypress/OWNERS
  • cypress/support/commands.ts
  • cypress/support/e2e.js
  • cypress/tsconfig.json
  • package.json
  • playwright.config.ts
  • renovate.json
  • tests/.eslintrc.yml
  • tests/README.md
  • tests/support/fixtures.ts
  • tests/support/global-setup.ts
  • tests/support/global-teardown.ts
  • tests/tests/lightspeed-install.cy.ts
  • tests/tests/lightspeed.spec.ts
  • tests/tsconfig.json
  • tests/views/operator-hub-page.ts
  • tests/views/pages.ts
  • tests/views/utils.ts
💤 Files with no reviewable changes (11)
  • tests/views/utils.ts
  • cypress/support/e2e.js
  • cypress.config.ts
  • tests/.eslintrc.yml
  • cypress/tsconfig.json
  • .dockerignore
  • tests/tests/lightspeed-install.cy.ts
  • tests/views/operator-hub-page.ts
  • cypress/OWNERS
  • tests/views/pages.ts
  • cypress/support/commands.ts

Comment thread tests/support/global-setup.ts Outdated
Comment on lines +246 to +247
const idp = process.env.LOGIN_IDP || 'kube:admin';
const password = process.env.LOGIN_PASSWORD!;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Missing validation for LOGIN_PASSWORD environment variable.

The non-null assertion on LOGIN_PASSWORD will cause a runtime error if the variable is not set. Consider adding an early validation with a clear error message to fail fast with actionable guidance.

💡 Proposed fix
   const idp = process.env.LOGIN_IDP || 'kube:admin';
-  const password = process.env.LOGIN_PASSWORD!;
+  const password = process.env.LOGIN_PASSWORD;
+  if (!password) {
+    throw new Error('LOGIN_PASSWORD environment variable is required for global setup');
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const idp = process.env.LOGIN_IDP || 'kube:admin';
const password = process.env.LOGIN_PASSWORD!;
const idp = process.env.LOGIN_IDP || 'kube:admin';
const password = process.env.LOGIN_PASSWORD;
if (!password) {
throw new Error('LOGIN_PASSWORD environment variable is required for global setup');
}
🤖 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 `@tests/support/global-setup.ts` around lines 246 - 247, Add an explicit
runtime check for the LOGIN_PASSWORD environment variable before using the
non-null assertion: read process.env.LOGIN_PASSWORD into a local (e.g.,
password) and if it is undefined or empty, throw an Error or call process.exit
with a clear message like "LOGIN_PASSWORD environment variable must be set" so
the code in tests/support/global-setup.ts fails fast instead of crashing at
runtime when using the password variable; update the block where idp and
password are set to validate password and provide actionable guidance.

@kyoto kyoto added the lgtm Indicates that a PR is ready to be merged. label Jun 1, 2026
@kyoto kyoto changed the title Migrate e2e tests from Cypress to Playwright OLS-3197: Migrate e2e tests from Cypress to Playwright Jun 1, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 1, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Jun 1, 2026

@kyoto: This pull request references OLS-3197 which is a valid jira issue.

Details

In response to this:

Summary by CodeRabbit

  • New Features

  • Switched end-to-end testing framework from Cypress to Playwright for improved performance and reliability.

  • Documentation

  • Updated test execution guides with new Playwright commands and tag-filtering syntax.

  • Chores

  • Updated dependencies: removed Cypress-related packages, added Playwright test framework.

  • Updated CI/CD pipeline to use Playwright instead of Cypress.

  • Removed legacy Cypress configuration and support files.

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.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kyoto kyoto force-pushed the tests-playwright branch from b913797 to cc7511d Compare June 1, 2026 05:39
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 1, 2026
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Jun 1, 2026

New changes are detected. LGTM label has been removed.

@kyoto kyoto added the lgtm Indicates that a PR is ready to be merged. label Jun 1, 2026
@kyoto
Copy link
Copy Markdown
Member Author

kyoto commented Jun 1, 2026

/override "Red Hat Konflux / e2e-console-pf6 / lightspeed-console"

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Jun 1, 2026

@kyoto: Overrode contexts on behalf of kyoto: Red Hat Konflux / e2e-console-pf6 / lightspeed-console

Details

In response to this:

/override "Red Hat Konflux / e2e-console-pf6 / lightspeed-console"

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.

@openshift-merge-bot openshift-merge-bot Bot merged commit 1a8bdf5 into openshift:main Jun 1, 2026
5 of 6 checks passed
@kyoto kyoto deleted the tests-playwright branch June 1, 2026 06:36
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. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants