Skip to content

NO-ISSUE: Add Playwright e2e test for operator lifecycle metadata UI#16701

Open
perdasilva wants to merge 1 commit into
openshift:mainfrom
perdasilva:operator-lifecycle-metadata-e2e
Open

NO-ISSUE: Add Playwright e2e test for operator lifecycle metadata UI#16701
perdasilva wants to merge 1 commit into
openshift:mainfrom
perdasilva:operator-lifecycle-metadata-e2e

Conversation

@perdasilva

@perdasilva perdasilva commented Jul 2, 2026

Copy link
Copy Markdown

Analysis / Root cause:
The operator lifecycle metadata UI (Cluster Compatibility and Support Phase columns on the Installed Operators page) had no e2e test coverage. Since no catalog with real lifecycle metadata exists yet, the test uses mocked API responses to verify the UI renders correctly across all three states.

Solution description:
Adds a Playwright e2e test (frontend/e2e/tests/olm/operator-lifecycle-metadata.spec.ts) and mock data helpers (frontend/e2e/mocks/operator-lifecycle.ts) that:

  1. Install the web-terminal operator from the redhat-operators catalog via k8sClient
  2. Mock the /api/olm/lifecycle/** endpoint using page.route() with a mutable reference pattern (consistent with update-modal.spec.ts)
  3. Read the cluster's actual releaseVersion from SERVER_FLAGS to build accurate mock data
  4. Skip automatically on clusters without tech preview enabled
  5. Verify three lifecycle states across test.step blocks:
    • Active support + compatible cluster — "Maintenance support" phase badge and "Compatible" indicator
    • Self-support — all phases expired, shows "Self-support" badge
    • Incompatible — cluster version not in compatibility list, shows "Incompatible" indicator
  6. Clean up the Subscription and CSVs in afterAll

Mock dates are computed dynamically relative to the current date to avoid time-bomb failures.

Screenshots / screen recording:

Test setup:

  • Requires a cluster with TechPreviewNoUpgrade feature gate enabled (for the OPERATOR_LIFECYCLE_METADATA feature flag)
  • The redhat-operators CatalogSource must be available in openshift-marketplace
  • On clusters without tech preview, the test is automatically skipped

Test cases:

  • Lifecycle columns show "Compatible" and active support phase name when mock data includes the cluster version and current-date phases
  • Lifecycle columns show "Self-support" badge when all mock phases have expired
  • Lifecycle columns show "Incompatible" when mock platform compatibility excludes the cluster version
  • Test is skipped on non-tech-preview clusters

Browser conformance:

  • Chrome

Additional info:
Verified against a live OCP 5.0 nightly cluster with tech preview enabled.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added end-to-end test coverage for operator lifecycle metadata in the installed Operators list.
    • Introduced reusable lifecycle mock payload helpers to simulate active support, self-support (expired phases), and incompatible status.
    • Provisions an OLM Subscription, waits for the CSV to succeed, then verifies lifecycle metadata UI columns using mocked lifecycle API responses.
    • Cleans up the created Subscription and removes related CSVs after the test finishes.

@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 2, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@perdasilva: This pull request explicitly references no jira issue.

Details

In response to this:

Analysis / Root cause:
The operator lifecycle metadata UI (Cluster Compatibility and Support Phase columns on the Installed Operators page) had no e2e test coverage. Since no catalog with real lifecycle metadata exists yet, the test uses mocked API responses to verify the UI renders correctly across all three states.

Solution description:
Adds a Playwright e2e test (frontend/e2e/tests/olm/operator-lifecycle-metadata.spec.ts) and mock data helpers (frontend/e2e/mocks/operator-lifecycle.ts) that:

  1. Install the web-terminal operator from the redhat-operators catalog via k8sClient
  2. Mock the /api/olm/lifecycle/** endpoint using page.route() with a mutable reference pattern (consistent with update-modal.spec.ts)
  3. Read the cluster's actual releaseVersion from SERVER_FLAGS to build accurate mock data
  4. Verify three lifecycle states across test.step blocks:
  • Active support + compatible cluster — "Maintenance support" phase badge and "Compatible" indicator
  • Self-support — all phases expired, shows "Self-support" badge
  • Incompatible — cluster version not in compatibility list, shows "Incompatible" indicator
  1. Clean up the Subscription and CSVs in afterAll

Mock dates are computed dynamically relative to the current date to avoid time-bomb failures.

Screenshots / screen recording:

Test setup:

  • Requires a cluster with TechPreviewNoUpgrade feature gate enabled (for the OPERATOR_LIFECYCLE_METADATA feature flag)
  • The redhat-operators CatalogSource must be available in openshift-marketplace

Test cases:

  • Lifecycle columns show "Compatible" and active support phase name when mock data includes the cluster version and current-date phases
  • Lifecycle columns show "Self-support" badge when all mock phases have expired
  • Lifecycle columns show "Incompatible" when mock platform compatibility excludes the cluster version

Browser conformance:

  • Chrome

Additional info:
Verified against a live OCP 5.0 nightly cluster with tech preview enabled.

🤖 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 openshift-ci Bot requested review from cajieh and fsgreco July 2, 2026 10:12
@openshift-ci

openshift-ci Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: perdasilva
Once this PR has been reviewed and has the lgtm label, please assign cajieh 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

coderabbitai Bot commented Jul 2, 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: f7b72120-6fd1-44e8-bbae-1f4c39be59b2

📥 Commits

Reviewing files that changed from the base of the PR and between c2bc5f0 and d651a59.

📒 Files selected for processing (2)
  • frontend/e2e/mocks/operator-lifecycle.ts
  • frontend/e2e/tests/olm/operator-lifecycle-metadata.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/e2e/tests/olm/operator-lifecycle-metadata.spec.ts
  • frontend/e2e/mocks/operator-lifecycle.ts

Walkthrough

Adds lifecycle mock factories and a Playwright e2e spec that provisions an OLM subscription, intercepts lifecycle API responses, and verifies lifecycle metadata labels for compatible, self-support, and incompatible states.

Changes

Operator Lifecycle E2E Test

Layer / File(s) Summary
Lifecycle payload helpers
frontend/e2e/mocks/operator-lifecycle.ts
Adds LifecycleData, date helpers, phase generators, and three lifecycle payload factories for active/compatible, expired, and incompatible cases.
Subscription setup and cleanup
frontend/e2e/tests/olm/operator-lifecycle-metadata.spec.ts
Defines test constants and CSV inspection types, creates the OLM Subscription before the test, waits for a succeeded CSV, and deletes created resources afterward.
Lifecycle metadata assertions
frontend/e2e/tests/olm/operator-lifecycle-metadata.spec.ts
Mocks the lifecycle API, opens the operators page, derives cluster version context, and verifies the UI labels for the three lifecycle scenarios.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Test
  participant K8sAPI
  participant Browser
  participant LifecycleAPI

  Test->>K8sAPI: create Subscription
  K8sAPI-->>Test: CSV reaches Succeeded
  Test->>LifecycleAPI: register mocked lifecycle route
  Test->>Browser: open installed operators page
  Browser->>LifecycleAPI: fetch lifecycle data
  LifecycleAPI-->>Browser: mocked payload
  Browser-->>Test: render lifecycle labels
  Test->>Browser: reload with updated mock
  Browser-->>Test: assert updated lifecycle label
Loading

Suggested reviewers: TheRealJon, jseseCCS

🚥 Pre-merge checks | ✅ 13 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title matches the PR content, but it uses 'NO-ISSUE' instead of the required Jira issue prefix. Prefix the title with a valid Jira key, e.g. 'CONSOLE-XXXX: Add Playwright e2e test for operator lifecycle metadata UI'.
Microshift Test Compatibility ⚠️ Warning The new e2e test creates OLM Subscription/CSV resources and depends on tech-preview-only behavior, with no MicroShift skip/tag/guard. Add MicroShift protection ([Skipped:MicroShift] or exutil.IsMicroShiftCluster()+g.Skip) or tag the test for the unsupported API group.
✅ Passed checks (13 passed)
Check name Status Explanation
Description check ✅ Passed The description is mostly complete and covers root cause, solution, test setup, test cases, and browser conformance.
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.
Stable And Deterministic Test Names ✅ Passed All Ginkgo titles in the new spec are static strings; no dynamic data appears in Describe, test, or step names.
Test Structure And Quality ✅ Passed Uses shared beforeAll/afterAll with cleanup, bounded polling/timeouts for cluster waits, and stepwise checks that match existing e2e patterns.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The new e2e test only installs an operator and checks UI metadata; it has no multi-node/HA assumptions and no SNO skip is needed.
Topology-Aware Scheduling Compatibility ✅ Passed Only e2e test/mocks were added; no deployment manifests, controllers, or pod scheduling constraints are introduced.
Ote Binary Stdout Contract ✅ Passed No stdout writes, klog, or log.SetOutput calls appear in the new test/mocks; the added code is limited to test-time logic.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed New spec uses only cluster-internal OLM Subscription and relative app/lifecycle routes; no IPv4 literals, IP parsing, or external hosts found.
No-Weak-Crypto ✅ Passed Changed files only add Playwright e2e test and lifecycle mock data; no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret comparisons found.
Container-Privileges ✅ Passed The PR only adds e2e mocks/specs; no K8s/container manifests or securityContext fields like privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, or allowPrivilegeEscalation were introduced.
No-Sensitive-Data-In-Logs ✅ Passed No logging statements or sensitive fields were added; the new e2e test only uses operator names, versions, and lifecycle mock data.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@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 (3)
frontend/e2e/mocks/operator-lifecycle.ts (1)

1-84: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consolidate duplicated shapes across type and factory functions.

The phase/platformCompatibility literal shape is declared three times (LifecycleData, activePhases, expiredPhases), and the schema string plus versions wrapper is repeated identically in all three factories. This makes it easy for the schema and mock shape to drift out of sync when one call site is updated but not the others.

♻️ Proposed consolidation
+type LifecyclePhase = { name: string; startDate: string; endDate: string };
+type PlatformCompatibility = { name: string; versions: string[] };
+
 export type LifecycleData = {
   package: string;
   schema: string;
   versions?: {
     name: string;
-    platformCompatibility?: { name: string; versions: string[] }[];
-    phases?: { name: string; startDate: string; endDate: string }[];
+    platformCompatibility?: PlatformCompatibility[];
+    phases?: LifecyclePhase[];
   }[];
 };

 const toDateStr = (d: Date): string => d.toISOString().slice(0, 10);

-const activePhases = (): { name: string; startDate: string; endDate: string }[] => {
+const activePhases = (): LifecyclePhase[] => {
   ...
 };

-const expiredPhases = (): { name: string; startDate: string; endDate: string }[] => {
+const expiredPhases = (): LifecyclePhase[] => {
   ...
 };
+
+const SCHEMA = 'io.openshift.operators.lifecycles.v1alpha1';
+
+const buildLifecycleData = (
+  packageName: string,
+  version: string,
+  clusterVersions: string[],
+  phases: LifecyclePhase[],
+): LifecycleData => ({
+  package: packageName,
+  schema: SCHEMA,
+  versions: [
+    {
+      name: version,
+      platformCompatibility: [{ name: 'openshift', versions: clusterVersions }],
+      phases,
+    },
+  ],
+});

 export const makeLifecycleActiveAndCompatible = (
   packageName: string,
   version: string,
   clusterVersion: string,
-): LifecycleData => ({
-  package: packageName,
-  schema: 'io.openshift.operators.lifecycles.v1alpha1',
-  versions: [
-    {
-      name: version,
-      platformCompatibility: [{ name: 'openshift', versions: [clusterVersion] }],
-      phases: activePhases(),
-    },
-  ],
-});
+): LifecycleData => buildLifecycleData(packageName, version, [clusterVersion], activePhases());
🤖 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/mocks/operator-lifecycle.ts` around lines 1 - 84, The lifecycle
mock shape is duplicated across LifecycleData, activePhases/expiredPhases, and
the three factory helpers, so centralize the shared
phase/platformCompatibility/version object types and the common schema/versions
wrapper. Reuse those shared symbols from operator-lifecycle.ts inside
makeLifecycleActiveAndCompatible, makeLifecycleSelfSupport, and
makeLifecycleIncompatible so the mock payload stays consistent when the schema
or version shape changes.
frontend/e2e/tests/olm/operator-lifecycle-metadata.spec.ts (2)

154-159: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Silent fallback on version-parse failure hides the real cause of later assertion failures.

If SERVER_FLAGS.releaseVersion is missing or has an unexpected format, clusterMinorVersion silently defaults to '4.18'. If that doesn't match the actual cluster version the UI compares against, the "compatible" step assertion will fail with no indication that the real root cause was a version-extraction problem rather than a UI/lifecycle-data bug.

♻️ Proposed fix to surface parse failures
     const versionMatch = releaseVersion.match(/^(\d+\.\d+)/);
-    const clusterMinorVersion = versionMatch ? versionMatch[1] : '4.18';
+    if (!versionMatch) {
+      throw new Error(`Unable to parse cluster minor version from releaseVersion: "${releaseVersion}"`);
+    }
+    const clusterMinorVersion = versionMatch[1];
🤖 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/olm/operator-lifecycle-metadata.spec.ts` around lines 154
- 159, The version parsing in operator-lifecycle-metadata.spec.ts is silently
falling back to a hardcoded minor version, which hides the real failure source.
Update the logic around the SERVER_FLAGS.releaseVersion handling so the test
explicitly fails or reports a clear error when the releaseVersion is missing or
doesn’t match the expected format, instead of defaulting to 4.18. Use the
existing releaseVersion, versionMatch, and clusterMinorVersion flow in the
Installed Operators test to surface the parse problem before the later
compatibility assertion runs.

98-134: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Cleanup errors are fully swallowed, risking silent resource leaks across CI runs.

Both catch blocks discard every error without logging. If deletion genuinely fails (e.g., permissions, API changes), the Subscription/CSVs leak into subsequent runs with no diagnostic trail.

♻️ Proposed fix to log instead of silently swallowing
     } catch {
-      // Ignore cleanup errors
+      // eslint-disable-next-line no-console
+      console.warn('Failed to delete web-terminal subscription during cleanup');
     }
🤖 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/olm/operator-lifecycle-metadata.spec.ts` around lines 98 -
134, The cleanup in test.afterAll currently swallows all errors when deleting
the Subscription and CSVs, which can hide leaked resources; update both catch
blocks to log the failure with enough context before continuing. Use the
existing k8sClient.deleteCustomResource and k8sClient.listCustomResources flow
in operator-lifecycle-metadata.spec.ts, and include the resource type/name
details in the log so CI failures can be diagnosed if cleanup does not succeed.
🤖 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/mocks/operator-lifecycle.ts`:
- Around line 1-84: The lifecycle mock shape is duplicated across LifecycleData,
activePhases/expiredPhases, and the three factory helpers, so centralize the
shared phase/platformCompatibility/version object types and the common
schema/versions wrapper. Reuse those shared symbols from operator-lifecycle.ts
inside makeLifecycleActiveAndCompatible, makeLifecycleSelfSupport, and
makeLifecycleIncompatible so the mock payload stays consistent when the schema
or version shape changes.

In `@frontend/e2e/tests/olm/operator-lifecycle-metadata.spec.ts`:
- Around line 154-159: The version parsing in
operator-lifecycle-metadata.spec.ts is silently falling back to a hardcoded
minor version, which hides the real failure source. Update the logic around the
SERVER_FLAGS.releaseVersion handling so the test explicitly fails or reports a
clear error when the releaseVersion is missing or doesn’t match the expected
format, instead of defaulting to 4.18. Use the existing releaseVersion,
versionMatch, and clusterMinorVersion flow in the Installed Operators test to
surface the parse problem before the later compatibility assertion runs.
- Around line 98-134: The cleanup in test.afterAll currently swallows all errors
when deleting the Subscription and CSVs, which can hide leaked resources; update
both catch blocks to log the failure with enough context before continuing. Use
the existing k8sClient.deleteCustomResource and k8sClient.listCustomResources
flow in operator-lifecycle-metadata.spec.ts, and include the resource type/name
details in the log so CI failures can be diagnosed if cleanup does not succeed.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 56b1ada9-9c89-47fd-ac4f-ddc8c32c8093

📥 Commits

Reviewing files that changed from the base of the PR and between 7707540 and 1d67461.

📒 Files selected for processing (2)
  • frontend/e2e/mocks/operator-lifecycle.ts
  • frontend/e2e/tests/olm/operator-lifecycle-metadata.spec.ts

Adds an e2e test that verifies the lifecycle metadata columns
(Cluster Compatibility and Support Phase) on the Installed Operators
page using mocked lifecycle API responses. The test is automatically
skipped on clusters without tech preview enabled.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@perdasilva perdasilva force-pushed the operator-lifecycle-metadata-e2e branch from c2bc5f0 to d651a59 Compare July 2, 2026 10:23
@perdasilva

Copy link
Copy Markdown
Author

/retest

@openshift-ci

openshift-ci Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

@perdasilva: 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/e2e-gcp-console d651a59 link true /test e2e-gcp-console

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

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