test: cover dotenv helpers and object key token encoding#4
Draft
cursor[bot] wants to merge 2 commits intomainfrom
Draft
test: cover dotenv helpers and object key token encoding#4cursor[bot] wants to merge 2 commits intomainfrom
cursor[bot] wants to merge 2 commits intomainfrom
Conversation
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
Adds focused Vitest coverage for
.envparsing/editing helpers used by the vault file workspace and secrets TRPC router, and for URL-safe S3 object key tokens used with access tokens.Risky behavior now covered
parseDotenv/removeDotenvKey/appendDotenvKey(src/lib/dotenv-parse.ts): comment and blank handling, quoted values, CRLF, key removal without stripping unrelated keys, append formatting and validation (empty key,=,#prefix, newlines, duplicates), and quoting rules for values that need escaping.encodeObjectKeyToken/decodeObjectKeyToken(src/lib/key-token.ts): round-trip for typical paths, Unicode keys, empty string, and a byte pattern that would produce+//in standard base64 (URL-safety regression guard).Test files added/updated
src/lib/dotenv-parse.test.ts(new)src/lib/key-token.test.ts(new)Why this reduces regression risk
These modules sit on high-blast-radius paths: wrong parsing or key edits corrupt stored secrets; broken token encoding breaks CI/API links that pass object keys in query strings. The tests lock in current behavior so refactors or parser tweaks surface immediately without needing the full app or S3.
Validation
npm run test(full Vitest suite) — all tests pass; deterministic, no network or DB.