Skip to content

Commit 788c79a

Browse files
committed
Minor clean up in tests. AI kind of left a bit of messy code
1 parent 9f545b0 commit 788c79a

3 files changed

Lines changed: 1 addition & 106 deletions

File tree

test/e2e/logs.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ describe('Logs API', async () => {
4747
TEST_CHILD_USER.password
4848
)
4949

50-
// Get the child user by username
5150
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
5251

5352
const response = await $fetch<LogsResponse>('/api/logs', {
@@ -71,7 +70,6 @@ describe('Logs API', async () => {
7170
TEST_PARENT_USER.password
7271
)
7372

74-
// Get the child user by username
7573
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
7674

7775
const response = await $fetch<LogsResponse>('/api/logs', {

test/e2e/tasks.test.ts

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,8 @@ describe('Tasks API', async () => {
4848
TEST_CHILD_USER.password
4949
)
5050

51-
// Get the child user by username
5251
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
5352

54-
if (!childUser) {
55-
throw new Error('Child user not found in database')
56-
}
57-
5853
const response = await $fetch<TasksResponse>('/api/tasks', {
5954
method: 'GET',
6055
headers: {
@@ -76,13 +71,8 @@ describe('Tasks API', async () => {
7671
TEST_PARENT_USER.password
7772
)
7873

79-
// Get the child user by username
8074
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
8175

82-
if (!childUser) {
83-
throw new Error('Child user not found in database')
84-
}
85-
8676
const response = await $fetch<TasksResponse>('/api/tasks', {
8777
method: 'GET',
8878
headers: {
@@ -104,13 +94,8 @@ describe('Tasks API', async () => {
10494
TEST_PARENT_USER.password
10595
)
10696

107-
// Get the child user by username
10897
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
10998

110-
if (!childUser) {
111-
throw new Error('Child user not found in database')
112-
}
113-
11499
const response = await $fetch<TaskResponse>('/api/tasks', {
115100
method: 'POST',
116101
body: {
@@ -195,13 +180,8 @@ describe('Tasks API', async () => {
195180
TEST_PARENT_USER.password
196181
)
197182

198-
// First create a task to update
199183
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
200184

201-
if (!childUser) {
202-
throw new Error('Child user not found in database')
203-
}
204-
205185
const createResponse = await $fetch<TaskResponse>('/api/tasks', {
206186
method: 'POST',
207187
body: {
@@ -270,13 +250,8 @@ describe('Tasks API', async () => {
270250
TEST_PARENT_USER.password
271251
)
272252

273-
// First create a task to delete
274253
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
275254

276-
if (!childUser) {
277-
throw new Error('Child user not found in database')
278-
}
279-
280255
const createResponse = await $fetch<TaskResponse>('/api/tasks', {
281256
method: 'POST',
282257
body: {
@@ -359,13 +334,8 @@ describe('Tasks API', async () => {
359334
TEST_PARENT_USER.password
360335
)
361336

362-
// Get the child user by username
363337
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
364338

365-
if (!childUser) {
366-
throw new Error('Child user not found in database')
367-
}
368-
369339
// Create a task first
370340
const createResponse = await $fetch<TaskResponse>('/api/tasks', {
371341
method: 'POST',
@@ -412,13 +382,8 @@ describe('Tasks API', async () => {
412382
TEST_PARENT_USER.password
413383
)
414384

415-
// Get the child user by username
416385
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
417386

418-
if (!childUser) {
419-
throw new Error('Child user not found in database')
420-
}
421-
422387
// Create a task first
423388
const createResponse = await $fetch<TaskResponse>('/api/tasks', {
424389
method: 'POST',
@@ -465,13 +430,8 @@ describe('Tasks API', async () => {
465430
TEST_PARENT_USER.password
466431
)
467432

468-
// Get the child user by username
469433
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
470434

471-
if (!childUser) {
472-
throw new Error('Child user not found in database')
473-
}
474-
475435
// Create a task first
476436
const createResponse = await $fetch<TaskResponse>('/api/tasks', {
477437
method: 'POST',
@@ -569,13 +529,8 @@ describe('Tasks API', async () => {
569529
TEST_PARENT_USER.password
570530
)
571531

572-
// Get the child user by username
573532
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
574533

575-
if (!childUser) {
576-
throw new Error('Child user not found in database')
577-
}
578-
579534
// Create a task first
580535
const createResponse = await $fetch<TaskResponse>('/api/tasks', {
581536
method: 'POST',
@@ -636,13 +591,8 @@ describe('Tasks API', async () => {
636591
TEST_PARENT_USER.password
637592
)
638593

639-
// Get the child user by username
640594
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
641595

642-
if (!childUser) {
643-
throw new Error('Child user not found in database')
644-
}
645-
646596
// Create a task first
647597
const createResponse = await $fetch<TaskResponse>('/api/tasks', {
648598
method: 'POST',
@@ -710,13 +660,8 @@ describe('Tasks API', async () => {
710660
TEST_PARENT_USER.password
711661
)
712662

713-
// Get the child user by username
714663
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
715664

716-
if (!childUser) {
717-
throw new Error('Child user not found in database')
718-
}
719-
720665
// Create a task first
721666
const createResponse = await $fetch<TaskResponse>('/api/tasks', {
722667
method: 'POST',
@@ -779,13 +724,8 @@ describe('Tasks API', async () => {
779724
TEST_PARENT_USER.password
780725
)
781726

782-
// Get the child user by username
783727
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
784728

785-
if (!childUser) {
786-
throw new Error('Child user not found in database')
787-
}
788-
789729
// Create a task first
790730
const createResponse = await $fetch<TaskResponse>('/api/tasks', {
791731
method: 'POST',
@@ -861,13 +801,8 @@ describe('Tasks API', async () => {
861801
TEST_PARENT_USER.password
862802
)
863803

864-
// Get the child user by username
865804
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
866805

867-
if (!childUser) {
868-
throw new Error('Child user not found in database')
869-
}
870-
871806
// Create a perpetual task first
872807
const createResponse = await $fetch<TaskResponse>('/api/tasks', {
873808
method: 'POST',

test/e2e/users.test.ts

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,8 @@ describe('Users API', async () => {
9898
TEST_PARENT_USER.password
9999
)
100100

101-
// Get the child user by username
102101
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
103102

104-
if (!childUser) {
105-
throw new Error('Child user not found in database')
106-
}
107-
108103
const response = await $fetch<UserResponse>(`/api/users/${childUser.id}`, {
109104
method: 'GET',
110105
headers: {
@@ -124,13 +119,8 @@ describe('Users API', async () => {
124119
TEST_CHILD_USER.password
125120
)
126121

127-
// Get the child user ID from database to ensure it exists
128122
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
129123

130-
if (!childUser) {
131-
throw new Error('Child user not found in database')
132-
}
133-
134124
const response = await $fetch<UserResponse>(`/api/users/${childUser.id}`, {
135125
method: 'GET',
136126
headers: {
@@ -153,10 +143,6 @@ describe('Users API', async () => {
153143
// Get a user that is NOT the child user (to test forbidden access)
154144
const otherUser = await getUserByUsername(TEST_PARENT_USER.username)
155145

156-
if (!otherUser) {
157-
throw new Error('Parent user not found in database')
158-
}
159-
160146
try {
161147
await $fetch<UserResponse>(`/api/users/${otherUser.id}`, {
162148
method: 'GET',
@@ -205,14 +191,8 @@ describe('Users API', async () => {
205191
TEST_PARENT_USER.password
206192
)
207193

208-
// Get the child user
209194
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
210195

211-
if (!childUser) {
212-
throw new Error('Child user not found in database')
213-
}
214-
215-
// Get initial points
216196
const initialPoints = childUser.points
217197

218198
// Update points
@@ -235,10 +215,7 @@ describe('Users API', async () => {
235215

236216
// Verify points were updated in database
237217
const updatedChildUser = await getUserByUsername(TEST_CHILD_USER.username)
238-
239-
if (updatedChildUser) {
240-
expect(updatedChildUser.points).toBe(initialPoints + 10)
241-
}
218+
expect(updatedChildUser.points).toBe(initialPoints + 10)
242219
})
243220

244221
it('should reject points update for non-child user', async () => {
@@ -248,13 +225,8 @@ describe('Users API', async () => {
248225
TEST_PARENT_USER.password
249226
)
250227

251-
// Get a parent user (not child)
252228
const parentUser = await getUserByUsername(TEST_PARENT_USER.username)
253229

254-
if (!parentUser) {
255-
throw new Error('Parent user not found in database')
256-
}
257-
258230
try {
259231
await $fetch<{ message: string }>(
260232
'/api/users/' + parentUser.id + '/points',
@@ -286,13 +258,8 @@ describe('Users API', async () => {
286258
TEST_CHILD_USER.password
287259
)
288260

289-
// Get the child user
290261
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
291262

292-
if (!childUser) {
293-
throw new Error('Child user not found in database')
294-
}
295-
296263
try {
297264
await $fetch<{ message: string }>(
298265
'/api/users/' + childUser.id + '/points',
@@ -324,13 +291,8 @@ describe('Users API', async () => {
324291
TEST_PARENT_USER.password
325292
)
326293

327-
// Get the child user
328294
const childUser = await getUserByUsername(TEST_CHILD_USER.username)
329295

330-
if (!childUser) {
331-
throw new Error('Child user not found in database')
332-
}
333-
334296
try {
335297
await $fetch<{ message: string }>(
336298
'/api/users/' + childUser.id + '/points',

0 commit comments

Comments
 (0)