test: add regression coverage for dotenv parse/append/remove#11
Draft
cursor[bot] wants to merge 1 commit intomainfrom
Draft
test: add regression coverage for dotenv parse/append/remove#11cursor[bot] wants to merge 1 commit intomainfrom
cursor[bot] wants to merge 1 commit intomainfrom
Conversation
Covers parsing edge cases (CRLF, quotes, invalid lines), key removal preserving comments, append validation messages, and quoted formatting used by the vault dotenv workspace and secrets APIs.
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 Vitest coverage for
src/lib/dotenv-parse.ts, which backs dotenv handling in the vault file workspace andsecretstRPC routes.Risky behavior now covered
#comments, CRLF, quoted values, and lines without a validKEY=valueshape (prevents silent mis-parse of stored secrets).removeDotenvKey: removes assignment lines for a key while preserving comments.appendDotenvKey: validation for empty keys,=and#in keys, newlines in key/value, duplicate keys (aligned withparseDotenv), trailing-whitespace normalization before append, safe vs quoted formatting, and escaping of embedded"in generated lines.Test files added/updated
src/lib/dotenv-parse.test.tsWhy this reduces regression risk
These helpers are shared across UI and API paths for
.envcontent. Failures here corrupt stored secrets, leak wrong values, or block legitimate edits. The tests lock in the intended parse/serialize rules and error messages without coupling to React or the database.Validation
npm run test(all Vitest files) — pass (30 tests). Tests are pure string logic, deterministic, no network or env dependencies.