Skip to content

test: SchemaTree mock leak and a test that can't fail #890

Closed

Description

@EVWorth

Two test-hygiene problems:

  1. A mock leaks between tests. In src/components/schema/__tests__/SchemaTree.test.tsx, the "shows a table's DDL…" test (around line 691) calls useResultStore.setState({ executeQuery }) with a mock and never restores it. Every later test in the file runs against that mock, so a test that depends on the real executeQuery can pass or fail depending on file order.
  2. A test that always passes. src/components/designer/__tests__/TableDesigner.test.tsx:123 assigns initialCount and never uses it (this is the lint warning 'initialCount' is assigned a value but never used). The assertion is >= 0, which can't fail, so the test checks nothing.

Reproduce

npx eslint src/components/designer/__tests__/TableDesigner.test.tsx
grep -n "useResultStore.setState" src/components/schema/__tests__/SchemaTree.test.tsx

Fix

  1. Capture useResultStore.getState() in a beforeEach and restore it in afterEach, or set the mock with vi.spyOn and restore it with vi.restoreAllMocks().
  2. Make the TableDesigner test assert the count it means to check, likely initialCount + 1 after the add. If it duplicates another test, delete it.

#867 (resultStore run bookkeeping leaks between tests) is the same kind of problem; fix them together if convenient.

Activity

  1. added
    bug
    on Oct 24, 2026
  2. added a commit that references this issue on Oct 25, 2026
    eda1da9
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions