Skip to content

ROX-33571: Add component tests for container display components#19513

Draft
dvail wants to merge 3 commits intodv/ROX-33571-consolidate-container-displayfrom
dv/ROX-33571-add-component-tests
Draft

ROX-33571: Add component tests for container display components#19513
dvail wants to merge 3 commits intodv/ROX-33571-consolidate-container-displayfrom
dv/ROX-33571-add-component-tests

Conversation

@dvail
Copy link
Contributor

@dvail dvail commented Mar 19, 2026

Description

Adds comprehensive Vitest component tests for the new shared container display components:

DeploymentContainersCard.test.tsx (90 lines):

  • Tests rendering with valid containers
  • Tests null/undefined container handling
  • Tests empty container array
  • Tests custom title prop
  • Tests image URL generation callback

SecurityContextCard.test.tsx (150 lines):

  • Tests rendering containers with security context
  • Tests filtering (only shows containers with security data)
  • Tests privileged container display
  • Tests add/drop capabilities display
  • Tests custom title and empty message props
  • Tests null/undefined container handling
  • Tests when no containers have security context

All tests use Vitest with React Testing Library and validate both rendering and props handling.

User-facing documentation

  • CHANGELOG.md is updated OR update is not needed - test-only change
  • documentation PR is created and is linked above OR is not needed - no docs needed

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag - tests only
  • CI results are inspected

Automated testing

  • added unit tests - 240 lines of component tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

  • All tests pass locally with npm run test
  • Tests cover edge cases: null, undefined, empty arrays, filtering
  • Tests validate props are properly threaded through components
  • Mock data matches actual Container type structure

Part of ROX-33571 container display consolidation stack.
Depends on: #19512

@dvail
Copy link
Contributor Author

dvail commented Mar 19, 2026

@openshift-ci
Copy link

openshift-ci bot commented Mar 19, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The container fixtures in both test files are quite verbose and largely duplicated; consider extracting a shared factory/helper for creating Container objects so individual tests can focus on the specific fields they care about.
  • In SecurityContextCard tests, assertions like getByText('true') are a bit brittle and could match unintended content; using more specific queries (e.g., scoped within a row/section or asserting on labels/roles) would make these tests more robust to UI changes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The container fixtures in both test files are quite verbose and largely duplicated; consider extracting a shared factory/helper for creating `Container` objects so individual tests can focus on the specific fields they care about.
- In `SecurityContextCard` tests, assertions like `getByText('true')` are a bit brittle and could match unintended content; using more specific queries (e.g., scoped within a row/section or asserting on labels/roles) would make these tests more robust to UI changes.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rhacs-bot
Copy link
Contributor

Images are ready for the commit at 0c9b676.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-393-g0c9b676044.

Create DeploymentContainersCard wrapper for container display

Migrate Violations container config to shared component

Create SecurityContextCard for filtered security context display

Migrate Violations security context to shared component

Migrate Risk container config to shared PF6 component

Migrate Risk security context to shared PF6 component

Fix ESLint: use ?? instead of ||
@dvail dvail force-pushed the dv/ROX-33571-consolidate-container-display branch from 4fdb017 to df2f821 Compare March 19, 2026 21:00
@dvail dvail force-pushed the dv/ROX-33571-add-component-tests branch from 0c9b676 to 7d53616 Compare March 19, 2026 21:00
Remove low-value tests, keep filtering logic test

Simplify test mocks with type casting

Fix type assertions with unknown cast
@dvail dvail force-pushed the dv/ROX-33571-add-component-tests branch from 7d53616 to 5fb2902 Compare March 19, 2026 21:02
@dvail dvail force-pushed the dv/ROX-33571-consolidate-container-display branch from df2f821 to 5095833 Compare March 19, 2026 21:06
@openshift-ci
Copy link

openshift-ci bot commented Mar 19, 2026

PR needs rebase.

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.

@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.26%. Comparing base (7a018d9) to head (5fb2902).
⚠️ Report is 2 commits behind head on dv/ROX-33571-consolidate-container-display.

Additional details and impacted files
@@                              Coverage Diff                               @@
##           dv/ROX-33571-consolidate-container-display   #19513      +/-   ##
==============================================================================
- Coverage                                       49.27%   49.26%   -0.01%     
==============================================================================
  Files                                            2726     2726              
  Lines                                          205625   205625              
==============================================================================
- Hits                                           101312   101299      -13     
- Misses                                          96777    96786       +9     
- Partials                                         7536     7540       +4     
Flag Coverage Δ
go-unit-tests 49.26% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants