Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions server/__tests__/workload-routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,15 @@ describe('workload routes', () => {
expect(res.status).toBe(404);
});

it('POST /api/workload/items/:id/promote — returns 404 for missing item with description but no title', async () => {
const res = await request(app)
.post('/api/workload/items/nonexistent-id/promote')
.set('Cookie', authCookie)
.send({ description: 'has context but no title' });

expect(res.status).toBe(404);
});

it('POST /api/workload/items/:id/promote — creates task from body fallback (Telos item)', async () => {
const res = await request(app)
.post('/api/workload/items/telos-item-123/promote')
Expand Down Expand Up @@ -546,9 +555,9 @@ describe('workload routes', () => {
});

it('POST /api/workload/items/:id/promote — fallback does not broadcast workload update', async () => {
const { setWorkloadBroadcast } = await import('../app.js');
const broadcasts: unknown[] = [];
const origBroadcast = (app as any)._workloadBroadcast;
(app as any)._workloadBroadcast = (msg: unknown) => broadcasts.push(msg);
setWorkloadBroadcast((msg: Record<string, unknown>) => broadcasts.push(msg));

await request(app)
.post('/api/workload/items/telos-no-broadcast/promote')
Expand All @@ -558,7 +567,8 @@ describe('workload routes', () => {
const workloadBroadcasts = broadcasts.filter((b: any) => b.type === 'workload_item_updated');
expect(workloadBroadcasts).toHaveLength(0);

(app as any)._workloadBroadcast = origBroadcast;
// Reset — no broadcast callback in test environment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 style: The reset comment '// Reset — no broadcast callback in test environment' explains what the line does, not why. The code setWorkloadBroadcast(() => {}) is self-explanatory. Per project conventions, this comment should be removed. [fixable]

setWorkloadBroadcast(() => {});
});

it('POST /api/workload/items/:id/promote — broadcasts workload_item_updated', async () => {
Expand Down
3 changes: 2 additions & 1 deletion server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@
if (ownerConnection !== connectionId) continue;

registry.suspend(found.clientId, lastSeq);
eventStore.setSessionState(entry.sessionId, 'SUSPENDED', {

Check failure on line 574 in server/app.ts

View workflow job for this annotation

GitHub Actions / ci

Unhandled error

TypeError: eventStore.setSessionState is not a function ❯ server/app.ts:574:18 This error originated in "server/__tests__/suspend-routes.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "handles multiple sessions in one request". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.

Check failure on line 574 in server/app.ts

View workflow job for this annotation

GitHub Actions / ci

Unhandled error

TypeError: eventStore.setSessionState is not a function ❯ server/app.ts:574:18 This error originated in "server/__tests__/suspend-routes.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "returns 204 and calls registry.suspend for valid request". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.

Check failure on line 574 in server/app.ts

View workflow job for this annotation

GitHub Actions / ci

Unhandled error

TypeError: eventStore.setSessionState is not a function ❯ server/app.ts:574:18 This error originated in "server/__tests__/routes.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "authenticates via cookie (sendBeacon sends cookies automatically)". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.

Check failure on line 574 in server/app.ts

View workflow job for this annotation

GitHub Actions / ci

Unhandled error

TypeError: eventStore.setSessionState is not a function ❯ server/app.ts:574:18 This error originated in "server/__tests__/routes.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "returns 204 and calls registry.suspend for valid request". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
clientId: found.clientId,
reason: 'ios_background_rest',
});
Expand Down Expand Up @@ -1921,7 +1921,8 @@
// Resolve title and context from workloadStore item or fallback body data (Telos items)
const title = item?.title ?? body.data.title;
if (!title) {
res.status(404).json({ error: 'Item not found and no title provided' });
const status = item ? 400 : 404;
res.status(status).json({ error: item ? 'No title provided' : 'Item not found and no title provided' });
return;
}

Expand Down
Loading