Skip to content

Commit 4ca5f3e

Browse files
committed
test(webview): combine codex speed snapshots
1 parent 0c7b0f9 commit 4ca5f3e

8 files changed

Lines changed: 43 additions & 56 deletions

webview-ui/src/components/settings/providers/__tests__/OpenAICodex.visual.fixture.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
/* v8 ignore file -- Playwright component fixture is covered by the visual test. */
22
import React from "react"
33

4-
import {
5-
OpenAiCodexServiceTier,
6-
type OpenAiCodexServiceTier as OpenAiCodexServiceTierValue,
7-
} from "@roo-code/types/model"
4+
import { OpenAiCodexServiceTier } from "@roo-code/types/model"
85

96
import { TranslationContext } from "@src/i18n/TranslationContext"
107
import { TooltipProvider } from "@src/components/ui/tooltip"
@@ -19,19 +16,16 @@ const translations: Record<string, string> = {
1916
"settings:openAiCodexSpeed.fast": "Fast (1.5x speed, increased usage)",
2017
}
2118

22-
interface OpenAICodexFixtureProps {
23-
value?: OpenAiCodexServiceTierValue
24-
}
25-
26-
export const OpenAICodexFixture = ({ value = OpenAiCodexServiceTier.Default }: OpenAICodexFixtureProps) => (
19+
export const OpenAICodexFixture = () => (
2720
<TranslationContext.Provider
2821
value={{
2922
t: (key) => translations[key] ?? key,
3023
i18n: null as unknown as typeof import("../../../../i18n/setup").default,
3124
}}>
3225
<TooltipProvider>
33-
<div className="w-[480px] bg-vscode-editor-background p-4 text-vscode-foreground">
34-
<OpenAICodexSpeedSelector value={value} onValueChange={() => {}} />
26+
<div className="flex w-[480px] flex-col gap-4 bg-vscode-editor-background p-4 text-vscode-foreground">
27+
<OpenAICodexSpeedSelector value={OpenAiCodexServiceTier.Default} onValueChange={() => {}} />
28+
<OpenAICodexSpeedSelector value={OpenAiCodexServiceTier.Priority} onValueChange={() => {}} />
3529
</div>
3630
</TooltipProvider>
3731
</TranslationContext.Provider>
Lines changed: 38 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React from "react"
22

3-
import { OpenAiCodexServiceTier } from "@roo-code/types/model"
4-
53
import { expect, test } from "../../../../../playwright/coverage-fixture"
64
import { OpenAICodexFixture } from "./OpenAICodex.visual.fixture"
75

@@ -24,54 +22,49 @@ const themes = [
2422
},
2523
] as const
2624

27-
const tiers = [
28-
{ name: "standard", value: OpenAiCodexServiceTier.Default },
29-
{ name: "priority", value: OpenAiCodexServiceTier.Priority },
30-
] as const
31-
3225
for (const theme of themes) {
33-
for (const tier of tiers) {
34-
test(`renders the ${tier.name} OpenAI Codex speed in the VS Code ${theme.name} theme`, async ({ mount }) => {
35-
const component = await mount(<OpenAICodexFixture value={tier.value} />)
36-
const selector = component.getByTestId("openai-codex-service-tier")
26+
test(`renders both OpenAI Codex speeds in the VS Code ${theme.name} theme`, async ({ mount }) => {
27+
const component = await mount(<OpenAICodexFixture />)
28+
const selectors = component.getByTestId("openai-codex-service-tier")
29+
const selector = selectors.first()
3730

38-
await selector.evaluate((element, { bodyClass, themeId }) => {
39-
const { document } = element.ownerDocument.defaultView!
31+
await expect(selectors).toHaveCount(2)
32+
await selector.evaluate((element, { bodyClass, themeId }) => {
33+
const { document } = element.ownerDocument.defaultView!
4034

41-
document.documentElement.className = bodyClass
42-
document.body.className = bodyClass
43-
document.body.dataset.vscodeThemeId = themeId
44-
}, theme)
45-
await expect
46-
.poll(() =>
47-
selector.evaluate((element) => {
48-
const body = element.ownerDocument.body
49-
const styles = getComputedStyle(body)
50-
const trigger = element.querySelector("button")!
35+
document.documentElement.className = bodyClass
36+
document.body.className = bodyClass
37+
document.body.dataset.vscodeThemeId = themeId
38+
}, theme)
39+
await expect
40+
.poll(() =>
41+
selector.evaluate((element) => {
42+
const body = element.ownerDocument.body
43+
const styles = getComputedStyle(body)
44+
const trigger = element.querySelector("button")!
5145

52-
return {
53-
documentClass: element.ownerDocument.documentElement.className,
54-
bodyClass: body.className,
55-
editorBackground: styles.getPropertyValue("--vscode-editor-background").trim(),
56-
dropdownBackground: styles.getPropertyValue("--vscode-dropdown-background").trim(),
57-
triggerBackground: getComputedStyle(trigger).backgroundColor,
58-
}
59-
}),
60-
)
61-
.toEqual({
62-
documentClass: theme.bodyClass,
63-
bodyClass: theme.bodyClass,
64-
editorBackground: theme.editorBackground,
65-
dropdownBackground: theme.dropdownBackground,
66-
triggerBackground: theme.triggerBackground,
67-
})
68-
69-
await selector.evaluate(async () => {
70-
await document.fonts.ready
71-
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))
46+
return {
47+
documentClass: element.ownerDocument.documentElement.className,
48+
bodyClass: body.className,
49+
editorBackground: styles.getPropertyValue("--vscode-editor-background").trim(),
50+
dropdownBackground: styles.getPropertyValue("--vscode-dropdown-background").trim(),
51+
triggerBackground: getComputedStyle(trigger).backgroundColor,
52+
}
53+
}),
54+
)
55+
.toEqual({
56+
documentClass: theme.bodyClass,
57+
bodyClass: theme.bodyClass,
58+
editorBackground: theme.editorBackground,
59+
dropdownBackground: theme.dropdownBackground,
60+
triggerBackground: theme.triggerBackground,
7261
})
7362

74-
await expect(selector).toHaveScreenshot(`openai-codex-speed-selector-${tier.name}-${theme.name}.png`)
63+
await component.evaluate(async () => {
64+
await document.fonts.ready
65+
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))
7566
})
76-
}
67+
68+
await expect(component).toHaveScreenshot(`openai-codex-speed-selector-states-${theme.name}.png`)
69+
})
7770
}
8.02 KB
Loading
7.67 KB
Loading

0 commit comments

Comments
 (0)