Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

test: align tests with column constraint

LAZIC Erwanaf8da2a76750
diff --git a/tests/api-integration/assigned-tasks.test.ts b/tests/api-integration/assigned-tasks.test.ts
index 4f182d6d8..148607b27 100644
--- a/tests/api-integration/assigned-tasks.test.ts
+++ b/tests/api-integration/assigned-tasks.test.ts
@@ -156,7 +156,7 @@ describe("API integration: assigned tasks", () => {
});
});
- it("uses column references when duplicate slugs include final columns", async () => {
+ it("counts open tasks by column reference and resolves legacy tasks by status slug", async () => {
const member = await createWorkspaceMember();
const { project, columns } = await createProjectFixture({
workspaceId: member.workspace.id,
@@ -181,35 +181,38 @@ describe("API integration: assigned tasks", () => {
userId: member.user.id,
})
.returning();
- await db.insert(schema.taskTable).values([
- {
- projectId: project.id,
- title: "In the final duplicate",
- status: columns.todo.slug,
- columnId: finalColumn.id,
- userId: member.user.id,
- number: 2,
- },
- {
- projectId: project.id,
- title: "Legacy ambiguous status",
- status: columns.todo.slug,
- userId: member.user.id,
- number: 3,
- },
- ]);
+ const [, legacy] = await db
+ .insert(schema.taskTable)
+ .values([
+ {
+ projectId: project.id,
+ title: "In the final duplicate",
+ status: columns.todo.slug,
+ columnId: finalColumn.id,
+ userId: member.user.id,
+ number: 2,
+ },
+ {
+ projectId: project.id,
+ title: "Legacy status without column",
+ status: columns.todo.slug,
+ userId: member.user.id,
+ number: 3,
+ },
+ ])
+ .returning();
mockAuthenticatedSession(member.user);
const { app } = createApp();
const countResponse = await app.request(
`/api/task/assigned?workspaceId=${member.workspace.id}&countOnly=true`,
);
- expect(await countResponse.json()).toEqual({ tasks: [], total: 1 });
+ expect(await countResponse.json()).toEqual({ tasks: [], total: 2 });
const response = await app.request(
`/api/task/assigned?workspaceId=${member.workspace.id}`,
);
expect(response.status).toBe(200);
const body = (await response.json()) as AssignedTasksResponse;
- expect(body.total).toBe(1);
+ expect(body.total).toBe(2);
const details = await app.request(`/api/task/${task.id}`);
expect(details.status).toBe(200);
expect(await details.json()).toMatchObject({
@@ -217,9 +220,12 @@ describe("API integration: assigned tasks", () => {
columnId: columns.todo.id,
workspaceId: member.workspace.id,
});
- expect(body.tasks).toEqual([
- expect.objectContaining({ id: task.id, statusName: columns.todo.name }),
- ]);
+ expect(body.tasks.map((t) => t.id).sort()).toEqual(
+ [task.id, legacy.id].sort(),
+ );
+ expect(body.tasks.every((t) => t.statusName === columns.todo.name)).toBe(
+ true,
+ );
});
it("refuses a workspace the caller does not belong to", async () => {
diff --git a/tests/api-integration/workspace-activity.test.ts b/tests/api-integration/workspace-activity.test.ts
index e613dc3f9..42cd16d9f 100644
--- a/tests/api-integration/workspace-activity.test.ts
+++ b/tests/api-integration/workspace-activity.test.ts
@@ -197,7 +197,7 @@ describe("API integration: workspace activity", () => {
expect(invalid.status).toBe(400);
}
});
- it("does not guess a historical column name when its status slug is ambiguous", async () => {
+ it("resolves historical column names by exact status slug", async () => {
const member = await createWorkspaceMember();
const { project, columns } = await createProjectFixture({
workspaceId: member.workspace.id,
@@ -232,9 +232,9 @@ describe("API integration: workspace activity", () => {
);
expect(response.status).toBe(200);
const [event] = await response.json();
- expect(event.eventData).not.toHaveProperty("oldStatusName");
expect(event.eventData).toMatchObject({
oldStatus: "to-do",
+ oldStatusName: "To Do",
newStatusName: "In Progress",
});
});