@@ -6,6 +6,7 @@ import logger from './logger.js'
66import getEnv from './env.js'
77import httpClient from './httpClient.js'
88import fs from 'fs'
9+ import { resolveCustomCSS } from './utils.js'
910
1011export default ( options : Record < string , string > ) : Context => {
1112 let env : Env = getEnv ( ) ;
@@ -25,6 +26,9 @@ export default (options: Record<string, string>): Context => {
2526 let buildNameObj : string ;
2627 let allowDuplicateSnapshotNames : boolean = false ;
2728 let useLambdaInternal : boolean = false ;
29+ let useRemoteDiscovery : boolean = false ;
30+ let useExtendedViewport : boolean = false ;
31+ let loadDomContent : boolean = false ;
2832 try {
2933 if ( options . config ) {
3034 config = JSON . parse ( fs . readFileSync ( options . config , 'utf-8' ) ) ;
@@ -37,12 +41,32 @@ export default (options: Record<string, string>): Context => {
3741 delete config . web . resolutions ;
3842 }
3943
44+ if ( config . approvalThreshold && config . rejectionThreshold ) {
45+ if ( config . rejectionThreshold <= config . approvalThreshold ) {
46+ throw new Error ( 'Invalid config; rejectionThreshold must be greater than approvalThreshold' ) ;
47+ }
48+ }
49+
4050 let validateConfigFn = options . scheduled ? validateConfigForScheduled : validateConfig ;
4151
4252 // validate config
4353 if ( ! validateConfigFn ( config ) ) {
4454 throw new Error ( validateConfigFn . errors [ 0 ] . message ) ;
4555 }
56+
57+ // Resolve customCSS if provided
58+ if ( ( config as any ) . customCSS ) {
59+ try {
60+ ( config as any ) . customCSS = resolveCustomCSS (
61+ ( config as any ) . customCSS ,
62+ options . config ,
63+ logger
64+ ) ;
65+ logger . debug ( 'Successfully resolved and validated customCSS from config' ) ;
66+ } catch ( error : any ) {
67+ throw new Error ( `customCSS error: ${ error . message } ` ) ;
68+ }
69+ }
4670 } else {
4771 logger . info ( "## No config file provided. Using default config." ) ;
4872 }
@@ -71,6 +95,8 @@ export default (options: Record<string, string>): Context => {
7195 if ( options . userName && options . accessKey ) {
7296 env . LT_USERNAME = options . userName
7397 env . LT_ACCESS_KEY = options . accessKey
98+ // process.env.LT_USERNAME = options.userName
99+ // process.env.LT_ACCESS_KEY = options.accessKey
74100 }
75101 } catch ( error : any ) {
76102 console . log ( `[smartui] Error: ${ error . message } ` ) ;
@@ -100,6 +126,15 @@ export default (options: Record<string, string>): Context => {
100126 if ( config . useLambdaInternal ) {
101127 useLambdaInternal = true ;
102128 }
129+ if ( config . useRemoteDiscovery ) {
130+ useRemoteDiscovery = true ;
131+ }
132+ if ( config . useExtendedViewport ) {
133+ useExtendedViewport = true ;
134+ }
135+ if ( config . loadDomContent ) {
136+ loadDomContent = true ;
137+ }
103138
104139 //if config.waitForPageRender has value and if its less than 30000 then make it to 30000 default
105140 if ( config . waitForPageRender && config . waitForPageRender < 30000 ) {
@@ -132,6 +167,13 @@ export default (options: Record<string, string>): Context => {
132167 requestHeaders : config . requestHeaders || { } ,
133168 allowDuplicateSnapshotNames : allowDuplicateSnapshotNames ,
134169 useLambdaInternal : useLambdaInternal ,
170+ useRemoteDiscovery : useRemoteDiscovery ,
171+ useExtendedViewport : useExtendedViewport ,
172+ loadDomContent : loadDomContent ,
173+ approvalThreshold : config . approvalThreshold ,
174+ rejectionThreshold : config . rejectionThreshold ,
175+ showRenderErrors : config . showRenderErrors ?? false ,
176+ customCSS : ( config as any ) . customCSS
135177 } ,
136178 uploadFilePath : '' ,
137179 webStaticConfig : [ ] ,
@@ -169,14 +211,18 @@ export default (options: Record<string, string>): Context => {
169211 fetchResultsFileName : fetchResultsFileObj ,
170212 baselineBranch : options . baselineBranch || '' ,
171213 baselineBuild : options . baselineBuild || '' ,
172- githubURL : options . githubURL || ''
214+ githubURL : options . githubURL || '' ,
215+ showRenderErrors : options . showRenderErrors ? true : false ,
216+ userName : options . userName || '' ,
217+ accessKey : options . accessKey || ''
173218 } ,
174219 cliVersion : version ,
175220 totalSnapshots : - 1 ,
176221 isStartExec : false ,
177222 isSnapshotCaptured : false ,
178223 sessionCapabilitiesMap : new Map < string , any [ ] > ( ) ,
179224 buildToSnapshotCountMap : new Map < string , number > ( ) ,
225+ sessionIdToSnapshotNameMap : new Map < string , string [ ] > ( ) ,
180226 fetchResultsForBuild : new Array < string > ,
181227 orgId : 0 ,
182228 userId : 0 ,
0 commit comments