Skip to content

CONSOLE-4809: Extend RTL Test Coverage for Components Migrated from Enzyme#16249

Open
cajieh wants to merge 1 commit intoopenshift:mainfrom
cajieh:extend-rtl-ests-overage-omponents-igrated-enzyme
Open

CONSOLE-4809: Extend RTL Test Coverage for Components Migrated from Enzyme#16249
cajieh wants to merge 1 commit intoopenshift:mainfrom
cajieh:extend-rtl-ests-overage-omponents-igrated-enzyme

Conversation

@cajieh
Copy link
Copy Markdown
Contributor

@cajieh cajieh commented Apr 2, 2026

Summary by CodeRabbit

  • New Features

    • Added accessibility labels (ARIA labels) to resource limit input fields for improved screen reader support.
    • Extended number input fields with min/max boundary enforcement capabilities.
  • Bug Fixes

    • Improved validation messaging for resource limit configurations.
  • Accessibility

    • Enhanced form field accessibility across multiple components with proper ARIA labels.
  • Localization

    • Added translation keys for resource configuration field labels.

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Apr 2, 2026

@cajieh: This pull request references CONSOLE-4809 which is a valid jira issue.

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

Details

In response to this:

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 Apr 2, 2026
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 2, 2026
@openshift-ci openshift-ci bot requested review from jhadvig and spadgett April 2, 2026 17:32
@openshift-ci openshift-ci bot added component/core Related to console core functionality component/olm Related to OLM approved Indicates a PR has been approved by an approver from all required OWNERS files. component/shared Related to console-shared labels Apr 2, 2026
@cajieh cajieh force-pushed the extend-rtl-ests-overage-omponents-igrated-enzyme branch 4 times, most recently from e926790 to e84ae1c Compare April 7, 2026 22:17
className={css('co-label tag-item-content', this.props.labelClassName)}
key={key}
onClose={() => onRemove(key)}
isTruncated
Copy link
Copy Markdown
Contributor Author

@cajieh cajieh Apr 7, 2026

Choose a reason for hiding this comment

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

Appears to be redundant props, which is causing console warnings. If the intent was to truncate the label, let's address that in a follow-up bug using textMaxWidth instead.

@cajieh cajieh force-pushed the extend-rtl-ests-overage-omponents-igrated-enzyme branch 3 times, most recently from 1db0f6b to f1beac9 Compare April 8, 2026 10:33
@cajieh cajieh changed the title [WIP] CONSOLE-4809: Extend RTL Test Coverage for Components Migrated from Enzyme CONSOLE-4809: Extend RTL Test Coverage for Components Migrated from Enzyme Apr 8, 2026
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 8, 2026
@cajieh cajieh force-pushed the extend-rtl-ests-overage-omponents-igrated-enzyme branch from f1beac9 to 86b8c52 Compare April 8, 2026 16:45
@openshift-ci openshift-ci bot added component/dev-console Related to dev-console kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated labels Apr 8, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Apr 8, 2026

@cajieh: This pull request references CONSOLE-4809 which is a valid jira issue.

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

Details

In response to this:

Summary by CodeRabbit

  • New Features

  • Added accessibility labels (ARIA labels) to resource limit input fields for improved screen reader support.

  • Extended number input fields with min/max boundary enforcement capabilities.

  • Bug Fixes

  • Improved validation messaging for resource limit configurations.

  • Accessibility

  • Enhanced form field accessibility across multiple components with proper ARIA labels.

  • Localization

  • Added translation keys for resource configuration field labels.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

This pull request modernizes frontend test suites across multiple shared components and dev-console packages by adopting Testing Library best practices (userEvent, role-based queries, renderWithProviders, waitFor). It expands component APIs with accessibility-focused props: NumberSpinner, NumberSpinnerField, ResourceLimitField, and RequestSizeInput now accept optional max and aria-label attributes to improve semantic HTML and ARIA labeling. New i18n keys are added for resource limit labels (CPU request/limit, Memory request/limit). Test coverage is extended for ResourceLimitsModal, SelectorInput, operand/catalog-source details, and form validation boundaries. A cosmetic change removes label truncation from selector tags. These changes reinforce accessibility standards and modernize testing practices without breaking existing public APIs.

✨ 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
Contributor

@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: 1

🧹 Nitpick comments (7)
frontend/packages/console-shared/src/components/loading/__tests__/loading.spec.tsx (1)

69-73: Test name could be slightly clearer on default behavior.

The test validates that blame prop content isn't rendered by default (i.e., without an explicit query param enabling it). The logic is correct, but the test name "does not render blame info when query param disabled" might be misread as actively disabling something. Consider renaming to 'does not render blame info by default' for clarity.

💡 Optional: Clearer test name
-  it('does not render blame info when query param disabled', () => {
+  it('does not render blame info by default', () => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/packages/console-shared/src/components/loading/__tests__/loading.spec.tsx`
around lines 69 - 73, The test name is ambiguous about default behavior; rename
the test in loading.spec.tsx to clarify it checks the default (no query param)
case by changing the spec for the LoadingBox component from "does not render
blame info when query param disabled" to something like "does not render blame
info by default" and keep the body unchanged (render(<LoadingBox blame={label}
/>); expect(screen.queryByText(label)).not.toBeInTheDocument();).
frontend/public/components/utils/__tests__/selector-input.spec.tsx (1)

94-103: Tighten tag-removal assertion to verify emitted value

Line 102 only checks that onChange fired. Please also assert the callback payload reflects removal of app=frontend; otherwise this test can pass on incorrect behavior.

As per coding guidelines, "-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/public/components/utils/__tests__/selector-input.spec.tsx` around
lines 94 - 103, The test "calls onChange when close button is clicked" only
asserts the callback fired; update it to also assert the emitted payload removes
"app=frontend". In the SelectorInput test, after clicking the close button,
replace or extend the expectation on the mock onChange to verify it was called
with the updated tags (e.g., ['env=prod'])—or with the exact payload shape
SelectorInput emits (use toHaveBeenCalledWith and toHaveBeenCalledTimes(1) as
appropriate) so the assertion verifies the removed tag rather than just the
call.
frontend/packages/console-shared/src/components/formik-fields/key-value-file-input-field/__tests__/KeyValueFileInputField.spec.tsx (1)

76-78: Tighten waitFor usage to avoid false-positive timing behavior

At Line 91, waitFor(() => expect(queryByRole...).not...) can pass too early. The same pattern at Line 76 and Line 106 adds retry loops where direct or findBy* assertions are clearer and less flaky.

Suggested cleanup
-    await waitFor(() => {
-      expect(screen.getAllByRole('button', { name: 'Remove key/value' })).toHaveLength(2);
-    });
+    expect(screen.getAllByRole('button', { name: 'Remove key/value' })).toHaveLength(2);

-    await waitFor(() => {
-      expect(screen.queryByRole('button', { name: 'Remove key/value' })).not.toBeInTheDocument();
-    });
+    expect(screen.queryByRole('button', { name: 'Remove key/value' })).not.toBeInTheDocument();

-    await waitFor(() => {
-      expect(screen.getByRole('button', { name: 'Remove key/value' })).toBeVisible();
-    });
+    expect(screen.getByRole('button', { name: 'Remove key/value' })).toBeVisible();

-    await waitFor(() => {
-      expect(screen.getAllByRole('textbox', { name: 'Key' })).toHaveLength(2);
-    });
+    expect(await screen.findAllByRole('textbox', { name: 'Key' })).toHaveLength(2);

As per coding guidelines, "Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."

Also applies to: 91-93, 106-108, 125-127

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/packages/console-shared/src/components/formik-fields/key-value-file-input-field/__tests__/KeyValueFileInputField.spec.tsx`
around lines 76 - 78, Tests using waitFor around assertions like
screen.getAllByRole('button', { name: 'Remove key/value' }) and queryByRole(...)
are adding unnecessary retry loops and can be flaky; replace those with explicit
async queries (e.g., await screen.findAllByRole('button', { name: 'Remove
key/value' }) and await screen.findByRole / findByText where appropri­ate) or
direct synchronous assertions when the element is already present, and remove
the surrounding waitFor blocks in the KeyValueFileInputField.spec.tsx tests
(referencing the uses of screen.getAllByRole, queryByRole and similar calls) so
assertions rely on findBy*/findAllBy* for waiting and on queryBy* for
non-existence checks without waitFor.
frontend/packages/console-shared/src/components/getting-started/__tests__/GettingStartedCard.spec.tsx (1)

15-18: Consider using a partial mock for @patternfly/react-icons to make tests resilient to future icon additions

The current full-module mock works for GettingStartedCard as currently written—it imports only ArrowRightIcon and ExternalLinkAltIcon. However, this approach is brittle: if the component or its render subtree later adopts another PatternFly icon, the test will fail due to the incomplete mock shape rather than revealing a real component issue.

Refactoring suggestion
-jest.mock('@patternfly/react-icons', () => ({
-  ArrowRightIcon: () => 'ArrowRightIcon',
-  ExternalLinkAltIcon: () => 'ExternalLinkAltIcon',
-}));
+jest.mock('@patternfly/react-icons', () => {
+  const actual = jest.requireActual('@patternfly/react-icons');
+  return {
+    ...actual,
+    ArrowRightIcon: () => 'ArrowRightIcon',
+    ExternalLinkAltIcon: () => 'ExternalLinkAltIcon',
+  };
+});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/packages/console-shared/src/components/getting-started/__tests__/GettingStartedCard.spec.tsx`
around lines 15 - 18, Replace the full-module mock for '@patternfly/react-icons'
in GettingStartedCard.spec.tsx with a partial mock that delegates to the real
module and only overrides ArrowRightIcon and ExternalLinkAltIcon; specifically,
change the jest.mock call so it calls
jest.requireActual('@patternfly/react-icons') (or imports the actual module) and
returns an object that spreads the actual exports and then replaces
ArrowRightIcon and ExternalLinkAltIcon with lightweight stubs—this ensures other
icons added later remain available and prevents brittle failures while keeping
tests stable.
frontend/packages/dev-console/src/components/import/advanced/ResourceLimitSection.tsx (1)

7-7: Consider using the barrel export path for consistency.

The import changed from @console/shared to the direct file path. While functional, using barrel exports (@console/shared) is typically preferred for maintainability—it decouples consumers from internal file structure changes.

💡 Suggested change
-import ResourceLimitField from '@console/shared/src/components/formik-fields/ResourceLimitField';
+import { ResourceLimitField } from '@console/shared';

This requires ensuring ResourceLimitField is exported from the @console/shared barrel. If it's intentionally not in the barrel, the direct path is acceptable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/packages/dev-console/src/components/import/advanced/ResourceLimitSection.tsx`
at line 7, The import in ResourceLimitSection uses the direct path to
ResourceLimitField; switch it to the barrel export by importing
ResourceLimitField from "@console/shared" for consistency (or, if
ResourceLimitField is intentionally not exported from the barrel, leave the
direct path but document/confirm the reason). Ensure the barrel index in
`@console/shared` re-exports ResourceLimitField (add an export { default as
ResourceLimitField } from '<internal-path>' if missing) so consumers can import
from "@console/shared" without coupling to internal file layout.
frontend/packages/operator-lifecycle-manager/src/components/operand/__tests__/index.spec.tsx (1)

28-132: Scope these mocks to the OperandDetails coverage.

These file-level jest.mock calls now affect every describe block in the barrel spec, not just the new OperandDetails cases. That makes OperandStatus, ProvidedAPIPage, etc. less representative and can hide regressions behind mocked PF/layout/descriptor implementations. Moving this setup into the OperandDetails block or a dedicated spec file would preserve isolation.

As per coding guidelines, "Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/packages/operator-lifecycle-manager/src/components/operand/__tests__/index.spec.tsx`
around lines 28 - 132, The file-level jest.mock calls are global and leak into
other describe blocks (affecting tests like OperandStatus/ProvidedAPIPage);
scope these mocks to only the OperandDetails tests by moving them into the
OperandDetails describe block (or into a new dedicated spec file) and
registering/unregistering them there (e.g., inside beforeAll/afterAll with
jest.resetModules if needed). Specifically, relocate mocks for symbols like
useK8sWatchResources, useK8sModels, useK8sModel, useParams/useLocation,
Grid/GridItem/DescriptionList/PaneBody, ResourceSummary/SectionHeading,
DescriptorDetailsItem/DescriptorConditions and DetailsPage so they are created
only for the OperandDetails test scope and do not affect other test suites.
frontend/packages/operator-lifecycle-manager/src/components/__tests__/catalog-source.spec.tsx (1)

206-217: Derive the loaded-state expectations from testPackageManifest.

alpha / testapp are copied from the fixture, and new RegExp(testPackageManifest.metadata.name) is unescaped. Pull the expected channel/CSV from the fixture and escape the dynamic regex so unrelated fixture edits don't make this assertion brittle or overly permissive.

♻️ Proposed tweak
   renderWithProviders(<CreateSubscriptionYAML />);
+  const defaultChannel = testPackageManifest.status.channels.find(
+    ({ name }) => name === testPackageManifest.status.defaultChannel,
+  )!;
 
-  expect(screen.getByText(new RegExp(testPackageManifest.metadata.name))).toBeVisible();
-  expect(screen.getByText(/channel:\s*alpha/)).toBeVisible();
+  expect(
+    screen.getByText(new RegExp(_.escapeRegExp(testPackageManifest.metadata.name))),
+  ).toBeVisible();
+  expect(
+    screen.getByText(new RegExp(`channel:\\s*${_.escapeRegExp(defaultChannel.name)}`)),
+  ).toBeVisible();
   expect(screen.getByText(/source:\s*ocs/)).toBeVisible();
-  expect(screen.getByText(/startingCSV:\s*testapp/)).toBeVisible();
+  expect(
+    screen.getByText(
+      new RegExp(`startingCSV:\\s*${_.escapeRegExp(defaultChannel.currentCSV)}`),
+    ),
+  ).toBeVisible();

As per coding guidelines, "Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/packages/operator-lifecycle-manager/src/components/__tests__/catalog-source.spec.tsx`
around lines 206 - 217, The assertions in the test should derive expected values
from the testPackageManifest fixture and use an escaped regex to avoid
brittle/unintended matches: update the three expectations that currently
hardcode "alpha", "ocs", and "testapp" (and the unescaped package name regex) to
read channel, source and startingCSV (and metadata.name) from
testPackageManifest, escape them with an escapeRegExp helper, and pass the
escaped strings into RegExp for screen.getByText; adjust the test around
CreateSubscriptionYAML and mockUseK8sWatchResources to use those derived,
escaped values so the assertions remain correct when the fixture changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@frontend/packages/console-app/src/components/modals/resource-limits/__tests__/ResourceLimitsModal.spec.tsx`:
- Around line 186-193: The test asserts validation UI immediately after keyboard
input but Formik validation runs in a useEffect, so update the assertions in
ResourceLimitsModal.spec.tsx to wait for asynchronous state changes: after
interacting with cpuRequest (the spinbutton) and entering '300', replace the
immediate expect(save).toBeDisabled() with an awaited assertion inside waitFor()
or use findByText/findByRole to await the disabled state, and replace the direct
screen.getByText('CPU request must be less than or equal to limit.') check with
await screen.findByText(...) (or assert inside waitFor) so the test waits for
Formik's validateForm to finish; apply the same pattern for other similar
assertions around lines where save and validation messages are checked.

---

Nitpick comments:
In
`@frontend/packages/console-shared/src/components/formik-fields/key-value-file-input-field/__tests__/KeyValueFileInputField.spec.tsx`:
- Around line 76-78: Tests using waitFor around assertions like
screen.getAllByRole('button', { name: 'Remove key/value' }) and queryByRole(...)
are adding unnecessary retry loops and can be flaky; replace those with explicit
async queries (e.g., await screen.findAllByRole('button', { name: 'Remove
key/value' }) and await screen.findByRole / findByText where appropri­ate) or
direct synchronous assertions when the element is already present, and remove
the surrounding waitFor blocks in the KeyValueFileInputField.spec.tsx tests
(referencing the uses of screen.getAllByRole, queryByRole and similar calls) so
assertions rely on findBy*/findAllBy* for waiting and on queryBy* for
non-existence checks without waitFor.

In
`@frontend/packages/console-shared/src/components/getting-started/__tests__/GettingStartedCard.spec.tsx`:
- Around line 15-18: Replace the full-module mock for '@patternfly/react-icons'
in GettingStartedCard.spec.tsx with a partial mock that delegates to the real
module and only overrides ArrowRightIcon and ExternalLinkAltIcon; specifically,
change the jest.mock call so it calls
jest.requireActual('@patternfly/react-icons') (or imports the actual module) and
returns an object that spreads the actual exports and then replaces
ArrowRightIcon and ExternalLinkAltIcon with lightweight stubs—this ensures other
icons added later remain available and prevents brittle failures while keeping
tests stable.

In
`@frontend/packages/console-shared/src/components/loading/__tests__/loading.spec.tsx`:
- Around line 69-73: The test name is ambiguous about default behavior; rename
the test in loading.spec.tsx to clarify it checks the default (no query param)
case by changing the spec for the LoadingBox component from "does not render
blame info when query param disabled" to something like "does not render blame
info by default" and keep the body unchanged (render(<LoadingBox blame={label}
/>); expect(screen.queryByText(label)).not.toBeInTheDocument();).

In
`@frontend/packages/dev-console/src/components/import/advanced/ResourceLimitSection.tsx`:
- Line 7: The import in ResourceLimitSection uses the direct path to
ResourceLimitField; switch it to the barrel export by importing
ResourceLimitField from "@console/shared" for consistency (or, if
ResourceLimitField is intentionally not exported from the barrel, leave the
direct path but document/confirm the reason). Ensure the barrel index in
`@console/shared` re-exports ResourceLimitField (add an export { default as
ResourceLimitField } from '<internal-path>' if missing) so consumers can import
from "@console/shared" without coupling to internal file layout.

In
`@frontend/packages/operator-lifecycle-manager/src/components/__tests__/catalog-source.spec.tsx`:
- Around line 206-217: The assertions in the test should derive expected values
from the testPackageManifest fixture and use an escaped regex to avoid
brittle/unintended matches: update the three expectations that currently
hardcode "alpha", "ocs", and "testapp" (and the unescaped package name regex) to
read channel, source and startingCSV (and metadata.name) from
testPackageManifest, escape them with an escapeRegExp helper, and pass the
escaped strings into RegExp for screen.getByText; adjust the test around
CreateSubscriptionYAML and mockUseK8sWatchResources to use those derived,
escaped values so the assertions remain correct when the fixture changes.

In
`@frontend/packages/operator-lifecycle-manager/src/components/operand/__tests__/index.spec.tsx`:
- Around line 28-132: The file-level jest.mock calls are global and leak into
other describe blocks (affecting tests like OperandStatus/ProvidedAPIPage);
scope these mocks to only the OperandDetails tests by moving them into the
OperandDetails describe block (or into a new dedicated spec file) and
registering/unregistering them there (e.g., inside beforeAll/afterAll with
jest.resetModules if needed). Specifically, relocate mocks for symbols like
useK8sWatchResources, useK8sModels, useK8sModel, useParams/useLocation,
Grid/GridItem/DescriptionList/PaneBody, ResourceSummary/SectionHeading,
DescriptorDetailsItem/DescriptorConditions and DetailsPage so they are created
only for the OperandDetails test scope and do not affect other test suites.

In `@frontend/public/components/utils/__tests__/selector-input.spec.tsx`:
- Around line 94-103: The test "calls onChange when close button is clicked"
only asserts the callback fired; update it to also assert the emitted payload
removes "app=frontend". In the SelectorInput test, after clicking the close
button, replace or extend the expectation on the mock onChange to verify it was
called with the updated tags (e.g., ['env=prod'])—or with the exact payload
shape SelectorInput emits (use toHaveBeenCalledWith and toHaveBeenCalledTimes(1)
as appropriate) so the assertion verifies the removed tag rather than just the
call.
🪄 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: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: a6f1c433-0927-4332-a00b-b95417f1f640

📥 Commits

Reviewing files that changed from the base of the PR and between 12d651d and 86b8c52.

📒 Files selected for processing (18)
  • frontend/packages/console-app/src/components/modals/resource-limits/__tests__/ResourceLimitsModal.spec.tsx
  • frontend/packages/console-shared/src/components/empty-state/__tests__/empty-state.spec.tsx
  • frontend/packages/console-shared/src/components/formik-fields/NumberSpinnerField.tsx
  • frontend/packages/console-shared/src/components/formik-fields/ResourceLimitField.tsx
  • frontend/packages/console-shared/src/components/formik-fields/__tests__/NumberSpinnerField.spec.tsx
  • frontend/packages/console-shared/src/components/formik-fields/field-types.ts
  • frontend/packages/console-shared/src/components/formik-fields/key-value-file-input-field/__tests__/KeyValueFileInputField.spec.tsx
  • frontend/packages/console-shared/src/components/getting-started/__tests__/GettingStartedCard.spec.tsx
  • frontend/packages/console-shared/src/components/loading/__tests__/loading.spec.tsx
  • frontend/packages/console-shared/src/components/status/__tests__/status-box.spec.tsx
  • frontend/packages/dev-console/locales/en/devconsole.json
  • frontend/packages/dev-console/src/components/import/advanced/ResourceLimitSection.tsx
  • frontend/packages/operator-lifecycle-manager/src/components/__tests__/catalog-source.spec.tsx
  • frontend/packages/operator-lifecycle-manager/src/components/operand/__tests__/index.spec.tsx
  • frontend/public/components/utils/__tests__/selector-input.spec.tsx
  • frontend/public/components/utils/number-spinner.tsx
  • frontend/public/components/utils/request-size-input.tsx
  • frontend/public/components/utils/selector-input.jsx
💤 Files with no reviewable changes (1)
  • frontend/public/components/utils/selector-input.jsx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/packages/dev-console/locales/en/devconsole.json
  • frontend/packages/console-shared/src/components/formik-fields/field-types.ts
  • frontend/packages/console-shared/src/components/formik-fields/ResourceLimitField.tsx
  • frontend/packages/console-shared/src/components/formik-fields/NumberSpinnerField.tsx
  • frontend/public/components/utils/request-size-input.tsx
  • frontend/packages/console-shared/src/components/status/__tests__/status-box.spec.tsx
  • frontend/public/components/utils/number-spinner.tsx
  • frontend/packages/dev-console/src/components/import/advanced/ResourceLimitSection.tsx
  • frontend/packages/console-shared/src/components/loading/__tests__/loading.spec.tsx
  • frontend/packages/console-shared/src/components/formik-fields/__tests__/NumberSpinnerField.spec.tsx
  • frontend/public/components/utils/__tests__/selector-input.spec.tsx
  • frontend/packages/console-shared/src/components/empty-state/__tests__/empty-state.spec.tsx
  • frontend/packages/console-app/src/components/modals/resource-limits/__tests__/ResourceLimitsModal.spec.tsx
  • frontend/packages/console-shared/src/components/formik-fields/key-value-file-input-field/__tests__/KeyValueFileInputField.spec.tsx
  • frontend/packages/console-shared/src/components/getting-started/__tests__/GettingStartedCard.spec.tsx
  • frontend/packages/operator-lifecycle-manager/src/components/operand/__tests__/index.spec.tsx
  • frontend/packages/operator-lifecycle-manager/src/components/__tests__/catalog-source.spec.tsx
🔇 Additional comments (24)
frontend/packages/console-shared/src/components/loading/__tests__/loading.spec.tsx (3)

1-2: Good import structure aligning with RTL best practices.

Using screen queries and renderWithProviders for components requiring context (Redux, Router) is the correct approach. The distinction between renderWithProviders for LoadError and plain render for stateless indicators is appropriate given the provider dependencies shown in the relevant snippets.


25-35: Solid role-based assertions for accessibility.

Using getByRole('button', { name: 'Try again' }) and queryByRole is excellent — this ensures the retry button is actually accessible and labeled correctly, which is critical for a11y compliance in PatternFly-based UIs. Much better than relying on text content alone.


46-53: Clean synchronous assertions for inline loader.

The switch from async await getByTestId to synchronous screen.getByTestId with toBeVisible() is appropriate here since the component renders synchronously. Verifying the co-m-loader--inline class ensures the correct inline styling variant is applied.

frontend/packages/console-shared/src/components/status/__tests__/status-box.spec.tsx (1)

22-28: [Rewritten review comment]
[Classification tag]

frontend/public/components/utils/__tests__/selector-input.spec.tsx (2)

16-51: Strong coverage for selector conversion helpers

Good set of cases for arrayify, objectify, and requirement/object conversion paths (including null/empty handling).


53-90: Validation and rendering tests are well-structured

These assertions cover key UX states (placeholder behavior, invalid class toggling, and validation callback transitions) with appropriate async handling.

frontend/packages/console-shared/src/components/formik-fields/key-value-file-input-field/__tests__/KeyValueFileInputField.spec.tsx (1)

47-62: Good move to user-driven interactions and accessible queries

The updated flows (click/tab + role/name queries) make these tests closer to real behavior and less coupled to implementation details.

Also applies to: 111-127

frontend/packages/console-shared/src/components/getting-started/__tests__/GettingStartedCard.spec.tsx (1)

32-113: Strong RTL coverage expansion here

The interaction and rendering matrix is materially improved (link variants, click paths, loading/empty states, and style assertion), and this aligns well with the migration goals.

frontend/packages/console-shared/src/components/empty-state/__tests__/empty-state.spec.tsx (1)

1-83: Solid RTL test modernization with proper query patterns.

Good adoption of renderWithProviders, screen queries, and toBeVisible() assertions. The role-based queries (lines 48-49) follow accessibility testing best practices. Test coverage for conditional rendering paths (body/footer presence, error details alert) is thorough.

frontend/packages/dev-console/locales/en/devconsole.json (1)

359-366: Appropriate i18n keys for accessibility labeling.

New translation keys for resource limit aria-labels follow the established pattern. These enable proper localization of the accessibility labels used by screen readers.

frontend/packages/console-shared/src/components/formik-fields/field-types.ts (1)

107-114: Backward-compatible API extension for accessibility.

Adding inputAriaLabel?: string as optional maintains backward compatibility while enabling proper ARIA labeling. Clean type definition.

frontend/packages/console-shared/src/components/formik-fields/ResourceLimitField.tsx (1)

29-42: Proper accessibility wiring with both ariaLabel and describedBy.

Good pattern passing both ariaLabel for the accessible name and describedBy for helper text association. The inputID={fieldId} ensures the input is properly linked to the FormGroup label via fieldId.

frontend/public/components/utils/request-size-input.tsx (1)

56-68: Clean ARIA label forwarding to NumberSpinner.

Proper pass-through of aria-label alongside existing aria-describedby. The optional typing maintains backward compatibility.

frontend/packages/console-shared/src/components/formik-fields/NumberSpinnerField.tsx (1)

12-18: Interface properly extended for min/max bounds.

Adding optional min and max props with pass-through via spread maintains backward compatibility. These will correctly flow to the underlying NumberSpinner component.

frontend/packages/dev-console/src/components/import/advanced/ResourceLimitSection.tsx (1)

36-75: Proper accessibility labeling for all resource limit fields.

Each ResourceLimitField now has a distinct, localized inputAriaLabel that clearly describes the field purpose for screen reader users. This follows a11y best practices for form inputs.

frontend/public/components/utils/number-spinner.tsx (1)

16-34: PatternFly NumberInput props correctly applied for accessibility and validation.

The inputAriaLabel prop properly labels the inner input element per PatternFly's API, and the max prop enables upper-bound enforcement. Combined with minusBtnAriaLabel and plusBtnAriaLabel, this provides complete accessibility coverage for the spinner control.

frontend/packages/console-shared/src/components/formik-fields/__tests__/NumberSpinnerField.spec.tsx (1)

10-110: Strong RTL coverage upgrade for NumberSpinnerField

Good modernization here: role-based queries, userEvent, keyboard behavior, and min/max boundary checks all improve long-term test reliability and accessibility confidence.

frontend/packages/console-app/src/components/modals/resource-limits/__tests__/ResourceLimitsModal.spec.tsx (1)

87-113: Nice test harness consolidation

renderResourceLimitsModal is a solid helper: less duplication, realistic Formik wiring, and easier future extension for validation scenarios.

frontend/packages/operator-lifecycle-manager/src/components/operand/__tests__/index.spec.tsx (1)

216-299: Status precedence coverage is solid.

These cases line up with getOperandStatus's phase → status → state → conditions order and cover both array/object conditions plus the no-true fallback.

frontend/packages/operator-lifecycle-manager/src/components/__tests__/catalog-source.spec.tsx (5)

43-64: Good simplification of the suite-local test doubles.

Rendering these helpers as deterministic text wrappers keeps the assertions focused on CatalogSource behavior instead of PatternFly/internal markup.


111-138: Nice coverage for the details branches.

This now exercises the DEFAULT_SOURCE_NAMESPACE mapping from frontend/packages/operator-lifecycle-manager/src/components/catalog-source.tsx:103-106 and the spec.image endpoint branch.


152-171: Good DetailsPage wiring check.

Verifying namespace, name, kind, and the three tab keys keeps this wrapper test focused on the contract it owns.


196-204: Good loading-path coverage.

This makes the not-yet-loaded branch explicit instead of only asserting the rendered YAML case.


220-237: Nice fallback coverage for missing defaultChannel.

This directly hits the pkg.status.defaultChannel ? ... : pkg.status.channels[0] branch in frontend/packages/operator-lifecycle-manager/src/components/catalog-source.tsx:245-247.

@cajieh cajieh force-pushed the extend-rtl-ests-overage-omponents-igrated-enzyme branch from 86b8c52 to f852b6d Compare April 8, 2026 17:55
@cajieh
Copy link
Copy Markdown
Contributor Author

cajieh commented Apr 8, 2026

/retest

@cajieh
Copy link
Copy Markdown
Contributor Author

cajieh commented Apr 9, 2026

/test e2e-gcp-console

1 similar comment
@cajieh
Copy link
Copy Markdown
Contributor Author

cajieh commented Apr 9, 2026

/test e2e-gcp-console

@cajieh
Copy link
Copy Markdown
Contributor Author

cajieh commented Apr 9, 2026

/label docs-approved
/label px-approved

/assign @yapei

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 9, 2026

@cajieh: GitHub didn't allow me to assign the following users: yapei.

Note that only openshift members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

Details

In response to this:

/label docs-approved
/label px-approved

/assign @yapei

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-ci openshift-ci bot added docs-approved Signifies that Docs has signed off on this PR px-approved Signifies that Product Support has signed off on this PR labels Apr 9, 2026
@cajieh
Copy link
Copy Markdown
Contributor Author

cajieh commented Apr 9, 2026

/assign @yanpzhan

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 9, 2026

@cajieh: GitHub didn't allow me to assign the following users: yanpzhan.

Note that only openshift members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

Details

In response to this:

/assign @yanpzhan

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.

@stefanonardo
Copy link
Copy Markdown
Contributor

nit: if possible, I'd convert all the waitFor + getBy with findBy which does not require waitFor. However, the PR looks good to me.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 9, 2026

@cajieh: 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 f852b6d 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.

@stefanonardo
Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 9, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 9, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cajieh, stefanonardo

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

@cajieh
Copy link
Copy Markdown
Contributor Author

cajieh commented Apr 9, 2026

nit: if possible, I'd convert all the waitFor + getBy with findBy which does not require waitFor. However, the PR looks good to me.

@stefanonardo Thank you for review.
Switched a few tests to findByText / findByRole / findAllByRole where the intent is “wait until this appears in the DOM”.
Retained waitFor where the test is waiting for something findBy* cannot express like the Save button becoming disabled after async validation.

@cajieh
Copy link
Copy Markdown
Contributor Author

cajieh commented Apr 9, 2026

/test e2e-gcp-console

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. component/core Related to console core functionality component/dev-console Related to dev-console component/olm Related to OLM component/shared Related to console-shared docs-approved Signifies that Docs has signed off on this PR jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants