Skip to content

Commit 0061160

Browse files
committed
fix: correct test schemas and CI workflow order
- Fix activity.test.ts: use camelCase properties (entityType, surgeryId) and correct action types ('created'/'updated' instead of 'create'/'update') - Fix patient.test.ts: use correct schema (phn, birth_year, gender) - Fix dashboard.test.ts: use correct patient/surgery schema - Fix surgery.test.ts: use correct schema (title, bht, ward instead of procedure) - Fix surgery-template.test.ts: use title instead of name - Fix app-settings.test.ts: handle possibly undefined results - Fix backup.test.ts: add type annotation for array - Fix NewPatientForm.test.tsx: use Date objects for created_at/updated_at - Fix renderer-setup.ts: import beforeEach from vitest - Update tsconfig.web.json: add jest-dom types - Update CI workflow: run tests after lint and typecheck
1 parent 3de03de commit 0061160

File tree

11 files changed

+319
-442
lines changed

11 files changed

+319
-442
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ jobs:
5252
- name: Install dependencies
5353
run: pnpm install --frozen-lockfile
5454

55-
- name: Run Tests
56-
run: pnpm test:run
57-
5855
- name: Lint
5956
run: pnpm lint
6057

6158
- name: Typecheck
6259
run: pnpm typecheck
6360

61+
- name: Run Tests
62+
run: pnpm test:run
63+
6464
- name: Build
6565
run: pnpm build

src/main/__tests__/backup.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ describe('Backup Module', () => {
210210
})
211211

212212
it('should delete oldest backups when over limit', async () => {
213-
const files = []
213+
const files: string[] = []
214214
for (let i = 1; i <= 15; i++) {
215215
files.push(`data_2024-01-${String(i).padStart(2, '0')}_10-00-00.db`)
216216
}

src/main/repository/__tests__/activity.test.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('Activity Repository', () => {
4343
await activityRepo.logActivity({
4444
entityType: 'patient',
4545
entityId: 1,
46-
action: 'create',
46+
action: 'created',
4747
title: 'Patient Created',
4848
description: 'New patient John Doe created',
4949
patientId: 1
@@ -52,16 +52,16 @@ describe('Activity Repository', () => {
5252
const activities = await activityRepo.getRecentActivities(10)
5353

5454
expect(activities.length).toBe(1)
55-
expect(activities[0].entity_type).toBe('patient')
56-
expect(activities[0].action).toBe('create')
55+
expect(activities[0].entityType).toBe('patient')
56+
expect(activities[0].action).toBe('created')
5757
expect(activities[0].title).toBe('Patient Created')
5858
})
5959

6060
it('should log a surgery activity', async () => {
6161
await activityRepo.logActivity({
6262
entityType: 'surgery',
6363
entityId: 5,
64-
action: 'update',
64+
action: 'updated',
6565
title: 'Surgery Updated',
6666
description: 'Surgery details modified',
6767
patientId: 1,
@@ -71,15 +71,15 @@ describe('Activity Repository', () => {
7171
const activities = await activityRepo.getRecentActivities(10)
7272

7373
expect(activities.length).toBe(1)
74-
expect(activities[0].entity_type).toBe('surgery')
75-
expect(activities[0].surgery_id).toBe(5)
74+
expect(activities[0].entityType).toBe('surgery')
75+
expect(activities[0].surgeryId).toBe(5)
7676
})
7777

7878
it('should log a followup activity', async () => {
7979
await activityRepo.logActivity({
8080
entityType: 'followup',
8181
entityId: 10,
82-
action: 'create',
82+
action: 'created',
8383
title: 'Followup Added',
8484
description: 'New followup note added',
8585
patientId: 1,
@@ -88,7 +88,7 @@ describe('Activity Repository', () => {
8888

8989
const activities = await activityRepo.getRecentActivities(10)
9090

91-
expect(activities[0].entity_type).toBe('followup')
91+
expect(activities[0].entityType).toBe('followup')
9292
})
9393
})
9494

@@ -104,7 +104,7 @@ describe('Activity Repository', () => {
104104
await activityRepo.logActivity({
105105
entityType: 'patient',
106106
entityId: i,
107-
action: 'create',
107+
action: 'created',
108108
title: `Activity ${i}`,
109109
description: `Description ${i}`,
110110
patientId: i
@@ -120,7 +120,7 @@ describe('Activity Repository', () => {
120120
await activityRepo.logActivity({
121121
entityType: 'patient',
122122
entityId: 1,
123-
action: 'create',
123+
action: 'created',
124124
title: 'First',
125125
description: 'First activity',
126126
patientId: 1
@@ -132,7 +132,7 @@ describe('Activity Repository', () => {
132132
await activityRepo.logActivity({
133133
entityType: 'patient',
134134
entityId: 2,
135-
action: 'create',
135+
action: 'created',
136136
title: 'Second',
137137
description: 'Second activity',
138138
patientId: 2
@@ -151,7 +151,7 @@ describe('Activity Repository', () => {
151151
await activityRepo.logActivity({
152152
entityType: 'patient',
153153
entityId: 1,
154-
action: 'create',
154+
action: 'created',
155155
title: 'Patient 1 Created',
156156
description: 'Patient 1',
157157
patientId: 1
@@ -160,7 +160,7 @@ describe('Activity Repository', () => {
160160
await activityRepo.logActivity({
161161
entityType: 'patient',
162162
entityId: 2,
163-
action: 'create',
163+
action: 'created',
164164
title: 'Patient 2 Created',
165165
description: 'Patient 2',
166166
patientId: 2
@@ -169,7 +169,7 @@ describe('Activity Repository', () => {
169169
await activityRepo.logActivity({
170170
entityType: 'patient',
171171
entityId: 1,
172-
action: 'update',
172+
action: 'updated',
173173
title: 'Patient 1 Updated',
174174
description: 'Patient 1 update',
175175
patientId: 1
@@ -178,14 +178,14 @@ describe('Activity Repository', () => {
178178
const activities = await activityRepo.getActivitiesForEntity('patient', 1)
179179

180180
expect(activities.length).toBe(2)
181-
expect(activities.every((a) => a.entity_id === 1)).toBe(true)
181+
expect(activities.every((a) => a.entityId === 1)).toBe(true)
182182
})
183183

184184
it('should filter by entity type and id', async () => {
185185
await activityRepo.logActivity({
186186
entityType: 'patient',
187187
entityId: 1,
188-
action: 'create',
188+
action: 'created',
189189
title: 'Patient Activity',
190190
description: 'Patient',
191191
patientId: 1
@@ -194,7 +194,7 @@ describe('Activity Repository', () => {
194194
await activityRepo.logActivity({
195195
entityType: 'surgery',
196196
entityId: 1,
197-
action: 'create',
197+
action: 'created',
198198
title: 'Surgery Activity',
199199
description: 'Surgery',
200200
patientId: 1,
@@ -218,7 +218,7 @@ describe('Activity Repository', () => {
218218
await activityRepo.logActivity({
219219
entityType: 'patient',
220220
entityId: 1,
221-
action: 'create',
221+
action: 'created',
222222
title: 'Patient Created',
223223
description: 'New patient',
224224
patientId: 1
@@ -227,7 +227,7 @@ describe('Activity Repository', () => {
227227
await activityRepo.logActivity({
228228
entityType: 'surgery',
229229
entityId: 1,
230-
action: 'create',
230+
action: 'created',
231231
title: 'Surgery Created',
232232
description: 'New surgery',
233233
patientId: 1,
@@ -237,7 +237,7 @@ describe('Activity Repository', () => {
237237
await activityRepo.logActivity({
238238
entityType: 'patient',
239239
entityId: 1,
240-
action: 'update',
240+
action: 'updated',
241241
title: 'Patient Updated',
242242
description: 'Patient modified',
243243
patientId: 1
@@ -255,14 +255,14 @@ describe('Activity Repository', () => {
255255
const result = await activityRepo.listActivityLog({ entityType: 'patient' })
256256

257257
expect(result.data.length).toBe(2)
258-
expect(result.data.every((a) => a.entity_type === 'patient')).toBe(true)
258+
expect(result.data.every((a) => a.entityType === 'patient')).toBe(true)
259259
})
260260

261261
it('should filter by action', async () => {
262-
const result = await activityRepo.listActivityLog({ action: 'create' })
262+
const result = await activityRepo.listActivityLog({ action: 'created' })
263263

264264
expect(result.data.length).toBe(2)
265-
expect(result.data.every((a) => a.action === 'create')).toBe(true)
265+
expect(result.data.every((a) => a.action === 'created')).toBe(true)
266266
})
267267

268268
it('should filter by search term', async () => {

src/main/repository/__tests__/app-settings.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ describe('App Settings Repository', () => {
6363
const result = await settingsRepo.updateSetting('hospital_name', 'Test Hospital')
6464

6565
expect(result).toBeDefined()
66-
expect(result.key).toBe('hospital_name')
67-
expect(result.value).toBe('Test Hospital')
66+
expect(result!.key).toBe('hospital_name')
67+
expect(result!.value).toBe('Test Hospital')
6868
})
6969

7070
it('should allow setting a null value', async () => {
@@ -74,15 +74,15 @@ describe('App Settings Repository', () => {
7474
// Then set it to null
7575
const result = await settingsRepo.updateSetting('hospital_name', null)
7676

77-
expect(result.value).toBeNull()
77+
expect(result!.value).toBeNull()
7878
})
7979

8080
it('should update the same setting multiple times', async () => {
8181
await settingsRepo.updateSetting('unit_name', 'Unit A')
8282
await settingsRepo.updateSetting('unit_name', 'Unit B')
8383
const result = await settingsRepo.updateSetting('unit_name', 'Unit C')
8484

85-
expect(result.value).toBe('Unit C')
85+
expect(result!.value).toBe('Unit C')
8686
})
8787
})
8888

0 commit comments

Comments
 (0)