Skip to content

Conversation

@agatha197
Copy link
Contributor

@agatha197 agatha197 commented Jan 6, 2026

Add comprehensive tests for MyResourceWithinResourceGroup component

Resolves #4952 (FR-1876)

This PR adds comprehensive test coverage for the MyResourceWithinResourceGroup component. The tests cover various resource usage scenarios including:

  • Normal resource usage display
  • Zero resource usage
  • High resource usage
  • Handling of Infinity values
  • Scenarios without GPU resources
  • Handling of undefined values
  • Zero GPU usage and remaining resources

The PR also fixes an import path in the component file, changing from an absolute import to a relative import for the useFetchKey hook.

Checklist:

  • Documentation
  • Minium required manager version
  • Specific setting for review (eg., KB link, endpoint or how to setup): go to backend.ai-webui/react and run pnpm run test
  • Minimum requirements to check during review
  • Test case(s) to demonstrate the difference of before/after

Copilot AI review requested due to automatic review settings January 6, 2026 12:56
@github-actions github-actions bot added the size:L 100~500 LoC label Jan 6, 2026
Copy link
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • flow:merge-queue - adds this PR to the back of the merge queue
  • flow:hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

Coverage report for ./react

St.
Category Percentage Covered / Total
🔴 Statements
5.12% (+0.21% 🔼)
614/11988
🔴 Branches
4.68% (+0.2% 🔼)
394/8425
🔴 Functions
2.83% (+0.08% 🔼)
104/3676
🔴 Lines
4.95% (+0.21% 🔼)
580/11706

Test suite run success

181 tests passing in 14 suites.

Report generated by 🧪jest coverage report action from c0b06fb

Copy link
Contributor

@nowgnuesLee nowgnuesLee left a comment

Choose a reason for hiding this comment

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

Please add copilot as a reviewer

@agatha197 agatha197 changed the base branch from fix_FR-1876_/remove-unnecessary-filter to graphite-base/4953 January 7, 2026 04:16
Copilot AI review requested due to automatic review settings January 7, 2026 04:16
@agatha197 agatha197 force-pushed the chore_FR-1876_/add-test-code branch from c688cb2 to bb801ea Compare January 7, 2026 04:16
@agatha197 agatha197 changed the base branch from graphite-base/4953 to fix_FR-1876_/remove-unnecessary-filter January 7, 2026 04:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive test coverage for the MyResourceWithinResourceGroup component and fixes an import path inconsistency. The tests validate the component's behavior across various resource usage scenarios including normal usage, zero usage, high usage, Infinity values, and edge cases like missing GPU resources or undefined values.

Key Changes:

  • Fixed import path from absolute (src/hooks) to relative (../hooks), aligning with the standard pattern used in the components directory
  • Added 7 distinct test scenarios covering edge cases and different resource allocation states
  • Implemented comprehensive mocking for all dependencies including React Query, i18n, Ant Design components, and custom hooks

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
react/src/components/MyResourceWithinResourceGroup.tsx Changed import from absolute to relative path for useFetchKey hook, maintaining consistency with other component files
react/src/components/MyResourceWithinResourceGroup.test.tsx Added comprehensive test suite with 7 test cases covering various resource usage scenarios, edge cases, and component rendering validation

@agatha197 agatha197 force-pushed the chore_FR-1876_/add-test-code branch from bb801ea to 7328670 Compare January 7, 2026 05:57
@agatha197 agatha197 requested a review from nowgnuesLee January 7, 2026 05:58
Copy link
Contributor

@ironAiken2 ironAiken2 left a comment

Choose a reason for hiding this comment

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

I got error on using createMockReturnValue.

image.png

Copilot AI review requested due to automatic review settings January 7, 2026 08:54
@agatha197 agatha197 force-pushed the chore_FR-1876_/add-test-code branch from 7328670 to c1fd1cb Compare January 7, 2026 08:54
@agatha197 agatha197 force-pushed the fix_FR-1876_/remove-unnecessary-filter branch from 4162ce2 to d43b6ed Compare January 7, 2026 08:54
Copy link
Contributor Author

Oops, I forgot submitting.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

@agatha197 agatha197 force-pushed the chore_FR-1876_/add-test-code branch from c1fd1cb to c0b06fb Compare January 8, 2026 05:04
Copy link
Contributor

@ironAiken2 ironAiken2 left a comment

Choose a reason for hiding this comment

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

LGTM

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

Labels

size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants