Skip to content

Fix 16 test failures blocking coverage-hourly suite#11183

Merged
clubanderson merged 2 commits intomainfrom
fix/coverage-test-failures
May 1, 2026
Merged

Fix 16 test failures blocking coverage-hourly suite#11183
clubanderson merged 2 commits intomainfrom
fix/coverage-test-failures

Conversation

@clubanderson
Copy link
Copy Markdown
Collaborator

Fixes 16 test failures across 3 files blocking coverage-hourly. Badge stuck at 90%. Details: workloads.extended (13 fails, api.get→agentFetch migration), fetcherUtils-coverage (2 fails, Response body reuse + missing cluster context), useLastRoute (1 fail, setTimeout timing).

Hooks (useReplicaSets, useStatefulSets, useDaemonSets, useCronJobs,
useHPAs, usePodLogs) were migrated from api.get() to agentFetch() but
tests still asserted on mockApiGet. Updated test mocks to use a hoisted
mockAgentFetch with Response-shaped return values matching the agentFetch
contract (resp.ok + resp.json()).

Signed-off-by: Andrew Anderson <[email protected]>
- fetcherUtils: create fresh Response per call to avoid consumed body
- fetcherUtils: set up cluster context for SSE partial failure fallback
- useLastRoute: advance fake timers for setTimeout-based scroll restore

Signed-off-by: Andrew Anderson <[email protected]>
Copilot AI review requested due to automatic review settings May 1, 2026 00:13
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label May 1, 2026
@kubestellar-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify
Copy link
Copy Markdown

netlify Bot commented May 1, 2026

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit cd3a79e
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/69f3f021dde8d200086d8874
😎 Deploy Preview https://deploy-preview-11183.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kubestellar-prow kubestellar-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

Copy link
Copy Markdown
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

Addresses failing frontend test coverage in the coverage-hourly suite by updating mocks/expectations to match recent behavior changes (notably the api.getagentFetch migration and async timing in useLastRoute).

Changes:

  • Updated fetcherUtils coverage tests to avoid Response body reuse and to correctly exercise/expect the REST fallback partial-failure path.
  • Migrated workloads.extended tests from mockApiGet-based expectations to mockAgentFetch to reflect the new REST path implementation.
  • Stabilized a useLastRoute scroll-restore test by using fake timers to advance the internal setTimeout.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
web/src/lib/cache/tests/fetcherUtils-coverage.test.ts Fixes response-mocking semantics and aligns partial-failure expectation with the REST fallback behavior.
web/src/hooks/mcp/tests/workloads.extended.test.ts Updates mocks/assertions to validate URL/query params via agentFetch instead of api.get.
web/src/hooks/tests/useLastRoute.test.ts Uses fake timers to deterministically trigger the delayed scroll restoration.

Comment on lines +713 to +724
vi.useFakeTimers()
localStorage.setItem('kubestellar-remember-position', JSON.stringify({ '/clusters': true }))
localStorage.setItem('kubestellar-scroll-positions', JSON.stringify({
'/clusters': { position: 400, cardTitle: undefined }
}))
mockPathname = '/clusters'
renderHook(() => useLastRoute())
// restoreScrollPosition is called inside a setTimeout(…, 50) in the navigation effect
vi.advanceTimersByTime(100)
// scrollTo should be called with the saved position
expect(main.scrollTo).toHaveBeenCalledWith(expect.objectContaining({ top: 400 }))
vi.useRealTimers()
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

vi.useRealTimers() is called at the end of the test body, so if an assertion throws earlier the file can be left in fake-timer mode and leak into subsequent tests. Wrap the fake-timer section in a try/finally (or add a local afterEach that always calls vi.useRealTimers()) so timers are reliably restored even on failure.

Copilot uses AI. Check for mistakes.
@clubanderson clubanderson merged commit 4417040 into main May 1, 2026
30 of 33 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the fix/coverage-test-failures branch May 1, 2026 00:20
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

❌ Post-Merge Verification: failed

Commit: 441704094afca980ae3aeee08d59f7c1e200dde0
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/25195973019

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit 441704094afca980ae3aeee08d59f7c1e200dde0.

lightyagami2109 pushed a commit to lightyagami2109/kubestellar_console_OJT that referenced this pull request May 3, 2026
* Fix 13 failing tests: migrate from mockApiGet to mockAgentFetch

Hooks (useReplicaSets, useStatefulSets, useDaemonSets, useCronJobs,
useHPAs, usePodLogs) were migrated from api.get() to agentFetch() but
tests still asserted on mockApiGet. Updated test mocks to use a hoisted
mockAgentFetch with Response-shaped return values matching the agentFetch
contract (resp.ok + resp.json()).

Signed-off-by: Andrew Anderson <[email protected]>

* Fix 3 test failures in fetcherUtils-coverage and useLastRoute

- fetcherUtils: create fresh Response per call to avoid consumed body
- fetcherUtils: set up cluster context for SSE partial failure fallback
- useLastRoute: advance fake timers for setTimeout-based scroll restore

Signed-off-by: Andrew Anderson <[email protected]>

---------

Signed-off-by: Andrew Anderson <[email protected]>
Signed-off-by: lightyagami2109 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tier/1-lightweight

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants