Skip to content

feat(deployment): implement trial deployment badge#1764

Merged
baktun14 merged 7 commits intomainfrom
features/display-24h-notice-trial
Jul 31, 2025
Merged

feat(deployment): implement trial deployment badge#1764
baktun14 merged 7 commits intomainfrom
features/display-24h-notice-trial

Conversation

@baktun14
Copy link
Contributor

@baktun14 baktun14 commented Jul 31, 2025

#1700

Summary by CodeRabbit

  • New Features

    • Introduced a "Trial Deployment" badge displayed in multiple app sections when a user is trialing and the anonymous free trial feature is disabled.
    • Added detailed tooltips for trial deployments showing time remaining and prompts to add funds.
    • Added environment configuration to customize trial deployment durations.
  • Bug Fixes / Style

    • Improved icon alignment and spacing in account and wallet components.
    • Updated pagination link styles for better visual consistency.
  • Tests

    • Added thorough tests for the trial deployment badge, tooltip, and time remaining logic covering various scenarios.
  • Documentation

    • Updated shared component exports to include the new trial deployment badge.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 31, 2025

Walkthrough

This change introduces a "Trial Deployment Badge" feature across the deployment web app. It adds a reusable badge and tooltip component, a custom hook for calculating trial time remaining, and integrates them into various UI locations, conditionally displaying the badge based on a feature flag and wallet trial status. Supporting tests, environment configuration, and minor UI adjustments are also included.

Changes

Cohort / File(s) Change Summary
Trial Deployment Badge Feature Integration
apps/deploy-web/src/components/deployments/DeploymentListRow.tsx, apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx, apps/deploy-web/src/components/home/YourAccount.tsx, apps/deploy-web/src/components/new-deployment/ManifestEdit.tsx
Integrate the new TrialDeploymentBadge component into deployment list rows, subheaders, account, and deposit modal. Conditionally render the badge based on the "anonymous_free_trial" feature flag and wallet trial status.
TrialDeploymentBadge & Tooltip Implementation
apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx, apps/deploy-web/src/components/shared/TrialDeploymentTooltip.tsx
Add new components: TrialDeploymentBadge displays a badge with trial status and tooltip, and TrialDeploymentTooltip provides explanatory UI and an "Add Funds" action. Both support dependency injection for testing and customization.
Shared Components Exports
apps/deploy-web/src/components/shared/index.ts
Export TrialDeploymentBadge from shared components for use throughout the app.
Trial Badge & Tooltip Testing
apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx, apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
Add comprehensive test suites for badge and tooltip components, covering rendering, expiration logic, text content, and edge cases.
Trial Time Remaining Hook & Testing
apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.ts, apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts
Add a custom hook to calculate trial time left based on block height, duration, and average block time, with tests for all major scenarios and edge cases.
Environment Configuration
apps/deploy-web/src/config/browser-env.config.ts, apps/deploy-web/src/config/env-config.schema.ts
Add support for a new environment variable controlling trial deployment duration, with schema validation and browser exposure.
UI & Style Adjustments
apps/deploy-web/src/components/wallet/ManagedWalletPopup.tsx, packages/ui/components/pagination.tsx
Refine icon placement and spacing in wallet popup and adjust pagination link styling for active/inactive states.
API Environment Variable Change
apps/api/env/.env
Reduce TRIAL_DEPLOYMENT_ALLOWANCE_AMOUNT from 100,000,000 to 10,000,000.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI_Component
    participant useFlag
    participant useWallet
    participant TrialDeploymentBadge
    participant useTrialDeploymentTimeRemaining
    participant TrialDeploymentTooltip

    User->>UI_Component: Loads deployment/account UI
    UI_Component->>useFlag: Get "anonymous_free_trial" flag
    UI_Component->>useWallet: Get isTrialing status
    alt !anonymous_free_trial && isTrialing
        UI_Component->>TrialDeploymentBadge: Render with createdHeight
        TrialDeploymentBadge->>useTrialDeploymentTimeRemaining: Calculate trial time left
        TrialDeploymentBadge->>TrialDeploymentTooltip: Show tooltip with trial info
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • ygrishajev
  • stalniy

Poem

A badge for trials, shining bright,
Shows your status, day or night.
With tooltips clear and time to spare,
Add funds with ease, show you care!
From code to UI, the badge now hops—
A rabbit’s joy in every prop! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch features/display-24h-notice-trial

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

@codecov
Copy link

codecov bot commented Jul 31, 2025

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
902 2 900 0
View the top 2 failed test(s) by shortest run time
BillingView renders table with billing data
Stack Traces | 0.074s run time
TestingLibraryElementError: Unable to find an element with the text: 75.50. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

Ignored nodes: comments, script, style
<body>
  <div>
    <div
      class="space-y-2"
    >
      <h3
        class="text-xl font-semibold sm:text-2xl"
      >
        History
      </h3>
      <div
        class="flex flex-col justify-between gap-4 sm:flex-row sm:items-end"
      >
        <div>
          <label
            class="text-xs font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
          >
            Filter by Date:
          </label>
          <div>
            <label>
              <span>
                Filter by start date
              </span>
              <input
                type="date"
                value="2025-07-31"
              />
            </label>
            <label>
              <span>
                Filter by end date
              </span>
              <input
                type="date"
                value="2025-07-31"
              />
            </label>
          </div>
        </div>
        <button
          class="ring-offset-background focus-visible:ring-ring relative inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-secondary text-secondary-foreground hover:bg-secondary/80 px-4 py-2 h-12 gap-4"
        >
          <svg
            color="currentColor"
            fill="none"
            height="1.5em"
            stroke-width="1.5"
            viewBox="0 0 24 24"
            width="16"
            xmlns="http://www.w3.org/2000/svg"
          >
            <path
              d="M6 20L18 20"
              stroke="currentColor"
              stroke-linecap="round"
              stroke-linejoin="round"
            />
            <path
              d="M12 4V16M12 16L15.5 12.5M12 16L8.5 12.5"
              stroke="currentColor"
              stroke-linecap="round"
              stroke-linejoin="round"
            />
          </svg>
          Export as CSV
        </button>
      </div>
      <div>
        <div
          class="relative w-full overflow-auto"
        >
          <table
            class="w-full caption-bottom text-sm table-fixed"
          >
            <thead
              class="[&_tr]:border-b-0"
            >
              <tr
                class="border-b-muted-foreground/20 data-[state=selected]:bg-muted border-b transition-colors hover:bg-transparent"
              >
                <th
                  class="text-muted-foreground h-12 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0 w-32 px-4 py-2"
                >
                  Date
                </th>
                <th
                  class="text-muted-foreground h-12 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0 w-32 px-4 py-2"
                >
                  Amount
                </th>
                <th
                  class="text-muted-foreground h-12 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0 w-32 px-4 py-2"
                >
                  Account source
                </th>
                <th
                  class="text-muted-foreground h-12 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0 w-32 px-4 py-2"
                >
                  Status
                </th>
                <th
                  class="text-muted-foreground h-12 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0 w-4 px-4 py-2"
                >
                  Receipt
                </th>
              </tr>
            </thead>
          </table>
        </div>
        <div
          class="rounded border border-muted-foreground/20"
        >
          <div
            class="relative w-full overflow-auto"
          >
            <table
              class="w-full caption-bottom text-sm table-fixed"
            >
              <tbody
                class="[&_tr:last-child]:border-0"
              >
                <tr
                  class="border-b-muted-foreground/20 data-[state=selected]:bg-muted hover:bg-muted/100 border-b transition-colors"
                >
                  <td
                    class="p-4 align-middle [&:has([role=checkbox])]:pr-0 w-32 px-4 py-2"
                  >
                    10/20/57083
                  </td>
                  <td
                    class="p-4 align-middle [&:has([role=checkbox])]:pr-0 w-32 px-4 py-2"
                  >
                    <span>
                      75.5
                    </span>
                  </td>
                  <td
                    class="p-4 align-middle [&:has([role=checkbox])]:pr-0 w-32 px-4 py-2"
                  >
                    Amex **** 6739
                  </td>
                  <td
                    class="p-4 align-middle [&:has([role=checkbox])]:pr-0 w-32 px-4 py-2"
                  >
                    <div
                      class="inline-flex items-center justify-center rounded-full px-2 py-1 text-xs font-semibold bg-yellow-100 text-yellow-800"
                    >
                      Pending...
    at Object.getElementError (.../console/console/node_modules/@.../dom/dist/config.js:37:19)
    at .../console/console/node_modules/@.../dom/dist/query-helpers.js:76:38
    at .../console/console/node_modules/@.../dom/dist/query-helpers.js:52:17
    at .../console/console/node_modules/@.../dom/dist/query-helpers.js:95:19
    at Object.getByText (.../billing-usage/BillingView/BillingView.spec.tsx:41:19)
    at Promise.then.completed (.../console/console/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (.../console/console/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (.../console/console/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at _runTest (.../console/console/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (.../console/console/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (.../console/console/node_modules/jest-circus/build/run.js:121:9)
    at run (.../console/console/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (.../console/console/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (.../console/console/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (.../console/console/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (.../console/console/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (.../console/console/node_modules/jest-runner/build/testWorker.js:106:12)
Deployment Settings PATCH /v1/deployment-settings/{userId}/{dseq} should return 404 when updating other user's deployment settings
Stack Traces | 20s run time
Error: thrown: "Exceeded timeout of 20000 ms for a test.
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."
    at .../test/functional/deployment-setting.spec.ts:255:5
    at _dispatchDescribe (.../jest-circus/build/index.js:91:26)
    at describe (.../jest-circus/build/index.js:55:5)
    at .../test/functional/deployment-setting.spec.ts:203:3
    at _dispatchDescribe (.../jest-circus/build/index.js:91:26)
    at describe (.../jest-circus/build/index.js:55:5)
    at Object.<anonymous> (.../test/functional/deployment-setting.spec.ts:13:1)
    at Runtime._execModule (.../jest-runtime/build/index.js:1439:24)
    at Runtime._loadModule (.../jest-runtime/build/index.js:1022:12)
    at Runtime.requireModule (.../jest-runtime/build/index.js:882:12)
    at jestAdapter (.../build/legacy-code-todo-rewrite/jestAdapter.js:77:13)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at runTestInternal (.../jest-runner/build/runTest.js:367:16)
    at runTest (.../jest-runner/build/runTest.js:444:34)
    at Object.worker (.../jest-runner/build/testWorker.js:106:12)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@baktun14 baktun14 marked this pull request as ready for review July 31, 2025 15:32
@baktun14 baktun14 requested a review from a team as a code owner July 31, 2025 15:32
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: 3

🧹 Nitpick comments (1)
apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.ts (1)

65-91: Consider making refetch interval configurable.

The hook implementation is excellent with proper memoization and dependency injection. However, the hardcoded 30-second refetch interval could benefit from being configurable.

Consider making the refetch interval a parameter:

export function useTrialDeploymentTimeRemaining({
  createdHeight,
  trialDurationHours,
  averageBlockTime = 6,
+ refetchInterval = 30000,
  dependencies: d = DEPENDENCIES
}: UseTrialDeploymentTimeRemainingProps) {
  const { data: latestBlock } = d.useBlock("latest", {
-   refetchInterval: 30000
+   refetchInterval
  });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c25683c and 9eac247.

📒 Files selected for processing (15)
  • apps/deploy-web/src/components/deployments/DeploymentListRow.tsx (5 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx (3 hunks)
  • apps/deploy-web/src/components/home/YourAccount.tsx (6 hunks)
  • apps/deploy-web/src/components/new-deployment/ManifestEdit.tsx (2 hunks)
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx (1 hunks)
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx (1 hunks)
  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx (1 hunks)
  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.tsx (1 hunks)
  • apps/deploy-web/src/components/shared/index.ts (1 hunks)
  • apps/deploy-web/src/components/wallet/ManagedWalletPopup.tsx (1 hunks)
  • apps/deploy-web/src/config/browser-env.config.ts (1 hunks)
  • apps/deploy-web/src/config/env-config.schema.ts (1 hunks)
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts (1 hunks)
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.ts (1 hunks)
  • packages/ui/components/pagination.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{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:

  • packages/ui/components/pagination.tsx
  • apps/deploy-web/src/components/shared/index.ts
  • apps/deploy-web/src/components/new-deployment/ManifestEdit.tsx
  • apps/deploy-web/src/config/env-config.schema.ts
  • apps/deploy-web/src/config/browser-env.config.ts
  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.tsx
  • apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx
  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts
  • apps/deploy-web/src/components/wallet/ManagedWalletPopup.tsx
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx
  • apps/deploy-web/src/components/deployments/DeploymentListRow.tsx
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.ts
  • apps/deploy-web/src/components/home/YourAccount.tsx
**/*.{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:

  • packages/ui/components/pagination.tsx
  • apps/deploy-web/src/components/shared/index.ts
  • apps/deploy-web/src/components/new-deployment/ManifestEdit.tsx
  • apps/deploy-web/src/config/env-config.schema.ts
  • apps/deploy-web/src/config/browser-env.config.ts
  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.tsx
  • apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx
  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts
  • apps/deploy-web/src/components/wallet/ManagedWalletPopup.tsx
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx
  • apps/deploy-web/src/components/deployments/DeploymentListRow.tsx
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.ts
  • apps/deploy-web/src/components/home/YourAccount.tsx
**/*.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/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx
apps/{deploy-web,provider-console}/**/*.spec.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/query-by-in-tests.mdc)

Use queryBy methods instead of getBy methods in test expectations in .spec.tsx files

Files:

  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx
🧠 Learnings (14)
📓 Common learnings
Learnt from: baktun14
PR: akash-network/console#1725
File: apps/api/src/utils/constants.ts:5-5
Timestamp: 2025-07-24T17:00:52.361Z
Learning: In the Akash Network Console project, when cross-cutting concerns or broader refactoring issues are identified during PR review, the preferred approach is to create a separate GitHub issue to track the work rather than expanding the scope of the current PR. This maintains focus and allows for proper planning of architectural improvements.
📚 Learning: in the akash network console project, backend-specific feature flags are intentional and acceptable....
Learnt from: stalniy
PR: akash-network/console#1480
File: apps/deploy-web/src/hooks/useFlag.tsx:0-0
Timestamp: 2025-07-28T10:40:13.595Z
Learning: In the Akash Network Console project, backend-specific feature flags are intentional and acceptable. The frontend FeatureFlag union type should only include flags that are actually used by the frontend, not all flags defined in the backend. Backend can have internal feature flags for backend-only functionality without requiring frontend synchronization.

Applied to files:

  • apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx
  • apps/deploy-web/src/components/deployments/DeploymentListRow.tsx
  • apps/deploy-web/src/components/home/YourAccount.tsx
📚 Learning: the contactpointselect component in apps/deploy-web/src/components/alerts/contactpointselectform/con...
Learnt from: baktun14
PR: akash-network/console#1432
File: apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentCloseAlert.tsx:38-38
Timestamp: 2025-06-05T21:07:51.985Z
Learning: The ContactPointSelect component in apps/deploy-web/src/components/alerts/ContactPointSelectForm/ContactPointSelect.tsx uses the useFormContext hook internally to connect to React Hook Form, so it doesn't need to be wrapped in a FormField component.

Applied to files:

  • apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx
  • apps/deploy-web/src/components/deployments/DeploymentListRow.tsx
  • apps/deploy-web/src/components/home/YourAccount.tsx
📚 Learning: applies to apps/{deploy-web,provider-console}/**/*.spec.tsx : use `queryby` methods instead of `getb...
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

Applied to files:

  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx
📚 Learning: in apps/{deploy-web,provider-console}/**/*.spec.tsx files: use `getby` methods instead of `queryby` ...
Learnt from: stalniy
PR: akash-network/console#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.

Applied to files:

  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx
📚 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} : Use `setup` function instead of `beforeEach` in test files

Applied to files:

  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx
📚 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 use shared state in `setup` function

Applied to files:

  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx
📚 Learning: applies to **/*.spec.{ts,tsx} : `setup` function creates an object under test and returns it...
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

Applied to files:

  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx
📚 Learning: applies to **/*.spec.{ts,tsx} : don't use `jest.mock()` to mock dependencies in test files. instead,...
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.

Applied to files:

  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx
📚 Learning: applies to **/*.spec.{ts,tsx} : `setup` function must be at the bottom of the root `describe` block ...
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

Applied to files:

  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx
📚 Learning: applies to **/*.spec.{ts,tsx} : `setup` function should accept a single parameter with inline type d...
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

Applied to files:

  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
📚 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} : Don't specify return type of `setup` function

Applied to files:

  • apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx
  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts
📚 Learning: in react hook form setups with zod validation, child components using useformcontext() can rely on p...
Learnt from: ygrishajev
PR: akash-network/console#1512
File: apps/deploy-web/src/components/deployments/DeploymentBalanceAlert/DeploymentBalanceAlert.tsx:47-68
Timestamp: 2025-06-19T16:00:05.428Z
Learning: In React Hook Form setups with zod validation, child components using useFormContext() can rely on parent form validation rather than implementing local input validation. Invalid inputs like NaN from parseFloat() are handled by the parent schema validation, eliminating the need for additional local validation in child components.

Applied to files:

  • apps/deploy-web/src/components/deployments/DeploymentListRow.tsx
📚 Learning: the `getproviderearningsatheight` function in `apps/api/src/services/db/statsservice.ts` is designed...
Learnt from: devalpatel67
PR: akash-network/console#1646
File: apps/api/src/provider/services/provider-earnings/provider-earnings.service.ts:41-41
Timestamp: 2025-07-09T03:30:51.075Z
Learning: The `getProviderEarningsAtHeight` function in `apps/api/src/services/db/statsService.ts` is designed to be flexible and can be used for different earnings calculations: (1) For total lifetime earnings, pass `provider.createdHeight` as the second parameter, (2) For date-range earnings, pass `fromBlock.height` as the second parameter. The second parameter acts as a lower bound and the third parameter as an upper bound for the earnings calculation.

Applied to files:

  • apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.ts
🧬 Code Graph Analysis (3)
apps/deploy-web/src/components/new-deployment/ManifestEdit.tsx (2)
apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx (1)
  • TrialDeploymentBadge (26-49)
apps/deploy-web/src/components/shared/index.ts (1)
  • TrialDeploymentBadge (4-4)
apps/deploy-web/src/components/shared/TrialDeploymentTooltip.tsx (4)
apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx (1)
  • DEPENDENCIES (19-24)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (28-30)
apps/provider-console/src/utils/styleUtils.ts (1)
  • cn (4-6)
packages/ui/components/button.tsx (1)
  • buttonVariants (46-46)
apps/deploy-web/src/components/home/YourAccount.tsx (7)
apps/deploy-web/src/context/WalletProvider/WalletProvider.tsx (1)
  • useWallet (355-357)
apps/deploy-web/src/hooks/useFlag.tsx (1)
  • useFlag (13-13)
apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx (1)
  • TrialDeploymentBadge (26-49)
apps/deploy-web/src/components/user/AddFundsLink.tsx (1)
  • AddFundsLink (10-32)
apps/provider-console/src/utils/styleUtils.ts (1)
  • cn (4-6)
packages/ui/components/button.tsx (1)
  • buttonVariants (46-46)
apps/deploy-web/src/utils/urlUtils.ts (1)
  • UrlService (16-81)
⏰ 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: test-build
  • GitHub Check: test-build
🔇 Additional comments (33)
apps/deploy-web/src/config/browser-env.config.ts (1)

17-17: LGTM!

The environment variable addition follows the established naming convention and is properly placed within the configuration object.

apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.ts (1)

26-48: Well-structured calculation function.

The calculateTrialTimeRemaining function properly handles edge cases and provides clear return types. The logic for calculating blocks and time remaining is sound.

apps/deploy-web/src/components/shared/index.ts (1)

4-4: LGTM!

The export statement follows the established pattern and makes the TrialDeploymentBadge component available through the shared components index.

apps/deploy-web/src/config/env-config.schema.ts (1)

21-21: LGTM!

The environment variable schema addition follows established patterns with proper type coercion and a sensible default value of 24 hours.

apps/deploy-web/src/components/new-deployment/ManifestEdit.tsx (2)

40-40: LGTM!

The import follows the established pattern for shared components.


457-461: Consistent conditional rendering implementation.

The trial badge is properly conditionally rendered based on the feature flag and trial status, consistent with the pattern used in other components. The placement within the modal's info text is appropriate.

apps/deploy-web/src/components/wallet/ManagedWalletPopup.tsx (1)

73-74: LGTM! UI consistency improvement.

The reordering of the "Add Funds" text and HandCard icon with proper spacing enhances visual consistency across the application. The whitespace-nowrap class prevents awkward text wrapping.

packages/ui/components/pagination.tsx (1)

37-44: LGTM! Enhanced pagination styling.

The changes improve the visual distinction between active and inactive pagination links:

  • Using "text" variant for better contrast
  • Clear active state styling with background colors
  • Consistent cursor behavior
apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx (4)

14-14: LGTM! Feature flag hook import.

The useFlag hook import is properly added to support the trial deployment badge feature.


19-19: LGTM! Component import.

The TrialDeploymentBadge import is correctly added from the shared components.


35-36: LGTM! Consistent pattern implementation.

The feature flag check and wallet context usage follow the established pattern across the codebase. The logic correctly shows the badge only when the anonymous free trial is disabled and the user is trialing.


133-133: LGTM! Proper conditional rendering.

The trial deployment badge is conditionally rendered with the correct props. The createdHeight prop from deployment.createdAt is appropriate for calculating trial timing.

apps/deploy-web/src/components/deployments/DeploymentListRow.tsx (5)

26-26: LGTM! Feature flag hook import.

The useFlag hook import is properly added to support the trial deployment badge feature.


39-39: LGTM! Component import.

The TrialDeploymentBadge import is correctly added from the shared components.


65-65: LGTM! Consistent wallet context usage.

The isTrialing property is properly extracted from the wallet context, maintaining consistency with other components.


89-89: LGTM! Consistent feature flag usage.

The feature flag check follows the established pattern across the codebase.


186-190: LGTM! Well-positioned trial badge.

The trial deployment badge is appropriately placed within the deployment name cell with proper spacing (mt-2). The conditional logic and props are correct.

apps/deploy-web/src/components/home/YourAccount.tsx (6)

18-18: LGTM! Feature flag hook import.

The useFlag hook import is properly added to support the trial deployment badge feature.


29-29: LGTM! Component import.

The TrialDeploymentBadge import is correctly added from the shared components.


46-46: LGTM! Consistent wallet context usage.

The isTrialing property is properly extracted from the wallet context, maintaining consistency with other components.


60-60: LGTM! Consistent feature flag usage.

The feature flag check follows the established pattern across the codebase.


162-162: LGTM! Appropriate badge placement.

The trial deployment badge is well-positioned in the CardHeader, providing clear trial status visibility in the account overview. The conditional logic is consistent with other components.


234-240: LGTM! Consistent UI refinements.

The icon positioning and text wrapping improvements align with similar changes in ManagedWalletPopup.tsx, ensuring consistent visual design across the application.

apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.spec.ts (1)

28-258: Excellent test coverage and logic.

The test suite comprehensively covers all scenarios including edge cases, different block times, trial durations, and missing parameters. The assertions properly verify the hook's behavior in various states.

apps/deploy-web/src/components/shared/TrialDeploymentBadge.spec.tsx (2)

9-147: Excellent test coverage for component behavior.

The test suite comprehensively covers various scenarios including expired/active states, custom configurations, edge cases, and proper rendering verification.


12-12: Use getBy methods for toBeInTheDocument() assertions.

According to coding guidelines, 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.

-    expect(screen.queryByText("Trial")).toBeInTheDocument();
+    expect(screen.getByText("Trial")).toBeInTheDocument();

Apply this pattern to all similar assertions in the file.

Also applies to: 18-19, 27-28

⛔ Skipped due to learnings
Learnt from: stalniy
PR: akash-network/console#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/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/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 must be at the bottom of the root `describe` block in test files
apps/deploy-web/src/components/shared/TrialDeploymentTooltip.spec.tsx (1)

9-132: Excellent test implementation following coding guidelines.

The test suite properly uses getBy methods for toBeInTheDocument() assertions, follows the setup function pattern, uses appropriate mocking with ComponentMock, and provides comprehensive coverage of all tooltip states and edge cases.

apps/deploy-web/src/components/shared/TrialDeploymentTooltip.tsx (3)

10-28: Well-structured component with proper TypeScript and dependency injection.

The component uses clear TypeScript types, implements dependency injection for testability, and has a clean props interface. The structure follows React best practices.


29-64: Clear and logical conditional rendering.

The component properly handles three distinct states (no creation height, expired trial, active trial) with appropriate content for each scenario. The logic is easy to follow and maintainable.


66-77: Well-implemented AddFunds component with proper service integration.

The AddFunds component correctly uses the services context to get the payment URL, applies proper styling, includes an appropriate icon, and follows the dependency injection pattern consistently.

apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx (3)

11-17: Well-designed props interface with appropriate optional parameters.

The props interface uses proper TypeScript types, implements dependency injection correctly, and provides reasonable defaults for optional parameters.


26-33: Proper hook integration with environment config fallback.

The component correctly integrates with the custom hook, provides appropriate fallback to environment configuration for trial duration, and cleanly destructures the needed values.


35-49: Excellent UI implementation with proper accessibility and conditional styling.

The component properly integrates tooltip functionality, uses conditional styling based on trial state, includes appropriate accessibility features (cursor-help), and implements clean styling with utility functions.

stalniy
stalniy previously approved these changes Jul 31, 2025
averageBlockTime?: number;
}) {
return withTimers(() => {
const mockUseBlock = mockFn<() => UseQueryResult<BlockResponse, Error>>();
Copy link
Contributor

Choose a reason for hiding this comment

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

question(non-blocking): what is the purpose of using mockFn instead of jest.fn()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Going to revert in next another or thanks

trialDurationHours: input.trialDurationHours,
averageBlockTime: input.averageBlockTime,
dependencies: {
useBlock: mockUseBlock
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion(non-blocking): I'd recommend whenever possible to use hook implementation and mock only service because then we do a little bigger scope with no additional efforts.

We have setupQuery testing helper which encapsulates tests setup for hooks. It also includes built-in support for dependency injection (ie., passing mocks for services) and configuring queryClient specifically for testing

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/env/.env (1)

3-3: Re-order the key to satisfy dotenv-linter and keep the .env alphabetized.

The linter warns that TRIAL_DEPLOYMENT_ALLOWANCE_AMOUNT should precede WEBSITE_URL. While ordering has no runtime impact, leaving the warning unattended can break CI in repos that treat linter output as hard-fail.
Apply the one-line move:

-CORS_WEBSITE_URLS=…
-WEBSITE_URL=https://console-beta.akash.network
-TRIAL_DEPLOYMENT_ALLOWANCE_AMOUNT=10000000
+CORS_WEBSITE_URLS=…
+TRIAL_DEPLOYMENT_ALLOWANCE_AMOUNT=10000000
+WEBSITE_URL=https://console-beta.akash.network

Please confirm that all environments (staging, prod, etc.) are updated with the new 10 000 000 value so the frontend’s trial-badge logic aligns with the API limits. If any infra still points to the old 100 000 000, users could receive inconsistent allowance errors.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 651a2aa and 4c97974.

📒 Files selected for processing (1)
  • apps/api/env/.env (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: baktun14
PR: akash-network/console#1725
File: apps/api/src/utils/constants.ts:5-5
Timestamp: 2025-07-24T17:00:52.361Z
Learning: In the Akash Network Console project, when cross-cutting concerns or broader refactoring issues are identified during PR review, the preferred approach is to create a separate GitHub issue to track the work rather than expanding the scope of the current PR. This maintains focus and allows for proper planning of architectural improvements.
📚 Learning: the alert.console_web_url environment variable in the notifications app is controlled and configured...
Learnt from: ygrishajev
PR: akash-network/console#1461
File: apps/notifications/src/modules/alert/services/deployment-alert/deployment-alert.service.ts:194-197
Timestamp: 2025-06-10T14:19:14.122Z
Learning: The alert.CONSOLE_WEB_URL environment variable in the notifications app is controlled and configured by the Akash team, reducing XSS concerns for HTML link generation in alert messages.

Applied to files:

  • apps/api/env/.env
🪛 dotenv-linter (3.3.0)
apps/api/env/.env

[warning] 3-3: [UnorderedKey] The TRIAL_DEPLOYMENT_ALLOWANCE_AMOUNT key should go before the WEBSITE_URL key

⏰ 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). (7)
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: test-build
  • GitHub Check: Validate local packages

@baktun14 baktun14 merged commit 3e2fdae into main Jul 31, 2025
55 of 62 checks passed
@baktun14 baktun14 deleted the features/display-24h-notice-trial branch July 31, 2025 17:11
stalniy pushed a commit that referenced this pull request Nov 20, 2025
* feat(deployment): implement trial deployment badge

* test(deployment): fix tests

* fix(billing): trial deployment time remaining

* fix: pr fix

* fix: remove comments

* fix: pr fixes

* fix: revert trial amount to 10
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