Skip to content

Commit 61a133d

Browse files
committed
Test fixes
1 parent 6f37b02 commit 61a133d

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

webview-ui/src/__tests__/ContextWindowProgress.spec.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import TaskHeader from "@src/components/chat/TaskHeader"
88
// Mock formatLargeNumber function
99
vi.mock("@/utils/format", () => ({
1010
formatLargeNumber: vi.fn((num) => num.toString()),
11+
formatCost: (cost: number) => `$${cost.toFixed(2)}`,
1112
}))
1213

1314
// Mock VSCodeBadge component for all tests
@@ -128,12 +129,7 @@ describe("ContextWindowProgress", () => {
128129
expect(windowSize).toBeInTheDocument()
129130
expect(windowSize).toHaveTextContent("4000")
130131

131-
// The progress bar is now wrapped in tooltips, but we can verify the structure exists
132-
// by checking for the progress bar container
133-
const progressBarContainer = screen.getByTestId("context-tokens-count").parentElement
132+
const progressBarContainer = screen.getByTestId("context-progress-bar-container").parentElement
134133
expect(progressBarContainer).toBeInTheDocument()
135-
136-
// Verify the flex container has the expected structure
137-
expect(progressBarContainer?.querySelector(".flex-1.relative")).toBeInTheDocument()
138134
})
139135
})

webview-ui/src/components/chat/ContextWindowProgress.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ export const ContextWindowProgress = ({ contextWindow, contextTokens, maxTokens
6060
<StandardTooltip content={tooltipContent} side="top" sideOffset={8}>
6161
<div className="flex-1 relative">
6262
{/* Main progress bar container */}
63-
<div className="flex items-center h-1 rounded-[2px] overflow-hidden w-full bg-[color-mix(in_srgb,var(--vscode-foreground)_20%,transparent)]">
63+
<div
64+
data-testid="context-progress-bar-container"
65+
className="flex items-center h-1 rounded-[2px] overflow-hidden w-full bg-[color-mix(in_srgb,var(--vscode-foreground)_20%,transparent)]">
6466
{/* Current tokens container */}
6567
<div
6668
className="relative h-full"

webview-ui/src/components/chat/__tests__/TaskHeader.spec.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ vi.mock("@roo/array", () => ({
8888
},
8989
}))
9090

91+
// Mock the format utilities
92+
vi.mock("@/utils/format", async (importOriginal) => {
93+
const actual = await importOriginal<typeof import("@/utils/format")>()
94+
return {
95+
...actual,
96+
formatCost: (cost: number) => `$${cost.toFixed(2)}`,
97+
}
98+
})
99+
91100
describe("TaskHeader", () => {
92101
const defaultProps: TaskHeaderProps = {
93102
task: { type: "say", ts: Date.now(), text: "Test task", images: [] },

0 commit comments

Comments
 (0)