Skip to content

Fix: Test webhookHistoryToCSV - #1020

Merged
Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
popsman01:simple/932
Oct 17, 2026
Merged

Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
popsman01:simple/932

Conversation

@popsman01

Copy link
Copy Markdown
Contributor

Closes #932

Issues

#932 Test webhookHistoryToCSV

Description

Exporting webhook delivery history to CSV currently has no test coverage (0 calls in the Vitest coverage report).

Location

lib/export.ts (webhookHistoryToCSV, ~line 108)

Task

Add tests under __tests__/ (Vitest + Testing Library; only __tests__/** is collected). Cover at least:

  • header row
  • one row per delivery
  • values containing commas/quotes are escaped

Acceptance criteria

  • Tests live under __tests__/ and pass with npm test
  • Listed cases are covered
  • No production code changes needed (unless a bug is found — then note it in the PR)

Good for contributors because

Self-contained test task with clear inputs/outputs; a great way to learn the codebase.

Summary

Reuse the existing escapeCSV behavior for assertions: fields containing ,, ", \n, or \r are wrapped in double quotes and embedded quotes are doubled. Use fixed timestamps (e.g. 1_700_000_000_000 ms) so new Date(deliveredAt).toISOString() is deterministic. Keep the new tests in the existing __tests__/lib/export.test.ts to avoid a new file. The lib/export.ts step is a conditional no-op unless a bug is uncovered.

Changes

  • Add a describe('webhookHistoryToCSV', ...) block to the existing test file. Import webhookHistoryToCSV from @/lib/export alongside streamsToCSV. Create a small fixture helper that builds delivery objects of shape { webhookId, eventType, statusCode, deliveredAt, success }. Add tests asserting: (1) the first line equals the expected header row Webhook ID,Event Type,Status Code,Delivered At,Success; (2) the number of lines equals history.length + 1 (one row per delivery) and that each row contains the delivery's webhookId/eventType/status; (3) a statusCode of null renders as an empty field; (4) success renders as true/false; (5) values containing commas (e.g. webhookId id,with,commas) are wrapped in double quotes, and values containing double quotes (e.g. he said "hi") are escaped by doubling the quotes and wrapping the field in quotes. Run npm test to confirm the new tests pass and the coverage report shows webhookHistoryToCSV is exercised. (tests/lib/export.test.ts)
  • Only touch this file if the new tests reveal a bug in webhookHistoryToCSV (e.g. incorrect escaping, wrong header, or wrong row count). The current implementation already uses the shared escapeCSV/row helpers, so no change is expected; if a defect is found, apply the minimal fix and document it in the PR description. Do not modify this file otherwise. (lib/export.ts)

Co-authored-by: Simple Agent <agent@simple.dev>
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@popsman01 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Austinaminu2
Austinaminu2 merged commit a570186 into FlowwStar:main Oct 17, 2026
@grantfox-oss grantfox-oss Bot mentioned this pull request Oct 17, 2026
3 tasks
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.

Test webhookHistoryToCSV

2 participants