[E2E] Test: Interactive Terminal (Cmd+K) #9

Open
opened 2026-09-08 04:47:39 +00:00 by rock · 0 comments
Owner

Parent

Ref: #5
Depends on: #6

Objective

Test Interactive Terminal: keyboard shortcut, commands, LLM chat streaming, kubectl exec, resize drag handle.

Components Under Test

  • components/InteractiveTerminal.tsx — Terminal UI, commands, streaming, resize
  • lib/TerminalContext.tsx — Open/close state
  • app/api/chat/route.ts — LLM inference endpoint
  • app/api/exec/route.ts — kubectl execution endpoint

Test Cases

Open/Close (terminal.spec.ts)

  • Terminal hidden by default
  • Cmd+K (Mac) / Ctrl+K (non-Mac) opens terminal
  • Terminal panel visible after open
  • Press Cmd+K again closes terminal
  • "Ask Poimen" header button also opens terminal

Built-in Commands

  • Type help → shows help text with command list
  • Type about → shows Rock Liang bio info
  • Type clear or /clear → clears history
  • Command history displays in scrollable area
  • Input field auto-focuses when terminal opens

LLM Chat (mock API for CI)

  • Type a question → shows loading spinner
  • Response streams in (verify text appears progressively)
  • Thinking section shows if returned by API
  • Markdown rendered in response (react-markdown)
  • Multiple messages in history scroll correctly

Kubectl Execution (mock API for CI)

  • Type ! kubectl get pods → calls /api/exec
  • Non-kubectl commands after ! show error message
  • Response displays in terminal
  • Streaming output works

Resize

  • Resize handle visible at top-left corner
  • Drag resize handle changes terminal width + height
  • Minimum size respected
  • Terminal stays anchored bottom-right during resize
  • Cursor changes to nw-resize during drag

API Mocking Strategy

// Mock /api/chat for CI (no real LLM in test pod)
await page.route('**/api/chat', async route => {
  const body = JSON.stringify({ response: 'Mock LLM response', thinking: 'Mock thinking' })
  await route.fulfill({ status: 200, body, contentType: 'application/json' })
})

// Mock /api/exec for CI (no real kubectl)
await page.route('**/api/exec', async route => {
  await route.fulfill({ status: 200, body: 'NAME  READY  STATUS\npod1  1/1    Running' })
})

Acceptance

  • Keyboard shortcut works on Chromium + Firefox + WebKit
  • Built-in commands return correct output
  • Mocked LLM/kubectl responses render correctly
  • Resize drag changes dimensions (verify via getBoundingClientRect)
## Parent Ref: #5 Depends on: #6 ## Objective Test Interactive Terminal: keyboard shortcut, commands, LLM chat streaming, kubectl exec, resize drag handle. ## Components Under Test - `components/InteractiveTerminal.tsx` — Terminal UI, commands, streaming, resize - `lib/TerminalContext.tsx` — Open/close state - `app/api/chat/route.ts` — LLM inference endpoint - `app/api/exec/route.ts` — kubectl execution endpoint ## Test Cases ### Open/Close (`terminal.spec.ts`) - [ ] Terminal hidden by default - [ ] Cmd+K (Mac) / Ctrl+K (non-Mac) opens terminal - [ ] Terminal panel visible after open - [ ] Press Cmd+K again closes terminal - [ ] "Ask Poimen" header button also opens terminal ### Built-in Commands - [ ] Type `help` → shows help text with command list - [ ] Type `about` → shows Rock Liang bio info - [ ] Type `clear` or `/clear` → clears history - [ ] Command history displays in scrollable area - [ ] Input field auto-focuses when terminal opens ### LLM Chat (mock API for CI) - [ ] Type a question → shows loading spinner - [ ] Response streams in (verify text appears progressively) - [ ] Thinking section shows if returned by API - [ ] Markdown rendered in response (`react-markdown`) - [ ] Multiple messages in history scroll correctly ### Kubectl Execution (mock API for CI) - [ ] Type `! kubectl get pods` → calls /api/exec - [ ] Non-kubectl commands after `!` show error message - [ ] Response displays in terminal - [ ] Streaming output works ### Resize - [ ] Resize handle visible at top-left corner - [ ] Drag resize handle changes terminal width + height - [ ] Minimum size respected - [ ] Terminal stays anchored bottom-right during resize - [ ] Cursor changes to `nw-resize` during drag ## API Mocking Strategy ```ts // Mock /api/chat for CI (no real LLM in test pod) await page.route('**/api/chat', async route => { const body = JSON.stringify({ response: 'Mock LLM response', thinking: 'Mock thinking' }) await route.fulfill({ status: 200, body, contentType: 'application/json' }) }) // Mock /api/exec for CI (no real kubectl) await page.route('**/api/exec', async route => { await route.fulfill({ status: 200, body: 'NAME READY STATUS\npod1 1/1 Running' }) }) ``` ## Acceptance - Keyboard shortcut works on Chromium + Firefox + WebKit - Built-in commands return correct output - Mocked LLM/kubectl responses render correctly - Resize drag changes dimensions (verify via `getBoundingClientRect`)
rock added this to the Functional Testing milestone 2026-09-08 04:55:47 +00:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rock/riotpiao.com#9