feat(repos): spaces, projects, tasks with audit stub
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
36
tests/repos/tasks.test.js
Normal file
36
tests/repos/tasks.test.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { resetDb } from '../helpers/db.js';
|
||||
import { migrateUp } from '../../lib/db/migrate.js';
|
||||
import * as spaces from '../../lib/db/repos/spaces.js';
|
||||
import * as projects from '../../lib/db/repos/projects.js';
|
||||
import * as tasks from '../../lib/db/repos/tasks.js';
|
||||
|
||||
const owner = { kind: 'user', id: null };
|
||||
|
||||
beforeEach(async () => { await resetDb(); await migrateUp(); });
|
||||
|
||||
describe('tasks repo', () => {
|
||||
it('creates a task with optional project', async () => {
|
||||
const s = await spaces.create({ slug: 'h', name: 'H' }, owner);
|
||||
const t = await tasks.create({ space_id: s.id, title: 'do it' }, owner);
|
||||
expect(t.status).toBe('todo');
|
||||
expect(t.project_id).toBeNull();
|
||||
});
|
||||
|
||||
it('marking done sets completed_at', async () => {
|
||||
const s = await spaces.create({ slug: 'h', name: 'H' }, owner);
|
||||
const t = await tasks.create({ space_id: s.id, title: 'x' }, owner);
|
||||
const u = await tasks.update(t.id, { status: 'done' }, owner);
|
||||
expect(u.status).toBe('done');
|
||||
expect(u.completed_at).not.toBeNull();
|
||||
});
|
||||
|
||||
it('listByProject returns project tasks only', async () => {
|
||||
const s = await spaces.create({ slug: 'h', name: 'H' }, owner);
|
||||
const p = await projects.create({ space_id: s.id, slug: 'p', name: 'P' }, owner);
|
||||
await tasks.create({ space_id: s.id, project_id: p.id, title: 'a' }, owner);
|
||||
await tasks.create({ space_id: s.id, title: 'orphan' }, owner);
|
||||
const list = await tasks.listByProject(p.id);
|
||||
expect(list).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user