Add 60 unit tests for modules with least coverage#3
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Add 60 unit tests for modules with least coverage#3devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Cover previously untested functions across all core modules: - SessionService: extractAuthTokens (5), validateChatGptAuth (5), resolveCodexExecutable (4), extractEmailFromIdToken extended (4), pruneBackups (3) - UsageService: buildEmptyUsageSnapshot (1), resolveUsageUrl (5), scanLogFile (6) - ProfileService: buildEmptyState (1), getActiveAccount (3), resolveAccountByIdentifier (4), formatStateSummary (2), sanitizeState edge cases (10), computeAuthSignature edge cases (2) - kfl-bridge: buildBridgeStatusPayload (5) Total: 8 existing + 60 new = 68 tests, 149 expect() calls. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The existing test suite had 8 tests covering
sanitizeState,computeAuthSignature,extractEmailFromIdToken, a mockedprimeAccount,ensureCurrentCodexLinkedmatching, and oneresolveUsageUrlcase. Several core modules had zero or near-zero test coverage.This PR adds 60 new unit tests (8 → 68 total, 149
expect()calls) targeting the least-covered areas:SessionService(21 new tests)extractAuthTokens— ChatGPT tokens, API key path, missing token throw, optional field defaults, API key precedence overtokensblockvalidateChatGptAuth— valid chatgpt/api_key/null modes pass; empty token and unexpected mode throwresolveCodexExecutable— env var resolution (KEYFLOW_CODEX_PATH,KFL_CODEX_PATH), PATH search, fallback to"codex"extractEmailFromIdToken(extended) —preferred_usernamefallback, no-email payload, non-email value, base64url paddingpruneBackups— keeps 10 newest, no-op for ≤10, no-throw on missing dirUsageService(12 new tests)buildEmptyUsageSnapshot— all fields arenull/'never'resolveUsageUrl— no config default,chat.openai.com→/backend-api, custom non-ChatGPT base →/api/codex/usage, trailing slash stripping, pre-existing/backend-apiscanLogFile— valid log parsing (source/plan/windows/timestamps), email filtering, empty-file null, missing-file null, last-entry-wins, percentage clampingProfileService(22 new tests)buildEmptyState,getActiveAccount(null/match/fallback),resolveAccountByIdentifier(by id/label/unknown/duplicate),formatStateSummary(active flags, empty state)sanitizeStateedge cases — non-object input, generated id, default label, percentage clamping,remainingPercentderivation,activeAccountIdfallback/auto-set, invalid status default, source handlingcomputeAuthSignatureedge cases — different auth modes produce different sigs, no stable identity falls back toaccessTokenseedkfl-bridge(5 new tests)buildBridgeStatusPayload— empty state,isActive/canSwitch/needsAttentionflags,isBlockedfor deactivated accounts,displayNameemail-vs-label fallbackLink to Devin session: https://app.devin.ai/sessions/72c3dfb1736048ad8b92da2b8a550854
Requested by: @hbui290