test: unit tests for the 10 candidates (#139) #142
Reference in New Issue
Block a user
Delete Branch "test/unit-tests-139"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements the 10 unit-test candidates from #139 (gap-audit of the QA plan). Tests-only PR, with three minimal, behavior-preserving extractions the issue called for.
Test files (path → #tests)
dictation/utils/encode-wav.test.ts— 7 (WAV header + PCM16 clamp)editor-ext/embed-provider.spec.ts— 19 (all 11 providers: canonical / already-embed / junk)editor-ext/utils.spec.ts— 8 (sanitizeUrlXSS boundary,isInternalFileUrl)editor-ext/indent.spec.ts— 6 (clampIndent0..8)label/dto/label.dto.spec.ts— 6 (name regex;~only non-leading)page/dto/move-page.dto.spec.ts— 3 (incl. 1test.failing— see below)home/components/can-create-page.test.ts— 4 (role gate)page-history/components/history-diff.test.ts— 7 (diff decorations + counts)notification/notification.constants.spec.ts— 6 (incl. 1test.failing)search/search.service.spec.ts— +8 (buildTsQueryadversarial inputs)Minimal extractions (so the logic is purely testable)
canCreatePage→ new siblingcan-create-page.ts(importing the component pulls inmain.tsx).computeHistoryDiff(...)→ newhistory-diff.ts;history-editor.tsximports it (editor side-effects stay in the component).buildTsQuery(raw)extracted insearch.service.tsand now sanitizes the input (strips all but Unicode letters/numbers/whitespace) so operator inputs (&,!,*,<->,\) degrade to a safe/empty query instead of ato_tsquery500 — while normal/accented/CJK queries are unchanged.Two genuine bugs locked via
test.failing(suite stays green, flips red when fixed)MovePageDto.position@MaxLength(12)rejects dense fractional-index keys thatgenerateJitteredKeyBetweenlegitimately produces (13+ chars) → a move in a deep tree 400s. (A fresh key is ~5 chars and passes@MinLength(5).)'direct'tab whitelist (5 types) diverges from the notification repo'stype != PAGE_UPDATEDfilter (which also returns verification/approval types).'updates'matches exactly (green).Verification
editor-ext build clean; client+server
tscclean; all new suites green (editor-ext 32, client 18, server 31 = 81), no regressions in the touched existing suites (search, editor-ext full).🤖 Generated with Claude Code