fix(v0210): importNote 가 capture revision 을 함께 INSERT (final review fix)
final code review 발견: F5 import 후 first user edit 시 import 시점 본문이 note_revisions 에 없어 history 에서 사라지는 회귀. importNote transaction 안 INSERT 추가 (createdAt = edited_at). 부수 작업: ImportNoteInput / importNote 의 "raw_text invariant guard" 주석을 v0.2.10 의 'fork-on-id-collision (sync determinism)' 정확한 의미로 갱신. 테스트 +2 — insert path / fork path 모두 capture revision 검증.
This commit is contained in:
@@ -107,4 +107,65 @@ describe('NoteRepository — note_revisions', () => {
|
||||
expect(note?.rawText).toBe('v2 corrected');
|
||||
});
|
||||
});
|
||||
|
||||
describe('importNote — capture revision 생성 (final review 보강)', () => {
|
||||
it('insert path: imported note 가 capture revision (createdAt = edited_at) 을 함께 갖는다', () => {
|
||||
const r = repo.importNote({
|
||||
id: '00000000-0000-0000-0000-000000000001',
|
||||
rawText: 'imported text',
|
||||
createdAt: '2026-04-01T00:00:00Z',
|
||||
updatedAt: '2026-04-02T00:00:00Z',
|
||||
aiTitle: 't',
|
||||
aiSummary: 's',
|
||||
titleEditedByUser: false,
|
||||
summaryEditedByUser: false,
|
||||
aiProvider: 'p',
|
||||
aiGeneratedAt: '2026-04-02T00:00:00Z',
|
||||
userIntent: null,
|
||||
intentPromptedAt: null,
|
||||
tags: []
|
||||
});
|
||||
expect(r.status).toBe('inserted');
|
||||
|
||||
const revs = repo.listRevisions(r.id);
|
||||
expect(revs).toHaveLength(1);
|
||||
expect(revs[0]!.rawText).toBe('imported text');
|
||||
expect(revs[0]!.editedBy).toBe('capture');
|
||||
expect(revs[0]!.editedAt).toBe('2026-04-01T00:00:00Z');
|
||||
});
|
||||
|
||||
it('fork path: id 충돌 시 fresh uuidv7 + 새 capture revision (옛 노트 revision 보존)', () => {
|
||||
// 기존 노트 (capture 'v1' revision 자동 생성됨)
|
||||
const existing = repo.create({ rawText: 'v1' });
|
||||
// 동일 id 로 다른 raw_text 를 import → fork
|
||||
const r = repo.importNote({
|
||||
id: existing.id,
|
||||
rawText: 'imported v2',
|
||||
createdAt: '2026-04-01T00:00:00Z',
|
||||
updatedAt: '2026-04-02T00:00:00Z',
|
||||
aiTitle: null,
|
||||
aiSummary: null,
|
||||
titleEditedByUser: false,
|
||||
summaryEditedByUser: false,
|
||||
aiProvider: null,
|
||||
aiGeneratedAt: null,
|
||||
userIntent: null,
|
||||
intentPromptedAt: null,
|
||||
tags: []
|
||||
});
|
||||
expect(r.status).toBe('forked');
|
||||
expect(r.id).not.toBe(existing.id);
|
||||
|
||||
// forked 노트에 capture revision
|
||||
const forkRevs = repo.listRevisions(r.id);
|
||||
expect(forkRevs).toHaveLength(1);
|
||||
expect(forkRevs[0]!.rawText).toBe('imported v2');
|
||||
expect(forkRevs[0]!.editedBy).toBe('capture');
|
||||
|
||||
// 기존 노트의 revision 은 그대로 보존
|
||||
const existingRevs = repo.listRevisions(existing.id);
|
||||
expect(existingRevs).toHaveLength(1);
|
||||
expect(existingRevs[0]!.rawText).toBe('v1');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user