Skip to content

test(frontend): extend ComputingUnitSelectionComponent coverage with resource getters#6555

Merged
aglinxinyuan merged 1 commit into
apache:mainfrom
mengw15:chore/6551-computing-unit-selection-test
Jul 20, 2026
Merged

test(frontend): extend ComputingUnitSelectionComponent coverage with resource getters#6555
aglinxinyuan merged 1 commit into
apache:mainfrom
mengw15:chore/6551-computing-unit-selection-test

Conversation

@mengw15

@mengw15 mengw15 commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Extends the existing ComputingUnitSelectionComponent spec
(frontend/src/app/workspace/component/power-button/, codecov ~59%) to cover the
previously-untested resource-display getters and a few small handlers. Follows
frontend/TESTING.md and reuses the existing makeComputingUnit fixture.

Adds 13 tests:

  • resource accessorsgetCurrentComputingUnit{Cpu,Memory}Usage,
    getCurrentComputingUnit{Cpu,Memory,Gpu}Limit, getCurrentComputingUnitJvmMemorySize,
    getCurrentSharedMemorySize: read the selected unit's raw values, and return
    "NaN" for every accessor when nothing is selected.
  • derived gettersgetCpuLimit/getMemoryLimit (numbers), getGpuLimit/
    getJvmMemorySize/getSharedMemorySize, getCpuLimitUnit/getMemoryLimitUnit/
    getCpuUnit/getMemoryUnit; getCpuValue/getMemoryValue/getCpuPercentage/
    getMemoryPercentage return 0 when metrics are unavailable; getCpuStatus/
    getMemoryStatus map to "success"; getBadgeColor and getUnitStatusTooltip
    map status → color/tooltip.
  • misc handlerstrackByCuid/trackByIndex identity, cancelEditingUnitName
    state reset, openComputingUnitMetadataModal opens the metadata modal with the
    unit as nzData, and scrollToBottomOfPipModal scrolls the deferred pip-log
    element (and is a safe no-op when it is absent).

No production code was changed.

Any related issues, documentation, discussions?

Closes #6551

How was this PR tested?

Extended Vitest spec, run locally in frontend/ (whole file green, run 4× to
confirm determinism; failure path verified by breaking an assertion). To stay
deterministic, scrollToBottomOfPipModal is driven with fake timers and a
stubbed document.getElementById (a plain stand-in object, restored after each
test) rather than relying on jsdom layout.

ng test --watch=false --include src/app/workspace/component/power-button/computing-unit-selection.component.spec.ts
# Test Files 1 passed (1) / Tests 100 passed (100)
eslint <spec>      # clean
prettier --check   # clean

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 4.8 [1M context])

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Jul 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @aglinxinyuan
    You can notify them by mentioning @aglinxinyuan in a comment.

@codecov-commenter

codecov-commenter commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.58%. Comparing base (80c45be) to head (ff3d8e1).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6555      +/-   ##
============================================
+ Coverage     72.54%   72.58%   +0.04%     
  Complexity     3436     3436              
============================================
  Files          1145     1145              
  Lines         45129    45129              
  Branches       4975     4975              
============================================
+ Hits          32738    32757      +19     
+ Misses        10709    10686      -23     
- Partials       1682     1686       +4     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 80c45be
agent-service 76.76% <ø> (ø) Carriedforward from 80c45be
amber 66.81% <ø> (ø) Carriedforward from 80c45be
computing-unit-managing-service 17.72% <ø> (ø) Carriedforward from 80c45be
config-service 66.66% <ø> (ø) Carriedforward from 80c45be
file-service 66.80% <ø> (ø) Carriedforward from 80c45be
frontend 73.91% <ø> (+0.10%) ⬆️
notebook-migration-service 78.94% <ø> (ø) Carriedforward from 80c45be
pyamber 91.79% <ø> (ø) Carriedforward from 80c45be
workflow-compiling-service 55.14% <ø> (ø) Carriedforward from 80c45be

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

Copilot AI 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.

Pull request overview

This PR extends the existing frontend unit test coverage for ComputingUnitSelectionComponent by adding deterministic tests for previously-untested resource-display accessors/getters and a few small UI helper/handler methods. It aligns with the linked issue’s request to cover the “pure getter” surface area without changing production code.

Changes:

  • Added unit tests for getCurrentComputingUnit* resource accessors, derived display getters (limits/units/values/percentages/status), and status mapping helpers.
  • Added tests for trackBy*, cancelEditingUnitName, openComputingUnitMetadataModal, and scrollToBottomOfPipModal (including an absent-element no-op case).
  • Imported ComputingUnitMetadataComponent for modal expectation matching in the new tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mengw15
mengw15 force-pushed the chore/6551-computing-unit-selection-test branch from 90df8bb to ff3d8e1 Compare July 19, 2026 08:14
@mengw15
mengw15 requested a review from aglinxinyuan July 19, 2026 08:22

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

LGTM!

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Jul 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 20, 2026
@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Jul 20, 2026
Merged via the queue into apache:main with commit 4f82883 Jul 20, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add unit test coverage for ComputingUnitSelectionComponent

4 participants