4.4 KiB
id, title, status, assignee, created_date, updated_date, labels, dependencies, references, parent_task_id, ordinal
| id | title | status | assignee | created_date | updated_date | labels | dependencies | references | parent_task_id | ordinal | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| TASK-1.5 | Phase 5: Add critical behavior tests for untested services | Done |
|
2026-02-10 18:46 | 2026-02-18 04:11 |
|
|
TASK-1 | 5000 |
Description
Add meaningful behavior tests for high-risk services called out in plan.md: mpv, subsync, tokenizer, and expanded CLI command coverage.
Acceptance Criteria
- #1
mpvservice has focused tests for protocol parsing, event dispatch, request/response matching, reconnection, and subtitle extraction behavior. - #2
subsyncservice has focused tests for engine path resolution, command construction, timeout/error handling, and result parsing. - #3
tokenizerservice has focused tests for parser readiness, token extraction, fallback behavior, and edge-case inputs. - #4 CLI command service tests cover all dispatch paths, async error propagation, and second-instance forwarding behavior.
- #5
pnpm run test:corepasses with all new tests green.
Implementation Plan
- Add focused tests for
tokenizer-service.tsbehavior (normalization, Yomitan-unavailable fallback, mecab fallback success/error paths, empty input handling). - Add focused tests for
subsync-service.tscommand/engine selection and failure handling using mocked command utilities where feasible. - Add focused tests for
mpv-service.tsprotocol handling (line parsing, request-response routing, property-change dispatch) with lightweight socket stubs. - Expand
cli-command-service.tstests for dispatch/error/second-instance forwarding edge paths not currently covered. - Run
pnpm run test:coreiteratively and update acceptance criteria as each service reaches meaningful coverage.
Implementation Notes
Added new tokenizer behavior tests in src/core/services/tokenizer-service.test.ts covering empty normalized input, newline normalization, mecab fallback success, and mecab error fallback-to-null.
Added new mpv protocol tests in src/core/services/mpv-service.test.ts covering JSON line-buffer parsing, property-change subtitle dispatch behavior, and request/response resolution by request_id.
Added new subsync workflow tests in src/core/services/subsync-service.test.ts covering already-running guard, manual-mode picker flow, and error propagation to OSD when MPV is unavailable.
Expanded src/core/services/cli-command-service.test.ts to cover socket/start dispatch, texthooker port override warning path, help-without-window shutdown, and async trigger-subsync error reporting.
Updated package.json test:core to include new/renamed test files; verification remains green with pnpm run test:core (17 tests total).
Expanded mpv-service tests with request rejection when disconnected, requestProperty error propagation, and pending-request disconnect resolution behavior.
Expanded subsync-service tests with manual alass source-track validation and auto-mode executable-path failure handling while ensuring in-progress state cleanup.
All updated tests remain green via pnpm run test:core after these additions.
Added Yomitan parser token-extraction coverage in tokenizer-service.test.ts (parser-available success path) in addition to fallback/edge-case tests.
Added MPV reconnection/request robustness tests (scheduleReconnect, disconnected request rejection, pending request disconnect resolution) to complement protocol/event/request-id tests in mpv-service.test.ts.
Added subsync command-construction tests using executable stubs for both engines (ffsubsync and alass) and validated success/failure result behavior; added timeout behavior coverage in src/subsync/utils.test.ts for child-process timeout handling used by subsync.
Expanded CLI dispatch tests with broad branch coverage for visibility/settings/copy/multi-copy/mining/open-runtime-options/stop/help/second-instance behaviors and async error propagation.
Verification: pnpm run test:core passes with 18 green tests including newly added dist/subsync/utils.test.js.