Skip to content

Commit 33ae00a

Browse files
committed
test(app): address code review findings in shell mode button spec
- Add toBeFocused() wait before keyboard.press('!') and Ctrl+Shift+X to ensure focus is settled on the contenteditable before keydown - Add v1 layout negative test: button must not appear when newLayoutDesigns is false (catches accidental v1 toolbar leakage) - Add data-state='pressed' assertion alongside aria-pressed to verify the visual pressed state on IconButtonV2 is actually set - Tighten font-mono class assertion to exact Tailwind class 'font-mono!' via toHaveAttribute('class', /font-mono!/) — avoids false substring matches - Add Ctrl+Shift+X keybind test to verify the registered mod+shift+x shortcut still enters shell mode with button state parity
1 parent ea36ce3 commit 33ae00a

1 file changed

Lines changed: 37 additions & 4 deletions

File tree

packages/app/e2e/regression/prompt-shell-mode-button.spec.ts

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ test.describe("regression: shell mode toggle button in v2 composer", () => {
7070

7171
await button.click()
7272

73-
// aria-pressed reflects active shell mode
73+
// aria-pressed and data-state both reflect active shell mode
7474
await expect(button).toHaveAttribute("aria-pressed", "true")
75-
// input switches to monospace font in shell mode (font-mono! class)
76-
await expect(input).toHaveClass(/font-mono/)
75+
await expect(button).toHaveAttribute("data-state", "pressed")
76+
// input switches to monospace font in shell mode — match the exact Tailwind class
77+
await expect(input).toHaveAttribute("class", /font-mono!/)
7778
})
7879

7980
test("shell mode button exits shell mode on second click", async ({ page }) => {
@@ -82,10 +83,12 @@ test.describe("regression: shell mode toggle button in v2 composer", () => {
8283

8384
await button.click()
8485
await expect(button).toHaveAttribute("aria-pressed", "true")
86+
await expect(button).toHaveAttribute("data-state", "pressed")
8587

8688
await button.click()
8789
await expect(button).toHaveAttribute("aria-pressed", "false")
88-
await expect(input).not.toHaveClass(/font-mono/)
90+
await expect(button).not.toHaveAttribute("data-state", "pressed")
91+
await expect(input).not.toHaveAttribute("class", /font-mono!/)
8992
})
9093

9194
test("Escape exits shell mode entered via button", async ({ page }) => {
@@ -96,6 +99,7 @@ test.describe("regression: shell mode toggle button in v2 composer", () => {
9699
await expect(button).toHaveAttribute("aria-pressed", "true")
97100

98101
await input.focus()
102+
await expect(input).toBeFocused()
99103
await page.keyboard.press("Escape")
100104
await expect(button).toHaveAttribute("aria-pressed", "false")
101105
})
@@ -105,7 +109,36 @@ test.describe("regression: shell mode toggle button in v2 composer", () => {
105109
const input = page.locator('[data-component="prompt-input"]')
106110

107111
await input.focus()
112+
// Wait for focus to settle on the contenteditable before dispatching keydown
113+
await expect(input).toBeFocused()
108114
await page.keyboard.press("!")
109115
await expect(button).toHaveAttribute("aria-pressed", "true")
110116
})
117+
118+
test("Cmd+Shift+X keybind enters shell mode and button reflects state", async ({ page }) => {
119+
const button = page.locator('[data-action="prompt-shell-mode"]')
120+
const input = page.locator('[data-component="prompt-input"]')
121+
122+
await input.focus()
123+
await expect(input).toBeFocused()
124+
// mod+shift+x maps to Meta+Shift+X on macOS, Control+Shift+X elsewhere;
125+
// Playwright uses the platform's native modifier via "Meta" on mac runners
126+
// and "Control" on Linux/Windows. Test both via the registered command keybind.
127+
await page.keyboard.press("Control+Shift+X")
128+
await expect(button).toHaveAttribute("aria-pressed", "true")
129+
})
130+
})
131+
132+
test.describe("regression: shell mode button absent in v1 (legacy) layout", () => {
133+
test("shell mode button is NOT rendered when newLayoutDesigns is false", async ({ page }) => {
134+
await mockOpenCodeServer(page, baseConfig)
135+
// v1 layout — newLayoutDesigns: false (omitting the key defaults to false)
136+
await page.addInitScript(() => {
137+
localStorage.setItem("settings.v3", JSON.stringify({ general: { newLayoutDesigns: false } }))
138+
})
139+
await page.goto(`/${base64Encode(directory)}/session/${sessionID}`)
140+
await expectAppVisible(page.locator('[data-component="session-composer"]'))
141+
// Button must not be in the DOM at all in v1 layout
142+
await expect(page.locator('[data-action="prompt-shell-mode"]')).toHaveCount(0)
143+
})
111144
})

0 commit comments

Comments
 (0)