Skip to content

Commit a92aed6

Browse files
committed
test(webview): add model info visual snapshot
1 parent 5f0179c commit a92aed6

3 files changed

Lines changed: 82 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import React from "react"
2+
3+
import { OpenAiServiceTier, providerIdentifiers, type ModelInfo } from "@roo-code/types"
4+
5+
import { TranslationContext } from "../../../i18n/TranslationContext"
6+
import { ModelInfoView } from "../ModelInfoView"
7+
8+
const modelInfo: ModelInfo = {
9+
contextWindow: 400_000,
10+
maxTokens: 128_000,
11+
supportsImages: true,
12+
supportsPromptCache: true,
13+
inputPrice: 2,
14+
outputPrice: 8,
15+
cacheReadsPrice: 0.5,
16+
tiers: [
17+
{
18+
name: OpenAiServiceTier.Flex,
19+
contextWindow: 400_000,
20+
inputPrice: 1,
21+
outputPrice: 4,
22+
cacheReadsPrice: 0.25,
23+
},
24+
{
25+
name: OpenAiServiceTier.Priority,
26+
contextWindow: 400_000,
27+
inputPrice: 3.5,
28+
outputPrice: 14,
29+
cacheReadsPrice: 0.875,
30+
},
31+
],
32+
}
33+
34+
const translations: Record<string, string> = {
35+
"settings:modelInfo.contextWindow": "Context window:",
36+
"settings:modelInfo.maxOutput": "Max output",
37+
"settings:modelInfo.supportsImages": "Supports images",
38+
"settings:modelInfo.noImages": "Does not support images",
39+
"settings:modelInfo.supportsPromptCache": "Supports prompt caching",
40+
"settings:modelInfo.noPromptCache": "Does not support prompt caching",
41+
"settings:serviceTier.pricingTableTitle": "Service tier pricing (per 1M tokens)",
42+
"settings:serviceTier.columns.tier": "Tier",
43+
"settings:serviceTier.columns.input": "Input",
44+
"settings:serviceTier.columns.output": "Output",
45+
"settings:serviceTier.columns.cacheReads": "Cache reads",
46+
"settings:serviceTier.standard": "Standard",
47+
"settings:serviceTier.flex": "Flex",
48+
"settings:serviceTier.priority": "Priority",
49+
}
50+
51+
export const ModelInfoViewFixture = () => (
52+
<TranslationContext.Provider
53+
value={{
54+
t: (key) => translations[key] ?? key,
55+
i18n: null as unknown as typeof import("../../../i18n/setup").default,
56+
}}>
57+
<div className="w-[480px] bg-vscode-editor-background p-4 text-vscode-foreground">
58+
<ModelInfoView
59+
apiProvider={providerIdentifiers.openaiNative}
60+
selectedModelId="gpt-5.2"
61+
modelInfo={modelInfo}
62+
isDescriptionExpanded={false}
63+
setIsDescriptionExpanded={() => {}}
64+
/>
65+
</div>
66+
</TranslationContext.Provider>
67+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from "react"
2+
3+
import { expect, test } from "../../../../playwright/coverage-fixture"
4+
import { ModelInfoViewFixture } from "./ModelInfoView.visual.fixture"
5+
6+
test("renders OpenAI service tier pricing in the VS Code dark theme", async ({ mount }) => {
7+
const component = await mount(<ModelInfoViewFixture />)
8+
9+
await component.evaluate(async () => {
10+
await document.fonts.ready
11+
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))
12+
})
13+
14+
await expect(component).toHaveScreenshot("model-info-service-tier-pricing-dark.png")
15+
})
16.5 KB
Loading

0 commit comments

Comments
 (0)