Skip to content

refactor: finalizes strict types migration for console-api#1745

Merged
stalniy merged 1 commit intomainfrom
refactor/final-strict-api
Jul 28, 2025
Merged

refactor: finalizes strict types migration for console-api#1745
stalniy merged 1 commit intomainfrom
refactor/final-strict-api

Conversation

@stalniy
Copy link
Contributor

@stalniy stalniy commented Jul 28, 2025

Summary by CodeRabbit

  • Chores
    • Updated TypeScript configuration to enable strict type-checking for improved code quality.
    • Removed an unused strict type-checking configuration file.
    • Cleaned up package scripts and removed redundant script entries.
    • Adjusted error logging for clearer output in the console.
    • Updated lint-staged configuration to stop running strict type validation on API TypeScript files.
    • Improved test robustness by adding safety checks and optional chaining to prevent runtime errors.
    • Made lease closing date optional in test data to reflect real-world scenarios.

@stalniy stalniy requested a review from a team as a code owner July 28, 2025 09:48
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 28, 2025

Walkthrough

This change removes the strict type-checking validation script and its related lint-staged configuration for the apps/api project. The TypeScript build configuration is updated to enable strict mode by default and the redundant strict config file is deleted. Type annotations are improved in the application entry point, error logging is adjusted in the CLI handler, and multiple test files are updated with safer optional chaining. A generic parameter is added to a test service class, and a lease interface property is made optional.

Changes

Cohort / File(s) Change Summary
Script & Lint Configuration Cleanup
apps/api/package.json, package.json
Removes the validate:types-strict script and its lint-staged usage for API TypeScript files; deletes trailing comma.
TypeScript Strictness Configuration
apps/api/tsconfig.build.json, apps/api/tsconfig.strict.json
Enables "strict": true in the main build config and deletes the redundant strict config file.
Type Annotation Improvement
apps/api/src/app.ts
Adds explicit AppEnv type parameter to the Hono app instance and imports the type.
Error Logging Update
apps/api/src/console.ts
Changes error logging to output the whole error object instead of just message and stack.
Test Code Safety Enhancements
apps/api/test/functional/api-key.spec.ts, apps/api/test/functional/bids.spec.ts, apps/api/test/functional/blocks.spec.ts, apps/api/test/functional/dashboard-data.spec.ts, apps/api/test/functional/gpu.spec.ts, apps/api/test/functional/provider-regions.spec.ts, apps/api/test/functional/start-trial.spec.ts, apps/api/test/functional/stripe-webhook.spec.ts, apps/api/test/functional/templates.spec.ts, apps/api/test/functional/user-init.spec.ts, apps/api/test/functional/wallets-refill.spec.ts
Adds optional chaining and nullish coalescing to prevent runtime errors in test assertions and mocks; improves error handling and environment variable checks in tests.
Interface Update
apps/api/test/seeders/lease-api-response.seeder.ts
Makes the closed_on property optional in the LeaseOutput interface.
Generic Class Parameterization
apps/api/test/services/wallet-testing.service.ts
Updates WalletTestingService class to be generic over T extends Hono<any> and adjusts constructor accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI Handler
    participant Logger

    User->>CLI Handler: Execute command
    CLI Handler->>CLI Handler: Try to run handler
    alt Error occurs
        CLI Handler->>Logger: Log error object
        CLI Handler->>CLI Handler: Set process exit code to 1
    end
    CLI Handler->>CLI Handler: Perform finally block
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Suggested reviewers

  • baktun14

Poem

Oh, what a tidy change has come,
Strictness now by default, not some!
No more scripts to check the types,
The configs trimmed of extra stripes.
Errors logged in fuller light—
This bunny hops with code delight! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/final-strict-api

🪧 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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

Documentation and Community

  • 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.

baktun14
baktun14 previously approved these changes Jul 28, 2025
@stalniy stalniy force-pushed the refactor/final-strict-api branch from 3f10ce8 to 14c81fa Compare July 28, 2025 16:50
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 (1)
apps/api/test/functional/user-init.spec.ts (1)

45-62: Consider migrating to setup function pattern.

This test file uses beforeEach instead of the recommended setup function pattern specified in the coding guidelines. Consider refactoring to use a setup function at the bottom of the root describe block.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11d666f and 14c81fa.

📒 Files selected for processing (19)
  • apps/api/package.json (1 hunks)
  • apps/api/src/app.ts (2 hunks)
  • apps/api/src/console.ts (1 hunks)
  • apps/api/test/functional/api-key.spec.ts (1 hunks)
  • apps/api/test/functional/bids.spec.ts (1 hunks)
  • apps/api/test/functional/blocks.spec.ts (4 hunks)
  • apps/api/test/functional/dashboard-data.spec.ts (2 hunks)
  • apps/api/test/functional/gpu.spec.ts (3 hunks)
  • apps/api/test/functional/provider-regions.spec.ts (1 hunks)
  • apps/api/test/functional/start-trial.spec.ts (1 hunks)
  • apps/api/test/functional/stripe-webhook.spec.ts (2 hunks)
  • apps/api/test/functional/templates.spec.ts (1 hunks)
  • apps/api/test/functional/user-init.spec.ts (1 hunks)
  • apps/api/test/functional/wallets-refill.spec.ts (2 hunks)
  • apps/api/test/seeders/lease-api-response.seeder.ts (1 hunks)
  • apps/api/test/services/wallet-testing.service.ts (1 hunks)
  • apps/api/tsconfig.build.json (1 hunks)
  • apps/api/tsconfig.strict.json (0 hunks)
  • package.json (0 hunks)
💤 Files with no reviewable changes (2)
  • package.json
  • apps/api/tsconfig.strict.json
✅ Files skipped from review due to trivial changes (3)
  • apps/api/test/seeders/lease-api-response.seeder.ts
  • apps/api/src/app.ts
  • apps/api/test/services/wallet-testing.service.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/api/tsconfig.build.json
  • apps/api/src/console.ts
  • apps/api/package.json
🧰 Additional context used
📓 Path-based instructions (3)
**/*.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/start-trial.spec.ts
  • apps/api/test/functional/templates.spec.ts
  • apps/api/test/functional/provider-regions.spec.ts
  • apps/api/test/functional/api-key.spec.ts
  • apps/api/test/functional/bids.spec.ts
  • apps/api/test/functional/dashboard-data.spec.ts
  • apps/api/test/functional/stripe-webhook.spec.ts
  • apps/api/test/functional/user-init.spec.ts
  • apps/api/test/functional/wallets-refill.spec.ts
  • apps/api/test/functional/gpu.spec.ts
  • apps/api/test/functional/blocks.spec.ts
**/*.{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/test/functional/start-trial.spec.ts
  • apps/api/test/functional/templates.spec.ts
  • apps/api/test/functional/provider-regions.spec.ts
  • apps/api/test/functional/api-key.spec.ts
  • apps/api/test/functional/bids.spec.ts
  • apps/api/test/functional/dashboard-data.spec.ts
  • apps/api/test/functional/stripe-webhook.spec.ts
  • apps/api/test/functional/user-init.spec.ts
  • apps/api/test/functional/wallets-refill.spec.ts
  • apps/api/test/functional/gpu.spec.ts
  • apps/api/test/functional/blocks.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/test/functional/start-trial.spec.ts
  • apps/api/test/functional/templates.spec.ts
  • apps/api/test/functional/provider-regions.spec.ts
  • apps/api/test/functional/api-key.spec.ts
  • apps/api/test/functional/bids.spec.ts
  • apps/api/test/functional/dashboard-data.spec.ts
  • apps/api/test/functional/stripe-webhook.spec.ts
  • apps/api/test/functional/user-init.spec.ts
  • apps/api/test/functional/wallets-refill.spec.ts
  • apps/api/test/functional/gpu.spec.ts
  • apps/api/test/functional/blocks.spec.ts
🧠 Learnings (11)
📓 Common learnings
Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/general.mdc:0-0
Timestamp: 2025-07-27T12:16:08.566Z
Learning: Applies to **/*.{js,ts,tsx} : Never use deprecated methods from libraries.
Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/general.mdc:0-0
Timestamp: 2025-07-27T12:16:08.566Z
Learning: Applies to **/*.{ts,tsx} : Never use type any or cast to type any. Always define the proper TypeScript types.
Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use `queryBy` methods instead of `getBy` methods in test expectations in `.spec.tsx` files
Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function should accept a single parameter with inline type definition
Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't specify return type of `setup` function
Learnt from: stalniy
PR: akash-network/console#1362
File: apps/api/src/core/services/open-api-hono-handler/open-api-hono-handler.ts:21-21
Timestamp: 2025-05-24T04:26:25.511Z
Learning: In TypeScript strict mode, double casts like `c as unknown as AppContext` may be necessary even when types are structurally compatible, as strict mode enforces more restrictive type compatibility rules than regular mode.
Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/general.mdc:0-0
Timestamp: 2025-07-27T12:16:08.566Z
Learning: Applies to **/*.{js,ts,tsx} : Don't add unnecessary comments to the code
Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-07-21T08:24:24.269Z
Learning: Applies to **/*.spec.{ts,tsx} : 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.
Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Use `setup` function instead of `beforeEach` in test files
apps/api/test/functional/templates.spec.ts (9)

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Use setup function instead of beforeEach in test files

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : setup function should accept a single parameter with inline type definition

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't specify return type of setup function

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : setup function must be at the bottom of the root describe block in test files

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use shared state in setup function

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-07-21T08:24:24.269Z
Learning: Applies to **/*.spec.{ts,tsx} : 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.

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : setup function creates an object under test and returns it

Learnt from: stalniy
PR: #1660
File: apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx:54-56
Timestamp: 2025-07-11T10:46:43.711Z
Learning: In apps/{deploy-web,provider-console}/**/*.spec.tsx files: Use getBy methods instead of queryBy methods when testing element presence with toBeInTheDocument() because getBy throws an error and shows DOM state when element is not found, providing better debugging information than queryBy which returns null.

apps/api/test/functional/provider-regions.spec.ts (8)

Learnt from: stalniy
PR: #1436
File: apps/api/src/provider/repositories/provider/provider.repository.ts:79-90
Timestamp: 2025-06-08T03:07:13.871Z
Learning: The getProvidersHostUriByAttributes method in apps/api/src/provider/repositories/provider/provider.repository.ts already has comprehensive test coverage in provider.repository.spec.ts, including tests for complex HAVING clause logic with COUNT(*) FILTER (WHERE ...) syntax, signature conditions (anyOf/allOf), and glob pattern matching.

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-07-21T08:24:24.269Z
Learning: Applies to **/*.spec.{ts,tsx} : 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.

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Use setup function instead of beforeEach in test files

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use shared state in setup function

Learnt from: stalniy
PR: #1660
File: apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx:54-56
Timestamp: 2025-07-11T10:46:43.711Z
Learning: In apps/{deploy-web,provider-console}/**/*.spec.tsx files: Use getBy methods instead of queryBy methods when testing element presence with toBeInTheDocument() because getBy throws an error and shows DOM state when element is not found, providing better debugging information than queryBy which returns null.

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't specify return type of setup function

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : setup function should accept a single parameter with inline type definition

apps/api/test/functional/api-key.spec.ts (3)

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-07-21T08:24:24.269Z
Learning: Applies to **/*.spec.{ts,tsx} : 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.

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Use setup function instead of beforeEach in test files

apps/api/test/functional/bids.spec.ts (2)

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-07-21T08:24:24.269Z
Learning: Applies to **/*.spec.{ts,tsx} : 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.

apps/api/test/functional/dashboard-data.spec.ts (1)

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

apps/api/test/functional/stripe-webhook.spec.ts (6)

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Use setup function instead of beforeEach in test files

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : setup function should accept a single parameter with inline type definition

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use shared state in setup function

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't specify return type of setup function

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-07-21T08:24:24.269Z
Learning: Applies to **/*.spec.{ts,tsx} : 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.

apps/api/test/functional/user-init.spec.ts (1)

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

apps/api/test/functional/wallets-refill.spec.ts (3)

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

Learnt from: stalniy
PR: #1660
File: apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx:54-56
Timestamp: 2025-07-11T10:46:43.711Z
Learning: In apps/{deploy-web,provider-console}/**/*.spec.tsx files: Use getBy methods instead of queryBy methods when testing element presence with toBeInTheDocument() because getBy throws an error and shows DOM state when element is not found, providing better debugging information than queryBy which returns null.

Learnt from: stalniy
PR: #1436
File: apps/api/src/provider/repositories/provider/provider.repository.ts:79-90
Timestamp: 2025-06-08T03:07:13.871Z
Learning: The getProvidersHostUriByAttributes method in apps/api/src/provider/repositories/provider/provider.repository.ts already has comprehensive test coverage in provider.repository.spec.ts, including tests for complex HAVING clause logic with COUNT(*) FILTER (WHERE ...) syntax, signature conditions (anyOf/allOf), and glob pattern matching.

apps/api/test/functional/gpu.spec.ts (3)

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

Learnt from: stalniy
PR: #1436
File: apps/api/src/provider/repositories/provider/provider.repository.ts:79-90
Timestamp: 2025-06-08T03:07:13.871Z
Learning: The getProvidersHostUriByAttributes method in apps/api/src/provider/repositories/provider/provider.repository.ts already has comprehensive test coverage in provider.repository.spec.ts, including tests for complex HAVING clause logic with COUNT(*) FILTER (WHERE ...) syntax, signature conditions (anyOf/allOf), and glob pattern matching.

Learnt from: stalniy
PR: #1660
File: apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx:54-56
Timestamp: 2025-07-11T10:46:43.711Z
Learning: In apps/{deploy-web,provider-console}/**/*.spec.tsx files: Use getBy methods instead of queryBy methods when testing element presence with toBeInTheDocument() because getBy throws an error and shows DOM state when element is not found, providing better debugging information than queryBy which returns null.

apps/api/test/functional/blocks.spec.ts (8)

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-07-21T08:24:27.953Z
Learning: Applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Use setup function instead of beforeEach in test files

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : setup function must be at the bottom of the root describe block in test files

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-07-21T08:24:24.269Z
Learning: Applies to **/*.spec.{ts,tsx} : 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.

Learnt from: stalniy
PR: #1660
File: apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx:54-56
Timestamp: 2025-07-11T10:46:43.711Z
Learning: In apps/{deploy-web,provider-console}/**/*.spec.tsx files: Use getBy methods instead of queryBy methods when testing element presence with toBeInTheDocument() because getBy throws an error and shows DOM state when element is not found, providing better debugging information than queryBy which returns null.

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't specify return type of setup function

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : setup function should accept a single parameter with inline type definition

Learnt from: CR
PR: akash-network/console#0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use shared state in setup function

⏰ 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 (17)
apps/api/test/functional/start-trial.spec.ts (1)

41-42: LGTM! Good defensive coding pattern.

The explicit null check with a descriptive error message prevents subsequent API calls from executing with invalid data and provides clearer test failure diagnostics compared to cryptic errors that would occur later.

apps/api/test/functional/stripe-webhook.spec.ts (1)

34-35: LGTM! Good refactor for environment variable handling.

Extracting the environment variable to a local constant with explicit validation improves code clarity and provides better error messaging when the required STRIPE_WEBHOOK_SECRET is not set.

Also applies to: 44-44

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

254-255: LGTM! Good use of optional chaining for defensive programming.

The optional chaining provides runtime safety when accessing storedKey properties, making the tests more robust against potential changes in the assertion flow.

apps/api/test/functional/bids.spec.ts (1)

48-51: LGTM! Enhanced mock implementation with proper validation.

The mock now includes proper TypeScript typing (string | undefined) and explicit validation logic that mirrors real behavior, making tests more reliable and providing better error diagnostics.

apps/api/test/functional/wallets-refill.spec.ts (1)

32-32: LGTM! Consistent use of optional chaining for safer property access.

The optional chaining prevents runtime errors when accessing properties on potentially undefined objects (walletRecord, trialingWallet), making the tests more robust and aligned with the strict TypeScript migration.

Also applies to: 64-64, 66-67

apps/api/test/functional/user-init.spec.ts (1)

101-101: LGTM! Appropriate use of optional chaining for strict mode.

The optional chaining additions correctly handle cases where wallet, existingUser, and anonymousWalletAfterResponse might be undefined, which is essential for TypeScript strict mode compliance.

Also applies to: 108-108, 114-114

apps/api/test/functional/blocks.spec.ts (3)

37-44: Excellent defensive coding for strict mode compliance.

The expectBlocks helper function is properly updated to handle optional parameters and uses safe property access patterns:

  • Optional parameters prevent runtime errors when blocks is undefined
  • Optional chaining with fallback to empty array ensures safe iteration
  • The logic remains intact while becoming more robust

87-87: Good type assertion improvement.

Replacing the any type assertion with the proper AkashBlock type follows TypeScript best practices and coding guidelines.


54-54: Consistent optional chaining usage throughout tests.

The optional chaining is appropriately applied to array operations where blocks might be undefined, ensuring test stability under strict mode.

Also applies to: 64-64, 83-83, 90-90

apps/api/test/functional/templates.spec.ts (1)

46-47: Proper defensive coding in test helper function.

The expectCategory helper function correctly uses optional chaining to handle cases where category might be undefined, with appropriate fallback to empty array for safe iteration.

apps/api/test/functional/provider-regions.spec.ts (1)

36-36: Appropriate optional chaining with fallback.

The expectRegion helper function correctly handles potential undefined region values by using optional chaining with a fallback to empty array, maintaining test logic while preventing runtime errors.

apps/api/test/functional/dashboard-data.spec.ts (1)

217-221: Excellent use of nullish coalescing for numeric calculations.

The nullish coalescing operator (?? 0) is appropriately used to handle cases where block properties might be null or undefined, preventing NaN results in arithmetic operations. This ensures robust calculations for both storage totals and daily differences while maintaining correct test logic.

Also applies to: 236-240

apps/api/test/functional/gpu.spec.ts (5)

65-65: Optional chaining is unnecessary here.

The expectedVendors object is always defined when returned from the setup() function, making the optional chaining (?.) redundant. However, this defensive coding doesn't cause any issues and aligns with the strict TypeScript migration.


80-80: Optional chaining is unnecessary here.

Similar to the previous case, expectedVendors is always defined from setup(), making the optional chaining redundant but harmless.


95-95: Optional chaining is unnecessary here.

The expectedVendors object and its nvidia array are always populated in the setup() function, making this optional chaining redundant but safe.


102-102: Optional chaining is unnecessary here.

The providers array is always populated with two providers in the setup() function, so providers?.[0] will always exist. The optional chaining is redundant but doesn't harm the test logic.


110-110: Optional chaining is unnecessary but consistent.

These optional chaining operators are redundant since expectedVendors, providers, and their properties are always defined from the setup() function. However, the defensive coding is consistent across the test file and aligns with the strict TypeScript migration.

Also applies to: 117-117, 125-125

@codecov
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.52%. Comparing base (c6925e5) to head (14c81fa).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1745      +/-   ##
==========================================
- Coverage   72.66%   72.52%   -0.14%     
==========================================
  Files         627      622       -5     
  Lines       15022    14845     -177     
  Branches     2644     2629      -15     
==========================================
- Hits        10915    10767     -148     
+ Misses       3851     3739     -112     
- Partials      256      339      +83     
Flag Coverage Δ *Carryforward flag
api 80.30% <100.00%> (+0.02%) ⬆️
deploy-web 58.64% <ø> (ø) Carriedforward from c6925e5
log-collector ?
notifications 87.25% <ø> (ø) Carriedforward from c6925e5
provider-console 80.95% <ø> (ø) Carriedforward from c6925e5
provider-proxy 85.00% <ø> (ø) Carriedforward from c6925e5

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

Files with missing lines Coverage Δ
apps/api/src/app.ts 87.27% <100.00%> (ø)

... and 38 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.

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