Skip to content

feat: churn-analysis golden fixtures and deterministic tests - #992

Merged
orunganiekan merged 3 commits into
SiLioLabs:masterfrom
iexwr:feat/886-churn-golden-fixtures
Aug 31, 2026
Merged

feat: churn-analysis golden fixtures and deterministic tests#992
orunganiekan merged 3 commits into
SiLioLabs:masterfrom
iexwr:feat/886-churn-golden-fixtures

Conversation

@iexwr

@iexwr iexwr commented Aug 31, 2026

Copy link
Copy Markdown

Summary

Closes #886 — expand the churn-analysis script test suite with checked-in golden fixtures and a fixture-driven runner, so analytics metrics can no longer regress silently.

Changes

  • scripts/data/churn-analysis-fixtures.json (new): 7 golden fixtures covering:
    • Cohort retention under both new and retention resubscription logic (80%+ of the metric surface).
    • Merchant-level churn breakdown with single-subscriber merchant filtering.
    • Multi-completed-cohort churn projection (average churn + projected count).
    • Grace-period cancelled_with_refund treated identically to cancelled.
    • Empty event list and single-event edge cases.
    • Single-subscriber merchant exclusion to avoid statistical skew.
  • scripts/test-churn-analysis.ts (rewritten): loads fixtures from data/, asserts cohort metrics, merchant breakdown, and projection per fixture per logic; keeps the existing report-structure and SQLite/RPC fallback coverage; exits non-zero on any assertion failure.
  • scripts/package.json: adds npm testtsx test-churn-analysis.ts.

Validation

cd scripts && npm install && npm test   # all assertions PASS, exit 0

Acceptance Criteria

  • Tests cover core metrics (cohort retention 30d/90d, merchant churn, projection)
  • Fixtures checked in under scripts/data/ with documented descriptions
  • Non-zero exit on assertion failure (process.exit(1))

…iLioLabs#886)

Expand churn-analysis coverage with checked-in golden fixtures under
scripts/data/churn-analysis-fixtures.json and a fixture-driven test runner
in test-churn-analysis.ts:

- 7 fixtures covering cohort retention (new/retention resubscription logic),
  merchant churn breakdown with single-subscriber filtering, multi-cohort
  churn projection, grace-period cancelled-with-refund handling, empty/single
  event edge cases, and single-subscriber merchant exclusion.
- Non-zero exit on any assertion failure; add npm test script mapping to
  npx tsx test-churn-analysis.ts.
- Preserve existing SQLite/RPC fallback and report-structure coverage.

Tests: npm test (scripts) passes.
@iexwr
iexwr force-pushed the feat/886-churn-golden-fixtures branch from dc02493 to 6e47bef Compare August 31, 2026 04:28
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@iexwr 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

@iexwr

iexwr commented Aug 31, 2026

Copy link
Copy Markdown
Author

Rebased onto the latest master (which had advanced with #980/#986, touching scripts/package.json). Resolved the conflict by keeping both the new test:event-dedup/test:renewal-forecast scripts and the test (churn-analysis) script, and fixed a missing comma the merge had left in package.json (valid JSON verified). npm test passes.

Note: npm run typecheck currently fails on upstream master itself (errors in pre-upgrade-check.ts, rotate-fee-collector.ts, etc. from the recently merged PRs) — this is pre-existing and unrelated to this PR; test-churn-analysis.ts is typecheck-clean.

@orunganiekan
orunganiekan merged commit 0856198 into SiLioLabs:master Aug 31, 2026
0 of 3 checks passed
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.

Issue 091: Add churn-analysis deterministic tests and golden fixtures

3 participants