PG1204 opened a new pull request, #6435:
URL: https://github.com/apache/texera/pull/6435

   ### What changes were proposed in this PR?
   Adds unit test coverage for the pure resource-helper functions in 
[frontend/src/app/common/util/computing-unit.util.ts](vscode-webview://1epki5h79lmkghv36u4evg54fuvmk17ndjca203mcg7opnnd5sg9/frontend/src/app/common/util/computing-unit.util.ts),
 which previously had no direct test coverage. These functions parse Kubernetes 
resource strings, compute CPU/memory usage percentages, and derive UI status 
indicators.
   
   A new spec file, frontend/src/app/common/util/computing-unit.util.spec.ts, 
was created following the style of size-formatter.util.spec.ts (same 
directory). It adds 34 tests covering all 15 exported functions:
   
   parseResourceUnit / parseResourceNumber - unit extraction, decimals, and 
empty/NaN/invalid inputs
   cpuResourceConversion / memoryResourceConversion - precision scaling per 
target unit
   cpuPercentage / memoryPercentage - N/A and non-positive-limit guards, and 
the 100% clamp
   validateName - empty names, the 128-character boundary, and valid names
   getComputingUnitBadgeColor / getComputingUnitStatusTooltip - status mapping 
with fallback
   getComputingUnitCpuStatus / getComputingUnitMemoryStatus - percentage 
thresholds
   getComputingUnitCpuLimitUnit, isComputingUnitShmTooLarge (including mixed 
Mi/Gi comparisons), getJvmMemorySliderConfig, and buildLocalComputingUnitUri
   No production code was modified.
   
   Note: the issue lists a findNearestValidStep function that does not exist in 
the current codebase, so it was omitted; the actual exported functions are 
covered.
   
   ### Any related issues, documentation, discussions?
   Closes #6253
   
   ### How was this PR tested?
   Added 34 unit tests in the new spec file, all passing via ng test:
   
   cd frontend && npx ng test --watch=false 
--include='**/computing-unit.util.spec.ts'
   
   ✓ src/app/common/util/computing-unit.util.spec.ts (34 tests) 10ms
    Test Files - 1, passed (1)
         Tests - 34, passed (34)
   
   ### Was this PR authored or co-authored using generative AI tooling?
   Co-authored with Claude Opus 4.8 in compliance with ASF


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to