@@ -3,8 +3,9 @@ const fs = require('fs');
33const path = require ( 'path' )
44const formData = require ( 'form-data' ) ;
55const { JSDOM } = require ( "jsdom" ) ;
6+ const Table = require ( 'cli-table3' ) ;
67var { constants } = require ( './constants' ) ;
7- const { getLastCommit } = require ( './git' )
8+ const { getLastCommit } = require ( './git' ) ;
89
910var INTERVAL = 2000
1011const MAX_INTERVAL = 512000
@@ -88,22 +89,41 @@ async function shortPolling(buildId, retries = 0, options) {
8889 if ( response . data . buildStatus === 'completed' ) {
8990 console . log ( '[smartui] Build successful\n' ) ;
9091 console . log ( '[smartui] Build details:\n' ,
91- // 'Build URL: ', response.data.buildId , '\n',
92+ 'Build URL: ' , response . data . buildURL , '\n' ,
9293 'Build Name: ' , response . data . buildName , '\n' ,
93- 'Total Screenshots: ' , response . data . screenshots . length , '\n' ,
94+ 'Total Screenshots: ' , response . data . totalScreenshots , '\n' ,
9495 'Approved: ' , response . data . buildResults . approved , '\n' ,
9596 'Changes found: ' , response . data . buildResults . changesFound , '\n'
9697 ) ;
97-
98- response . data . screenshots . forEach ( screenshot => {
99- console . log ( screenshot . storyName , ' | Mis-match: ' , screenshot . mismatchPercentage ) ;
100- } ) ;
101-
98+
99+ if ( response . data . screenshots && response . data . screenshots . length > 0 ) {
100+ import ( 'chalk' ) . then ( ( chalk ) => {
101+ const table = new Table ( {
102+ head : [
103+ { content : chalk . default . white ( 'Story' ) , hAlign : 'center' } ,
104+ { content : chalk . default . white ( 'Mis-match %' ) , hAlign : 'center' } ,
105+ ]
106+ } ) ;
107+ response . data . screenshots . forEach ( screenshot => {
108+ let mismatch = screenshot . mismatchPercentage
109+ table . push ( [
110+ chalk . default . yellow ( screenshot . storyName ) ,
111+ mismatch > 0 ? chalk . default . red ( mismatch ) : chalk . default . green ( mismatch )
112+ ] )
113+ } ) ;
114+ console . log ( table . toString ( ) ) ;
115+ } )
116+ } else {
117+ if ( response . data . baseline ) {
118+ console . log ( 'No comparisons run. This is a baseline build.' ) ;
119+ }
120+ console . log ( 'No comparisons run. No screenshot in the current build has the corresponding screenshot in baseline build.' ) ;
121+ }
102122 return ;
103123 } else {
104124 if ( response . data . screenshots && response . data . screenshots . length > 0 ) {
105- // TODO: show Screenshots processed 8/10
106- console . log ( '[smartui] Screenshots processed : ' , response . data . screenshots . length )
125+ // TODO: show Screenshots processed current/total
126+ console . log ( '[smartui] Screenshots compared : ' , response . data . screenshots . length )
107127 }
108128 }
109129 }
@@ -125,8 +145,7 @@ async function shortPolling(buildId, retries = 0, options) {
125145 console . log ( '[smartui] Please check the build status on LambdaTest SmartUI.' ) ;
126146 return ;
127147 }
128-
129- console . log ( 'here2' ) ;
148+
130149 setTimeout ( function ( ) {
131150 shortPolling ( buildId , retries + 1 , options ) ;
132151 } , 2000 ) ;
0 commit comments