|
| 1 | +## App E2E Smoke Suite (CI) |
| 2 | + |
| 3 | +Implement a small set of high-signal, low-flake Playwright tests to run in CI. |
| 4 | + |
| 5 | +These tests are intended to catch regressions in the “core shell” of the app (navigation, dialogs, prompt UX, file viewer, terminal), without relying on model output. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +### Summary |
| 10 | + |
| 11 | +Add 6 smoke tests to `packages/app/e2e/`: |
| 12 | + |
| 13 | +- Settings dialog: open, switch tabs, close |
| 14 | +- Prompt slash command: `/open` opens the file picker dialog |
| 15 | +- Prompt @mention: `@<file>` inserts a file pill token |
| 16 | +- Model picker: open model selection and choose a model |
| 17 | +- File viewer: open a known file and assert contents render |
| 18 | +- Terminal: open terminal, verify Ghostty mounts, create a second terminal |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +### Progress |
| 23 | + |
| 24 | +- [x] 1. Settings dialog open / switch / close (`packages/app/e2e/settings.spec.ts`) |
| 25 | +- [ ] 2. Prompt slash command path: `/open` opens file picker |
| 26 | +- [ ] 3. Prompt @mention inserts a file pill token |
| 27 | +- [ ] 4. Model selection UI works end-to-end |
| 28 | +- [ ] 5. File viewer renders real file content |
| 29 | +- [ ] 8. Terminal init + create new terminal |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +### Goals |
| 34 | + |
| 35 | +- Tests run reliably in CI using the existing local runner (`packages/app/script/e2e-local.ts`). |
| 36 | +- Cover “wiring” regressions across UI + backend APIs: |
| 37 | + - dialogs + command routing |
| 38 | + - prompt contenteditable parsing |
| 39 | + - file search + file read + code viewer render |
| 40 | + - terminal open + pty creation + Ghostty mount |
| 41 | +- Avoid assertions that depend on LLM output. |
| 42 | +- Keep runtime low (these should be “smoke”, not full workflows). |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +### Non-goals |
| 47 | + |
| 48 | +- Verifying complex model behavior, streaming correctness, or tool call semantics. |
| 49 | +- Testing provider auth flows (CI has no secrets). |
| 50 | +- Testing share, MCP, or LSP download flows (disabled in the e2e runner). |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +### Current State |
| 55 | + |
| 56 | +Existing tests in `packages/app/e2e/` already cover: |
| 57 | + |
| 58 | +- Home renders + server picker opens |
| 59 | +- Directory route redirects to `/session` |
| 60 | +- Sidebar collapse/expand |
| 61 | +- Command palette opens/closes |
| 62 | +- Basic session open + prompt input + (optional) prompt/reply flow |
| 63 | +- File open via palette (but shallow assertion: tab exists) |
| 64 | +- Terminal panel toggles (but doesn’t assert Ghostty mounted) |
| 65 | +- Context panel open |
| 66 | + |
| 67 | +We want to add a focused smoke layer that increases coverage of the most regression-prone UI paths. |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +### Proposed Tests |
| 72 | + |
| 73 | +All tests should use the shared fixtures in: |
| 74 | + |
| 75 | +- `packages/app/e2e/fixtures.ts` (for `sdk`, `directory`, `gotoSession`) |
| 76 | +- `packages/app/e2e/utils.ts` (for `modKey`, `promptSelector`, `terminalToggleKey`) |
| 77 | + |
| 78 | +Prefer creating new spec files rather than overloading existing ones, so it’s easy to run these tests as a group via grep. |
| 79 | + |
| 80 | +Suggested file layout: |
| 81 | + |
| 82 | +- `packages/app/e2e/settings.spec.ts` |
| 83 | +- `packages/app/e2e/prompt-slash-open.spec.ts` |
| 84 | +- `packages/app/e2e/prompt-mention.spec.ts` |
| 85 | +- `packages/app/e2e/model-picker.spec.ts` |
| 86 | +- `packages/app/e2e/file-viewer.spec.ts` |
| 87 | +- `packages/app/e2e/terminal-init.spec.ts` |
| 88 | + |
| 89 | +Name each test with a “smoke” prefix so CI can run only this suite if needed. |
| 90 | + |
| 91 | +#### 1) Settings dialog open / switch / close |
| 92 | + |
| 93 | +Purpose: catch regressions in dialog infra, settings rendering, tabs. |
| 94 | + |
| 95 | +Steps: |
| 96 | + |
| 97 | +1. `await gotoSession()`. |
| 98 | +2. Open settings via keybind (preferred for stability): `await page.keyboard.press(`${modKey}+Comma`)`. |
| 99 | +3. Assert dialog visible (`page.getByRole('dialog')`). |
| 100 | +4. Click the "Shortcuts" tab (role `tab`, name "Shortcuts"). |
| 101 | +5. Assert shortcuts view renders (e.g. the search field placeholder or reset button exists). |
| 102 | +6. Close with `Escape` and assert dialog removed. |
| 103 | + |
| 104 | +Notes: |
| 105 | + |
| 106 | +- If `Meta+Comma` / `Control+Comma` key name is flaky, fall back to clicking the sidebar settings icon. |
| 107 | +- Favor role-based selectors over brittle class selectors. |
| 108 | +- If `Escape` doesn’t dismiss reliably (tooltips can intercept), fall back to clicking the dialog overlay. |
| 109 | + |
| 110 | +Implementation: `packages/app/e2e/settings.spec.ts` |
| 111 | + |
| 112 | +Acceptance criteria: |
| 113 | + |
| 114 | +- Settings dialog opens reliably. |
| 115 | +- Switching to Shortcuts tab works. |
| 116 | +- Escape closes the dialog. |
| 117 | + |
| 118 | +#### 2) Prompt slash command path: `/open` opens file picker |
| 119 | + |
| 120 | +Purpose: validate contenteditable parsing + slash popover + builtin command dispatch (distinct from `mod+p`). |
| 121 | + |
| 122 | +Steps: |
| 123 | + |
| 124 | +1. `await gotoSession()`. |
| 125 | +2. Click prompt (`promptSelector`). |
| 126 | +3. Type `/open`. |
| 127 | +4. Press `Enter` (while slash popover is active). |
| 128 | +5. Assert a dialog appears and contains a textbox (the file picker search input). |
| 129 | +6. Close dialog with `Escape`. |
| 130 | + |
| 131 | +Acceptance criteria: |
| 132 | + |
| 133 | +- `/open` triggers `file.open` and opens `DialogSelectFile`. |
| 134 | + |
| 135 | +#### 3) Prompt @mention inserts a file pill token |
| 136 | + |
| 137 | +Purpose: validate the most fragile prompt behavior: structured tokens inside contenteditable. |
| 138 | + |
| 139 | +Steps: |
| 140 | + |
| 141 | +1. `await gotoSession()`. |
| 142 | +2. Focus the prompt. |
| 143 | +3. Type `@packages/app/package.json`. |
| 144 | +4. Press `Tab` to accept the active @mention suggestion. |
| 145 | +5. Assert a pill element is inserted: |
| 146 | + - `page.locator('[data-component="prompt-input"] [data-type="file"][data-path="packages/app/package.json"]')` exists. |
| 147 | + |
| 148 | +Acceptance criteria: |
| 149 | + |
| 150 | +- A file pill is inserted and has the expected `data-*` attributes. |
| 151 | +- Prompt editor remains interactable (e.g. typing a trailing space works). |
| 152 | + |
| 153 | +#### 4) Model selection UI works end-to-end |
| 154 | + |
| 155 | +Purpose: validate model list rendering, selection wiring, and prompt footer updating. |
| 156 | + |
| 157 | +Implementation approach: |
| 158 | + |
| 159 | +- Use `/model` to open the model selection dialog (builtin command). |
| 160 | + |
| 161 | +Steps: |
| 162 | + |
| 163 | +1. `await gotoSession()`. |
| 164 | +2. Focus prompt, type `/model`, press `Enter`. |
| 165 | +3. In the model dialog, use the search field to filter to a deterministic model, e.g. `qwen3-coder`. |
| 166 | +4. Select the first matching model. |
| 167 | +5. Assert dialog closed. |
| 168 | +6. Assert the prompt footer now shows the chosen model name. |
| 169 | + |
| 170 | +Acceptance criteria: |
| 171 | + |
| 172 | +- A model can be selected without requiring provider auth. |
| 173 | +- The prompt footer reflects the new selection. |
| 174 | + |
| 175 | +#### 5) File viewer renders real file content |
| 176 | + |
| 177 | +Purpose: ensure file search + open + file.read + code viewer render all work. |
| 178 | + |
| 179 | +Steps: |
| 180 | + |
| 181 | +1. `await gotoSession()`. |
| 182 | +2. Open file picker (either `mod+p` or `/open`). |
| 183 | +3. Search for `packages/app/package.json`. |
| 184 | +4. Click the matching file result. |
| 185 | +5. Assert the code viewer contains a known substring: |
| 186 | + - `"name": "@opencode-ai/app"`. |
| 187 | +6. Optionally assert the file tab is active and visible. |
| 188 | + |
| 189 | +Acceptance criteria: |
| 190 | + |
| 191 | +- Code view shows expected content (not just “tab exists”). |
| 192 | + |
| 193 | +#### 8) Terminal init + create new terminal |
| 194 | + |
| 195 | +Purpose: ensure terminal isn’t only “visible”, but actually mounted and functional. |
| 196 | + |
| 197 | +Steps: |
| 198 | + |
| 199 | +1. `await gotoSession()`. |
| 200 | +2. Open terminal with `terminalToggleKey` (currently `Control+Backquote`). |
| 201 | +3. Assert terminal container exists and is visible: `[data-component="terminal"]`. |
| 202 | +4. Assert Ghostty textarea exists: `[data-component="terminal"] textarea`. |
| 203 | +5. Create a new terminal via keybind (`terminal.new` is `ctrl+alt+t`). |
| 204 | +6. Assert terminal tab count increases to 2. |
| 205 | + |
| 206 | +Acceptance criteria: |
| 207 | + |
| 208 | +- Ghostty mounts (textarea present). |
| 209 | +- Creating a new terminal results in a second tab. |
| 210 | + |
| 211 | +--- |
| 212 | + |
| 213 | +### CI Stability + Flake Avoidance |
| 214 | + |
| 215 | +These tests run with `fullyParallel: true` in `packages/app/playwright.config.ts`. Keep them isolated and deterministic. |
| 216 | + |
| 217 | +- Avoid ordering-based assertions: never assume a “first” session/project/file is stable unless you filtered by unique text. |
| 218 | +- Prefer deterministic targets: |
| 219 | + - use `packages/app/package.json` rather than bare `package.json` (multiple hits possible) |
| 220 | + - filter model search to a specific id/name (e.g. `qwen3-coder`) |
| 221 | +- Prefer robust selectors: |
| 222 | + - role selectors: `getByRole('dialog')`, `getByRole('textbox')`, `getByRole('tab')` |
| 223 | + - stable data attributes already present: `promptSelector`, `[data-component="terminal"]` |
| 224 | +- Keep tests local and fast: |
| 225 | + - do not submit prompts that require real model replies |
| 226 | + - avoid `page.waitForTimeout`; use `expect(...).toBeVisible()` and `expect.poll` when needed |
| 227 | +- Watch for silent UI failures: |
| 228 | + - capture `page.on('pageerror')` and fail test if any are emitted |
| 229 | + - optionally capture console errors (`page.on('console', ...)`) and fail on `type==='error'` |
| 230 | +- Cleanup: |
| 231 | + - these tests should not need to create sessions |
| 232 | + - if a test ever creates sessions or PTYs directly, clean up with SDK calls in `finally` |
| 233 | + |
| 234 | +--- |
| 235 | + |
| 236 | +### Validation Plan |
| 237 | + |
| 238 | +Run locally: |
| 239 | + |
| 240 | +- `cd packages/app` |
| 241 | +- `bun run test:e2e:local -- --grep smoke` |
| 242 | + |
| 243 | +Verify: |
| 244 | + |
| 245 | +- all new tests pass consistently across multiple runs |
| 246 | +- overall e2e suite time does not increase significantly |
| 247 | + |
| 248 | +--- |
| 249 | + |
| 250 | +### Open Questions |
| 251 | + |
| 252 | +- Should we add a small helper in `packages/app/e2e/utils.ts` for “type into prompt contenteditable” to reduce duplication? |
| 253 | +- Do we want to gate these smoke tests with a dedicated `@smoke` naming convention (or `test.describe('smoke', ...)`) so CI can target them explicitly? |