@@ -526,55 +526,54 @@ export function startPdfPolling(ctx: Context) {
526526 }
527527
528528 let attempts = 0 ;
529- const maxAttempts = 30 ; // 5 minutes (10 seconds * 30)
529+ const maxAttempts = 60 ; // 5 minutes (10 seconds * 30)
530530
531531 console . log ( chalk . yellow ( 'Waiting for results...' ) ) ;
532532
533533 const interval = setInterval ( async ( ) => {
534534 attempts ++ ;
535535
536536 try {
537- const response = await ctx . client . fetchPdfResults ( ctx , ctx . log ) ;
537+ const response = await ctx . client . fetchPdfResults ( ctx ) ;
538538
539- if ( response . status === 'success' && response . data && response . data . Screenshots ) {
539+ if ( response . screenshots ) {
540540 clearInterval ( interval ) ;
541541
542- const pdfGroups = groupScreenshotsByPdf ( response . data . Screenshots ) ;
543-
542+ const pdfGroups = groupScreenshotsByPdf ( response . screenshots ) ;
544543 const pdfsWithMismatches = countPdfsWithMismatches ( pdfGroups ) ;
545- const pagesWithMismatches = countPagesWithMismatches ( response . data . Screenshots ) ;
544+ const pagesWithMismatches = countPagesWithMismatches ( response . screenshots ) ;
546545
547546 console . log ( chalk . green ( '\n✓ PDF Test Results:' ) ) ;
548- console . log ( chalk . green ( `Build Name: ${ response . data . buildName } ` ) ) ;
549- console . log ( chalk . green ( `Project Name: ${ response . data . projectName } ` ) ) ;
547+ console . log ( chalk . green ( `Build Name: ${ response . build . name } ` ) ) ;
548+ console . log ( chalk . green ( `Project Name: ${ response . project . name } ` ) ) ;
550549 console . log ( chalk . green ( `Total PDFs: ${ Object . keys ( pdfGroups ) . length } ` ) ) ;
551- console . log ( chalk . green ( `Total Pages: ${ response . data . Screenshots . length } ` ) ) ;
550+ console . log ( chalk . green ( `Total Pages: ${ response . screenshots . length } ` ) ) ;
552551
553552 if ( pdfsWithMismatches > 0 || pagesWithMismatches > 0 ) {
554- console . log ( chalk . yellow ( `${ pdfsWithMismatches } PDFs and ${ pagesWithMismatches } Pages in build ${ response . data . buildName } have changes present.` ) ) ;
553+ console . log ( chalk . yellow ( `${ pdfsWithMismatches } PDFs and ${ pagesWithMismatches } Pages in build ${ response . build . name } have changes present.` ) ) ;
555554 } else {
556555 console . log ( chalk . green ( 'All PDFs match the baseline.' ) ) ;
557556 }
558557
559558 Object . entries ( pdfGroups ) . forEach ( ( [ pdfName , pages ] ) => {
560- const hasMismatch = pages . some ( page => page . mismatchPercentage > 0 ) ;
559+ const hasMismatch = pages . some ( page => page . mismatch_percentage > 0 ) ;
561560 const statusColor = hasMismatch ? chalk . yellow : chalk . green ;
562561
563562 console . log ( statusColor ( `\n📄 ${ pdfName } (${ pages . length } pages)` ) ) ;
564563
565564 pages . forEach ( page => {
566- const pageStatusColor = page . mismatchPercentage > 0 ? chalk . yellow : chalk . green ;
567- console . log ( pageStatusColor ( ` - Page ${ getPageNumber ( page . screenshotName ) } : ${ page . status } (Mismatch: ${ page . mismatchPercentage } %)` ) ) ;
565+ const pageStatusColor = page . mismatch_percentage > 0 ? chalk . yellow : chalk . green ;
566+ console . log ( pageStatusColor ( ` - Page ${ getPageNumber ( page . screenshot_name ) } : ${ page . status } (Mismatch: ${ page . mismatch_percentage } %)` ) ) ;
568567 } ) ;
569568 } ) ;
570569
571570 const formattedResults = {
572- status : response . status ,
571+ status : 'success' ,
573572 data : {
574- buildId : response . data . buildId ,
575- buildName : response . data . buildName ,
576- projectName : response . data . projectName ,
577- buildStatus : response . data . buildStatus ,
573+ buildId : response . build . id ,
574+ buildName : response . build . name ,
575+ projectName : response . project . name ,
576+ buildStatus : response . build . build_satus ,
578577 pdfs : formatPdfsForOutput ( pdfGroups )
579578 }
580579 } ;
@@ -588,12 +587,6 @@ export function startPdfPolling(ctx: Context) {
588587 }
589588
590589 return ;
591- } else if ( response . status === 'error' ) {
592- clearInterval ( interval ) ;
593- console . log ( chalk . red ( `\nError fetching results: ${ response . message || 'Unknown error' } ` ) ) ;
594- return ;
595- } else {
596- process . stdout . write ( chalk . yellow ( '.' ) ) ;
597590 }
598591
599592 if ( attempts >= maxAttempts ) {
@@ -625,7 +618,7 @@ function groupScreenshotsByPdf(screenshots: any[]): Record<string, any[]> {
625618
626619 screenshots . forEach ( screenshot => {
627620 // screenshot name format: "pdf-name.pdf#page-number"
628- const pdfName = screenshot . screenshotName . split ( '#' ) [ 0 ] ;
621+ const pdfName = screenshot . screenshot_name . split ( '#' ) [ 0 ] ;
629622
630623 if ( ! pdfGroups [ pdfName ] ) {
631624 pdfGroups [ pdfName ] = [ ] ;
@@ -641,7 +634,7 @@ function countPdfsWithMismatches(pdfGroups: Record<string, any[]>): number {
641634 let count = 0 ;
642635
643636 Object . values ( pdfGroups ) . forEach ( pages => {
644- if ( pages . some ( page => page . mismatchPercentage > 0 ) ) {
637+ if ( pages . some ( page => page . mismatch_percentage > 0 ) ) {
645638 count ++ ;
646639 }
647640 } ) ;
@@ -650,7 +643,7 @@ function countPdfsWithMismatches(pdfGroups: Record<string, any[]>): number {
650643}
651644
652645function countPagesWithMismatches ( screenshots : any [ ] ) : number {
653- return screenshots . filter ( screenshot => screenshot . mismatchPercentage > 0 ) . length ;
646+ return screenshots . filter ( screenshot => screenshot . mismatch_percentage > 0 ) . length ;
654647}
655648
656649function formatPdfsForOutput ( pdfGroups : Record < string , any [ ] > ) : any [ ] {
@@ -659,12 +652,11 @@ function formatPdfsForOutput(pdfGroups: Record<string, any[]>): any[] {
659652 pdfName,
660653 pageCount : pages . length ,
661654 pages : pages . map ( page => ( {
662- pageNumber : getPageNumber ( page . screenshotName ) ,
663- screenshotId : page . screenshotId ,
664- mismatchPercentage : page . mismatchPercentage ,
665- threshold : page . threshold ,
655+ pageNumber : getPageNumber ( page . screenshot_name ) ,
656+ screenshotId : page . captured_image_id ,
657+ mismatchPercentage : page . mismatch_percentage ,
666658 status : page . status ,
667- screenshotUrl : page . screenshotUrl
659+ screenshotUrl : page . shareable_link
668660 } ) )
669661 } ;
670662 } ) ;
0 commit comments