@@ -18,7 +18,7 @@ describe('useBackgroundJobs', () => {
1818 const createMockJob = (
1919 overrides : Partial < BackgroundJob > = { } ,
2020 ) : BackgroundJob => ( {
21- id : 'test-job-1 ' ,
21+ id : 'resp_1234567890abcdef1234567890abcdef12345678 ' ,
2222 status : 'running' ,
2323 createdAt : '2025-01-01T00:00:00Z' ,
2424 title : 'Test Job' ,
@@ -28,7 +28,9 @@ describe('useBackgroundJobs', () => {
2828 describe ( 'initialization and persistence' , ( ) => {
2929 it ( 'should reset jobs using resetJobs()' , ( ) => {
3030 const { result } = renderHook ( ( ) => useBackgroundJobs ( ) )
31- const job = createMockJob ( { id : 'reset-job' } )
31+ const job = createMockJob ( {
32+ id : 'resp_abcdef1234567890abcdef1234567890abcdef12' ,
33+ } )
3234 act ( ( ) => {
3335 result . current . addJob ( job )
3436 } )
@@ -47,8 +49,13 @@ describe('useBackgroundJobs', () => {
4749 } )
4850
4951 it ( 'should load existing jobs from localStorage' , ( ) => {
50- const job1 = createMockJob ( { id : 'job1' } )
51- const job2 = createMockJob ( { id : 'job2' , status : 'completed' } )
52+ const job1 = createMockJob ( {
53+ id : 'resp_abcdef1234567890abcdef1234567890abcdef11' ,
54+ } )
55+ const job2 = createMockJob ( {
56+ id : 'resp_abcdef1234567890abcdef1234567890abcdef22' ,
57+ status : 'completed' ,
58+ } )
5259 const storedData = { job1, job2 }
5360
5461 // Initialize store with existing data using proper API
@@ -96,8 +103,14 @@ describe('useBackgroundJobs', () => {
96103
97104 it ( 'should add multiple jobs' , ( ) => {
98105 const { result } = renderHook ( ( ) => useBackgroundJobs ( ) )
99- const job1 = createMockJob ( { id : 'job1' , title : 'Job 1' } )
100- const job2 = createMockJob ( { id : 'job2' , title : 'Job 2' } )
106+ const job1 = createMockJob ( {
107+ id : 'resp_abcdef1234567890abcdef1234567890abcdef11' ,
108+ title : 'Job 1' ,
109+ } )
110+ const job2 = createMockJob ( {
111+ id : 'resp_abcdef1234567890abcdef1234567890abcdef22' ,
112+ title : 'Job 2' ,
113+ } )
101114
102115 expect ( result . current . jobs ) . toHaveLength ( 0 )
103116
@@ -134,22 +147,36 @@ describe('useBackgroundJobs', () => {
134147
135148 it ( 'should remove a job by id' , ( ) => {
136149 const { result } = renderHook ( ( ) => useBackgroundJobs ( ) )
137- const job1 = createMockJob ( { id : 'job1' } )
138- const job2 = createMockJob ( { id : 'job2' } )
150+ const job1 = createMockJob ( {
151+ id : 'resp_abcdef1234567890abcdef1234567890abcdef11' ,
152+ } )
153+ const job2 = createMockJob ( {
154+ id : 'resp_abcdef1234567890abcdef1234567890abcdef22' ,
155+ } )
139156
140157 act ( ( ) => {
141158 result . current . addJob ( job1 )
142159 result . current . addJob ( job2 )
143160 } )
144161
145162 act ( ( ) => {
146- result . current . removeJob ( 'job1' )
163+ result . current . removeJob (
164+ 'resp_abcdef1234567890abcdef1234567890abcdef11' ,
165+ )
147166 } )
148167
149168 expect ( result . current . jobs ) . toHaveLength ( 1 )
150169 expect ( result . current . jobs ) . toContainEqual ( job2 )
151- expect ( result . current . getJobById ( 'job1' ) ) . toBeUndefined ( )
152- expect ( result . current . getJobById ( 'job2' ) ) . toEqual ( job2 )
170+ expect (
171+ result . current . getJobById (
172+ 'resp_abcdef1234567890abcdef1234567890abcdef11' ,
173+ ) ,
174+ ) . toBeUndefined ( )
175+ expect (
176+ result . current . getJobById (
177+ 'resp_abcdef1234567890abcdef1234567890abcdef22' ,
178+ ) ,
179+ ) . toEqual ( job2 )
153180 } )
154181
155182 it ( 'should handle removing non-existent job gracefully' , ( ) => {
@@ -191,7 +218,9 @@ describe('useBackgroundJobs', () => {
191218
192219 it ( 'should handle updating non-existent job gracefully' , ( ) => {
193220 const { result } = renderHook ( ( ) => useBackgroundJobs ( ) )
194- const existingJob = createMockJob ( { id : 'existing' } )
221+ const existingJob = createMockJob ( {
222+ id : 'resp_abcdef1234567890abcdef1234567890abcdef99' ,
223+ } )
195224
196225 act ( ( ) => {
197226 result . current . addJob ( existingJob )
@@ -209,8 +238,12 @@ describe('useBackgroundJobs', () => {
209238
210239 it ( 'should clear all jobs' , ( ) => {
211240 const { result } = renderHook ( ( ) => useBackgroundJobs ( ) )
212- const job1 = createMockJob ( { id : 'job1' } )
213- const job2 = createMockJob ( { id : 'job2' } )
241+ const job1 = createMockJob ( {
242+ id : 'resp_abcdef1234567890abcdef1234567890abcdef11' ,
243+ } )
244+ const job2 = createMockJob ( {
245+ id : 'resp_abcdef1234567890abcdef1234567890abcdef22' ,
246+ } )
214247
215248 act ( ( ) => {
216249 result . current . addJob ( job1 )
@@ -257,17 +290,17 @@ describe('useBackgroundJobs', () => {
257290 it ( 'should handle concurrent job operations' , ( ) => {
258291 const { result } = renderHook ( ( ) => useBackgroundJobs ( ) )
259292 const runningJob = createMockJob ( {
260- id : 'concurrent-running-xyz ' ,
293+ id : 'resp_1111111111111111111111111111111111111111 ' ,
261294 status : 'running' ,
262295 title : 'Running Job' ,
263296 } )
264297 const completedJob = createMockJob ( {
265- id : 'concurrent-completed-abc ' ,
298+ id : 'resp_2222222222222222222222222222222222222222 ' ,
266299 status : 'completed' ,
267300 title : 'Completed Job' ,
268301 } )
269302 const failedJob = createMockJob ( {
270- id : 'concurrent-failed-def ' ,
303+ id : 'resp_3333333333333333333333333333333333333333 ' ,
271304 status : 'failed' ,
272305 title : 'Failed Job' ,
273306 } )
@@ -296,34 +329,45 @@ describe('useBackgroundJobs', () => {
296329 expect ( result . current . jobs ) . toHaveLength ( 3 )
297330
298331 act ( ( ) => {
299- result . current . removeJob ( 'concurrent-completed-abc' )
332+ result . current . removeJob (
333+ 'resp_2222222222222222222222222222222222222222' ,
334+ )
300335 } )
301336
302337 act ( ( ) => {
303- result . current . updateJob ( 'concurrent-running-xyz' , {
304- status : 'completed' ,
305- } )
338+ result . current . updateJob (
339+ 'resp_1111111111111111111111111111111111111111' ,
340+ {
341+ status : 'completed' ,
342+ } ,
343+ )
306344 } )
307345
308346 expect ( result . current . jobs ) . toHaveLength ( 2 )
309- expect ( result . current . getJobById ( 'concurrent-running-xyz' ) ?. status ) . toBe (
310- 'completed' ,
311- )
312347 expect (
313- result . current . getJobById ( 'concurrent-completed-abc' ) ,
348+ result . current . getJobById (
349+ 'resp_1111111111111111111111111111111111111111' ,
350+ ) ?. status ,
351+ ) . toBe ( 'completed' )
352+ expect (
353+ result . current . getJobById (
354+ 'resp_2222222222222222222222222222222222222222' ,
355+ ) ,
314356 ) . toBeUndefined ( )
315- expect ( result . current . getJobById ( 'concurrent-failed-def' ) ) . toEqual (
316- failedJob ,
317- )
357+ expect (
358+ result . current . getJobById (
359+ 'resp_3333333333333333333333333333333333333333' ,
360+ ) ,
361+ ) . toEqual ( failedJob )
318362 } )
319363
320364 it ( 'should maintain data integrity across browser sessions' , ( ) => {
321365 const job1 = createMockJob ( {
322- id : 'browser-session-alpha ' ,
366+ id : 'resp_6880e725623081a1af3dc14ba0d562620d62da8686c56bdd ' ,
323367 title : 'Session 1 Job' ,
324368 } )
325369 const job2 = createMockJob ( {
326- id : 'browser-session-beta ' ,
370+ id : 'resp_7e2b1c8e9f4a3d2b6c1e8f7a9d4c3b2e1f6a8d7c2b3e1f4a6c8d ' ,
327371 title : 'Session 2 Job' ,
328372 } )
329373
@@ -351,30 +395,42 @@ describe('useBackgroundJobs', () => {
351395 const secondSessionResult = renderHook ( ( ) => useBackgroundJobs ( ) )
352396 expect ( secondSessionResult . result . current . jobs ) . toHaveLength ( 2 )
353397 expect (
354- secondSessionResult . result . current . getJobById ( 'browser-session-alpha' ) ,
398+ secondSessionResult . result . current . getJobById (
399+ 'resp_6880e725623081a1af3dc14ba0d562620d62da8686c56bdd' ,
400+ ) ,
355401 ) . toEqual ( job1 )
356402 expect (
357- secondSessionResult . result . current . getJobById ( 'browser-session-beta' ) ,
403+ secondSessionResult . result . current . getJobById (
404+ 'resp_7e2b1c8e9f4a3d2b6c1e8f7a9d4c3b2e1f6a8d7c2b3e1f4a6c8d' ,
405+ ) ,
358406 ) . toEqual ( job2 )
359407
360408 act ( ( ) => {
361- secondSessionResult . result . current . updateJob ( 'browser-session-alpha' , {
362- status : 'completed' ,
363- } )
409+ secondSessionResult . result . current . updateJob (
410+ 'resp_6880e725623081a1af3dc14ba0d562620d62da8686c56bdd' ,
411+ {
412+ status : 'completed' ,
413+ } ,
414+ )
364415 } )
365416
366417 expect (
367- secondSessionResult . result . current . getJobById ( 'browser-session-alpha' )
368- ?. status ,
418+ secondSessionResult . result . current . getJobById (
419+ 'resp_6880e725623081a1af3dc14ba0d562620d62da8686c56bdd' ,
420+ ) ?. status ,
369421 ) . toBe ( 'completed' )
370422
371423 act ( ( ) => {
372- secondSessionResult . result . current . removeJob ( 'browser-session-beta' )
424+ secondSessionResult . result . current . removeJob (
425+ 'resp_7e2b1c8e9f4a3d2b6c1e8f7a9d4c3b2e1f6a8d7c2b3e1f4a6c8d' ,
426+ )
373427 } )
374428
375429 expect ( secondSessionResult . result . current . jobs ) . toHaveLength ( 1 )
376430 expect (
377- secondSessionResult . result . current . getJobById ( 'browser-session-beta' ) ,
431+ secondSessionResult . result . current . getJobById (
432+ 'resp_7e2b1c8e9f4a3d2b6c1e8f7a9d4c3b2e1f6a8d7c2b3e1f4a6c8d' ,
433+ ) ,
378434 ) . toBeUndefined ( )
379435
380436 secondSessionResult . unmount ( )
@@ -383,13 +439,15 @@ describe('useBackgroundJobs', () => {
383439 expect ( thirdSessionResult . result . current . jobs ) . toHaveLength ( 1 )
384440
385441 const persistedJob = thirdSessionResult . result . current . getJobById (
386- 'browser-session-alpha ' ,
442+ 'resp_6880e725623081a1af3dc14ba0d562620d62da8686c56bdd ' ,
387443 )
388444 expect ( persistedJob ) . toBeDefined ( )
389445 expect ( persistedJob ?. status ) . toBe ( 'completed' )
390446 expect ( persistedJob ?. title ) . toBe ( 'Session 1 Job' ) // Should preserve other fields
391447 expect (
392- thirdSessionResult . result . current . getJobById ( 'browser-session-beta' ) ,
448+ thirdSessionResult . result . current . getJobById (
449+ 'resp_7e2b1c8e9f4a3d2b6c1e8f7a9d4c3b2e1f6a8d7c2b3e1f4a6c8d' ,
450+ ) ,
393451 ) . toBeUndefined ( )
394452 thirdSessionResult . unmount ( )
395453 } )
0 commit comments