Skip to content

fix(billing): lease flow test#1890

Merged
baktun14 merged 2 commits intomainfrom
fix/lease-flow-test
Sep 4, 2025
Merged

fix(billing): lease flow test#1890
baktun14 merged 2 commits intomainfrom
fix/lease-flow-test

Conversation

@baktun14
Copy link
Contributor

@baktun14 baktun14 commented Sep 4, 2025

Summary by CodeRabbit

  • Documentation

    • Updated API documentation base URL to use the origin only (version path removed) while keeping docs version as v1. This aligns server listings and may improve client generation and tooling compatibility.
  • Chores

    • Added a script to start a mock OAuth2 server to streamline testing workflows.
  • Tests

    • Adjusted functional tests to clear balances via the updated balance service, improving test reliability around balance checks.

@baktun14 baktun14 requested a review from a team as a code owner September 4, 2025 12:22
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

Walkthrough

Adds a new npm script to start a mock OAuth2 server, updates OpenAPI docs to use the origin-only server URL (no version in path), and updates functional tests to clear cache keys for BalancesService#getFullBalance instead of WalletController#getBalances.

Changes

Cohort / File(s) Summary
Build/Test Scripts
apps/api/package.json
Adds script test:oauth2-serverdc up:dev -d mock-oauth2-server.
OpenAPI Docs Generation
apps/api/src/core/services/openapi-docs/openapi-docs.service.ts
Changes servers entry from ${env.SERVER_ORIGIN}/${version} to env.SERVER_ORIGIN. No other logic changes.
Functional Tests
apps/api/test/functional/lease-flow.spec.ts
Replaces cache clear targets from WalletController#getBalances to BalancesService#getFullBalance in three places.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • stalniy
  • ygrishajev

Poem

In the burrow of builds, I twitch my nose,
A mock server hums where the pipeline goes.
Docs hop to origins, paths trimmed slight,
Caches cleared for balances right.
With thumps of joy on fertile ground—
The tests all pass; what a happy sound! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/lease-flow-test

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
apps/api/package.json (1)

34-34: Add a matching teardown convenience script for the mock OAuth2 server.

This helps avoid leaving containers running locally and mirrors the existing CI setup.

You could add:

   "test:functional:watch": "npm run test:functional -- --watch",
-  "test:oauth2-server": "dc up:dev -d mock-oauth2-server",
+  "test:oauth2-server": "dc up:dev -d mock-oauth2-server",
+  "test:oauth2-server:down": "dc down",
   "test:unit": "jest --selectProjects unit",

Confirm that the dc alias exists in local dev environments (it’s already used elsewhere) and that mock-oauth2-server matches the Compose service name.

apps/api/test/functional/lease-flow.spec.ts (1)

159-159: Use explicit prefix clearing for getFullBalance cache
clearCache("BalancesService#getFullBalance") only clears the exact key (which includes the address suffix), so it’s a no-op on cold cache. Change all three calls in lease-flow.spec.ts (lines 159, 218, 262) to:

- clearCache("BalancesService#getFullBalance");
+ clearCache("BalancesService#getFullBalance*");
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 68c3c67 and 3de657f.

⛔ Files ignored due to path filters (1)
  • apps/api/test/functional/__snapshots__/docs.spec.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • apps/api/package.json (1 hunks)
  • apps/api/src/core/services/openapi-docs/openapi-docs.service.ts (1 hunks)
  • apps/api/test/functional/lease-flow.spec.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Never use type any or cast to type any. Always define the proper TypeScript types.

Files:

  • apps/api/src/core/services/openapi-docs/openapi-docs.service.ts
  • apps/api/test/functional/lease-flow.spec.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code

Files:

  • apps/api/src/core/services/openapi-docs/openapi-docs.service.ts
  • apps/api/test/functional/lease-flow.spec.ts
**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/no-jest-mock.mdc)

Don't use jest.mock() to mock dependencies in test files. Instead, use jest-mock-extended to create mocks and pass mocks as dependencies to the service under test.

**/*.spec.{ts,tsx}: Use setup function instead of beforeEach in test files
setup function must be at the bottom of the root describe block in test files
setup function creates an object under test and returns it
setup function should accept a single parameter with inline type definition
Don't use shared state in setup function
Don't specify return type of setup function

Files:

  • apps/api/test/functional/lease-flow.spec.ts
🧬 Code graph analysis (1)
apps/api/test/functional/lease-flow.spec.ts (1)
apps/api/test/setup-functional-tests.ts (1)
  • clearCache (13-31)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
🔇 Additional comments (1)
apps/api/src/core/services/openapi-docs/openapi-docs.service.ts (1)

13-13: Confirmed: all OpenAPI handler paths include /v1, so omitting /v1 from servers.url is safe.

@codecov
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.09%. Comparing base (68c3c67) to head (3de657f).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1890      +/-   ##
==========================================
- Coverage   44.40%   44.09%   -0.32%     
==========================================
  Files         970      963       -7     
  Lines       27293    27000     -293     
  Branches     7041     7017      -24     
==========================================
- Hits        12119    11905     -214     
+ Misses      13985    13915      -70     
+ Partials     1189     1180       -9     
Flag Coverage Δ *Carryforward flag
api 81.26% <ø> (+0.04%) ⬆️
deploy-web 22.65% <ø> (ø) Carriedforward from 68c3c67
log-collector ?
notifications 87.92% <ø> (ø) Carriedforward from 68c3c67
provider-console 81.48% <ø> (ø) Carriedforward from 68c3c67
provider-proxy 84.47% <ø> (ø) Carriedforward from 68c3c67

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...core/services/openapi-docs/openapi-docs.service.ts 85.71% <ø> (ø)

... and 27 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@baktun14 baktun14 merged commit 3343c6a into main Sep 4, 2025
62 checks passed
@baktun14 baktun14 deleted the fix/lease-flow-test branch September 4, 2025 12:51
stalniy pushed a commit that referenced this pull request Nov 20, 2025
* fix(config): remove duplicate version from swagger docs

* fix(config): lease flow test + swagger docs
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.

2 participants

Comments