Skip to content

test(auth): add unit coverage for logoutCleanup branches (#24639) - #24657

Closed
markankamaransheogarat-sys wants to merge 1 commit into
kubestellar:mainfrom
markankamaransheogarat-sys:test/logout-cleanup-unit-coverage-24639
Closed

markankamaransheogarat-sys wants to merge 1 commit into
kubestellar:mainfrom
markankamaransheogarat-sys:test/logout-cleanup-unit-coverage-24639

Conversation

@markankamaransheogarat-sys

Copy link
Copy Markdown

📌 Fixes

Fixes #24639


📝 Summary of Changes

Adds dedicated unit test coverage for web/src/lib/auth/logoutCleanup.ts exercising branches in invalidateServerSession(), clearLocalAuthStorage(), and clearSessionCaches().


Changes Made

  • Added web/src/lib/auth/__tests__/logoutCleanup.test.ts
  • Covered invalidateServerSession() skipping logout POST for absent or demo tokens
  • Covered invalidateServerSession() sending Bearer token and X-Requested-With: XMLHttpRequest
  • Covered invalidateServerSession() gracefully swallowing network errors
  • Covered clearLocalAuthStorage() clearing token stores, resetting demo flags, and wiping kc-auth-user-cache and kc-session-id from sessionStorage
  • Covered clearLocalAuthStorage() handling environments where sessionStorage throws
  • Covered clearSessionCaches() invoking cache clears and presence disconnect

Checklist

  • I used a coding agent (Claude Code, Copilot, Gemini, or Codex) to generate/review this code
  • I have reviewed the project's contribution guidelines
  • I have written unit tests for the changes
  • All commits are signed with DCO (git commit -s)

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 27, 2026
@netlify

netlify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kubestellarconsole ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 10090f0
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6ae07c99767ab5c58142b235
😎 Deploy Preview https://deploy-preview-24657.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

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 eeshaansa 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

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 27, 2026
@hivecommons-hive hivecommons-hive Bot added author/human A person pushed this PR themselves dco All commits are DCO signed-off role/untrusted Author has no registry profile or verified hive claim (or is revoked); never auto-merged stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 27, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

File-overlap note: this PR and #24640 both add web/src/lib/auth/__tests__/logoutCleanup.test.ts for the same issue (#24639). #24640 was opened earlier and already carries a hive review approval; whichever merges first will conflict with the other. Maintainers may want to pick one and close the other.


🐝 Hive Agent: scanner | Instance: hosted-kubestellar-console-4vkt | SHA: 39f1b59

— hive: agent=scanner backend=copilot model=claude-fable-5 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Heads-up for maintainers: this PR and #24640 both add web/src/lib/auth/__tests__/logoutCleanup.test.ts and both close #24639 — whichever merges second will conflict on the same file. #24640 is the earlier PR with all checks green; this PR currently has a Test (chromium, shard 2) failure. Suggest merging one and closing the other as duplicate.


🐝 Hive Agent: scanner | Instance: hosted-kubestellar-console-4vkt | SHA: e568d94

— hive: agent=scanner backend=copilot model=claude-fable-5 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot 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.

Decision needed: @clubanderson should decide whether to close this PR in favour of #24640, which adds the same logoutCleanup test file for #24639 and is green.

This duplicates #24640. Both PRs add the identical new file web/src/lib/auth/__tests__/logoutCleanup.test.ts for issue #24639, covering the same branches of invalidateServerSession() / clearLocalAuthStorage(); only one can merge. #24640 is earlier, all checks are green, and its PR body includes a mutation check. This PR adds one extra block (clearSessionCaches coverage) but has a failing Test (chromium, shard 2) check. I have not closed anything.

Beyond the duplication, this PR's module specifiers don't resolve. The test lives in web/src/lib/auth/__tests__/, but it imports and mocks paths relative to web/src/lib/auth/:

  • logoutCleanup.test.ts:40 vi.mock('../authToken', …) resolves to web/src/lib/auth/authToken, which does not exist — the real module is web/src/lib/authToken.ts, i.e. ../../authToken from the test (compare #24640, which mocks ../../authToken).
  • Same offset error for ../demoMode, ../safeLocalStorage, ../sseClient, ../dashboards/dashboardSync, and ../../hooks/* (should be ../../../hooks/*); I verified against the tree — web/src/lib/auth/ contains none of those modules.
  • logoutCleanup.test.ts:100 imports DEMO_TOKEN_VALUE etc. from '../constants', which also resolves to a nonexistent web/src/lib/auth/constants.

Mechanism/consequence: the direct ../constants import cannot resolve, and the vi.mock registrations target ids that differ from the ones logoutCleanup.ts actually imports (../authToken from lib/auth/ = web/src/lib/authToken), so the mocks would not intercept even if resolution succeeded. The suite cannot run as written.

Recommendation: close in favour of #24640. If maintainers want the extra clearSessionCaches coverage, it would be a small follow-up on top of #24640's correctly-pathed file.

— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 27, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

Needs a decision, not a merge:

Head: verdict requires_human @10090f0, 31/31 checks green, DCO yes, soak 30m0s elapsed.

What to do: a trusted merger approves this head (10090f0) — a GitHub Approve review, or a /hive approve reply posted after the verdict — and the hive re-evaluates on its next pass; the PR author cannot release their own PR, and the hive does not push to a PR it did not open.

Clear the cause and the hive re-evaluates on its next pass; the stage moves to stage/090-ready-for-human-merge, stage/095-pre-merge-soak or the merge queue on its own. An approval does not bypass CI, hold labels or other merge gates.

1 similar comment
@hivecommons-hive

Copy link
Copy Markdown
Contributor

Needs a decision, not a merge:

Head: verdict requires_human @10090f0, 31/31 checks green, DCO yes, soak 30m0s elapsed.

What to do: a trusted merger approves this head (10090f0) — a GitHub Approve review, or a /hive approve reply posted after the verdict — and the hive re-evaluates on its next pass; the PR author cannot release their own PR, and the hive does not push to a PR it did not open.

Clear the cause and the hive re-evaluates on its next pass; the stage moves to stage/090-ready-for-human-merge, stage/095-pre-merge-soak or the merge queue on its own. An approval does not bypass CI, hold labels or other merge gates.

@markankamaransheogarat-sys

Copy link
Copy Markdown
Author

Closing this as a duplicate of #24640, which already covers the same logoutCleanup tests. Sorry for the noise!

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

Labels

author/human A person pushed this PR themselves dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. role/untrusted Author has no registry profile or verified hive claim (or is revoked); never auto-merged size/L Denotes a PR that changes 100-499 lines, ignoring generated files. stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: add unit coverage for lib/auth/logoutCleanup branches

2 participants