|
| 1 | +# Spec: Close user-journey test coverage gaps before 1.1.0 (#190) |
| 2 | + |
| 3 | +## Goal |
| 4 | + |
| 5 | +Add regression and journey tests for the five highest-risk flows identified in the 1.1.0 coverage audit, and fix three test-infrastructure flakiness items. |
| 6 | + |
| 7 | +## Why now |
| 8 | + |
| 9 | +1.1.0 milestone. Milestone bugs (#51, #144, #167, #170) are fixed; none has a test that would catch a recurrence. Release without coverage leaves those fixes unverifiable. |
| 10 | + |
| 11 | +## In scope |
| 12 | + |
| 13 | +### Tests to add |
| 14 | + |
| 15 | +1. **Mark-task-complete code action (E2E)** |
| 16 | + - Files: `src/provider/codeactions/for-open-tasks.ts`, `for-completed-tasks.ts` |
| 17 | + - Scenario: seed entry with `- [ ] foo`, invoke `ForOpenTasksCodeAction`, assert line becomes `- [x] foo` with completed timestamp. |
| 18 | + - Currently: zero direct tests on either file. |
| 19 | + |
| 20 | +2. **Weekly entry creation full write path (#167 regression)** |
| 21 | + - Files: `src/actions/writer.ts` (`createWeeklyForWeek`), `src/ext/conf.ts` (weekly template resolution) |
| 22 | + - Scenario: call weekly creation with tmp base, assert file exists at `${base}/${year}/wNN.md` and body matches resolved `weekly` template. |
| 23 | + - Currently: `phase1-regression.test.ts:10` only resolves the template object, does not write. |
| 24 | + |
| 25 | +3. **`Inject.injectInput` E2E — memo / task / file link** |
| 26 | + - File: `src/actions/inject.ts` |
| 27 | + - Scenarios: seed today's entry, run `journal.memo` with `memo: lorem ipsum`, assert file gains the line at correct anchor. Parallel cases for `task:` and file link. |
| 28 | + - Currently: no targeted inject suite. |
| 29 | + |
| 30 | +4. **Prev/next under non-default scope (#144 regression)** |
| 31 | + - File: `src/actions/navigation.ts` |
| 32 | + - Scenarios: |
| 33 | + - Seed `${base}/scopes/work/2025/03/{05,08}.md`, anchor on `08.md` in `work` scope, assert `OpenPreviousEntryCommand` opens `05.md` and does not cross into default scope. |
| 34 | + - Calendar mode backward through a non-existent day. |
| 35 | + - Currently: navigation tests use only default scope. |
| 36 | + |
| 37 | +5. **`journal.today` command-layer E2E under remote-style URI (#51 closure)** |
| 38 | + - File: `src/provider/commands/show-entry-for-date.ts` |
| 39 | + - Scenario: `vscode.commands.executeCommand('journal.today')` against tmp base with no existing entry, assert no error and entry file exists afterwards. |
| 40 | + - Currently: `issue-51-remote-create.test.ts` stops at `Reader.loadEntryForDay`. |
| 41 | + |
| 42 | +### Test-infrastructure fixes |
| 43 | + |
| 44 | +- **`read-templates.test.ts`**: mutates `journal.scopes` without teardown → add `afterEach` restore. |
| 45 | +- **`phase1-regression.test.ts:74`**: today-offset brittle near midnight UTC → use fixed clock or assert sign only. |
| 46 | +- **`week-input.test.ts`**: `next week` uses `moment().week()`, fails on year-rollover week 52→1 → injected clock or relative offset assertion. |
| 47 | +- **`notes-sync.test.ts`**: 8×500ms poll with no diagnostic dump on failure → log captured state on timeout. |
| 48 | + |
| 49 | +## Out of scope |
| 50 | + |
| 51 | +Zero-coverage modules not needed for 1.1.0: |
| 52 | +- `codelens/migrate-tasks.ts`, `shift-task.ts` |
| 53 | +- `features/scan-entries.ts`, `show-pick-list.ts` |
| 54 | +- `features/sync-note-links.ts` (only indirect), `load-note.ts` (indirect) |
| 55 | +- `src/ext/conf.ts` template/scope path resolution |
| 56 | + |
| 57 | +## Acceptance criteria |
| 58 | + |
| 59 | +- All five test groups added and green in `npm test`. |
| 60 | +- Each closed 1.1.0 bug (#170, #167, #51, #144) has ≥1 regression test that would catch a recurrence. |
| 61 | +- Four infra flakiness items addressed. |
| 62 | +- No new ESLint or TypeScript errors introduced. |
| 63 | + |
| 64 | +## Entities / contracts |
| 65 | + |
| 66 | +- `ForOpenTasksCodeAction` / `ForCompletedTasksCodeAction` in `src/provider/codeactions/` |
| 67 | +- `Writer.createWeeklyForWeek(input, ctrl)` in `src/actions/writer.ts` |
| 68 | +- `Inject.injectInput(input, document, ctrl)` in `src/actions/inject.ts` |
| 69 | +- `OpenPreviousEntryCommand` / `OpenNextEntryCommand` in `src/provider/commands/` |
| 70 | +- Test helpers: `command-test-helpers.ts`, `TestLogger` (`src/test/test-logger.ts`) |
| 71 | +- Pattern for config: `config.update('base', tmpBase, ConfigurationTarget.Workspace)` + fresh `Ctrl` |
| 72 | + |
| 73 | +## Constraints |
| 74 | + |
| 75 | +- Tests run inside real VS Code Extension Host — no mocking of `vscode.workspace.fs`. |
| 76 | +- Do not register commands in tests — instantiate command classes directly. |
| 77 | +- Must pass on Linux (CI uses `xvfb-run`). |
| 78 | + |
| 79 | +## Open questions |
| 80 | + |
| 81 | +None after reviewing issue body. |
| 82 | + |
| 83 | +## Related issues |
| 84 | + |
| 85 | +- Blocks: milestone 1.1.0 release |
| 86 | +- Regression coverage for: #51, #144, #167, #170 |
0 commit comments