Add Integration and unit tests on Billing (#9317)

Solves [ https://github.com/twentyhq/private-issues/issues/214 ]

**TLDR**
Add unit and integration tests to Billing. First approach to run jest
integration tests directly from VSCode.

**In order to run the unit tests:**
Run unit test using the CLI or with the jest extension directly from
VSCode.

**In order to run the integration tests:**
Ensure that your database has the billingTables. If that's not the case,
migrate the database with IS_BILLING_ENABLED set to true:
` npx nx run twenty-server:test:integration
test/integration/billing/suites/billing-controller.integration-spec.ts`

**Doing:**
- Unit test on transformSubscriptionEventToSubscriptionItem
- More tests cases in billingController integration tests.

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
Co-authored-by: Weiko <corentin@twenty.com>
Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
This commit is contained in:
Ana Sofia Marin Alexandre
2025-01-09 14:30:41 -03:00
committed by GitHub
parent 4ed1db3845
commit c39af5f063
49 changed files with 2157 additions and 335 deletions

View File

@ -184,6 +184,15 @@ jobs:
- name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/yarn-install
- name: Update .env.test for billing
if: steps.changed-files.outputs.any_changed == 'true'
run: |
sed -i '$ a\
IS_BILLING_ENABLED=true\
BILLING_STRIPE_API_KEY=test-api-key\
BILLING_STRIPE_BASE_PLAN_PRODUCT_ID=test-base-plan-product-id\
BILLING_STRIPE_WEBHOOK_SECRET=test-webhook-secret' .env.test
- name: Server / Restore Task Cache
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/task-cache