Skip to content

ACM-37999 Edit Cluster Description via Modal#6527

Open
oksanabaza wants to merge 7 commits into
stolostron:mainfrom
oksanabaza:ACM-37999
Open

ACM-37999 Edit Cluster Description via Modal#6527
oksanabaza wants to merge 7 commits into
stolostron:mainfrom
oksanabaza:ACM-37999

Conversation

@oksanabaza

@oksanabaza oksanabaza commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

📝 Summary

Ticket Summary (Title):

ACM-37999 Edit Cluster Description via Modal

Ticket Link:

https://redhat.atlassian.net/browse/ACM-37999

Type of Change:

  • 🐞 Bug Fix
  • ✨ Feature
  • 🔧 Refactor
  • 💸 Tech Debt
  • 🧪 Test-related
  • 📄 Docs

✅ Checklist

General

  • PR title follows the convention (e.g. ACM-12340 Fix bug with...)
  • Code builds and runs locally without errors
  • No console logs, commented-out code, or unnecessary files
  • All commits are meaningful and well-labeled
  • All new display strings are externalized for localization (English only)
  • (Nice to have) JSDoc comments added for new functions and interfaces

If Feature

  • UI/UX reviewed (if applicable)
  • All acceptance criteria met
  • Unit test coverage added or updated
  • Relevant documentation or comments included

If Bugfix

  • Root cause and fix summary are documented in the ticket (for future reference / errata)
  • Fix tested thoroughly and resolves the issue
  • Test(s) added to prevent regression

🗒️ Notes for Reviewers

Commands used in demo:

  1. oc get managedcluster weekly -o jsonpath='{.metadata.annotations.console\.open-cluster-management\.io/description}'
  2. oc annotate managedcluster weekly 'console.open-cluster-management.io/description=**Updated Description** - _test cli_' --overwrite
  3. oc annotate managedcluster weekly 'console.open-cluster-management.io/description=**Production Cluster** - This is an extremely long description designed to stress test the UI rendering capabilities and ensure that the markdown component can handle very long single-line strings without breaking the layout or causing performance issues. The cluster runs critical workloads including [microservices](https://kubernetes.io/docs/concepts/services-networking/), [databases](https://www.postgresql.org/), and [message queues](https://kafka.apache.org/) across multiple availability zones. It features auto-scaling with HPA configured for CPU and memory metrics, network policies for security segmentation, service mesh integration with Istio for traffic management and observability, persistent storage backed by Ceph RBD and CephFS storage classes, monitoring stack including Prometheus, Grafana, and AlertManager, centralized logging with Elasticsearch and Fluentd, backup solutions with Velero, disaster recovery procedures documented in the runbook, regular security scanning with Trivy and Falco, compliance checks against CIS benchmarks, automated certificate rotation via cert-manager, ingress controllers with rate limiting and WAF rules, GitOps deployment pipelines using ArgoCD and Tekton, chaos engineering tests with Chaos Mesh, cost optimization policies, resource quotas per namespace, multi-tenancy isolation, federated identity management, audit logging enabled, encryption at rest and in transit, regular vulnerability assessments, incident response procedures, on-call rotation schedules, SLO definitions and SLI monitoring, capacity planning reports, performance benchmarking results, network latency measurements between zones, database replication lag monitoring, cache hit ratio tracking, API response time percentiles, error rate thresholds, saturation metrics for CPU memory disk and network, and comprehensive documentation for all operational procedures including deployment rollback strategies upgrade procedures node maintenance workflows and troubleshooting guides.' --overwrite
  4. oc annotate managedcluster weekly 'console.open-cluster-management.io/description-'

Demo:

Demo.mov

Summary by CodeRabbit

  • New Features
    • Added support for viewing managed cluster descriptions with Markdown formatting.
    • Added an editor for creating and updating cluster descriptions.
    • Added Markdown formatting tools for bold, italic, links, and lists.
    • Added options to save, clear, or cancel description changes.
  • Bug Fixes
    • Added error handling and feedback when description updates fail.

@openshift-ci

openshift-ci Bot commented Jul 21, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: oksanabaza

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

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ae1ad104-9d0f-47ce-97a4-861c10dd4593

📥 Commits

Reviewing files that changed from the base of the PR and between 9b491f0 and ffa597c.

⛔ Files ignored due to path filters (1)
  • frontend/public/locales/en/translation.json is excluded by !frontend/public/locales/**
📒 Files selected for processing (3)
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/ClusterDetails/ClusterOverview/ClusterOverview.tsx
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.tsx
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/ClusterDetails/ClusterOverview/ClusterOverview.tsx

📝 Walkthrough

Walkthrough

Managed cluster descriptions are rendered from annotations as Markdown and can be edited through a new modal. The editor supports Markdown formatting, persists trimmed values or clears them with null, reports save errors, and is covered by component tests.

Changes

Managed cluster description

Layer / File(s) Summary
Description editor and annotation patching
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.tsx
Adds a modal editor that loads the description annotation, provides Markdown formatting controls, patches the cluster annotation, handles empty values and errors, and supports cancellation.
Overview rendering and editor wiring
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/ClusterDetails/ClusterOverview/ClusterOverview.tsx
Renders descriptions as Markdown and adds a managed-cluster RBAC-protected action that opens and closes the editor.
Editor behavior coverage
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx
Tests rendering, accessibility, saving, clearing, formatting, error handling, and resources without annotations.

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

Sequence Diagram(s)

sequenceDiagram
  participant ClusterOverview
  participant EditDescription
  participant patchResource
  ClusterOverview->>EditDescription: Open with cluster identity and annotations
  EditDescription->>patchResource: Save description annotation
  patchResource-->>EditDescription: Return success or error
  EditDescription-->>ClusterOverview: Close after success or cancel
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, specific, and matches the main change: editing cluster descriptions via a modal.
Description check ✅ Passed The description matches the template with summary, ticket link, change type, checklist, and reviewer notes.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

frontend/src/routes/Infrastructure/Clusters/ManagedClusters/ClusterDetails/ClusterOverview/ClusterOverview.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.


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

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/ClusterDetails/ClusterOverview/ClusterOverview.tsx (3)

87-89: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use UPPER_SNAKE_CASE for constant values and move outside the component.

As per the coding guidelines, constants that are truly constant values must use UPPER_SNAKE_CASE. Moving it outside the component also prevents unnecessary re-evaluations during renders.

♻️ Proposed refactor

Move this definition outside of ClusterOverviewPageContent:

+const CLUSTER_DESCRIPTION_ANNOTATION = 'console.open-cluster-management.io/description'
+
 export function ClusterOverviewPageContent() {

And remove it from within the component:

-  const clusterDescriptionAnnotation = 'console.open-cluster-management.io/description'
   const [showEditLabels, setShowEditLabels] = useState<boolean>(false)
🤖 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/src/routes/Infrastructure/Clusters/ManagedClusters/ClusterDetails/ClusterOverview/ClusterOverview.tsx`
around lines 87 - 89, Move the immutable cluster description annotation value
outside the ClusterOverviewPageContent component and rename it to
UPPER_SNAKE_CASE, then update all references from clusterDescriptionAnnotation
to the new constant.

Source: Coding guidelines


519-530: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Avoid inline object creation in JSX.

As per coding guidelines, avoid inline object creation for the resource prop to prevent unnecessary re-renders of the EditDescription component. Consider using useMemo for the resource payload and useCallback for the close handler.

🤖 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/src/routes/Infrastructure/Clusters/ManagedClusters/ClusterDetails/ClusterOverview/ClusterOverview.tsx`
around lines 519 - 530, Update ClusterOverview’s EditDescription props to avoid
creating the resource object and close callback inline during render. Use
useMemo for the conditional resource payload and useCallback for the
setShowEditDescription(false) handler, preserving the existing values and
undefined behavior when editing is hidden.

Source: Coding guidelines


344-361: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Avoid inline object/array and function creation in JSX.

As per coding guidelines, avoid inline functions and inline array creation (e.g., rbac={[...]}, onClick={() => ...}) in JSX to prevent unnecessary re-renders.

Consider extracting the rbac array and the onClick handler. Also, if you apply the constant renaming suggested above, ensure you update clusterDescriptionAnnotation to CLUSTER_DESCRIPTION_ANNOTATION.

🤖 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/src/routes/Infrastructure/Clusters/ManagedClusters/ClusterDetails/ClusterOverview/ClusterOverview.tsx`
around lines 344 - 361, In the ClusterOverview component, extract the inline
rbac array and edit-description onClick callback from the description keyAction
JSX into stable variables or callbacks, then reference them in RbacButton to
avoid recreating them during render. If the annotation constant was renamed,
update all references from clusterDescriptionAnnotation to
CLUSTER_DESCRIPTION_ANNOTATION.

Source: Coding guidelines

🤖 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
`@frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.tsx`:
- Around line 111-160: Extract the inline save handler from AcmSubmit into a
named handleSave function, preserving alert clearing, patchResource success, and
error handling. Change the patch from a JSON Patch array to a merge-patch object
whose metadata.annotations entry sets the trimmed description or null for
deletion, allowing existing annotations to merge safely. Update AcmSubmit’s
onClick to reference handleSave.

---

Nitpick comments:
In
`@frontend/src/routes/Infrastructure/Clusters/ManagedClusters/ClusterDetails/ClusterOverview/ClusterOverview.tsx`:
- Around line 87-89: Move the immutable cluster description annotation value
outside the ClusterOverviewPageContent component and rename it to
UPPER_SNAKE_CASE, then update all references from clusterDescriptionAnnotation
to the new constant.
- Around line 519-530: Update ClusterOverview’s EditDescription props to avoid
creating the resource object and close callback inline during render. Use
useMemo for the conditional resource payload and useCallback for the
setShowEditDescription(false) handler, preserving the existing values and
undefined behavior when editing is hidden.
- Around line 344-361: In the ClusterOverview component, extract the inline rbac
array and edit-description onClick callback from the description keyAction JSX
into stable variables or callbacks, then reference them in RbacButton to avoid
recreating them during render. If the annotation constant was renamed, update
all references from clusterDescriptionAnnotation to
CLUSTER_DESCRIPTION_ANNOTATION.
🪄 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: d9bfd23a-9364-4f5d-945d-b857ebdd069b

📥 Commits

Reviewing files that changed from the base of the PR and between 0c50f56 and 8d4d21a.

📒 Files selected for processing (3)
  • frontend/src/resources/utils/get-cluster.ts
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/ClusterDetails/ClusterOverview/ClusterOverview.tsx
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.tsx (1)

4-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a type-only import for IAlertContext.

IAlertContext is only used in a type position. Move it to import type to comply with the frontend TypeScript import rule.

Proposed fix
 import {
   AcmAlertContext,
   AcmAlertGroup,
   AcmForm,
   AcmModal,
   AcmSubmit,
-  IAlertContext,
 } from '../../../../../ui-components'
+import type { IAlertContext } from '../../../../../ui-components'
🤖 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/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.tsx`
around lines 4 - 11, Update the imports used by EditDescription so IAlertContext
is imported with a type-only import, while AcmAlertContext, AcmAlertGroup,
AcmForm, AcmModal, and AcmSubmit remain value imports.

Source: Coding guidelines

🤖 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/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.tsx`:
- Around line 4-11: Update the imports used by EditDescription so IAlertContext
is imported with a type-only import, while AcmAlertContext, AcmAlertGroup,
AcmForm, AcmModal, and AcmSubmit remain value imports.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 2c15c6b8-c673-4d0d-afd7-f0f550f0acc3

📥 Commits

Reviewing files that changed from the base of the PR and between 8d4d21a and f5f9182.

📒 Files selected for processing (1)
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx (3)

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

Use userEvent.click for save actions.

Native .click() bypasses the interaction model used by the rest of this suite.

  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx#L54-L54: replace .click() with userEvent.click(...).
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx#L75-L75: replace .click() with userEvent.click(...).
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx#L115-L115: replace .click() with userEvent.click(...).

As per coding guidelines, “Use @testing-library/user-event for user interactions instead of fireEvent.”

🤖 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/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx`
at line 54, Replace the native save-button click calls in
EditDescription.test.tsx at lines 54, 75, and 115 with userEvent.click
interactions, ensuring userEvent is available through the suite’s existing
testing setup.

Source: Coding guidelines


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

Reuse a close mock and assert modal lifecycle behavior.

Inline no-op callbacks prevent verifying that successful saves close the modal and failed saves do not.

  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx#L27-L27: pass a named mock instead of an inline callback.
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx#L32-L32: pass a named mock instead of an inline callback.
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx#L37-L37: assert the mock is called after a successful update.
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx#L59-L59: assert the mock is called after clearing succeeds.
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx#L80-L82: pass a named mock instead of an inline callback.
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx#L97-L97: assert the mock is not called after the corrected failure response.
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx#L127-L127: pass a named mock instead of an inline callback.

As per coding guidelines, “avoid inline functions ... in JSX.”

🤖 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/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx`
at line 27, In EditDescription.test.tsx, create and reuse a named close mock
across all EditDescription renders at lines 27, 32, 80-82, and 127 instead of
inline callbacks; assert it is called after successful update and clearing at
lines 37 and 59, and not called after the corrected failure response at line 97.

Source: Coding guidelines


3-7: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use aliases and a type-only import.

IResource is used only as a type, and the added relative imports should use ~/ paths.

Proposed change
-import { IResource, ManagedClusterApiVersion, ManagedClusterKind } from '../../../../../resources'
+import { ManagedClusterApiVersion, ManagedClusterKind } from '~/resources'
+import type { IResource } from '~/resources'
 import { render, waitFor } from '`@testing-library/react`'
 import userEvent from '`@testing-library/user-event`'
-import { mockBadRequestStatus, nockIgnoreApiPaths, nockPatch } from '../../../../../lib/nock-util'
-import { EditDescription } from './EditDescription'
+import { mockBadRequestStatus, nockIgnoreApiPaths, nockPatch } from '~/lib/nock-util'
+import { EditDescription } from '~/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription'

As per coding guidelines, “When adding imports, use the ~/ shorthand” and “Use import type for type-only imports.”

🤖 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/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx`
around lines 3 - 7, Update the imports in EditDescription.test.tsx to use the ~/
alias for the added project-relative imports, and split IResource into an import
type statement while keeping ManagedClusterApiVersion and ManagedClusterKind as
value imports.

Source: Coding guidelines

🤖 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
`@frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx`:
- Around line 103-116: Update the nockPatch setup in the EditDescription test to
pass mockBadRequestStatus as the response status argument rather than the
response body, then assert that the expected error alert is displayed after
clicking the Save button. Keep the existing request-completion assertion and
ensure the test exercises the failed update path.

---

Nitpick comments:
In
`@frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx`:
- Line 54: Replace the native save-button click calls in
EditDescription.test.tsx at lines 54, 75, and 115 with userEvent.click
interactions, ensuring userEvent is available through the suite’s existing
testing setup.
- Line 27: In EditDescription.test.tsx, create and reuse a named close mock
across all EditDescription renders at lines 27, 32, 80-82, and 127 instead of
inline callbacks; assert it is called after successful update and clearing at
lines 37 and 59, and not called after the corrected failure response at line 97.
- Around line 3-7: Update the imports in EditDescription.test.tsx to use the ~/
alias for the added project-relative imports, and split IResource into an import
type statement while keeping ManagedClusterApiVersion and ManagedClusterKind as
value imports.
🪄 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: d3f409aa-7d8b-4429-89e6-ae9d5ac6be61

📥 Commits

Reviewing files that changed from the base of the PR and between f5f9182 and 9b491f0.

⛔ Files ignored due to path filters (1)
  • frontend/public/locales/en/translation.json is excluded by !frontend/public/locales/**
📒 Files selected for processing (1)
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx

Comment on lines +103 to +116
const nockScope = nockPatch(
{ apiVersion: resource.apiVersion, kind: resource.kind, metadata: { name: resource.metadata!.name } },
{
metadata: {
annotations: {
[CLUSTER_DESCRIPTION_ANNOTATION]: 'New description',
},
},
},
mockBadRequestStatus
)

getByRole('button', { name: /save/i }).click()
await waitFor(() => expect(nockScope.isDone()).toBeTruthy())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Return an actual failure status and assert the alert.

nockPatch treats mockBadRequestStatus as the response body; without a fourth argument, it returns 204. This test currently exercises the success path and never verifies the error UI.

Proposed change
       },
-      mockBadRequestStatus
+      mockBadRequestStatus,
+      400
     )

     getByRole('button', { name: /save/i }).click()
     await waitFor(() => expect(nockScope.isDone()).toBeTruthy())
+    expect(getByText('Bad request.')).toBeInTheDocument()
📝 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 nockScope = nockPatch(
{ apiVersion: resource.apiVersion, kind: resource.kind, metadata: { name: resource.metadata!.name } },
{
metadata: {
annotations: {
[CLUSTER_DESCRIPTION_ANNOTATION]: 'New description',
},
},
},
mockBadRequestStatus
)
getByRole('button', { name: /save/i }).click()
await waitFor(() => expect(nockScope.isDone()).toBeTruthy())
const nockScope = nockPatch(
{ apiVersion: resource.apiVersion, kind: resource.kind, metadata: { name: resource.metadata!.name } },
{
metadata: {
annotations: {
[CLUSTER_DESCRIPTION_ANNOTATION]: 'New description',
},
},
},
mockBadRequestStatus,
400
)
getByRole('button', { name: /save/i }).click()
await waitFor(() => expect(nockScope.isDone()).toBeTruthy())
expect(getByText('Bad request.')).toBeInTheDocument()
🤖 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/src/routes/Infrastructure/Clusters/ManagedClusters/components/EditDescription.test.tsx`
around lines 103 - 116, Update the nockPatch setup in the EditDescription test
to pass mockBadRequestStatus as the response status argument rather than the
response body, then assert that the expected error alert is displayed after
clicking the Save button. Keep the existing request-completion assertion and
ensure the test exercises the failed update path.

@oksanabaza

Copy link
Copy Markdown
Contributor Author

/retest

Signed-off-by: Oksana Bazylieva <obazylie@redhat.com>
Signed-off-by: Oksana Bazylieva <obazylie@redhat.com>
Signed-off-by: Oksana Bazylieva <obazylie@redhat.com>
Signed-off-by: Oksana Bazylieva <obazylie@redhat.com>
Signed-off-by: Oksana Bazylieva <obazylie@redhat.com>
Signed-off-by: Oksana Bazylieva <obazylie@redhat.com>
Signed-off-by: Oksana Bazylieva <obazylie@redhat.com>
@sonarqubecloud

Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant