feat(notes): list/listByStatus/countByStatus/search 에 notebookId 옵션
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1255,3 +1255,49 @@ describe('NoteRepository.create with notebook', () => {
|
||||
expect(r?.notebookId).toBe(defaultId);
|
||||
});
|
||||
});
|
||||
|
||||
describe('NoteRepository.list / countByStatus with notebookId', () => {
|
||||
let db: Database.Database;
|
||||
let repo: NoteRepository;
|
||||
let nbA: string, nbB: string;
|
||||
beforeEach(() => {
|
||||
db = new Database(':memory:');
|
||||
db.pragma('foreign_keys = ON');
|
||||
runMigrations(db);
|
||||
repo = new NoteRepository(db);
|
||||
nbA = (db.prepare(`SELECT id FROM notebooks`).get() as { id: string }).id;
|
||||
nbB = 'nb-b';
|
||||
db.prepare(`INSERT INTO notebooks(id,name,created_at,updated_at) VALUES(?,?,?,?)`).run(nbB,'회사','2099-01-01','2099-01-01');
|
||||
});
|
||||
|
||||
it('list 가 notebookId 필터로 노트 분리', () => {
|
||||
repo.create({ rawText: 'in-default' });
|
||||
repo.create({ rawText: 'in-B', notebookId: nbB });
|
||||
expect(repo.list({ limit: 10, notebookId: nbA }).map((n) => n.rawText)).toEqual(['in-default']);
|
||||
expect(repo.list({ limit: 10, notebookId: nbB }).map((n) => n.rawText)).toEqual(['in-B']);
|
||||
});
|
||||
|
||||
it('list 의 notebookId 미지정 시 모든 notebook 의 노트', () => {
|
||||
repo.create({ rawText: 'in-default' });
|
||||
repo.create({ rawText: 'in-B', notebookId: nbB });
|
||||
expect(repo.list({ limit: 10 })).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('countByStatus(notebookId) — 각 notebook 의 active 갯수', () => {
|
||||
repo.create({ rawText: 'a1' });
|
||||
repo.create({ rawText: 'a2' });
|
||||
repo.create({ rawText: 'b1', notebookId: nbB });
|
||||
expect(repo.countByStatus('active', { notebookId: nbA })).toBe(2);
|
||||
expect(repo.countByStatus('active', { notebookId: nbB })).toBe(1);
|
||||
expect(repo.countByStatus('active')).toBe(3); // 옵션 미지정 시 전체
|
||||
});
|
||||
|
||||
it('listByStatus(notebookId) — 같은 status 라도 notebook 별 분리', () => {
|
||||
const { id: a1 } = repo.create({ rawText: 'a1' });
|
||||
const { id: b1 } = repo.create({ rawText: 'b1', notebookId: nbB });
|
||||
repo.setStatus(a1, 'completed', null);
|
||||
repo.setStatus(b1, 'completed', null);
|
||||
expect(repo.listByStatus('completed', { notebookId: nbA }).map((n) => n.id)).toEqual([a1]);
|
||||
expect(repo.listByStatus('completed', { notebookId: nbB }).map((n) => n.id)).toEqual([b1]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user