Skip to content

test: add regression coverage for dotenv parse/append/remove#11

Draft
cursor[bot] wants to merge 1 commit intomainfrom
cursor/regression-test-coverage-b0fe
Draft

test: add regression coverage for dotenv parse/append/remove#11
cursor[bot] wants to merge 1 commit intomainfrom
cursor/regression-test-coverage-b0fe

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor bot commented Apr 7, 2026

Summary

Adds Vitest coverage for src/lib/dotenv-parse.ts, which backs dotenv handling in the vault file workspace and secrets tRPC routes.

Risky behavior now covered

  • Parsing: blank lines, # comments, CRLF, quoted values, and lines without a valid KEY=value shape (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 with parseDotenv), trailing-whitespace normalization before append, safe vs quoted formatting, and escaping of embedded " in generated lines.

Test files added/updated

  • Added: src/lib/dotenv-parse.test.ts

Why this reduces regression risk

These helpers are shared across UI and API paths for .env content. 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.
Open in Web View Automation 

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