Skip to content

Commit 5689144

Browse files
committed
test(webview): add visual snapshot for OpenCode Go temperature visibility (#2055)
1 parent a71496d commit 5689144

4 files changed

Lines changed: 76 additions & 0 deletions

File tree

‎webview-ui/playwright/gallery/stories.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ export const stories: Record<string, Story> = {
275275
await import("@/components/settings/providers/__tests__/OpenAICompatible.visual.fixture")
276276
return <OpenAICompatibleExtraBodyFixture />
277277
},
278+
"opencode-go-temperature": async () => {
279+
const { OpencodeGoTemperatureFixture } =
280+
await import("@/components/settings/__tests__/OpencodeGoTemperature.visual.fixture")
281+
return <OpencodeGoTemperatureFixture />
282+
},
278283
"rendered-content-contrast": async () => {
279284
const [{ AppProviders }, { RenderedContentContrastFixture }] = await Promise.all([
280285
import("../AppProviders"),
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React from "react"
2+
3+
import { type ProviderSettings, opencodeGoModels, providerIdentifiers } from "@roo-code/types"
4+
5+
import { TemperatureControl } from "../TemperatureControl"
6+
import { isTemperatureControlSupported } from "../utils/temperatureSupport"
7+
import { AppProviders } from "../../../../playwright/AppProviders"
8+
9+
const SAVED_TEMPERATURE = 0.42
10+
11+
const cases: { modelId: string; reasoningEffort: ProviderSettings["reasoningEffort"] }[] = [
12+
{ modelId: "gpt-6-luna", reasoningEffort: "none" },
13+
{ modelId: "gpt-6-luna", reasoningEffort: "high" },
14+
{ modelId: "grok-4.6", reasoningEffort: "high" },
15+
]
16+
17+
/**
18+
* Renders the temperature control through the same gate ApiOptions uses, for
19+
* supported and unsupported OpenCode Go Responses states (#2055). Each case has
20+
* a saved custom temperature, so a hidden control shows the value is kept but
21+
* not offered.
22+
*/
23+
export function OpencodeGoTemperatureFixture() {
24+
return (
25+
<AppProviders>
26+
<div
27+
className="w-[480px] p-4 flex flex-col gap-4 bg-vscode-editor-background text-vscode-foreground"
28+
data-testid="opencode-go-temperature-story">
29+
{cases.map(({ modelId, reasoningEffort }) => {
30+
const apiConfiguration: ProviderSettings = {
31+
apiProvider: providerIdentifiers.opencodeGo,
32+
opencodeGoModelId: modelId,
33+
reasoningEffort,
34+
modelTemperature: SAVED_TEMPERATURE,
35+
}
36+
const supported = isTemperatureControlSupported({
37+
provider: providerIdentifiers.opencodeGo,
38+
modelId,
39+
modelInfo: opencodeGoModels[modelId],
40+
apiConfiguration,
41+
})
42+
return (
43+
<section key={`${modelId}-${reasoningEffort}`} className="flex flex-col gap-2">
44+
<h3 className="m-0 text-sm font-medium">
45+
{modelId} · reasoning effort {reasoningEffort}
46+
</h3>
47+
{supported ? (
48+
<TemperatureControl
49+
value={apiConfiguration.modelTemperature}
50+
onChange={() => undefined}
51+
maxValue={2}
52+
/>
53+
) : (
54+
<p className="m-0 text-vscode-descriptionForeground">Temperature control hidden</p>
55+
)}
56+
</section>
57+
)
58+
})}
59+
</div>
60+
</AppProviders>
61+
)
62+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { expect, test } from "../../../../playwright/coverage-fixture"
2+
import { mountedStory } from "../../../../playwright/mounted-story"
3+
4+
test("shows the temperature control only for supported OpenCode Go Responses states", async ({ mount }) => {
5+
const component = mountedStory(await mount("opencode-go-temperature"))
6+
const story = component.getByTestId("opencode-go-temperature-story")
7+
8+
await expect(story).toHaveScreenshot("opencode-go-temperature.png")
9+
})
24.4 KB
Loading

0 commit comments

Comments
 (0)