refactor: finalizes strict types migration for console-api#1745
Conversation
WalkthroughThis change removes the strict type-checking validation script and its related lint-staged configuration for the Changes
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
11d666f to
3f10ce8
Compare
3f10ce8 to
14c81fa
Compare
There was a problem hiding this comment.
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
beforeEachinstead of the recommendedsetupfunction pattern specified in the coding guidelines. Consider refactoring to use asetupfunction at the bottom of the rootdescribeblock.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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, usejest-mock-extendedto create mocks and pass mocks as dependencies to the service under test.
**/*.spec.{ts,tsx}: Usesetupfunction instead ofbeforeEachin test files
setupfunction must be at the bottom of the rootdescribeblock in test files
setupfunction creates an object under test and returns it
setupfunction should accept a single parameter with inline type definition
Don't use shared state insetupfunction
Don't specify return type ofsetupfunction
Files:
apps/api/test/functional/start-trial.spec.tsapps/api/test/functional/templates.spec.tsapps/api/test/functional/provider-regions.spec.tsapps/api/test/functional/api-key.spec.tsapps/api/test/functional/bids.spec.tsapps/api/test/functional/dashboard-data.spec.tsapps/api/test/functional/stripe-webhook.spec.tsapps/api/test/functional/user-init.spec.tsapps/api/test/functional/wallets-refill.spec.tsapps/api/test/functional/gpu.spec.tsapps/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.tsapps/api/test/functional/templates.spec.tsapps/api/test/functional/provider-regions.spec.tsapps/api/test/functional/api-key.spec.tsapps/api/test/functional/bids.spec.tsapps/api/test/functional/dashboard-data.spec.tsapps/api/test/functional/stripe-webhook.spec.tsapps/api/test/functional/user-init.spec.tsapps/api/test/functional/wallets-refill.spec.tsapps/api/test/functional/gpu.spec.tsapps/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.tsapps/api/test/functional/templates.spec.tsapps/api/test/functional/provider-regions.spec.tsapps/api/test/functional/api-key.spec.tsapps/api/test/functional/bids.spec.tsapps/api/test/functional/dashboard-data.spec.tsapps/api/test/functional/stripe-webhook.spec.tsapps/api/test/functional/user-init.spec.tsapps/api/test/functional/wallets-refill.spec.tsapps/api/test/functional/gpu.spec.tsapps/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_SECRETis 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
storedKeyproperties, 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, andanonymousWalletAfterResponsemight 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
expectBlockshelper function is properly updated to handle optional parameters and uses safe property access patterns:
- Optional parameters prevent runtime errors when
blocksis 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
anytype assertion with the properAkashBlocktype 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
blocksmight 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
expectCategoryhelper function correctly uses optional chaining to handle cases wherecategorymight 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
expectRegionhelper function correctly handles potential undefinedregionvalues 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
expectedVendorsobject is always defined when returned from thesetup()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,
expectedVendorsis always defined fromsetup(), making the optional chaining redundant but harmless.
95-95: Optional chaining is unnecessary here.The
expectedVendorsobject and itsnvidiaarray are always populated in thesetup()function, making this optional chaining redundant but safe.
102-102: Optional chaining is unnecessary here.The
providersarray is always populated with two providers in thesetup()function, soproviders?.[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 thesetup()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 Report✅ All modified and coverable lines are covered by tests. 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
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
Summary by CodeRabbit