@@ -55,6 +55,15 @@ describe('ProjectShowcasePostService', () => {
5555 } ,
5656 } ,
5757 ] ,
58+ media : [
59+ {
60+ id : BigInt ( 101 ) ,
61+ type : 'image/png' ,
62+ url : 'https://example.com/image.png' ,
63+ createdAt : new Date ( '2026-01-01T00:00:00Z' ) ,
64+ createdBy : BigInt ( 42 ) ,
65+ } ,
66+ ] ,
5867 ...overrides ,
5968 } as const ;
6069 }
@@ -188,12 +197,72 @@ describe('ProjectShowcasePostService', () => {
188197 categories : {
189198 create : [ { categoryId : BigInt ( 7 ) } ] ,
190199 } ,
200+ media : {
201+ create : [ ] ,
202+ } ,
191203 } ) ,
192204 } ) ,
193205 ) ;
194206 expect ( response . status ) . toBe ( 'DRAFT' ) ;
195207 } ) ;
196208
209+ it ( 'creates a new project showcase post with media assets' , async ( ) => {
210+ prismaMock . projectShowcasePost . create . mockResolvedValue (
211+ buildPostRecord ( {
212+ status : 'DRAFT' ,
213+ media : [
214+ {
215+ id : BigInt ( 101 ) ,
216+ type : 'image/png' ,
217+ url : 'https://example.com/image.png' ,
218+ createdAt : new Date ( '2026-01-01T00:00:00Z' ) ,
219+ createdBy : BigInt ( 42 ) ,
220+ } ,
221+ ] ,
222+ } ) ,
223+ ) ;
224+
225+ const response = await service . createPost (
226+ '1001' ,
227+ {
228+ title : 'New post' ,
229+ content : 'New content' ,
230+ industryIds : [ '5' ] ,
231+ categoryIds : [ '7' ] ,
232+ media : [
233+ {
234+ type : 'image/png' ,
235+ url : 'https://example.com/image.png' ,
236+ } ,
237+ ] ,
238+ } ,
239+ user ,
240+ ) ;
241+
242+ expect ( prismaMock . projectShowcasePost . create ) . toHaveBeenCalledWith (
243+ expect . objectContaining ( {
244+ data : expect . objectContaining ( {
245+ media : {
246+ create : [
247+ {
248+ type : 'image/png' ,
249+ url : 'https://example.com/image.png' ,
250+ createdBy : 42 ,
251+ } ,
252+ ] ,
253+ } ,
254+ } ) ,
255+ } ) ,
256+ ) ;
257+ expect ( response . media ) . toEqual ( [
258+ expect . objectContaining ( {
259+ id : '101' ,
260+ type : 'image/png' ,
261+ url : 'https://example.com/image.png' ,
262+ } ) ,
263+ ] ) ;
264+ } ) ;
265+
197266 it ( 'throws NotFoundException when create hits an industry foreign key constraint' , async ( ) => {
198267 const error = Object . create (
199268 Prisma . PrismaClientKnownRequestError . prototype ,
@@ -300,6 +369,66 @@ describe('ProjectShowcasePostService', () => {
300369 expect ( response . title ) . toBe ( 'Updated title' ) ;
301370 } ) ;
302371
372+ it ( 'updates a post with media assets' , async ( ) => {
373+ prismaMock . projectShowcasePost . findFirst . mockResolvedValue (
374+ buildPostRecord ( ) ,
375+ ) ;
376+ prismaMock . projectShowcasePost . update . mockResolvedValue (
377+ buildPostRecord ( {
378+ title : 'Updated title' ,
379+ media : [
380+ {
381+ id : BigInt ( 102 ) ,
382+ type : 'video/mp4' ,
383+ url : 'https://example.com/video.mp4' ,
384+ createdAt : new Date ( '2026-01-01T00:00:00Z' ) ,
385+ createdBy : BigInt ( 42 ) ,
386+ } ,
387+ ] ,
388+ } ) ,
389+ ) ;
390+
391+ const response = await service . updatePost (
392+ '1001' ,
393+ '10' ,
394+ {
395+ title : 'Updated title' ,
396+ media : [
397+ {
398+ type : 'video/mp4' ,
399+ url : 'https://example.com/video.mp4' ,
400+ } ,
401+ ] ,
402+ } ,
403+ user ,
404+ ) ;
405+
406+ expect ( prismaMock . projectShowcasePost . update ) . toHaveBeenCalledWith (
407+ expect . objectContaining ( {
408+ where : { id : BigInt ( 10 ) } ,
409+ data : expect . objectContaining ( {
410+ media : {
411+ deleteMany : { } ,
412+ create : [
413+ {
414+ type : 'video/mp4' ,
415+ url : 'https://example.com/video.mp4' ,
416+ createdBy : 42 ,
417+ } ,
418+ ] ,
419+ } ,
420+ } ) ,
421+ } ) ,
422+ ) ;
423+ expect ( response . media ) . toEqual ( [
424+ expect . objectContaining ( {
425+ id : '102' ,
426+ type : 'video/mp4' ,
427+ url : 'https://example.com/video.mp4' ,
428+ } ) ,
429+ ] ) ;
430+ } ) ;
431+
303432 it ( 'throws NotFoundException when update hits an industry foreign key constraint' , async ( ) => {
304433 prismaMock . projectShowcasePost . findFirst . mockResolvedValue (
305434 buildPostRecord ( ) ,
0 commit comments