You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

3.7 KiB

phase plan status
17-component-tests 8 complete

Summary: Core Modal Component Tests

Completed Tasks

Task 1: Add ModelSearchDialog component tests

Commit: 2cac199

Created comprehensive tests for the ModelSearchDialog component covering:

  • Visibility tests (not rendered when closed, renders when open, modal count registration)
  • Search functionality (search input rendering, debounced search, auto-focus)
  • Provider filter (dropdown, API filtering by provider, initialProvider prop)
  • Capability filter (dropdown, image vs video filtering, initialCapabilityFilter prop)
  • Model card rendering (name, description, provider badges, capability badges, model count)
  • Model selection behavior:
    • Callback mode calls onModelSelected
    • Create node mode calls addNode with correct node type
    • Video models create generateVideo nodes
  • Close behavior (close button, Escape key, backdrop click, click inside doesn't close)
  • Loading state (spinner, loading text)
  • Error state (error message, Try Again button, refetch on retry)
  • Empty state (no models message)
  • API headers (includes provider API keys)

Tests: 31

Task 2: Add ProjectSetupModal and CostDialog tests

Commit: c5c2171

ProjectSetupModal.test.tsx:

  • Visibility tests (not rendered when closed, renders with correct title for mode)
  • Tab navigation (Project/Providers tabs, starts on Project tab)
  • New Project mode (empty form, Create button)
  • Settings mode (pre-filled form, Save button)
  • Form validation:
    • Project name required error
    • Project directory required error
    • Directory does not exist error
    • Path is not a directory error
  • Save behavior:
    • Calls onSave with project details when valid
    • Shows "Validating..." during directory validation
    • Updates external storage setting
  • Browse button functionality:
    • Calls browse-directory API
    • Updates directory input on selection
    • Shows "..." while browsing
    • Handles cancelled dialog
  • Keyboard shortcuts (Escape closes, Enter submits)
  • Providers tab:
    • Renders all provider sections (Gemini, OpenAI, Replicate, fal.ai)
    • Shows API key inputs with placeholders
    • Shows "Configured via .env" for env-configured providers
    • Shows Override button for env-configured providers
    • Toggle Show/Hide for API key visibility
    • Save closes modal

Tests: 33

CostDialog.test.tsx:

  • Basic rendering (title, close button, sections)
  • Predicted Cost and Incurred Cost sections
  • Pricing Reference section
  • Cost display formatting ($0.00, formatted values)
  • Per-model cost breakdown rows
  • Resolution display for Nano Banana Pro
  • Subtotal display for each model type
  • Empty state (no generation nodes message)
  • Reset costs button:
    • Not shown when incurredCost is 0
    • Shown when incurredCost > 0
    • Shows confirmation dialog
    • Calls resetIncurredCost when confirmed
    • Doesn't call when cancelled
  • Close behavior (button click, Escape key)
  • Pricing reference display (all tiers, currency note)

Tests: 24

Files Created/Modified

  • /src/components/__tests__/ModelSearchDialog.test.tsx (704 lines) - NEW
  • /src/components/__tests__/ProjectSetupModal.test.tsx (929 lines) - NEW
  • /src/components/__tests__/CostDialog.test.tsx (347 lines) - NEW

Verification Results

  • npm test -- --run passes all tests (731 tests)
  • npm run build succeeds without errors
  • ModelSearchDialog search and filter logic tested
  • ProjectSetupModal form validation tested

Test Count

  • New tests added: 88 (31 + 33 + 24)
  • Total project tests: 731

Deviations

None. All tasks completed as planned.

Commit History

  1. 2cac199 - test(17-08): add ModelSearchDialog component tests
  2. c5c2171 - test(17-08): add ProjectSetupModal and CostDialog tests