Skip to content

Commit bd25f41

Browse files
authored
Merge pull request #2572 from trycompai/main
[comp] Production Deploy
2 parents faedd6f + 3f4faf2 commit bd25f41

34 files changed

+1628
-198
lines changed

apps/api/src/findings/dto/create-finding.dto.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
IsOptional,
88
MaxLength,
99
} from 'class-validator';
10-
import { FindingType } from '@db';
10+
import { FindingScope, FindingType } from '@db';
1111
import {
1212
evidenceFormTypeSchema,
1313
type EvidenceFormType,
@@ -43,6 +43,16 @@ export class CreateFindingDto {
4343
@IsOptional()
4444
evidenceFormType?: EvidenceFormType;
4545

46+
@ApiProperty({
47+
description:
48+
'People area scope (e.g. people directory) when not tied to a task or evidence',
49+
enum: FindingScope,
50+
required: false,
51+
})
52+
@IsEnum(FindingScope)
53+
@IsOptional()
54+
scope?: FindingScope;
55+
4656
@ApiProperty({
4757
description: 'Type of finding (SOC 2 or ISO 27001)',
4858
enum: FindingType,

apps/api/src/findings/finding-audit.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export class FindingAuditService {
2121
taskTitle?: string;
2222
evidenceSubmissionId?: string;
2323
evidenceSubmissionFormType?: string;
24+
findingScope?: string;
2425
content: string;
2526
type: FindingType;
2627
},
@@ -41,6 +42,7 @@ export class FindingAuditService {
4142
taskTitle: params.taskTitle,
4243
evidenceSubmissionId: params.evidenceSubmissionId,
4344
evidenceSubmissionFormType: params.evidenceSubmissionFormType,
45+
findingScope: params.findingScope,
4446
content: params.content,
4547
type: params.type,
4648
status: FindingStatus.open,
@@ -155,6 +157,7 @@ export class FindingAuditService {
155157
taskTitle?: string;
156158
evidenceSubmissionId?: string;
157159
evidenceSubmissionFormType?: string;
160+
findingScope?: string;
158161
content: string;
159162
},
160163
): Promise<void> {
@@ -174,6 +177,7 @@ export class FindingAuditService {
174177
taskTitle: params.taskTitle,
175178
evidenceSubmissionId: params.evidenceSubmissionId,
176179
evidenceSubmissionFormType: params.evidenceSubmissionFormType,
180+
findingScope: params.findingScope,
177181
content: params.content,
178182
},
179183
},

apps/api/src/findings/finding-notifier.service.spec.ts

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ jest.mock(
1010
soc2: 'soc2',
1111
iso27001: 'iso27001',
1212
},
13+
FindingScope: {
14+
people: 'people',
15+
people_tasks: 'people_tasks',
16+
people_devices: 'people_devices',
17+
people_chart: 'people_chart',
18+
},
1319
FindingStatus: {
1420
open: 'open',
1521
ready_for_review: 'ready_for_review',
@@ -75,8 +81,14 @@ const mockDbModule: {
7581
soc2: 'soc2';
7682
iso27001: 'iso27001';
7783
};
84+
FindingScope: {
85+
people: 'people';
86+
people_tasks: 'people_tasks';
87+
people_devices: 'people_devices';
88+
people_chart: 'people_chart';
89+
};
7890
} = jest.requireMock('@db');
79-
const { db, FindingType } = mockDbModule;
91+
const { db, FindingType, FindingScope } = mockDbModule;
8092

8193
describe('FindingNotifierService', () => {
8294
const mockedDb = db;
@@ -194,5 +206,49 @@ describe('FindingNotifierService', () => {
194206
}),
195207
);
196208
});
209+
210+
it('builds People page URLs with tab query for scope-based findings', async () => {
211+
await service.notifyFindingCreated({
212+
organizationId: 'org_123',
213+
findingId: 'fdg_scope',
214+
findingScope: FindingScope.people_devices,
215+
findingContent: 'Device area finding',
216+
findingType: FindingType.soc2,
217+
actorUserId: 'usr_actor',
218+
actorName: 'Actor',
219+
});
220+
221+
expect(mockedDb.task.findUnique).not.toHaveBeenCalled();
222+
expect(mockedDb.evidenceSubmission.findUnique).not.toHaveBeenCalled();
223+
224+
expect(novuTriggerMock).toHaveBeenCalledWith(
225+
expect.objectContaining({
226+
payload: expect.objectContaining({
227+
findingUrl: 'https://app.trycomp.ai/org_123/people?tab=people',
228+
}),
229+
}),
230+
);
231+
});
232+
233+
it('aligns title and URL by preferring People scope over document fields when both are set', async () => {
234+
await service.notifyFindingCreated({
235+
organizationId: 'org_123',
236+
findingId: 'fdg_mixed',
237+
findingScope: FindingScope.people,
238+
evidenceSubmissionFormType: 'meeting',
239+
findingContent: 'Ambiguous finding',
240+
findingType: FindingType.soc2,
241+
actorUserId: 'usr_actor',
242+
actorName: 'Actor',
243+
});
244+
245+
expect(novuTriggerMock).toHaveBeenCalledWith(
246+
expect.objectContaining({
247+
payload: expect.objectContaining({
248+
findingUrl: 'https://app.trycomp.ai/org_123/people?tab=devices',
249+
}),
250+
}),
251+
);
252+
});
197253
});
198254
});

0 commit comments

Comments
 (0)