switchman-dev 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/CLAUDE.md +0 -98
- package/examples/taskapi/.switchman/switchman.db +0 -0
- package/examples/taskapi/package-lock.json +0 -4736
- package/examples/taskapi/tests/api.test.js +0 -112
- package/examples/worktrees/agent-rate-limiting/package-lock.json +0 -4736
- package/examples/worktrees/agent-rate-limiting/package.json +0 -18
- package/examples/worktrees/agent-rate-limiting/src/db.js +0 -179
- package/examples/worktrees/agent-rate-limiting/src/middleware/auth.js +0 -96
- package/examples/worktrees/agent-rate-limiting/src/middleware/validate.js +0 -133
- package/examples/worktrees/agent-rate-limiting/src/routes/tasks.js +0 -65
- package/examples/worktrees/agent-rate-limiting/src/routes/users.js +0 -38
- package/examples/worktrees/agent-rate-limiting/src/server.js +0 -7
- package/examples/worktrees/agent-rate-limiting/tests/api.test.js +0 -112
- package/examples/worktrees/agent-tests/package-lock.json +0 -4736
- package/examples/worktrees/agent-tests/package.json +0 -18
- package/examples/worktrees/agent-tests/src/db.js +0 -179
- package/examples/worktrees/agent-tests/src/middleware/auth.js +0 -96
- package/examples/worktrees/agent-tests/src/middleware/validate.js +0 -133
- package/examples/worktrees/agent-tests/src/routes/tasks.js +0 -65
- package/examples/worktrees/agent-tests/src/routes/users.js +0 -38
- package/examples/worktrees/agent-tests/src/server.js +0 -7
- package/examples/worktrees/agent-tests/tests/api.test.js +0 -112
- package/examples/worktrees/agent-validation/package-lock.json +0 -4736
- package/examples/worktrees/agent-validation/package.json +0 -18
- package/examples/worktrees/agent-validation/src/db.js +0 -179
- package/examples/worktrees/agent-validation/src/middleware/auth.js +0 -96
- package/examples/worktrees/agent-validation/src/middleware/validate.js +0 -133
- package/examples/worktrees/agent-validation/src/routes/tasks.js +0 -65
- package/examples/worktrees/agent-validation/src/routes/users.js +0 -38
- package/examples/worktrees/agent-validation/src/server.js +0 -7
- package/examples/worktrees/agent-validation/tests/api.test.js +0 -112
- package/tests/test.js +0 -259
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
const request = require('supertest');
|
|
2
|
-
const app = require('../src/app');
|
|
3
|
-
const db = require('../src/dbstore/store');
|
|
4
|
-
|
|
5
|
-
beforeEach(() => db._reset());
|
|
6
|
-
|
|
7
|
-
describe('Tasks', () => {
|
|
8
|
-
test('GET /api/tasks returns all tasks', async () => {
|
|
9
|
-
const res = await request(app).get('/api/tasks');
|
|
10
|
-
expect(res.status).toBe(200);
|
|
11
|
-
expect(Array.isArray(res.body)).toBe(true);
|
|
12
|
-
expect(res.body.length).toBeGreaterThan(0);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('GET /api/tasks?status=todo filters correctly', async () => {
|
|
16
|
-
const res = await request(app).get('/api/tasks?status=todo');
|
|
17
|
-
expect(res.status).toBe(200);
|
|
18
|
-
expect(res.body.every(t => t.status === 'todo')).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('GET /api/tasks/:id returns single task', async () => {
|
|
22
|
-
const res = await request(app).get('/api/tasks/1');
|
|
23
|
-
expect(res.status).toBe(200);
|
|
24
|
-
expect(res.body.id).toBe(1);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('GET /api/tasks/:id returns 404 for unknown id', async () => {
|
|
28
|
-
const res = await request(app).get('/api/tasks/999');
|
|
29
|
-
expect(res.status).toBe(404);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('POST /api/tasks creates a task', async () => {
|
|
33
|
-
const res = await request(app)
|
|
34
|
-
.post('/api/tasks')
|
|
35
|
-
.send({ title: 'New task', projectId: 1 });
|
|
36
|
-
expect(res.status).toBe(201);
|
|
37
|
-
expect(res.body.title).toBe('New task');
|
|
38
|
-
expect(res.body.status).toBe('todo');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('POST /api/tasks returns 400 without title', async () => {
|
|
42
|
-
const res = await request(app).post('/api/tasks').send({ projectId: 1 });
|
|
43
|
-
expect(res.status).toBe(400);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('PATCH /api/tasks/:id updates status', async () => {
|
|
47
|
-
const res = await request(app)
|
|
48
|
-
.patch('/api/tasks/1')
|
|
49
|
-
.send({ status: 'in_progress' });
|
|
50
|
-
expect(res.status).toBe(200);
|
|
51
|
-
expect(res.body.status).toBe('in_progress');
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('PATCH /api/tasks/:id rejects invalid status', async () => {
|
|
55
|
-
const res = await request(app)
|
|
56
|
-
.patch('/api/tasks/1')
|
|
57
|
-
.send({ status: 'flying' });
|
|
58
|
-
expect(res.status).toBe(400);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('DELETE /api/tasks/:id deletes task', async () => {
|
|
62
|
-
const res = await request(app).delete('/api/tasks/1');
|
|
63
|
-
expect(res.status).toBe(204);
|
|
64
|
-
const get = await request(app).get('/api/tasks/1');
|
|
65
|
-
expect(get.status).toBe(404);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe('Projects', () => {
|
|
70
|
-
test('GET /api/projects returns all projects', async () => {
|
|
71
|
-
const res = await request(app).get('/api/projects');
|
|
72
|
-
expect(res.status).toBe(200);
|
|
73
|
-
expect(Array.isArray(res.body)).toBe(true);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test('GET /api/projects/:id/tasks returns tasks for project', async () => {
|
|
77
|
-
const res = await request(app).get('/api/projects/1/tasks');
|
|
78
|
-
expect(res.status).toBe(200);
|
|
79
|
-
expect(res.body.every(t => t.projectId === 1)).toBe(true);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('POST /api/projects creates project', async () => {
|
|
83
|
-
const res = await request(app)
|
|
84
|
-
.post('/api/projects')
|
|
85
|
-
.send({ name: 'New Project', ownerId: 1 });
|
|
86
|
-
expect(res.status).toBe(201);
|
|
87
|
-
expect(res.body.name).toBe('New Project');
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe('Users', () => {
|
|
92
|
-
test('GET /api/users returns all users', async () => {
|
|
93
|
-
const res = await request(app).get('/api/users');
|
|
94
|
-
expect(res.status).toBe(200);
|
|
95
|
-
expect(res.body.length).toBeGreaterThan(0);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test('POST /api/users creates user', async () => {
|
|
99
|
-
const res = await request(app)
|
|
100
|
-
.post('/api/users')
|
|
101
|
-
.send({ name: 'Charlie', email: 'charlie@example.com' });
|
|
102
|
-
expect(res.status).toBe(201);
|
|
103
|
-
expect(res.body.name).toBe('Charlie');
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
test('POST /api/users rejects duplicate email', async () => {
|
|
107
|
-
const res = await request(app)
|
|
108
|
-
.post('/api/users')
|
|
109
|
-
.send({ name: 'Dup', email: 'alice@example.com' });
|
|
110
|
-
expect(res.status).toBe(409);
|
|
111
|
-
});
|
|
112
|
-
});
|