@@ -7,6 +7,8 @@ import { CompetitionResultsContainer } from './CompetitionResults';
77let mockWcaLiveRoundResults : unknown [ ] = [ ] ;
88let mockWcaCompetitionResults : unknown [ ] | undefined = [ ] ;
99let mockWcaCompetitionResultsStatus = 'success' ;
10+ const mockUseWcaLiveRoundLink = jest . fn ( ) ;
11+ const mockUseWcaLiveRoundResults = jest . fn ( ) ;
1012
1113jest . mock ( '@/components/Container' , ( ) => ( {
1214 Container : ( { children } : { children : React . ReactNode } ) => < div > { children } </ div > ,
@@ -18,14 +20,8 @@ jest.mock('@/lib/events', () => ({
1820} ) ) ;
1921
2022jest . mock ( '@/hooks/queries/useWcaLive' , ( ) => ( {
21- useWcaLiveRoundLink : ( ) => ( {
22- data : 'https://live.worldcubeassociation.org/competitions/TestComp2026/rounds/1' ,
23- status : 'success' ,
24- } ) ,
25- useWcaLiveRoundResults : ( ) => ( {
26- data : { results : mockWcaLiveRoundResults } ,
27- status : 'success' ,
28- } ) ,
23+ useWcaLiveRoundLink : ( ...args : unknown [ ] ) => mockUseWcaLiveRoundLink ( ...args ) ,
24+ useWcaLiveRoundResults : ( ...args : unknown [ ] ) => mockUseWcaLiveRoundResults ( ...args ) ,
2925} ) ) ;
3026
3127jest . mock ( '@/hooks/queries/useWcaResults' , ( ) => ( {
@@ -248,6 +244,14 @@ describe('CompetitionResultsContainer', () => {
248244 mockWcaLiveRoundResults = [ ] ;
249245 mockWcaCompetitionResults = [ ] ;
250246 mockWcaCompetitionResultsStatus = 'success' ;
247+ mockUseWcaLiveRoundLink . mockReturnValue ( {
248+ data : 'https://live.worldcubeassociation.org/competitions/TestComp2026/rounds/1' ,
249+ status : 'success' ,
250+ } ) ;
251+ mockUseWcaLiveRoundResults . mockImplementation ( ( ) => ( {
252+ data : { results : mockWcaLiveRoundResults } ,
253+ status : 'success' ,
254+ } ) ) ;
251255 } ) ;
252256
253257 afterEach ( ( ) => {
@@ -380,7 +384,11 @@ describe('CompetitionResultsContainer', () => {
380384 round_type_id : '2' ,
381385 format_id : 'a' ,
382386 wca_id : '2010THOM03' ,
383- attempts : [ 900 , 950 , 1000 ] ,
387+ attempts : [ 900 , 950 , 1000 , 1050 , 1200 ] ,
388+ best_index : 0 ,
389+ worst_index : 4 ,
390+ regional_single_record : 'NR' ,
391+ regional_average_record : 'WR' ,
384392 } ,
385393 ] ;
386394
@@ -391,10 +399,31 @@ describe('CompetitionResultsContainer', () => {
391399 'href' ,
392400 '/competitions/TestComp2026/persons/1/results' ,
393401 ) ;
402+ expect (
403+ within ( screen . getByRole ( 'row' , { name : / 1 B l a k e T h o m p s o n / } ) ) . getByText ( '(9.00)' ) ,
404+ ) . toBeInTheDocument ( ) ;
405+ expect (
406+ within ( screen . getByRole ( 'row' , { name : / 1 B l a k e T h o m p s o n / } ) ) . getByText ( '(12.00)' ) ,
407+ ) . toBeInTheDocument ( ) ;
394408 expect (
395409 within ( screen . getByRole ( 'row' , { name : / 1 B l a k e T h o m p s o n / } ) ) . getAllByText ( '9.50' ) ,
396410 ) . toHaveLength ( 2 ) ;
397- expect ( screen . getAllByText ( '9.00' ) ) . toHaveLength ( 2 ) ;
411+ expect ( screen . getAllByText ( '9.00' ) ) . toHaveLength ( 1 ) ;
412+ expect ( screen . getByLabelText ( 'WR record' ) ) . toHaveTextContent ( 'WR' ) ;
413+ expect ( screen . getByLabelText ( 'NR record' ) ) . toHaveTextContent ( 'NR' ) ;
414+ expect (
415+ within ( screen . getByRole ( 'navigation' , { name : 'Event rounds' } ) )
416+ . getAllByRole ( 'link' )
417+ . map ( ( link ) => link . getAttribute ( 'href' ) ) ,
418+ ) . toEqual ( [
419+ '/competitions/TestComp2026/results/333-r1' ,
420+ '/competitions/TestComp2026/results/333-r2' ,
421+ ] ) ;
422+ expect (
423+ within ( screen . getByRole ( 'navigation' , { name : 'Event rounds' } ) ) . getByRole ( 'link' , {
424+ name : / R o u n d 2 / ,
425+ } ) ,
426+ ) . toHaveClass ( 'bg-blue-700' , 'text-white' ) ;
398427 expect (
399428 within ( screen . getByRole ( 'navigation' , { name : 'Round' } ) ) . getAllByText ( 'Done' ) ,
400429 ) . toHaveLength ( 2 ) ;
@@ -413,16 +442,23 @@ describe('CompetitionResultsContainer', () => {
413442 } ) ;
414443
415444 it ( 'uses WCA Live partial results for the selected round when they are available' , ( ) => {
416- jest . useFakeTimers ( ) . setSystemTime ( new Date ( '2026-05-03T12:00:00' ) ) ;
417445 mockWcaLiveRoundResults = [
418446 {
419447 id : 'live-result-1' ,
420448 ranking : 3 ,
421449 advancing : true ,
422450 advancingQuestionable : true ,
423- attempts : [ { result : 1100 } , { result : 1200 } ] ,
451+ attempts : [
452+ { result : 1100 } ,
453+ { result : 1200 } ,
454+ { result : 1300 } ,
455+ { result : 1400 } ,
456+ { result : 1500 } ,
457+ ] ,
424458 best : 1100 ,
425- average : 0 ,
459+ average : 1300 ,
460+ singleRecordTag : 'PR' ,
461+ averageRecordTag : 'PR' ,
426462 person : {
427463 id : 'live-person-1' ,
428464 registrantId : 1 ,
@@ -433,6 +469,15 @@ describe('CompetitionResultsContainer', () => {
433469
434470 renderResults ( '333-r1' ) ;
435471
472+ expect ( mockUseWcaLiveRoundLink ) . toHaveBeenCalledWith ( 'TestComp2026' , '333' , 1 , {
473+ enabled : true ,
474+ } ) ;
475+ expect ( mockUseWcaLiveRoundResults ) . toHaveBeenCalledWith (
476+ 'https://live.worldcubeassociation.org/competitions/TestComp2026/rounds/1' ,
477+ {
478+ enabled : true ,
479+ } ,
480+ ) ;
436481 expect ( screen . getByRole ( 'link' , { name : 'Blake Thompson' } ) ) . toHaveAttribute (
437482 'href' ,
438483 '/competitions/TestComp2026/persons/1/results' ,
@@ -451,14 +496,23 @@ describe('CompetitionResultsContainer', () => {
451496 expect (
452497 within ( screen . getByRole ( 'row' , { name : / C a s e y N g u y e n / } ) ) . getAllByRole ( 'cell' ) [ 0 ] ,
453498 ) . toBeEmptyDOMElement ( ) ;
454- expect ( screen . getAllByText ( '11.00' ) ) . toHaveLength ( 2 ) ;
499+ expect (
500+ within ( screen . getByRole ( 'row' , { name : / 3 B l a k e T h o m p s o n / } ) ) . getByText ( '(11.00)' ) ,
501+ ) . toBeInTheDocument ( ) ;
502+ expect (
503+ within ( screen . getByRole ( 'row' , { name : / 3 B l a k e T h o m p s o n / } ) ) . getByText ( '(15.00)' ) ,
504+ ) . toBeInTheDocument ( ) ;
505+ expect ( screen . getAllByText ( '11.00' ) ) . toHaveLength ( 1 ) ;
506+ expect ( screen . getAllByLabelText ( 'PR record' ) . map ( ( badge ) => badge . textContent ) ) . toEqual ( [
507+ 'PR' ,
508+ 'PR' ,
509+ ] ) ;
455510 expect (
456511 within ( screen . getByRole ( 'row' , { name : / 2 N i c k S i l v e s t r i / } ) ) . getAllByText ( '15.00' ) ,
457512 ) . toHaveLength ( 2 ) ;
458513 expect (
459514 screen . getByText ( 'Data is pulled from WCA Live and may be delayed.' ) ,
460515 ) . toBeInTheDocument ( ) ;
461- expect ( screen . queryByText ( '13.00' ) ) . not . toBeInTheDocument ( ) ;
462516 } ) ;
463517
464518 it ( 'opens full result details from a narrow results row' , ( ) => {
0 commit comments