Skip to content

test(integration): config-aware billing equivalences + plan id (closes #3609)#3610

Merged
PierreBrisorgueil merged 3 commits into
masterfrom
fix/billing-tests-config-aware
May 6, 2026
Merged

test(integration): config-aware billing equivalences + plan id (closes #3609)#3610
PierreBrisorgueil merged 3 commits into
masterfrom
fix/billing-tests-config-aware

Conversation

@PierreBrisorgueil
Copy link
Copy Markdown
Contributor

@PierreBrisorgueil PierreBrisorgueil commented May 6, 2026

Summary

  • auth.integration line 1545 — replaces expect(...equivalences).toBeNull() with toEqual(config.billing?.equivalences ?? null) so downstreams that define equivalences (e.g. trawl /pricing) no longer fail.
  • billing.lifecycle.integration first test — derives the initial/upgrade plan ids from config.billing.plans (with legacy 'starter'/'pro' fallback for upstream defaults) instead of hardcoding 'starter'. The Subscription/Organization schema enum is locked at import time, so trawl's ['free','growth','pro'] enum was rejecting the literal 'starter'.

Why

The integration job split (commit efbd7bcb) made these two failures visible to downstreams. trawl_node currently carries a DOWNSTREAM_PATCHES.md override (PR comes-io/trawl_node#1128), which it can drop once this lands.

Refs feedback_update_stack_theirs_wipes_patches.md — second instance of the same pattern, durable fix is upstream.

Test plan

  • npm run test:integration — 24 suites / 335 tests pass on upstream defaults (no planDefinitions, no equivalences)
  • ESLint clean on both touched files
  • CI green
  • CodeRabbit clean
  • After merge: /update-stack propagation to trawl_node revert the DOWNSTREAM_PATCHES.md override

Closes #3609

Summary by CodeRabbit

Release Notes

  • Tests
    • Updated authentication config test to properly reflect configured billing equivalence values.
    • Enhanced billing lifecycle tests to support dynamic plan configurations and plan upgrade scenarios via configuration instead of hard-coded values.

…ions (#3609)

- auth.integration: assert billing.equivalences against config.billing.equivalences
  (was hardcoded to null — broke any downstream that defines equivalences for /pricing)
- billing.lifecycle.integration: derive plan ids from config.billing.plans for the
  starter→pro transition test (was hardcoded 'starter' — broke any downstream whose
  plan enum excludes starter, e.g. trawl with free/growth/pro)

Tests still cover the upstream defaults (no planDefinitions → fallback to legacy
'starter'/'pro'; no equivalences → null) but no longer assume those values.

Refs #3609.
Copilot AI review requested due to automatic review settings May 6, 2026 08:40
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Warning

Rate limit exceeded

@PierreBrisorgueil has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 53 minutes and 28 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: fd32c4e6-df2c-4f20-bd81-748b6a06d43f

📥 Commits

Reviewing files that changed from the base of the PR and between b7d20ed and 306ccd6.

📒 Files selected for processing (1)
  • modules/billing/tests/billing.lifecycle.integration.tests.js

Walkthrough

Two integration tests are updated to use dynamic values from billing config instead of hard-coded expectations. Auth test assertion for billing.equivalences now reflects configured value; billing lifecycle test uses dynamic plan IDs and versions from config to test plan upgrades via webhook.

Changes

Config-Aware Integration Tests

Layer / File(s) Summary
Auth Assertion
modules/auth/tests/auth.integration.tests.js
Test expectation for billing.equivalences changes from hardcoded null to config.billing?.equivalences ?? null, making assertion config-aware.
Billing Test Setup & Plan Upgrade Flow
modules/billing/tests/billing.lifecycle.integration.tests.js
New test "plan.changed webhook updates active week quota snapshot mid-week" derives initialPlan/upgradePlan from config.billing.plans and initialVersion/upgradeVersion as derived plan versions. Seeds dynamic planDefinitions on config. Creates Organization and Subscription with initialPlan, seeds BillingUsage with initialVersion. Invokes handleSubscriptionUpdated with payload showing upgrade from initialPlan to upgradePlan, then asserts meterQuota and planVersion update to upgraded values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

  • pierreb-devkit/Node#3582 — Both modify billing lifecycle integration tests and plan-change handling via handleSubscriptionUpdated with dynamic plan definitions.
  • pierreb-devkit/Node#3562 — Both drive plan configuration from config.billing.planDefinitions and derived config.billing.plans at boot.
  • pierreb-devkit/Node#3555 — Both introduce/use planDefinitions seeding via config and plan lifecycle management in tests.

Suggested labels

test

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly and specifically describes the main changes: config-aware billing assertions and plan ID flexibility, with reference to the closed issue.
Description check ✅ Passed Description covers required sections: what changed, why, test plan status, and linked issue. All critical information is present though some optional validation checkboxes remain unchecked.
Linked Issues check ✅ Passed Changes fully address #3609: billing.equivalences now respects config values instead of asserting null, and plan IDs are derived from config.billing.plans with legacy fallbacks.
Out of Scope Changes check ✅ Passed All changes are scoped to two integration test files and directly address the config-awareness objectives outlined in #3609; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/billing-tests-config-aware

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 6, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown

@codacy-production codacy-production Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR successfully transitions the integration test suite from hardcoded billing plans to configuration-driven values, ensuring compatibility across different environments. Codacy results indicate the changes are up to standards with no new issues reported. However, a logic flaw was identified in billing.lifecycle.integration.tests.js where the absence of billing configuration could cause a TypeError, contradicting the safer implementation found in auth.integration.tests.js.

About this PR

  • There is a systemic inconsistency in how config.billing is accessed. While auth.integration.tests.js uses defensive checks, billing.lifecycle.integration.tests.js accesses the object directly. Standardizing on the defensive pattern used in the auth tests will prevent environment-specific test failures.

Test suggestions

  • Verify auth integration response matches configured billing equivalences
  • Verify billing lifecycle test correctly handles dynamic plan IDs from config
  • Verify BillingUsage planVersion is updated correctly upon plan upgrade

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

Comment thread modules/billing/tests/billing.lifecycle.integration.tests.js Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts integration tests to be config-aware so downstream projects with customized billing configuration (e.g., custom billing.equivalences and non-starter plan enums) don’t fail during test:integration.

Changes:

  • Update auth config integration assertion to match config.billing.equivalences (defaulting to null).
  • Update billing lifecycle integration test to select plan ids from config.billing.plans rather than hardcoding 'starter'.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
modules/billing/tests/billing.lifecycle.integration.tests.js Derives initial/upgrade plan ids from config to avoid hardcoded upstream-only plan values.
modules/auth/tests/auth.integration.tests.js Makes billing.equivalences assertion reflect the current config instead of assuming null.

Comment thread modules/billing/tests/billing.lifecycle.integration.tests.js
Comment thread modules/billing/tests/billing.lifecycle.integration.tests.js Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.57%. Comparing base (5b5490b) to head (306ccd6).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3610   +/-   ##
=======================================
  Coverage   87.57%   87.57%           
=======================================
  Files         132      132           
  Lines        4049     4049           
  Branches     1260     1260           
=======================================
  Hits         3546     3546           
  Misses        390      390           
  Partials      113      113           
Flag Coverage Δ
integration 61.69% <ø> (ø)
unit 61.24% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dfee01a...306ccd6. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@PierreBrisorgueil PierreBrisorgueil merged commit 07517bc into master May 6, 2026
8 checks passed
@PierreBrisorgueil PierreBrisorgueil deleted the fix/billing-tests-config-aware branch May 6, 2026 09:13
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(integration): config-aware assertions for billing.equivalences + plan id

2 participants