Skip to content

Commit 4346be6

Browse files
committed
feat: update identifier
1 parent 9e70fe6 commit 4346be6

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

docs/useCases.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,7 @@ The above example would submit feedback to all contacts of a object where the ob
14271427
In ContactDTO, it takes the following information:
14281428

14291429
- **targetId**: the numeric identifier of the collection, dataset, or datafile. Persistent ids and collection aliases are not supported. (Optional)
1430+
- **identifier**: the alias of a collection or the persistence id of a dataset or datafile. (Optional)
14301431
- **subject**: the email subject line
14311432
- **body**: the email body to send
14321433
- **fromEmail**: the email to list in the reply-to field.

src/contactInfo/domain/dtos/ContactDTO.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export interface ContactDTO {
22
targetId?: number
3+
identifier?: string
34
subject: string
45
body: string
56
fromEmail: string

test/functional/contact/SubmitContactInfo.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ describe('submitContactInfo', () => {
5252
}
5353
})
5454

55+
test('should return Contact when contact info is successfully submitted', async () => {
56+
const test2ContactDTO: ContactDTO = {
57+
identifier: 'root',
58+
subject: 'Data Question',
59+
body: 'Please help me understand your data. Thank you!',
60+
fromEmail: '[email protected]'
61+
}
62+
const contactInfo = await submitContactInfo.execute(test2ContactDTO)
63+
64+
expect(contactInfo).toBeDefined()
65+
expect(contactInfo[0].fromEmail).toEqual(test2ContactDTO.fromEmail)
66+
expect(contactInfo[0].subject).toEqual(expect.any(String))
67+
expect(contactInfo[0].body).toEqual(expect.any(String))
68+
})
69+
5570
test('should return error if the target id is unexisted', async () => {
5671
const contactDTO: ContactDTO = {
5772
targetId: 0,

test/integration/contact/ContactRepository.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,33 @@ describe('submitContactInfo', () => {
1919
fromEmail: '[email protected]'
2020
}
2121

22+
const test2ContactDTO: ContactDTO = {
23+
identifier: 'root',
24+
subject: 'Data Question',
25+
body: 'Please help me understand your data. Thank you!',
26+
fromEmail: '[email protected]'
27+
}
28+
2229
const sut: ContactRepository = new ContactRepository()
2330

2431
test('should return Contact when contact info is successfully submitted', async () => {
25-
const contactInfo = await sut.submitContactInfo(testContactDTO)
32+
const contactInfo = await sut.submitContactInfo(test2ContactDTO)
2633

2734
expect(contactInfo).toBeDefined()
2835
expect(contactInfo[0].fromEmail).toEqual(testContactDTO.fromEmail)
2936
expect(contactInfo[0].subject).toEqual(expect.any(String))
3037
expect(contactInfo[0].body).toEqual(expect.any(String))
3138
})
3239

40+
test('should return Contact when contact info is successfully submitted if accessed by identifier', async () => {
41+
const contactInfo = await sut.submitContactInfo(testContactDTO)
42+
43+
expect(contactInfo).toBeDefined()
44+
expect(contactInfo[0].fromEmail).toEqual(test2ContactDTO.fromEmail)
45+
expect(contactInfo[0].subject).toEqual(expect.any(String))
46+
expect(contactInfo[0].body).toEqual(expect.any(String))
47+
})
48+
3349
test('should return a Contact when targetId is not provided', async () => {
3450
const contactDTOWithoutTargetId: Partial<ContactDTO> = {
3551
subject: 'General Inquiry',

0 commit comments

Comments
 (0)