feat(v0210): NoteRepository.create 가 capture revision 을 함께 INSERT
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -61,6 +61,10 @@ export class NoteRepository {
|
||||
.prepare(`INSERT INTO notes (id, raw_text, ai_status, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?)`)
|
||||
.run(id, input.rawText, aiStatus, now, now);
|
||||
this.db
|
||||
.prepare(`INSERT INTO note_revisions (note_id, raw_text, edited_at, edited_by)
|
||||
VALUES (?, ?, ?, 'capture')`)
|
||||
.run(id, input.rawText, now);
|
||||
// pending_jobs 는 'pending' 일 때만 생성 — 'disabled' 노트는 worker 가 처리 안 함.
|
||||
if (aiStatus === 'pending') {
|
||||
this.db
|
||||
|
||||
@@ -1054,3 +1054,23 @@ describe('NoteRepository.countByAiStatus', () => {
|
||||
expect(repo.countByAiStatus('done')).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('NoteRepository — note_revisions', () => {
|
||||
let db: Database.Database;
|
||||
let repo: NoteRepository;
|
||||
|
||||
beforeEach(() => {
|
||||
db = new Database(':memory:');
|
||||
runMigrations(db);
|
||||
repo = new NoteRepository(db);
|
||||
});
|
||||
|
||||
it('create() 가 첫 revision (edited_by=capture) 을 INSERT 한다', () => {
|
||||
const { id } = repo.create({ rawText: 'hello' });
|
||||
const rows = db
|
||||
.prepare(`SELECT raw_text, edited_by FROM note_revisions WHERE note_id=?`)
|
||||
.all(id) as Array<{ raw_text: string; edited_by: string }>;
|
||||
expect(rows).toHaveLength(1);
|
||||
expect(rows[0]).toEqual({ raw_text: 'hello', edited_by: 'capture' });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user