|
1 | 1 | import React from "react" |
2 | 2 |
|
| 3 | +import { OpenAiCodexServiceTier } from "@roo-code/types/model" |
| 4 | + |
3 | 5 | import { expect, test } from "../../../../../playwright/coverage-fixture" |
4 | 6 | import { OpenAICodexFixture } from "./OpenAICodex.visual.fixture" |
5 | 7 |
|
6 | | -test("renders the OpenAI Codex speed selector in the VS Code dark theme", async ({ mount }) => { |
7 | | - const component = await mount(<OpenAICodexFixture />) |
8 | | - const selector = component.getByTestId("openai-codex-service-tier") |
| 8 | +const themes = [ |
| 9 | + { |
| 10 | + name: "dark", |
| 11 | + bodyClass: "vscode-dark", |
| 12 | + themeId: "Default Dark Modern", |
| 13 | + editorBackground: "#1e1e1e", |
| 14 | + dropdownBackground: "#3c3c3c", |
| 15 | + triggerBackground: "rgb(60, 60, 60)", |
| 16 | + }, |
| 17 | + { |
| 18 | + name: "light", |
| 19 | + bodyClass: "vscode-light", |
| 20 | + themeId: "Default Light Modern", |
| 21 | + editorBackground: "#ffffff", |
| 22 | + dropdownBackground: "#ffffff", |
| 23 | + triggerBackground: "rgb(255, 255, 255)", |
| 24 | + }, |
| 25 | +] as const |
| 26 | + |
| 27 | +const tiers = [ |
| 28 | + { name: "standard", value: OpenAiCodexServiceTier.Default }, |
| 29 | + { name: "priority", value: OpenAiCodexServiceTier.Priority }, |
| 30 | +] as const |
| 31 | + |
| 32 | +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") |
| 37 | + |
| 38 | + await selector.evaluate((element, { bodyClass, themeId }) => { |
| 39 | + const { document } = element.ownerDocument.defaultView! |
| 40 | + |
| 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")! |
| 51 | + |
| 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 | + }) |
9 | 68 |
|
10 | | - await selector.evaluate(async () => { |
11 | | - await document.fonts.ready |
12 | | - await new Promise<void>((resolve) => requestAnimationFrame(() => resolve())) |
13 | | - }) |
| 69 | + await selector.evaluate(async () => { |
| 70 | + await document.fonts.ready |
| 71 | + await new Promise<void>((resolve) => requestAnimationFrame(() => resolve())) |
| 72 | + }) |
14 | 73 |
|
15 | | - await expect(selector).toHaveScreenshot("openai-codex-speed-selector-dark.png") |
16 | | -}) |
| 74 | + await expect(selector).toHaveScreenshot(`openai-codex-speed-selector-${tier.name}-${theme.name}.png`) |
| 75 | + }) |
| 76 | + } |
| 77 | +} |
0 commit comments