From eab3bd8a568972e7a81d360afc115fa13d6c3625 Mon Sep 17 00:00:00 2001 From: Eugene Cheah Date: Wed, 8 Jun 2022 00:20:19 +0000 Subject: [PATCH] Fixing user agent handling bug --- src/api/SpaceAndProjectApi.js | 3 +++ src/cli-command/project/run.js | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/api/SpaceAndProjectApi.js b/src/api/SpaceAndProjectApi.js index 986f2df..b3d2d4e 100755 --- a/src/api/SpaceAndProjectApi.js +++ b/src/api/SpaceAndProjectApi.js @@ -301,6 +301,9 @@ class SpaceAndProjectApi { height: height, cli: 1 }; + if( testParams.userAgent != null && testParams.userAgent.length >= 1 ) { + reqObj.userAgent = testParams.userAgent; + } if( dataSetID != null ) { reqObj["environmentId"] = dataSetID; } else { diff --git a/src/cli-command/project/run.js b/src/cli-command/project/run.js index 6037508..6fe638c 100644 --- a/src/cli-command/project/run.js +++ b/src/cli-command/project/run.js @@ -158,6 +158,7 @@ class TestRunnerSession { // Script path and browser settings let scriptPath = argv["script-path"]; + let userAgent = argv.userAgent || null; let browser = argv.browser || "chrome"; let width = argv.width || 1280; let height = argv.height || 960; @@ -215,6 +216,7 @@ class TestRunnerSession { this.height = height; this.region = region; this.dataSet = dataSet; + this.userAgent = userAgent; this.startTimeout = startTimeout; this.startTimeout_sec = startTimeout_sec; this.startTimeout_ms = startTimeout_ms; @@ -259,6 +261,12 @@ class TestRunnerSession { `> Test Dir: ${this.testCodeDir}` ) } + // Custom UA + if( this.userAgent != null ) { + OutputHandler.standardGreen( + `> User Agent: ${this.userAgent}` + ) + } OutputHandler.standardGreen(">") } @@ -331,13 +339,9 @@ class TestRunnerSession { region: this.region, dataSetID: this.dataSetID, data: this.dataObject, - secretData: this.secretObject + secretData: this.secretObject, + userAgent: this.userAgent }; - - // User agent support - if( this.userAgent != null && this.userAgent != "" && this.userAgent.length > 2 ) { - startRequestParams.userAgent = this.userAgent; - } // Start the test let result = await SpaceAndProjectApi.startProjectTest( //