Skip to content

Test/682 referral panel - #568

Open
Nusirat12345 wants to merge 4 commits into
scout-off:mainfrom
Nusirat12345:test/682-referral-panel
Open

Test/682 referral panel#568
Nusirat12345 wants to merge 4 commits into
scout-off:mainfrom
Nusirat12345:test/682-referral-panel

Conversation

@Nusirat12345

Copy link
Copy Markdown
Contributor

No description provided.

- src/frontend/components/scout/ReferralPanel.ts:
  - ReferralPanel class driven by injected deps (getReferralStats, generateReferralCode, copyToClipboard)
  - loadStats(): loading flag, populates stats on success, sets error on failure
  - generateCode(): generating flag, double-submit guard, appends code on success
  - copyCode(id, text): sets copiedCodeId on success, sets error on failure
  - clearCopied(): resets copiedCodeId to null
  - getState(): returns a snapshot copy of current state

- tests/frontend/components/scout/ReferralPanel.test.ts:
  - Initial state: null stats, empty codes, all flags false
  - loadStats: loading=true during request, stats populated after, error on failure
  - loadStats: non-Error rejection gets fallback message
  - loadStats: previous error cleared on subsequent success
  - generateCode: generating=true during request, appended to codes after
  - generateCode: double-submit guard (second concurrent call is no-op)
  - generateCode: failure sets error, codes unchanged
  - copyCode: copiedCodeId set on success, correct text passed to clipboard
  - copyCode: error set on clipboard failure, copiedCodeId NOT set
  - clearCopied: resets copiedCodeId to null; safe to call when already null
  - Error propagation: error accessible for all three failure paths
  - Successful operation after failure clears the error (Toast path)
- src/controllers/apiKeyController.ts: remove unused touchApiKeyLastUsed
  import (it is accessed via lazy require in auth.ts, not statically here)
- tests/frontend/components/scout/ReferralPanel.test.ts:
  - Fix parsing error: replace curly apostrophe in test description with
    plain text to avoid ESLint/parser treating it as a quote delimiter
  - Change let capturedLoading / capturedGenerating to const (prefer-const)
- tests/frontend/hooks/useRequireSubscription.test.ts:
  - Remove unused PUBLIC_KEY constant (no-unused-vars)
The test file lives four directories below the project root
(tests/frontend/components/scout/) so the import needs four
levels of ../ to reach src/, not three.

  Wrong:  '../../../src/frontend/components/scout/ReferralPanel'
  Fixed: '../../../../src/frontend/components/scout/ReferralPanel'

All 85 frontend tests now pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant