Skip to content

Cover the AI chat, tools and tree actions, then raise coverage thresholds #58

Backlog

Description

@vadim9999

Problem

Follow-up to #57. After #57, thresholds still sit right at the current coverage, and four files hold most of the untested logic. Numbers are from master after #56:

File Stmts Branch Funcs What is not tested
src/editor/Main/Chat/ChatPanel.tsx 70.24 75.67 51.61 Confirming a tool action (approve, decline, Stop while the confirm is open), Stop, Clear, Enter vs Shift+Enter, changing settings (provider/model/key), timeout error text
src/ai/tools.ts 79.1 69.36 80 create_element, update_element, delete_element (lines 534–589): success, "not found", user declines; plus single uncovered branches at 197–344, 457–516
src/editor/Main/TemplateTree/TemplateTree.tsx 87.5 64.28 85.71 Add node when the picked element no longer exists (86–89), cancel of the add/edit modals (115, 119)
src/ai/providers.ts 75 66.66 75 fetchWithTimeout (70–73): aborts after REQUEST_TIMEOUT_MS, keeps the caller's signal; createModel for each provider (Anthropic sends anthropic-dangerous-direct-browser-access)

These are the parts users touch most (the AI chat and its tools). A regression there passes CI today.

Proposal

One PR per row, so each stays small and reviewable. Each PR:

  1. Adds the tests for that file. Mock the API with vi.mock("@/api/main", …), and for fetchWithTimeout use fake timers. No network.
  2. Raises coverage.thresholds in vitest.config.mts to the new measured values, rounded down. No threshold goes down.

Acceptance criteria

  • ChatPanel.tsx: confirm, Stop, Clear, keyboard and settings flows tested
  • tools.ts: element tools tested, including "not found" and the declined deletion
  • TemplateTree.tsx: missing element and modal cancel tested
  • providers.ts: timeout and createModel tested
  • Final thresholds are at least functions 85 and branches 80, with npm run test:coverage green

Area

Tests (Vitest, coverage thresholds)

Out of scope

  • Changing behavior. If a test finds a bug, open a separate issue/PR for the fix.
  • E2E (Playwright) coverage.

Depends on #57 (merge it first so the threshold changes do not conflict).

Activity

  1. added
    enhancement
    on Nov 24, 2026
  2. vadim9999 commented on Nov 26, 2026

    @vadim9999
    ContributorAuthor

    Found while reviewing #55: AddElementForm loads the elements without error handling, so a failed request leaves the select empty with no message. It is a behavior fix, so per the scope of this issue it is tracked separately in #59. A test for it there also adds coverage for AddElementForm.tsx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions