Skip to content

HDDS-9793. [Recon][UI][Test] Add tests for Containers page - #11417

Merged
chihsuan merged 2 commits into
apache:masterfrom
sravani-revuri:HDDS-9793
Oct 12, 2026
Merged

chihsuan merged 2 commits into
apache:masterfrom
sravani-revuri:HDDS-9793

Conversation

@sravani-revuri

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This task adds test for the container page on recon UI

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-9793

How was this patch tested?

Ran tests.

 ✓ src/__tests__/containers/Containers.test.tsx (12 tests) 1814ms
   ✓ Containers Component (12)
     ✓ renders component correctly 217ms
     ✓ Loads data on mount 66ms
     ✓ loads missing containers on mount and updates highlights 62ms
     ✓ Renders table with correct number of rows 60ms
     ✓ Displays no data message if the missing containers API returns an empty array 65ms
     ✓ lazy-loads data when switching to under-replicated tab 205ms
     ✓ lazy-loads data when switching to over-replicated tab 134ms
     ✓ lazy-loads quasi closed containers when switching tabs 122ms
     ✓ Handles search input change  375ms
     ✓ Displays a message when no results match the search term  366ms
     ✓ Handles API errors gracefully by showing error message 51ms
     ✓ Handles API errors when loading under-replicated tab 89ms

 Test Files  1 passed (1)
      Tests  12 passed (12)
   Start at  11:26:25
   Duration  5.18s (transform 129ms, setup 136ms, collect 2.19s, tests 1.81s, environment 537ms, prepare 124ms)

@sravani-revuri
sravani-revuri marked this pull request as ready for review October 7, 2026 06:40

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for working on this! @sravani-revuri The structure looks good and matches the other Recon tests nicely.

I tried breaking the behavior each test names, and a few still pass. See inline for details.

return {
...actual,
useApiData: <T,>(url: string, defaultValue: T, options = {}) => {
if (url === '/api/v1/clusterState') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Is this special case needed? The mock server already handles this endpoint, and the tests still pass for me without it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The server already handles /api/v1/clusterState and the test assertions do pass, but vitest run reports unhandled CanceledErrors on that URL without this check . Containers fetches clusterState twice on mount (initialFetch: true + clusterState.refetch() from autoReload), so the second request aborts the first and that rejection isn’t caught. I checked out how pipelines is doing it and it uses initialFetch: false instead hence it doesn't face this problem.

I've currently added a comment to justify this, happy to drop / modify in a follow-up accordingly.

Image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for digging into this! @sravani-revuri The double fetch also happens on the page itself, so I've opened HDDS-16877 as a follow-up, and #11484 fixes it. Since this PR will merge first, we can drop the special case in #11484.

@smengcl smengcl 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.

The 12 tests pass locally, but the suite also passes with these deliberate regressions:

  • An empty API response incorrectly produces a row: the empty-state assertion passes against the initial “No Data” placeholder.
  • The Quasi Closed highlight shows N/A: the whole-card match for 2 also matches 20 or 25.
  • Tab data loads eagerly on mount or reloads on every visit: the lazy-loading tests only check that rows eventually appear.

Could we strengthen these assertions before merging? The existing inline threads already cover the highlight and lazy-loading gaps.

@smengcl smengcl 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.

Thanks for the update. lgtm

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @sravani-revuri for the patch, @smengcl for the review.

@chihsuan
chihsuan merged commit c3fa499 into apache:master Oct 12, 2026
51 checks passed
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.

3 participants