Skip to content

test: add comprehensive Vitest suites for CSV import, allowlist, and core plugins - #305

Open
Vallejo1921 wants to merge 1 commit into
outerbase:mainfrom
Vallejo1921:test/expand-vitest-coverage-71
Open

Vallejo1921 wants to merge 1 commit into
outerbase:mainfrom
Vallejo1921:test/expand-vitest-coverage-71

Conversation

@Vallejo1921

Copy link
Copy Markdown

Resolves #71

/claim #71

Summary of Changes

Adds 5 new, focused, and non-overlapping Vitest test suites (32 new tests) bringing test coverage to core modules and plugins that previously had zero tests:

  1. ** (9 tests)**:

    • Empty body validation (400)
    • Unsupported Content-Type rejection (400)
    • Missing file in multipart form-data (400)
    • Raw text/csv payload parsing and SQL insertion
    • JSON-wrapped CSV data with custom columnMapping
    • Multipart form-data CSV file upload parsing
    • Invalid CSV / empty rows error handling (400)
    • Partial insert failure reporting with failedStatements
    • Unhandled exception / 500 error boundary
  2. ** (7 tests)**:

    • Feature disabled pass-through
    • Admin role bypass
    • Empty SQL guard check
    • Allowed AST query matching
    • Disallowed query rejection and audit record insertion into tmp_allowlist_rejections
    • Trailing semicolon normalization equivalence
    • Resilient fallback on allowlist query loading errors
  3. ** (4 tests)**:

    • Plugin initialization with API key
    • Successful email dispatch via Resend API
    • Non-ok API response error propagation
    • Default error message fallback
  4. ** (7 tests)**:

    • Cron expression parsing and next execution time calculation
    • Plugin initialization and authentication requirements
    • Missing data source guard on addEvent
    • Route and middleware registration
    • Event callback invocation on /cron/callback
    • Execution context waitUntil handling for async callbacks
  5. ** (5 tests)**:

    • Missing stripeSecretKey validation guard
    • Plugin initialization with correct non-auth webhook configuration
    • Route registration (/stripe/subscribe, /stripe/unsubscribe)
    • Subscribe required fields validation
    • Unsubscribe required fields validation

Verification

All 32 new tests run and pass cleanly:

pnpm vitest run src/import/csv.test.ts src/allowlist/index.test.ts plugins/resend/index.test.ts plugins/cron/index.test.ts plugins/stripe/index.test.ts
  • Result: 5 test files passed, 32 tests passed (100% pass rate).
  • Code style: Verified and formatted with Prettier (npx prettier --check).

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.

Improve test coverage with Vitest

1 participant