Skip to content

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

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:pattern-fly-5from
kyoto:pf5-tests-playwright
Jun 1, 2026
Merged

PF5: OLS-3197: Migrate e2e tests from Cypress to Playwright#2005
openshift-merge-bot[bot] merged 1 commit into
openshift:pattern-fly-5from
kyoto:pf5-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

    • End-to-end testing migrated to Playwright with a comprehensive UI test suite covering popover flows, streaming responses, attachments, approvals, clipboard, and embedded resource rendering.
  • Changes

    • Test commands updated to run Playwright; test-related env vars renamed (removed CYPRESS_ prefix).
    • Test artifacts and reporting consolidated for Playwright; auth artifacts ignored in source control.
  • Documentation

    • Testing docs updated with Playwright setup and run instructions.

@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 04:01
@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

📝 Walkthrough

Walkthrough

This PR migrates end-to-end tests from Cypress to Playwright: it adds Playwright config, fixtures, global setup/teardown, and a new Playwright test suite; removes Cypress configs/support; and updates CI, scripts, and docs to use Playwright and SKIP_OLS_SETUP.

Changes

End-to-End Testing Framework Migration

Layer / File(s) Summary
Playwright Configuration and Package Setup
playwright.config.ts, package.json, tests/tsconfig.json, .claude/commands/test.md, .claude/settings.json
Adds playwright.config.ts with env-driven baseURL and storageState, updates package.json to use @playwright/test and Playwright test scripts, removes Cypress types from test tsconfig, and updates test command docs to use SKIP_OLS_SETUP and --grep.
Playwright Fixtures and Helpers
tests/support/fixtures.ts
Exports CONVERSATION_ID, mock SSE bodies, oc() wrapper, interceptQuery and interceptFeedback helpers, and a custom Playwright test fixture that captures console errors/warnings.
Global Setup and Teardown
tests/support/global-setup.ts, tests/support/global-teardown.ts
Global setup prepares OpenShift (roles, operator install/patch, OLSConfig/secret), performs browser login, captures storageState to tests/.auth/state.json. Global teardown optionally cleans up cluster resources and revokes bindings.
Playwright End-to-End Test Suite
tests/tests/lightspeed.spec.ts
New comprehensive Playwright suite covering popover UI, streamed responses (including errors/partial), HITL tool approval flows, feedback submissions, clipboard operations, attachments (YAML/Events/Logs/file uploads), ACM scenarios (skipped), and MCP iframe rendering tests.
Docs and CI Updates
tests/README.md, AGENTS.md, .tekton/...yaml, .gitignore, .dockerignore, .cursor/skills/test/SKILL.md
Documentation and CI pipeline updated to use Playwright commands, npx playwright install guidance, rename env vars (drop CYPRESS_ prefix to BASE_URL, KUBECONFIG_PATH, SKIP_OLS_SETUP, etc.), change CI test image to Playwright, and add tests/.auth/ to .gitignore.
Cypress Removal / Cleanup
cypress.config.ts, cypress/support/*, tests/views/*, tests/tests/lightspeed-install.cy.ts
Remove Cypress config, support commands, TS config, helper view modules, and legacy Cypress test spec content.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

lgtm

Suggested reviewers

  • JoaoFula
  • xrajesh

Poem

🐰 I hopped through tests from Cypress glade,
Now Playwright gardens get my blade.
I seed a state, a browser's cheer,
Capture the log when bugs appear.
A carrot for tests, a hop of glee—Lightspeed runs fast and nibble-free!

🚥 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 PR title 'PF5: OLS-3197: Migrate e2e tests from Cypress to Playwright' clearly and concisely describes the main change—a comprehensive migration of the end-to-end testing framework from Cypress to Playwright, which is confirmed by the extensive file modifications throughout the 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: 3

🧹 Nitpick comments (1)
.tekton/integration-tests/lightspeed-console-pre-commit-417.yaml (1)

149-149: Confirm Playwright image tag and flag minor lint-image overhead

  • mcr.microsoft.com/playwright:v1.60.0-noble is a published MCR tag, so the version reference is valid.
  • Using the Playwright image for the lint task (which doesn’t run Playwright) is unnecessary overhead; consider a smaller Node-based image for lint if you want to optimize.
🤖 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 @.tekton/integration-tests/lightspeed-console-pre-commit-417.yaml at line
149, The pipeline currently uses the Playwright container image string "image:
mcr.microsoft.com/playwright:v1.60.0-noble"; confirm that tag is intentional for
steps that actually run Playwright, but for the lint task replace that image
with a lightweight Node image (for example node:18-alpine or node:lts-alpine) to
avoid unnecessary Playwright overhead; keep the Playwright image only for
jobs/steps that run browser tests and update the "image:
mcr.microsoft.com/playwright:v1.60.0-noble" entry accordingly.
🤖 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/fixtures.ts`:
- Around line 67-71: The helper oc currently uses a non-null assertion on
process.env.KUBECONFIG_PATH, causing opaque runtime failures; modify oc in
tests/support/fixtures.ts to validate that process.env.KUBECONFIG_PATH is set
(or read it into a validated constant) and throw a clear, early error if missing
so tests fail fast; update the oc function (and any module-level initialization)
to check the env var before calling execFileSync so calls from
tests/support/global-setup.ts and global-teardown.ts produce an explicit failure
message when KUBECONFIG_PATH is not provided.

In `@tests/support/global-setup.ts`:
- Around line 201-204: The current execSync call builds a bash -c string
interpolating KUBECONFIG and risks command injection; replace this shell loop
with safe JS polling that calls the existing oc helper (or use
execFileSync/spawnSync with argv form) so kubeconfig is passed as a normal
argument. Specifically, remove the backticked bash -c execSync invocation and
implement a loop in tests/support/global-setup.ts that repeatedly calls the oc
helper (using OLS_CONFIG_KIND and OLS_CONFIG_NAME) with KUBECONFIG passed as an
argument, sleeping between retries and timing out after the same interval; this
avoids embedding ${KUBECONFIG} in a shell string and eliminates
injection/quoting issues.

In `@tests/tests/lightspeed.spec.ts`:
- Around line 412-417: Don't swallow assertion failures by wrapping the expect
in the same try/catch; instead only guard the clipboard read. Call
navigator.clipboard.readText() inside a try and assign to clipboardText, then
perform expect(clipboardText).toBe(MOCK_STREAMED_RESPONSE_TEXT) outside that try
so assertion failures surface; alternatively, if you prefer a single catch,
rethrow any caught error that is not a clipboard-permission error (e.g., check
error.name or message for "NotAllowedError"/"NotFoundError"/"permission" and
only suppress those), referencing navigator.clipboard.readText(), clipboardText
and MOCK_STREAMED_RESPONSE_TEXT to locate the lines to change.

---

Nitpick comments:
In @.tekton/integration-tests/lightspeed-console-pre-commit-417.yaml:
- Line 149: The pipeline currently uses the Playwright container image string
"image: mcr.microsoft.com/playwright:v1.60.0-noble"; confirm that tag is
intentional for steps that actually run Playwright, but for the lint task
replace that image with a lightweight Node image (for example node:18-alpine or
node:lts-alpine) to avoid unnecessary Playwright overhead; keep the Playwright
image only for jobs/steps that run browser tests and update the "image:
mcr.microsoft.com/playwright:v1.60.0-noble" entry accordingly.
🪄 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: 574d04e5-434c-471b-8f8a-0658cdf0793e

📥 Commits

Reviewing files that changed from the base of the PR and between 0b6d015 and f736d07.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (25)
  • .claude/commands/test.md
  • .claude/settings.json
  • .cursor/skills/test/SKILL.md
  • .dockerignore
  • .gitignore
  • .tekton/integration-tests/lightspeed-console-pre-commit-417.yaml
  • AGENTS.md
  • cypress.config.ts
  • cypress/OWNERS
  • cypress/support/commands.ts
  • cypress/support/e2e.js
  • cypress/tsconfig.json
  • package.json
  • playwright.config.ts
  • 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/tests/lightspeed-install.cy.ts
  • tests/.eslintrc.yml
  • tests/views/utils.ts
  • tests/views/operator-hub-page.ts
  • tests/views/pages.ts
  • cypress/OWNERS
  • cypress.config.ts
  • cypress/tsconfig.json
  • .dockerignore
  • cypress/support/e2e.js
  • cypress/support/commands.ts

Comment thread tests/support/fixtures.ts
Comment on lines +67 to +71
export const oc = (args: string[]): string =>
execFileSync('oc', [...args, '--kubeconfig', process.env.KUBECONFIG_PATH!], {
encoding: 'utf-8',
timeout: 180_000,
});
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 | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify unguarded kubeconfig env assertions in e2e support/setup files
rg -n -C2 'KUBECONFIG_PATH!' tests/support/fixtures.ts tests/support/global-setup.ts

Repository: openshift/lightspeed-console

Length of output: 389


🏁 Script executed:

#!/bin/bash
rg -n --hidden -S "from ['\"].*fixtures['\"]|import .*oc|export const oc|\\boc\\(" tests/support tests | head -n 200

Repository: openshift/lightspeed-console

Length of output: 4078


Fail fast when KUBECONFIG_PATH is missing (tests e2e reliability).

tests/support/fixtures.ts uses a non-null assertion (process.env.KUBECONFIG_PATH!) in oc, and both tests/support/global-setup.ts and tests/support/global-teardown.ts call oc(...), so an unset env var causes a late/opaque failure for the whole e2e run.

Proposed fix
 export const oc = (args: string[]): string =>
-  execFileSync('oc', [...args, '--kubeconfig', process.env.KUBECONFIG_PATH!], {
-    encoding: 'utf-8',
-    timeout: 180_000,
-  });
+  {
+    const kubeconfigPath = process.env.KUBECONFIG_PATH;
+    if (!kubeconfigPath) {
+      throw new Error('KUBECONFIG_PATH must be set for Playwright e2e setup');
+    }
+    return execFileSync('oc', [...args, '--kubeconfig', kubeconfigPath], {
+      encoding: 'utf-8',
+      timeout: 180_000,
+    });
+  };
📝 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
export const oc = (args: string[]): string =>
execFileSync('oc', [...args, '--kubeconfig', process.env.KUBECONFIG_PATH!], {
encoding: 'utf-8',
timeout: 180_000,
});
export const oc = (args: string[]): string =>
{
const kubeconfigPath = process.env.KUBECONFIG_PATH;
if (!kubeconfigPath) {
throw new Error('KUBECONFIG_PATH must be set for Playwright e2e setup');
}
return execFileSync('oc', [...args, '--kubeconfig', kubeconfigPath], {
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 helper oc currently uses
a non-null assertion on process.env.KUBECONFIG_PATH, causing opaque runtime
failures; modify oc in tests/support/fixtures.ts to validate that
process.env.KUBECONFIG_PATH is set (or read it into a validated constant) and
throw a clear, early error if missing so tests fail fast; update the oc function
(and any module-level initialization) to check the env var before calling
execFileSync so calls from tests/support/global-setup.ts and global-teardown.ts
produce an explicit failure message when KUBECONFIG_PATH is not provided.

Comment thread tests/support/global-setup.ts Outdated
Comment on lines +412 to +417
try {
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
expect(clipboardText).toBe(MOCK_STREAMED_RESPONSE_TEXT);
} catch {
// Clipboard access may be denied in headless mode
}
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 | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify broad catch blocks around clipboard assertions in Playwright tests
rg -n -C3 'clipboard\.readText\(\)|catch \{' tests/tests/lightspeed.spec.ts

Repository: openshift/lightspeed-console

Length of output: 420


🏁 Script executed:

#!/bin/bash
# Inspect surrounding Playwright test code for the clipboard assertion to ensure the catch also swallows expect failures.
sed -n '360,460p' tests/tests/lightspeed.spec.ts

Repository: openshift/lightspeed-console

Length of output: 4496


🏁 Script executed:

#!/bin/bash
# Inspect surrounding Playwright test code for the clipboard assertion to ensure the catch also swallows expect failures.
sed -n '380,450p' tests/tests/lightspeed.spec.ts

Repository: openshift/lightspeed-console

Length of output: 3292


🏁 Script executed:

#!/bin/bash
# Inspect surrounding Playwright test code for the clipboard assertion to ensure the catch also swallows expect failures.
sed -n '380,450p' tests/tests/lightspeed.spec.ts

Repository: openshift/lightspeed-console

Length of output: 3292


Stop swallowing clipboard assertion failures.
In tests/tests/lightspeed.spec.ts the broad try/catch wraps expect(clipboardText).toBe(...), so if the assertion fails (not just clipboard-read access), the test still passes.

Proposed fix
-      try {
-        const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
-        expect(clipboardText).toBe(MOCK_STREAMED_RESPONSE_TEXT);
-      } catch {
-        // Clipboard access may be denied in headless mode
-      }
+      const clipboardRead = await page.evaluate(async () => {
+        try {
+          return { ok: true as const, text: await navigator.clipboard.readText() };
+        } catch (error) {
+          return { ok: false as const, message: String(error) };
+        }
+      });
+      if (clipboardRead.ok) {
+        expect(clipboardRead.text).toBe(MOCK_STREAMED_RESPONSE_TEXT);
+      }
📝 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
try {
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
expect(clipboardText).toBe(MOCK_STREAMED_RESPONSE_TEXT);
} catch {
// Clipboard access may be denied in headless mode
}
const clipboardRead = await page.evaluate(async () => {
try {
return { ok: true as const, text: await navigator.clipboard.readText() };
} catch (error) {
return { ok: false as const, message: String(error) };
}
});
if (clipboardRead.ok) {
expect(clipboardRead.text).toBe(MOCK_STREAMED_RESPONSE_TEXT);
}
🤖 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/tests/lightspeed.spec.ts` around lines 412 - 417, Don't swallow
assertion failures by wrapping the expect in the same try/catch; instead only
guard the clipboard read. Call navigator.clipboard.readText() inside a try and
assign to clipboardText, then perform
expect(clipboardText).toBe(MOCK_STREAMED_RESPONSE_TEXT) outside that try so
assertion failures surface; alternatively, if you prefer a single catch, rethrow
any caught error that is not a clipboard-permission error (e.g., check
error.name or message for "NotAllowedError"/"NotFoundError"/"permission" and
only suppress those), referencing navigator.clipboard.readText(), clipboardText
and MOCK_STREAMED_RESPONSE_TEXT to locate the lines to change.

@kyoto kyoto added the lgtm Indicates that a PR is ready to be merged. label Jun 1, 2026
@kyoto kyoto changed the title PF5: Migrate e2e tests from Cypress to Playwright PF5: OLS-3197: Migrate e2e tests from Cypress to Playwright 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

Release Notes

  • New Features

  • End-to-end testing framework migrated to Playwright.

  • Changes

  • Updated test commands (test and test-headless) to use new framework.

  • Renamed test environment variables (e.g., CYPRESS_BASE_URLBASE_URL).

  • Reorganized test infrastructure and dependencies.

  • Documentation

  • Updated testing setup instructions, environment configuration, and test execution guidance.

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/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 1, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
@kyoto kyoto force-pushed the pf5-tests-playwright branch from f736d07 to aaa88b0 Compare June 1, 2026 04:43
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Jun 1, 2026

New changes are detected. LGTM label has been removed.

@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 1, 2026
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

🤖 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 111-122: The code extracts csvName via the oc(...) chain and
assumes it exists; if the CSV is not yet present csvName can be undefined and
later oc calls will fail. After the extraction of csvName (the variable assigned
from the oc(...).trim().split('\n').filter(Boolean)[0] expression) add a guard:
if (!csvName) either retry with a short backoff loop until a timeout or
throw/log a clear error and exit the setup flow so the later oc patch using
csvName is never invoked with an invalid value; ensure any retry uses the same
oc command and includes a timeout to avoid infinite loops.
- Around line 14-17: The setup reads required runtime inputs (baseURL from
config.projects[0].use.baseURL, username from process.env.LOGIN_USERNAME, and
KUBECONFIG from process.env.KUBECONFIG_PATH) without validating them; add
explicit guards at the start of the global-setup flow to validate these values
and throw or log a clear, actionable error if any are missing or empty. Locate
the initialization of baseURL, username, and KUBECONFIG in
tests/support/global-setup.ts (and the later usage around lines ~252–254) and
replace the silent assumptions with checks that: assert/throw with a descriptive
message if baseURL is falsy, assert/throw if KUBECONFIG_PATH is missing, and
optionally default username only after logging a warning or require it via an
env check so failures surface immediately.
🪄 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: 81897967-56ee-4ecf-a024-11ab71aed93e

📥 Commits

Reviewing files that changed from the base of the PR and between f736d07 and aaa88b0.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (25)
  • .claude/commands/test.md
  • .claude/settings.json
  • .cursor/skills/test/SKILL.md
  • .dockerignore
  • .gitignore
  • .tekton/integration-tests/lightspeed-console-pre-commit-417.yaml
  • AGENTS.md
  • cypress.config.ts
  • cypress/OWNERS
  • cypress/support/commands.ts
  • cypress/support/e2e.js
  • cypress/tsconfig.json
  • package.json
  • playwright.config.ts
  • 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
  • .dockerignore
  • tests/.eslintrc.yml
  • cypress/OWNERS
  • cypress/support/e2e.js
  • cypress.config.ts
  • tests/views/pages.ts
  • cypress/tsconfig.json
  • tests/views/operator-hub-page.ts
  • tests/tests/lightspeed-install.cy.ts
  • cypress/support/commands.ts
✅ Files skipped from review due to trivial changes (4)
  • .cursor/skills/test/SKILL.md
  • .gitignore
  • tests/README.md
  • .claude/commands/test.md
🚧 Files skipped from review as they are similar to previous changes (8)
  • .claude/settings.json
  • tests/tsconfig.json
  • playwright.config.ts
  • tests/support/global-teardown.ts
  • tests/support/fixtures.ts
  • package.json
  • .tekton/integration-tests/lightspeed-console-pre-commit-417.yaml
  • tests/tests/lightspeed.spec.ts

Comment on lines +14 to +17
const baseURL = config.projects[0].use.baseURL!;
const username = process.env.LOGIN_USERNAME || 'kubeadmin';
const KUBECONFIG = process.env.KUBECONFIG_PATH;

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 | 🟠 Major | ⚡ Quick win

Validate required runtime inputs before setup steps start.

Line 14, Line 16, and Line 253 rely on required values without an explicit guard. When one is missing, later failures are indirect (oc/login steps) and hard to diagnose.

Suggested fix
 const globalSetup = async (config: FullConfig) => {
-  const baseURL = config.projects[0].use.baseURL!;
+  const requireEnv = (name: string): string => {
+    const value = process.env[name];
+    if (!value) {
+      throw new Error(`Missing required environment variable: ${name}`);
+    }
+    return value;
+  };
+
+  const baseURL = config.projects[0]?.use?.baseURL;
+  if (!baseURL) {
+    throw new Error('Missing Playwright baseURL in project configuration.');
+  }
   const username = process.env.LOGIN_USERNAME || 'kubeadmin';
-  const KUBECONFIG = process.env.KUBECONFIG_PATH;
+  const kubeconfig = requireEnv('KUBECONFIG_PATH');
@@
-          KUBECONFIG!,
+          kubeconfig,
@@
-  const password = process.env.LOGIN_PASSWORD!;
+  const password = requireEnv('LOGIN_PASSWORD');

Also applies to: 252-254

🤖 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 14 - 17, The setup reads required
runtime inputs (baseURL from config.projects[0].use.baseURL, username from
process.env.LOGIN_USERNAME, and KUBECONFIG from process.env.KUBECONFIG_PATH)
without validating them; add explicit guards at the start of the global-setup
flow to validate these values and throw or log a clear, actionable error if any
are missing or empty. Locate the initialization of baseURL, username, and
KUBECONFIG in tests/support/global-setup.ts (and the later usage around lines
~252–254) and replace the silent assumptions with checks that: assert/throw with
a descriptive message if baseURL is falsy, assert/throw if KUBECONFIG_PATH is
missing, and optionally default username only after logging a warning or require
it via an env check so failures surface immediately.

Comment on lines +111 to +122
const csvName = oc([
'get',
'clusterserviceversion',
'--namespace',
OLS_NAMESPACE,
'-o',
'name',
])
.trim()
.split('\n')
.filter(Boolean)[0];

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 | 🟠 Major | ⚡ Quick win

Guard against empty CSV discovery before patching.

Line 121 can resolve to undefined when the CSV is not yet present; Line 131 then calls oc with an invalid resource name. This makes CONSOLE_IMAGE flows flaky.

Suggested fix
-      const csvName = oc([
-        'get',
-        'clusterserviceversion',
-        '--namespace',
-        OLS_NAMESPACE,
-        '-o',
-        'name',
-      ])
-        .trim()
-        .split('\n')
-        .filter(Boolean)[0];
+      let csvName: string | undefined;
+      const csvDeadline = Date.now() + 3 * MINUTE;
+      while (!csvName && Date.now() < csvDeadline) {
+        csvName = oc([
+          'get',
+          'clusterserviceversion',
+          '--namespace',
+          OLS_NAMESPACE,
+          '-o',
+          'name',
+        ])
+          .trim()
+          .split('\n')
+          .filter(Boolean)[0];
+
+        if (!csvName) {
+          await new Promise((resolve) => setTimeout(resolve, 5_000));
+        }
+      }
+
+      if (!csvName) {
+        throw new Error(`Timed out waiting for CSV in namespace ${OLS_NAMESPACE}.`);
+      }

Also applies to: 131-131

🤖 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 111 - 122, The code extracts
csvName via the oc(...) chain and assumes it exists; if the CSV is not yet
present csvName can be undefined and later oc calls will fail. After the
extraction of csvName (the variable assigned from the
oc(...).trim().split('\n').filter(Boolean)[0] expression) add a guard: if
(!csvName) either retry with a short backoff loop until a timeout or throw/log a
clear error and exit the setup flow so the later oc patch using csvName is never
invoked with an invalid value; ensure any retry uses the same oc command and
includes a timeout to avoid infinite loops.

@kyoto kyoto added the lgtm Indicates that a PR is ready to be merged. label Jun 1, 2026
@openshift-merge-bot openshift-merge-bot Bot merged commit 534c899 into openshift:pattern-fly-5 Jun 1, 2026
5 checks passed
@kyoto kyoto deleted the pf5-tests-playwright branch June 1, 2026 05:44
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