@@ -8,6 +8,7 @@ import * as noteService from '../../../src/services/note.ts';
88import * as noteHistoryService from '../../../src/services/noteHistory.ts' ;
99import { uuidv4Pattern } from '../../../src/utils/regexp.ts' ;
1010
11+ import type { InternalAxiosRequestConfig } from 'axios' ;
1112import type { Request , Response } from 'express' ;
1213import type { Mock } from 'vitest' ;
1314import type { Email , Note , NoteHistory } from '../../../src/types' ;
@@ -34,6 +35,7 @@ afterEach(() => {
3435describe ( 'send' , ( ) => {
3536 const emailSpy = vi . spyOn ( emailService , 'email' ) ;
3637 const getObjectSpy = vi . spyOn ( comsService , 'getObject' ) ;
38+ const searchObjectSpy = vi . spyOn ( comsService , 'searchObject' ) ;
3739 const createNoteSpy = vi . spyOn ( noteService , 'createNote' ) ;
3840 const createHistorySpy = vi . spyOn ( noteHistoryService , 'createNoteHistory' ) ;
3941
@@ -142,7 +144,7 @@ describe('send', () => {
142144 const req = {
143145 body : {
144146 activityId : 'ACTI1234' ,
145- selectedFileIds : [ '123 ' , '456 ' ] ,
147+ selectedFileIds : [ '550e8400-e29b-41d4-a716-446655440001 ' , '550e8400-e29b-41d4-a716-446655440002 ' ] ,
146148 emailData : {
147149 body : 'Some message text' ,
148150 bodyType : 'text' ,
@@ -178,6 +180,14 @@ describe('send', () => {
178180 status : 200
179181 } ;
180182
183+ const searchObjectResponse = {
184+ data : [ { name : 'foo' } ] ,
185+ status : 200 ,
186+ statusText : 'OK' ,
187+ headers : { } ,
188+ config : { } as InternalAxiosRequestConfig
189+ } ;
190+
181191 const createdHistory : NoteHistory = {
182192 ...TEST_NOTE_HISTORY_1 ,
183193 type : 'Roadmap' ,
@@ -192,6 +202,7 @@ describe('send', () => {
192202 createHistorySpy . mockResolvedValue ( createdHistory ) ;
193203 createNoteSpy . mockResolvedValue ( createdNote ) ;
194204 getObjectSpy . mockResolvedValue ( getObjectResponse ) ;
205+ searchObjectSpy . mockResolvedValue ( searchObjectResponse ) ;
195206 emailSpy . mockResolvedValue ( TEST_EMAIL_RESPONSE ) ;
196207
197208 await sendRoadmapController (
@@ -212,7 +223,7 @@ describe('send', () => {
212223 const req = {
213224 body : {
214225 activityId : 'ACTI1234' ,
215- selectedFileIds : [ '123 ' , '456 ' ] ,
226+ selectedFileIds : [ '550e8400-e29b-41d4-a716-446655440001 ' , '550e8400-e29b-41d4-a716-446655440002 ' ] ,
216227 emailData : {
217228 body : 'Some message text' ,
218229 bodyType : 'text' ,
@@ -270,7 +281,7 @@ describe('send', () => {
270281 const req = {
271282 body : {
272283 activityId : 'ACTI1234' ,
273- selectedFileIds : [ '123 ' , '456 ' ] ,
284+ selectedFileIds : [ '550e8400-e29b-41d4-a716-446655440001 ' , '550e8400-e29b-41d4-a716-446655440002 ' ] ,
274285 emailData : {
275286 body : 'Some message text' ,
276287 bodyType : 'text' ,
@@ -315,8 +326,24 @@ describe('send', () => {
315326 status : 200
316327 } ;
317328
318- const note1Name = `${ getObjectResponse1 . headers [ 'x-amz-meta-name' ] } ` ;
319- const note2Name = `${ getObjectResponse2 . headers [ 'x-amz-meta-name' ] } ` ;
329+ const searchObjectResponse1 = {
330+ data : [ { name : 'foo' } ] ,
331+ status : 200 ,
332+ statusText : 'OK' ,
333+ headers : { } ,
334+ config : { } as InternalAxiosRequestConfig
335+ } ;
336+
337+ const searchObjectResponse2 = {
338+ data : [ { name : 'bar' } ] ,
339+ status : 200 ,
340+ statusText : 'OK' ,
341+ headers : { } ,
342+ config : { } as InternalAxiosRequestConfig
343+ } ;
344+
345+ const note1Name = `${ searchObjectResponse1 . data [ 0 ] . name } ` ;
346+ const note2Name = `${ searchObjectResponse2 . data [ 0 ] . name } ` ;
320347
321348 const createdHistory : NoteHistory = {
322349 ...TEST_NOTE_HISTORY_1 ,
@@ -334,6 +361,8 @@ describe('send', () => {
334361 emailSpy . mockResolvedValue ( TEST_EMAIL_RESPONSE ) ;
335362 getObjectSpy . mockResolvedValueOnce ( getObjectResponse1 ) ;
336363 getObjectSpy . mockResolvedValueOnce ( getObjectResponse2 ) ;
364+ searchObjectSpy . mockResolvedValueOnce ( searchObjectResponse1 ) ;
365+ searchObjectSpy . mockResolvedValueOnce ( searchObjectResponse2 ) ;
337366
338367 await sendRoadmapController (
339368 req as unknown as Request < never , never , { activityId : string ; selectedFileIds : string [ ] ; emailData : Email } > ,
0 commit comments