Skip to content

test: cover Find, ConnectionGeneralTab, and session-hook error paths#131

Merged
nkcoder merged 2 commits into
mainfrom
test/improve-coverage-post-refactor
Jul 4, 2026
Merged

test: cover Find, ConnectionGeneralTab, and session-hook error paths#131
nkcoder merged 2 commits into
mainfrom
test/improve-coverage-post-refactor

Conversation

@nkcoder

@nkcoder nkcoder commented Jul 4, 2026

Copy link
Copy Markdown
Owner

What

Fills test-coverage gaps surfaced while regression-testing the #127#130 refactor, and replaces the flat issue-#51 coverage threshold with a two-tier gate. Tests + config only — no production code changed.

Tests added (28 unit + 4 e2e)

File Gap closed
e2e/query-editor-find.spec.ts In-editor Find (Cmd+F) had no e2e after the #128 QueryEditor/FindBar split — open/focus/close, match count, next/prev, clear-resets.
ConnectionGeneralTab.test.tsx The #129-extracted tab had no test (40% func) — field edits, port coercion, password mask/reveal, isEdit placeholder, derived URL.
useSidebarTree.test.ts (new) The hook had no direct test — live-load error branches (columns/sub-folder failures), toggleColumnsFolder guard + toggle, each sub-folder loader, close-without-reload.
useQueryExecution.test.ts Non-result-set (DDL) rows-affected path; error leaves a pinned tab intact; double-pin preserves the first; close a non-active tab.
useDatasourceSession.test.ts GetCompletions failure during connect/refresh; disconnect no-op; same-ds warning cleared on success; other-ds warning left intact.
useQueryHistory.test.ts Go nil-slice → JSON null coerces to [].

Coverage thresholds (two-tier)

Replaces the flat baseline threshold with:

  • Global ratchet floor (90 stmt / 82 branch / 90 func / 91 lines) — a regression gate set just below actuals, not an aspiration. Global 95% is deliberately avoided: the remaining few % are CodeMirror closures (QueryEditor) and App.tsx glue, exercised by e2e — unit-testing them is brittle.
  • Higher per-dir floors for pure logic: lib/ (97/90/100/99), hooks/ (95/82/95/97). Verified the glob thresholds are actually enforced (negative test failed as expected).

Numbers

  • Unit: 464 → 489 passing
  • E2E: 91 → 95 passing
  • hooks branch 78.6% → 82.7%; overall 90.6% stmt / 84.2% branch
  • ConnectionGeneralTab 40%→100% func; useDatasourceSession 95%→100% stmt

Test plan

  • cd frontend && npm run test — 489 pass, thresholds enforced
  • npx playwright test — 95 pass
  • go test ./... — pass
  • cd frontend && npm run build — clean
  • pre-commit hooks (biome, gofmt, govet, golangci, frontend-tests) — pass

Follow-up (not in this PR)

Wiring Playwright V8 coverage into the reported number would credit the QueryEditor/App paths that are e2e-tested, and is the honest way to reflect their real coverage.

nkcoder added 2 commits July 5, 2026 08:42
Fills gaps surfaced while regression-testing the #127#130 refactor:

- e2e/query-editor-find.spec.ts: in-editor Find (Cmd+F) had no e2e
  coverage after the #128 QueryEditor/FindBar split — open/focus/close,
  match count, next/prev navigation, clear-resets.
- ConnectionGeneralTab.test.tsx: the #129-extracted tab had no test
  (40% func) — field edits, port numeric coercion, password
  mask/reveal, isEdit placeholder, derived URL.
- useDatasourceSession: GetCompletions failure during connect/refresh;
  disconnect no-op when nothing is connected.
- useQueryHistory: null history result coerces to [].
Adds the missing hooks-branch tests and turns the flat #51 threshold into
a two-tier gate:

- useSidebarTree.test.ts (new): the hook had no direct test — covers the
  live-load error branches (columns/sub-folder load failures), the
  toggleColumnsFolder guard + toggle, and each sub-folder loader.
- useQueryExecution: non-result-set (DDL) rows-affected path; error leaves
  a pinned tab intact; double-pin preserves the first; close a non-active tab.
- useDatasourceSession: successful refresh clears a same-ds warning; a
  refresh for one ds leaves another ds's warning intact.

hooks branch coverage 78.6% -> 82.7%; overall 89.8% -> 90.6% stmt.

vitest.config.ts: global ratchet floor (90/82/90/91) as a regression gate,
plus higher per-dir floors for pure logic (lib/ 97/90/100/99, hooks/
95/82/95/97). Verified the glob thresholds are enforced.
@nkcoder nkcoder merged commit 21957b6 into main Jul 4, 2026
2 checks passed
@nkcoder nkcoder deleted the test/improve-coverage-post-refactor branch July 4, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant