Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions components/pollen-balance/pollen-balance-display-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export const PollenBalanceDisplayView = memo(function PollenBalanceDisplayView({
Error
</Badge>
</TooltipTrigger>
<TooltipContent
side="bottom"
<TooltipContent
side="bottom"
className="p-3 min-w-[200px] bg-popover border border-border dark:border-white/15 text-popover-foreground shadow-[0_20px_60px_0px_rgba(0,0,0,0.8)] animate-in fade-in-0 zoom-in-95 duration-200"
>
<div className="space-y-3">
Expand Down Expand Up @@ -98,8 +98,8 @@ export const PollenBalanceDisplayView = memo(function PollenBalanceDisplayView({
{formattedBalance}
</Badge>
</TooltipTrigger>
<TooltipContent
side="bottom"
<TooltipContent
side="bottom"
className="p-3 min-w-[200px] bg-popover border border-border dark:border-white/15 text-popover-foreground shadow-[0_20px_60px_0px_rgba(0,0,0,0.8)] animate-in fade-in-0 zoom-in-95 duration-200"
>
<div className="space-y-3">
Expand All @@ -118,7 +118,7 @@ export const PollenBalanceDisplayView = memo(function PollenBalanceDisplayView({
</div>
<p className="text-xs text-muted-foreground leading-relaxed">
{isLowBalance
? "Your balance is running low. Consider topping up."
? "Your balance is running low."
: "Your current Pollinations account balance."}
</p>
</div>
Expand Down
8 changes: 4 additions & 4 deletions hooks/use-pollen-balance.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ describe("hooks/use-pollen-balance", () => {
(balance) => {
const result = formatBalance(balance);
expect(result).not.toBeNull();

// Verify format: should have exactly 2 decimal places
const parts = result!.split(".");
expect(parts.length).toBe(2);
expect(parts[1].length).toBe(2);

// Verify the numeric value is preserved (within floating point tolerance)
const parsed = parseFloat(result!);
expect(Math.abs(parsed - balance)).toBeLessThan(0.01);
Expand Down Expand Up @@ -206,7 +206,7 @@ describe("usePollenBalance hook", () => {

// Make fetch hang to test loading state
mockFetchPollenBalance.mockImplementation(
() => new Promise(() => {}) // Never resolves
() => new Promise(() => { }) // Never resolves
);

const { result } = renderHook(() => usePollenBalance(), {
Expand Down Expand Up @@ -253,7 +253,7 @@ describe("usePollenBalance hook", () => {
isLoading: false,
});

mockFetchPollenBalance.mockResolvedValue({ balance: 0.5 }); // Below default threshold of 1
mockFetchPollenBalance.mockResolvedValue({ balance: 0.49 }); // Below default threshold of 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Stale comment: threshold reference is outdated.

The comment still references the old threshold of 1, but DEFAULT_LOW_BALANCE_THRESHOLD is now 0.5.

📝 Suggested fix
-      mockFetchPollenBalance.mockResolvedValue({ balance: 0.49 }); // Below default threshold of 1
+      mockFetchPollenBalance.mockResolvedValue({ balance: 0.49 }); // Below default threshold of 0.5
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mockFetchPollenBalance.mockResolvedValue({ balance: 0.49 }); // Below default threshold of 1
mockFetchPollenBalance.mockResolvedValue({ balance: 0.49 }); // Below default threshold of 0.5
🤖 Prompt for AI Agents
In `@hooks/use-pollen-balance.test.tsx` at line 256, The inline test comment is
stale — update the comment or the test value to match the new
DEFAULT_LOW_BALANCE_THRESHOLD (0.5). Locate the line using
mockFetchPollenBalance.mockResolvedValue({ balance: 0.49 }) and either change
the comment to say "Below default threshold of 0.5" or adjust the mocked balance
to be below/above DEFAULT_LOW_BALANCE_THRESHOLD as intended; reference
DEFAULT_LOW_BALANCE_THRESHOLD and mockFetchPollenBalance in your change so the
test and comment remain consistent.


const { result } = renderHook(() => usePollenBalance(), {
wrapper: createWrapper(),
Expand Down
6 changes: 3 additions & 3 deletions hooks/use-pollen-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import { queryKeys, STALE_TIMES, GC_TIMES } from "@/lib/query";

/**
* Default threshold for low balance warning (in pollen units)
* Set to 1 because we can't infer max balance from the API - users can top up
* via Polar.sh at any time. 1 pollen means they're genuinely running low.
* Set to 0.5 because we can't infer max balance from the API - users can top up
* via Polar.sh at any time. 0.5 pollen means they're genuinely running low.
*/
export const DEFAULT_LOW_BALANCE_THRESHOLD = 1;
export const DEFAULT_LOW_BALANCE_THRESHOLD = 0.5;
Comment thread
coderabbitai[bot] marked this conversation as resolved.

/**
* Minimum interval between balance refreshes (in milliseconds)
Expand Down