T5 reviewer identified 2 reads outside NoteRepository that were missing the 'WHERE deleted_at IS NULL' filter, breaking the silent invariant beyond the 3 originally-listed methods. - ContinuityService.get() now excludes trashed notes from streak / weekCount / lastNoteAt / recovery-toast math. A trashed note no longer counts toward weekly streak (regression: streak felt fake after trash). - NoteRepository.getPendingCount() now excludes trashed-but-still-pending notes. trash() removes the pending_jobs row but leaves notes.ai_status='pending'; the count would have drifted upward as users trashed pending notes. - MediaGc.run() gets an inline comment documenting why it intentionally does NOT filter — trashed notes still own their media until permanentDelete / emptyTrash. Removing here would defeat restore. Also: migrations.due_date.test.ts had 2 brittle assertions (latestVersion()===2, user_version===2) that broke with v3. Migration-system version assertions belong in migrations.test.ts (already covered there); m002-specific test keeps the due_date column assertion which is version-stable. Tests: 245 → 265 (+20). typecheck 0 errors. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
21 lines
953 B
TypeScript
21 lines
953 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import Database from 'better-sqlite3';
|
|
import { runMigrations } from '@main/db/migrations/index.js';
|
|
|
|
describe('migrations m002 due_date', () => {
|
|
// v3 (m003 soft_delete) lands in v0.2.3 #4 — latest version + user_version
|
|
// assertions migrate to migrations.test.ts. Here we keep only the m002-specific
|
|
// assertion (due_date column existence) which is version-stable.
|
|
it('due_date column exists with NULL default', () => {
|
|
const db = new Database(':memory:');
|
|
runMigrations(db);
|
|
db.prepare(
|
|
`INSERT INTO notes (id, raw_text, ai_status, created_at, updated_at)
|
|
VALUES (?, ?, 'pending', ?, ?)`
|
|
).run('n1', 'x', '2026-04-26T00:00:00Z', '2026-04-26T00:00:00Z');
|
|
const row = db.prepare('SELECT due_date, due_date_edited_by_user FROM notes WHERE id=?').get('n1') as any;
|
|
expect(row.due_date).toBeNull();
|
|
expect(row.due_date_edited_by_user).toBe(0);
|
|
});
|
|
});
|