test(08-01): add failing tests for candidate status field
- 5 tests: create with/without status, update status, getThreadWithCandidates includes status - Test helper updated with status column in thread_candidates CREATE TABLE Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -217,6 +217,87 @@ describe("Thread Service", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("candidate status", () => {
|
||||
it("createCandidate without status returns a candidate with status 'researching'", () => {
|
||||
const thread = createThread(db, { name: "Test Thread", categoryId: 1 });
|
||||
const candidate = createCandidate(db, thread.id, {
|
||||
name: "No Status",
|
||||
categoryId: 1,
|
||||
});
|
||||
|
||||
expect(candidate.status).toBe("researching");
|
||||
});
|
||||
|
||||
it("createCandidate with status 'ordered' returns a candidate with status 'ordered'", () => {
|
||||
const thread = createThread(db, { name: "Test Thread", categoryId: 1 });
|
||||
const candidate = createCandidate(db, thread.id, {
|
||||
name: "Ordered Item",
|
||||
categoryId: 1,
|
||||
status: "ordered",
|
||||
});
|
||||
|
||||
expect(candidate.status).toBe("ordered");
|
||||
});
|
||||
|
||||
it("updateCandidate can change status from 'researching' to 'ordered'", () => {
|
||||
const thread = createThread(db, { name: "Test Thread", categoryId: 1 });
|
||||
const candidate = createCandidate(db, thread.id, {
|
||||
name: "Status Change",
|
||||
categoryId: 1,
|
||||
});
|
||||
|
||||
expect(candidate.status).toBe("researching");
|
||||
|
||||
const updated = updateCandidate(db, candidate.id, {
|
||||
status: "ordered",
|
||||
});
|
||||
|
||||
expect(updated?.status).toBe("ordered");
|
||||
});
|
||||
|
||||
it("updateCandidate can change status from 'ordered' to 'arrived'", () => {
|
||||
const thread = createThread(db, { name: "Test Thread", categoryId: 1 });
|
||||
const candidate = createCandidate(db, thread.id, {
|
||||
name: "Arriving Item",
|
||||
categoryId: 1,
|
||||
status: "ordered",
|
||||
});
|
||||
|
||||
const updated = updateCandidate(db, candidate.id, {
|
||||
status: "arrived",
|
||||
});
|
||||
|
||||
expect(updated?.status).toBe("arrived");
|
||||
});
|
||||
|
||||
it("getThreadWithCandidates includes status field on each candidate", () => {
|
||||
const thread = createThread(db, { name: "Status Thread", categoryId: 1 });
|
||||
createCandidate(db, thread.id, {
|
||||
name: "Candidate A",
|
||||
categoryId: 1,
|
||||
});
|
||||
createCandidate(db, thread.id, {
|
||||
name: "Candidate B",
|
||||
categoryId: 1,
|
||||
status: "ordered",
|
||||
});
|
||||
|
||||
const result = getThreadWithCandidates(db, thread.id);
|
||||
expect(result).toBeDefined();
|
||||
expect(result?.candidates).toHaveLength(2);
|
||||
|
||||
const candidateA = result?.candidates.find(
|
||||
(c) => c.name === "Candidate A",
|
||||
);
|
||||
const candidateB = result?.candidates.find(
|
||||
(c) => c.name === "Candidate B",
|
||||
);
|
||||
|
||||
expect(candidateA?.status).toBe("researching");
|
||||
expect(candidateB?.status).toBe("ordered");
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveThread", () => {
|
||||
it("atomically creates collection item from candidate data and archives thread", () => {
|
||||
const thread = createThread(db, { name: "Tent Decision", categoryId: 1 });
|
||||
|
||||
Reference in New Issue
Block a user