import { describe, it, expect, beforeAll } from 'vitest'; import request from 'supertest'; import { pool } from '../../lib/db/pool.js'; import { setup } from './helpers.js'; let app, ownerHeaders, projectId; beforeAll(async () => { ({ app, ownerHeaders } = await setup()); const { rows: [s] } = await pool.query(`INSERT INTO spaces(slug,name) VALUES('p','P') RETURNING id`); const { rows: [p] } = await pool.query( `INSERT INTO projects(space_id,slug,name,status) VALUES($1,'proj','Proj','active') RETURNING id`, [s.id]); projectId = p.id; }); describe('project research stub', () => { it('defaults research_status to none', async () => { const { rows: [p] } = await pool.query(`SELECT research_status FROM projects WHERE id=$1`, [projectId]); expect(p.research_status).toBe('none'); }); it('POST /research → requested (owner)', async () => { const res = await request(app).post(`/api/projects/${projectId}/research`).set(ownerHeaders); expect(res.status).toBe(200); expect(res.body.research_status).toBe('requested'); expect(res.body.research_requested_at).toBeTruthy(); }); it('404 for an unknown project', async () => { const res = await request(app).post(`/api/projects/00000000-0000-0000-0000-000000000000/research`).set(ownerHeaders); expect(res.status).toBe(404); }); });