From d85bc4dcd075592838c349033433b65ee190f976 Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:43:01 +0530 Subject: [PATCH 01/61] Release v1.2.9 to develop (#82) Release v1.2.9 to develop --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ce6560d1..b3731133 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@provartesting/provardx-cli", "description": "A plugin for the Salesforce CLI to orchestrate testing activities and report quality metrics to Provar Manager", - "version": "1.2.7", + "version": "1.2.9", "license": "BSD-3-Clause", "plugins": [ "@provartesting/provardx-plugins-automation", @@ -19,8 +19,8 @@ "jsonschema": "^1.4.1", "node-stream-zip": "^1.15.0", "@provartesting/provardx-plugins-utils": "1.0.1", - "@provartesting/provardx-plugins-automation": "1.0.0", - "@provartesting/provardx-plugins-manager": "1.0.4", + "@provartesting/provardx-plugins-automation": "1.0.1", + "@provartesting/provardx-plugins-manager": "1.0.5", "sync-request": "^6.1.0", "xml-js": "^1.6.11" }, From 3cf3ae299f9c8a22b2083f4639af6e1383451f8c Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Fri, 26 Jul 2024 20:50:10 +0530 Subject: [PATCH 02/61] Release v1.2.10 to develop (#84) Release v1.2.10 to develop with version changes --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b3731133..21935568 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@provartesting/provardx-cli", "description": "A plugin for the Salesforce CLI to orchestrate testing activities and report quality metrics to Provar Manager", - "version": "1.2.9", + "version": "1.2.10", "license": "BSD-3-Clause", "plugins": [ "@provartesting/provardx-plugins-automation", @@ -19,7 +19,7 @@ "jsonschema": "^1.4.1", "node-stream-zip": "^1.15.0", "@provartesting/provardx-plugins-utils": "1.0.1", - "@provartesting/provardx-plugins-automation": "1.0.1", + "@provartesting/provardx-plugins-automation": "1.0.2", "@provartesting/provardx-plugins-manager": "1.0.5", "sync-request": "^6.1.0", "xml-js": "^1.6.11" From a470266bcb7c4a8d0df38ec5bf42a9687da40b3b Mon Sep 17 00:00:00 2001 From: himanshubhardwajprovar <48718034+himanshubhardwajprovar@users.noreply.github.com> Date: Mon, 26 Aug 2024 15:22:52 +0530 Subject: [PATCH 03/61] PDX-357: Adding tag while publishing npm plugin (#85) Adding tag while publishing npm plugin --- .github/workflows/DeployManual.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/DeployManual.yml b/.github/workflows/DeployManual.yml index a8115bc0..271f1d00 100644 --- a/.github/workflows/DeployManual.yml +++ b/.github/workflows/DeployManual.yml @@ -3,6 +3,9 @@ on: release: types: [published] workflow_dispatch: + inputs: + tag: + description: 'tag name e.g. beta, latest etc.' jobs: build: runs-on: ubuntu-latest @@ -25,6 +28,6 @@ jobs: cat /home/runner/work/_temp/.npmrc cat $NPM_CONFIG_USERCONFIG - name: Publish package on NPM - run: yarn publish + run: yarn publish --tag ${{ inputs.tag }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 3b1673cebb9859470dc9b90a59f6f3bdfd479935 Mon Sep 17 00:00:00 2001 From: himanshubhardwajprovar <48718034+himanshubhardwajprovar@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:46:03 +0530 Subject: [PATCH 04/61] PDX-382: Linking to utils before building (#86) Linking to utils before building --- .github/workflows/CI_Execution.yml | 53 ++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI_Execution.yml b/.github/workflows/CI_Execution.yml index d9d86513..8d549cce 100644 --- a/.github/workflows/CI_Execution.yml +++ b/.github/workflows/CI_Execution.yml @@ -13,7 +13,7 @@ on: workflow_dispatch: inputs: OS: - description: 'Comma-separated list of OS versions e.g. "macos-latest, windows-latest, ubuntu-latest"' + description: 'Comma-separated list of OS versions e.g. "windows-latest, ubuntu-latest"' default: '"ubuntu-latest"' required: true @@ -37,13 +37,60 @@ jobs: key: ${{ runner.os }}-node-v${{ matrix.nodeversion }}-${{ hashFiles('**/package.json') }} restore-keys: | ${{ runner.os }}-node-v${{ matrix.nodeversion }}- + - name: 'sf installation' + run: | + npm install -g @salesforce/cli + + - name: Determine Branch Name + id: set_branch_name + run: | + if [[ "${GITHUB_HEAD_REF}" ]]; then + echo "BRANCH_NAME=${GITHUB_HEAD_REF}" >> $GITHUB_ENV + else + echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV + fi + + - name: Check for target branch in Utils repo + id: check_branch + uses: actions/github-script@v6 + with: + script: | + const branch = process.env.BRANCH_NAME; + let branchExists = false; + try { + await github.rest.repos.getBranch({ + owner: 'ProvarTesting', + repo: 'provardx-plugins-utils', + branch: branch, + }); + branchExists = true; + } catch (error) { + console.log(`Branch ${branch} does not exist, falling back to develop.`); + } + return branchExists; + + - name: Check out Utils repo + uses: actions/checkout@v4 + with: + repository: ProvarTesting/provardx-plugins-utils + path: utils + ref: ${{ steps.check_branch.outputs.result == 'true' && env.BRANCH_NAME || 'develop' }} + token: ${{ secrets.PATUTILS }} + - name: Utils build and link + run: | + cd utils + yarn && yarn prepack + yarn link - name: Install Dependencies run: | - npm install -g @salesforce/cli yarn + - name: Link utils package + run: | + yarn link @provartesting/provardx-plugins-utils - name: Build the project run: | - yarn prepack + sf plugins link . + yarn prepack - name: Check out Regression repo uses: actions/checkout@v4 with: From 5a26aa47e6d03310fff1715db64acd85dae21f0e Mon Sep 17 00:00:00 2001 From: priyaprovar <92858824+priyaprovar@users.noreply.github.com> Date: Tue, 27 Aug 2024 22:33:25 +0530 Subject: [PATCH 05/61] PDX-391: Updated nuts for testoutputLevel and pluginOutputLevel that is added in boilerPlate (#87) RCA: testoutputLevel and pluginOutputLevel are added in boilerplate Fix: NUTs are update and added checks for testoutputLevel and pluginOutputLeve --- package.json | 2 +- test/assertion/loadConstants.ts | 4 +-- test/assertion/validateConstants.ts | 8 +++--- .../provar/automation/config/get.nut.ts | 28 +++++++++++++++++++ 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 21935568..e5cfbef3 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "postpack": "shx rm -f oclif.manifest.json", "prepack": "sf-prepack", "test": "wireit", - "test:nuts": "nyc mocha \"**/*setup.nut.ts\" \"**/*generate.nut.ts\" \"**/*permission.nut.ts\" \"**/*load.nut.ts\" \"**/*validate.nut.ts\" \"**/*get.nut.ts\" --slow 4500 --timeout 600000 --reporter mochawesome", + "test:nuts": "nyc mocha \"**/*generate.nut.ts\" \"**/*permission.nut.ts\" \"**/*load.nut.ts\" \"**/*validate.nut.ts\" \"**/*set.nut.ts\" \"**/*get.nut.ts\" --slow 4500 --timeout 600000 --reporter mochawesome", "test:only": "wireit", "version": "oclif readme" }, diff --git a/test/assertion/loadConstants.ts b/test/assertion/loadConstants.ts index 3455fca0..f69e7d0c 100644 --- a/test/assertion/loadConstants.ts +++ b/test/assertion/loadConstants.ts @@ -7,7 +7,7 @@ export const loadSuccessMessage = 'The properties file was loaded successfully.\n'; export const multipleErrors = - "Error (1): [MISSING_PROPERTY] The property 'projectPath' is missing. [INVALID_VALUES] The properties 'resultsPathDisposition', 'stopOnError', 'metadata.metadataLevel', 'environment.webBrowser' values are not valid.\n\n"; + "Error (1): [MISSING_PROPERTY] The property 'projectPath' is missing. [INVALID_VALUES] The properties 'resultsPathDisposition', 'testOutputLevel', 'pluginOutputlevel', 'stopOnError', 'metadata.metadataLevel', 'environment.webBrowser' values are not valid.\n\n"; export const invalidValuesError = "Error (1): [INVALID_VALUES] The properties 'provarHome', 'projectPath', 'resultsPath', 'metadata.metadataLevel', 'metadata.cachePath', 'environment.webBrowser', 'environment.webBrowserConfig', 'environment.webBrowserProviderName', 'environment.webBrowserDeviceName' values are not valid.\n\n"; @@ -46,7 +46,7 @@ export const multipleJsonErrors = { { code: 'INVALID_VALUES', message: - "The properties 'resultsPathDisposition', 'stopOnError', 'metadata.metadataLevel', 'environment.webBrowser' values are not valid.", + "The properties 'resultsPathDisposition', 'testOutputLevel', 'pluginOutputlevel', 'stopOnError', 'metadata.metadataLevel', 'environment.webBrowser' values are not valid.", }, ], }, diff --git a/test/assertion/validateConstants.ts b/test/assertion/validateConstants.ts index 61d55433..b247979f 100644 --- a/test/assertion/validateConstants.ts +++ b/test/assertion/validateConstants.ts @@ -16,10 +16,10 @@ export const invalidValueError = "Error (1): [INVALID_VALUE] The property 'resultsPathDisposition' value is not valid.\n\n"; export const invalidValuesError = - "Error (1): [INVALID_VALUES] The properties 'resultsPathDisposition', 'stopOnError', 'metadata.metadataLevel', 'environment.webBrowser' values are not valid.\n\n"; + "Error (1): [INVALID_VALUES] The properties 'resultsPathDisposition', 'testOutputLevel', 'pluginOutputlevel', 'stopOnError', 'metadata.metadataLevel', 'environment.webBrowser' values are not valid.\n\n"; export const multipleErrors = - "Error (1): [MISSING_PROPERTY] The property 'provarHome' is missing. [INVALID_VALUES] The properties 'resultsPathDisposition', 'stopOnError', 'metadata.metadataLevel', 'environment.webBrowser' values are not valid.\n\n"; + "Error (1): [MISSING_PROPERTY] The property 'provarHome' is missing. [INVALID_VALUES] The properties 'resultsPathDisposition', 'testOutputLevel', 'pluginOutputlevel', 'stopOnError', 'metadata.metadataLevel', 'environment.webBrowser' values are not valid.\n\n"; export const validateSuccessJson = { status: 0, @@ -108,7 +108,7 @@ export const invalidValuesJsonError = { { code: 'INVALID_VALUES', message: - "The properties 'resultsPathDisposition', 'stopOnError', 'metadata.metadataLevel', 'environment.webBrowser' values are not valid.", + "The properties 'resultsPathDisposition', 'testOutputLevel', 'pluginOutputlevel', 'stopOnError', 'metadata.metadataLevel', 'environment.webBrowser' values are not valid.", }, ], }, @@ -127,7 +127,7 @@ export const multipleJsonErrors = { { code: 'INVALID_VALUES', message: - "The properties 'resultsPathDisposition', 'stopOnError', 'metadata.metadataLevel', 'environment.webBrowser' values are not valid.", + "The properties 'resultsPathDisposition', 'testOutputLevel', 'pluginOutputlevel', 'stopOnError', 'metadata.metadataLevel', 'environment.webBrowser' values are not valid.", }, ], }, diff --git a/test/commands/provar/automation/config/get.nut.ts b/test/commands/provar/automation/config/get.nut.ts index cdfb4acc..f4917a4b 100644 --- a/test/commands/provar/automation/config/get.nut.ts +++ b/test/commands/provar/automation/config/get.nut.ts @@ -151,6 +151,19 @@ describe('sf provar config get NUTs', () => { ).shellOutput; expect(getOutput.stdout).to.deep.equal('\n'); }); + it('value should be returned for testOutputLevel property', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} testOutputLevel` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal('BASIC\n'); + }); + + it('value should be returned for pluginOutputlevel property', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} pluginOutputlevel` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal('WARNING\n'); + }); it('value should be returned for resultsPathDisposition property in json format', () => { const getOutput = execCmd( @@ -160,6 +173,14 @@ describe('sf provar config get NUTs', () => { expect(getOutput?.result.value).to.deep.equal('Increment'); }); + it('value should be returned for lightningMode property in json format', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} lightningMode --json` + ).jsonOutput; + expect(getOutput?.result.success).to.deep.equal(true); + expect(getOutput?.result.value).to.deep.equal(true); + }); + it('Value should be returned successfully for metdata object', () => { const getOutput = execCmd( `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} metadata` @@ -206,6 +227,13 @@ describe('sf provar config get NUTs', () => { expect(getOutput.stdout).to.deep.equal('${PROVAR_TEST_PROJECT_SECRETS}\n'); }); + it('Value should be returned successfully for connectionRefreshType property', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} connectionRefreshType` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal('Reload\n'); + }); + it('value should be returned for new added property', () => { execCmd( `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "Test Suite"="Multiple Suites"` From 3ef579ba31703fb38279eba211d1aabba12a8a81 Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Thu, 29 Aug 2024 12:19:37 +0530 Subject: [PATCH 06/61] PDX-390: bumped version --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e5cfbef3..e3e097fc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@provartesting/provardx-cli", "description": "A plugin for the Salesforce CLI to orchestrate testing activities and report quality metrics to Provar Manager", - "version": "1.2.10", + "version": "1.3.0-vBeta", "license": "BSD-3-Clause", "plugins": [ "@provartesting/provardx-plugins-automation", @@ -18,9 +18,9 @@ "fast-xml-parser": "^4.3.6", "jsonschema": "^1.4.1", "node-stream-zip": "^1.15.0", - "@provartesting/provardx-plugins-utils": "1.0.1", - "@provartesting/provardx-plugins-automation": "1.0.2", - "@provartesting/provardx-plugins-manager": "1.0.5", + "@provartesting/provardx-plugins-utils": "1.1.0-vBeta", + "@provartesting/provardx-plugins-automation": "1.1.0-vBeta", + "@provartesting/provardx-plugins-manager": "1.1.0-vBeta", "sync-request": "^6.1.0", "xml-js": "^1.6.11" }, From aefb0d2e24b1749e9dfbb6fe628b2769c3a0eb8d Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Thu, 29 Aug 2024 18:31:31 +0530 Subject: [PATCH 07/61] PDX-390: bumped version --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e3e097fc..db3a0aa6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@provartesting/provardx-cli", "description": "A plugin for the Salesforce CLI to orchestrate testing activities and report quality metrics to Provar Manager", - "version": "1.3.0-vBeta", + "version": "1.3.0", "license": "BSD-3-Clause", "plugins": [ "@provartesting/provardx-plugins-automation", @@ -18,9 +18,9 @@ "fast-xml-parser": "^4.3.6", "jsonschema": "^1.4.1", "node-stream-zip": "^1.15.0", - "@provartesting/provardx-plugins-utils": "1.1.0-vBeta", - "@provartesting/provardx-plugins-automation": "1.1.0-vBeta", - "@provartesting/provardx-plugins-manager": "1.1.0-vBeta", + "@provartesting/provardx-plugins-utils": "1.1.0", + "@provartesting/provardx-plugins-automation": "1.1.0", + "@provartesting/provardx-plugins-manager": "1.1.0", "sync-request": "^6.1.0", "xml-js": "^1.6.11" }, From a6ab2c1319c990e1e785338092ab231626597fbd Mon Sep 17 00:00:00 2001 From: anu-22 <90439583+anu-22@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:23:11 +0530 Subject: [PATCH 08/61] Update CI_Execution.yml Updated parameters for windows OS --- .github/workflows/CI_Execution.yml | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/CI_Execution.yml b/.github/workflows/CI_Execution.yml index 8d549cce..a6c33d70 100644 --- a/.github/workflows/CI_Execution.yml +++ b/.github/workflows/CI_Execution.yml @@ -22,7 +22,7 @@ jobs: provardx-ci-execution: strategy: matrix: - os: ${{ fromJSON(format('[{0}]', inputs.OS || '"ubuntu-latest"')) }} + os: ${{ fromJSON(format('[{0}]', inputs.OS || '"ubuntu-latest" || "macos-latest"')) }} nodeversion: [18] runs-on: ${{ matrix.os }} steps: @@ -33,7 +33,7 @@ jobs: - name: 'Cache node_modules' uses: actions/cache@v3 with: - path: ~/.npm + path: ${{ matrix.os == 'windows-latest' && 'C:\\Users\\runneradmin\\AppData\\Roaming\\npm-cache' || '~/.npm' }} key: ${{ runner.os }}-node-v${{ matrix.nodeversion }}-${{ hashFiles('**/package.json') }} restore-keys: | ${{ runner.os }}-node-v${{ matrix.nodeversion }}- @@ -42,13 +42,23 @@ jobs: npm install -g @salesforce/cli - name: Determine Branch Name - id: set_branch_name + if: matrix.os == 'windows-latest' + run: | + if ($env:GITHUB_HEAD_REF) { + echo "BRANCH_NAME=$env:GITHUB_HEAD_REF" | Out-File -FilePath $env:GITHUB_ENV -Append + } else { + echo "BRANCH_NAME=$(echo $env:GITHUB_REF -replace 'refs/heads/', '')" | Out-File -FilePath $env:GITHUB_ENV -Append + } + + - name: Determine Branch Name for Ubuntu/Mac + if: matrix.os != 'windows-latest' run: | if [[ "${GITHUB_HEAD_REF}" ]]; then - echo "BRANCH_NAME=${GITHUB_HEAD_REF}" >> $GITHUB_ENV + echo "BRANCH_NAME=${GITHUB_HEAD_REF}" >> $GITHUB_ENV else - echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV + echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV fi + shell: bash - name: Check for target branch in Utils repo id: check_branch @@ -82,11 +92,9 @@ jobs: yarn && yarn prepack yarn link - name: Install Dependencies - run: | - yarn + run: yarn - name: Link utils package - run: | - yarn link @provartesting/provardx-plugins-utils + run: yarn link @provartesting/provardx-plugins-utils - name: Build the project run: | sf plugins link . @@ -114,5 +122,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: nuts-report-${{ matrix.os }} - path: | - mochawesome-report + path: mochawesome-report From ce4405ef4f2ea6cafa77d546ebc435366a9667b5 Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:13:00 +0530 Subject: [PATCH 09/61] PDX-421 : Make Config Get/Set Commands Generic (#91) PDX-421 : Make Config Get/Set Commands Generic Make Config Get/Set Commands Generic. Restructuring commands to remove automation from them. Instead of reading from the loaded file reading the mandatory -f flag for file path --- ...var.config.get.md => provar.config.get.md} | 5 + ...var.config.set.md => provar.config.set.md} | 5 + .../provar/{automation => }/config/get.ts | 27 +++-- .../provar/{automation => }/config/set.ts | 27 +++-- test/assertion/commandConstants.ts | 7 ++ .../provar/automation/config/generate.nut.ts | 3 +- .../provar/automation/config/get.nut.ts | 90 +++++--------- .../provar/automation/config/load.nut.ts | 3 +- .../automation/config/permission.nut.ts | 3 +- .../provar/automation/config/set.nut.ts | 111 +++++++----------- .../provar/automation/config/validate.nut.ts | 3 +- 11 files changed, 135 insertions(+), 149 deletions(-) rename messages/{sf.provar.config.get.md => provar.config.get.md} (78%) rename messages/{sf.provar.config.set.md => provar.config.set.md} (79%) rename src/commands/provar/{automation => }/config/get.ts (82%) rename src/commands/provar/{automation => }/config/set.ts (85%) create mode 100644 test/assertion/commandConstants.ts diff --git a/messages/sf.provar.config.get.md b/messages/provar.config.get.md similarity index 78% rename from messages/sf.provar.config.get.md rename to messages/provar.config.get.md index a3b84bac..bf255c48 100644 --- a/messages/sf.provar.config.get.md +++ b/messages/provar.config.get.md @@ -15,3 +15,8 @@ Retrieves a value from the loaded properties file. # error.MultipleFailure %s + + +# flags.file-path.summary + +Config file-path to get the properties from. diff --git a/messages/sf.provar.config.set.md b/messages/provar.config.set.md similarity index 79% rename from messages/sf.provar.config.set.md rename to messages/provar.config.set.md index 51b7b29e..c20934b2 100644 --- a/messages/sf.provar.config.set.md +++ b/messages/provar.config.set.md @@ -15,3 +15,8 @@ Sets a property in the loaded properties file. # error.MultipleFailure %s + + +# flags.file-path.summary + +Config file-path to set the properties to. diff --git a/src/commands/provar/automation/config/get.ts b/src/commands/provar/config/get.ts similarity index 82% rename from src/commands/provar/automation/config/get.ts rename to src/commands/provar/config/get.ts index 1c8aa625..95a6f4b9 100644 --- a/src/commands/provar/automation/config/get.ts +++ b/src/commands/provar/config/get.ts @@ -6,9 +6,17 @@ */ import * as fileSystem from 'node:fs'; -import { SfCommand } from '@salesforce/sf-plugins-core'; -import { errorMessages, SfProvarCommandResult, populateResult, ErrorHandler, ProvarConfig, checkNestedProperty, getNestedProperty, Messages } from '@provartesting/provardx-plugins-utils'; - +import * as path from 'node:path'; +import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; +import { + errorMessages, + SfProvarCommandResult, + populateResult, + ErrorHandler, + checkNestedProperty, + getNestedProperty, + Messages, +} from '@provartesting/provardx-plugins-utils'; /** * Gets the value for specified propertykey under arguments from provardx-properties.json @@ -17,20 +25,25 @@ import { errorMessages, SfProvarCommandResult, populateResult, ErrorHandler, Pro */ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); -const messages = Messages.loadMessages('@provartesting/provardx-cli', 'sf.provar.config.get'); +const messages = Messages.loadMessages('@provartesting/provardx-cli', 'provar.config.get'); export default class SfProvarConfigGet extends SfCommand { public static readonly summary = messages.getMessage('summary'); public static readonly description = messages.getMessage('description'); public static readonly examples = messages.getMessages('examples'); public static readonly strict = false; - + public static readonly flags = { + 'file-path': Flags.string({ + summary: messages.getMessage('flags.file-path.summary'), + char: 'f', + required: true, + }), + }; private errorHandler = new ErrorHandler(); public async run(): Promise { const { argv, flags } = await this.parse(SfProvarConfigGet); - const config: ProvarConfig = await ProvarConfig.loadConfig(this.errorHandler); - const propertiesFilePath = config.get('PROVARDX_PROPERTIES_FILE_PATH')?.toString(); + const propertiesFilePath = path.resolve(flags['file-path']); let attributeValue = null; if (propertiesFilePath === undefined || !fileSystem.existsSync(propertiesFilePath)) { diff --git a/src/commands/provar/automation/config/set.ts b/src/commands/provar/config/set.ts similarity index 85% rename from src/commands/provar/automation/config/set.ts rename to src/commands/provar/config/set.ts index c1279cbb..1e10f2c8 100644 --- a/src/commands/provar/automation/config/set.ts +++ b/src/commands/provar/config/set.ts @@ -6,9 +6,17 @@ */ import * as fileSystem from 'node:fs'; -import { SfCommand, parseVarArgs } from '@salesforce/sf-plugins-core'; -import { SfProvarCommandResult, populateResult, ErrorHandler, Messages, ProvarConfig, parseJSONString, setNestedProperty, errorMessages } from '@provartesting/provardx-plugins-utils'; - +import * as path from 'node:path'; +import { SfCommand, parseVarArgs, Flags } from '@salesforce/sf-plugins-core'; +import { + SfProvarCommandResult, + populateResult, + ErrorHandler, + Messages, + parseJSONString, + setNestedProperty, + errorMessages, +} from '@provartesting/provardx-plugins-utils'; /** * Sets the specified property key and value inside provardx-properties.json @@ -17,22 +25,27 @@ import { SfProvarCommandResult, populateResult, ErrorHandler, Messages, ProvarCo */ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); -const messages = Messages.loadMessages('@provartesting/provardx-cli', 'sf.provar.config.set'); +const messages = Messages.loadMessages('@provartesting/provardx-cli', 'provar.config.set'); export default class SfProvarConfigSet extends SfCommand { public static readonly summary = messages.getMessage('summary'); public static readonly description = messages.getMessage('description'); public static readonly examples = messages.getMessages('examples'); public static readonly strict = false; + public static readonly flags = { + 'file-path': Flags.string({ + summary: messages.getMessage('flags.file-path.summary'), + char: 'f', + required: true, + }), + }; private errorHandler = new ErrorHandler(); public async run(): Promise { const { argv, flags } = await this.parse(SfProvarConfigSet); // eslint-disable-next-line - const config: ProvarConfig = await ProvarConfig.loadConfig(this.errorHandler); - const propertiesFilePath = config.get('PROVARDX_PROPERTIES_FILE_PATH')?.toString(); - + const propertiesFilePath = path.resolve(flags['file-path']); if (propertiesFilePath === undefined || !fileSystem.existsSync(propertiesFilePath)) { this.errorHandler.addErrorsToList('MISSING_FILE', errorMessages.MISSING_FILE_ERROR); return populateResult(flags, this.errorHandler, messages, this.log.bind(this)); diff --git a/test/assertion/commandConstants.ts b/test/assertion/commandConstants.ts new file mode 100644 index 00000000..4c4c3f66 --- /dev/null +++ b/test/assertion/commandConstants.ts @@ -0,0 +1,7 @@ +export enum commandConstants { + SF_PROVAR_AUTOMATION_CONFIG_GENERATE_COMMAND = 'provar automation config generate', + SF_PROVAR_AUTOMATION_CONFIG_LOAD_COMMAND = 'provar automation config load', + SF_PROVAR_AUTOMATION_CONFIG_VALIDATE_COMMAND = 'provar automation config validate', + SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND = 'provar config set', + SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND = 'provar config get', +} diff --git a/test/commands/provar/automation/config/generate.nut.ts b/test/commands/provar/automation/config/generate.nut.ts index 6caa7750..73d34168 100644 --- a/test/commands/provar/automation/config/generate.nut.ts +++ b/test/commands/provar/automation/config/generate.nut.ts @@ -8,13 +8,14 @@ import * as fileSystem from 'node:fs'; import { expect } from 'chai'; import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; -import { commandConstants, propertyFileContent, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; +import { propertyFileContent, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; import { INVALID_PATH, PASS_FILE_CONTENT, INVALID_FILE_EXTENSION } from '../../../../assertion/generateConstants.js'; import { successMessage, errorInvalidPath, errorInvalidFileExtension, } from '../../../../assertion/generateConstants.js'; +import { commandConstants } from '../../../../assertion/commandConstants.js'; describe('Config generate', () => { let testSession: TestSession; diff --git a/test/commands/provar/automation/config/get.nut.ts b/test/commands/provar/automation/config/get.nut.ts index f4917a4b..1b5aef8b 100644 --- a/test/commands/provar/automation/config/get.nut.ts +++ b/test/commands/provar/automation/config/get.nut.ts @@ -1,9 +1,9 @@ import * as fileSystem from 'node:fs'; import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; import { expect } from 'chai'; -import { commandConstants, errorMessages, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; -import * as validateConstants from '../../../../assertion/validateConstants.js'; +import { errorMessages, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; import * as getConstants from '../../../../assertion/getConstants.js'; +import { commandConstants } from '../../../../assertion/commandConstants.js'; describe('sf provar config get NUTs', () => { let session: TestSession; @@ -23,37 +23,6 @@ describe('sf provar config get NUTs', () => { }); }); - it('Missing file error as json file is not loaded', () => { - execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GENERATE_COMMAND} -p ${FILE_PATHS.INVALID_FILE}` - ); - const jsonFilePath = FILE_PATHS.INVALID_FILE; - const data = fileSystem.readFileSync(jsonFilePath, 'utf-8'); - const newData = data.substring(1); - fileSystem.writeFile(jsonFilePath, newData, (error) => { - if (error) { - return; - } - }); - execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_LOAD_COMMAND} -p ${FILE_PATHS.INVALID_FILE}` - ); - const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} provarHome` - ).shellOutput; - expect(result.stderr).to.deep.equal(`Error (1): [MISSING_FILE] ${errorMessages.MISSING_FILE_ERROR}\n\n`); - }); - - it('Missing file error in json format as json file is not loaded', () => { - const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} resultsPath --json`, - { - ensureExitCode: 0, - } - ); - expect(result.jsonOutput).to.deep.equal(validateConstants.missingFileJsonError); - }); - it('Missing property error as property name is missing', () => { execCmd( `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GENERATE_COMMAND} -p ${FILE_PATHS.VALUES_FILE}` @@ -63,42 +32,42 @@ describe('sf provar config get NUTs', () => { ); execCmd(`${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_VALIDATE_COMMAND}`); const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE}` ).shellOutput; expect(getOutput.stderr).to.deep.equal(`Error (1): [MISSING_PROPERTY] ${errorMessages.MISSING_PROPERTY_GET}\n\n`); }); it('Missing property error in json format as property name is missing', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} --json` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} --json` ).jsonOutput; expect(getOutput).to.deep.equal(getConstants.missingPropertyGetJson); }); it('Unknown Property error as property is not present in the file', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} metadata.test` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} metadata.test` ).shellOutput; expect(getOutput.stderr).to.deep.equal(`Error (1): [UNKNOWN_PROPERTY] ${errorMessages.UNKNOWN_PROPERTY}\n\n`); }); it('Unknown Property error as property is not present in the file', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} environment.webBrowserProvider` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} environment.webBrowserProvider` ).shellOutput; expect(getOutput.stderr).to.deep.equal(`Error (1): [UNKNOWN_PROPERTY] ${errorMessages.UNKNOWN_PROPERTY}\n\n`); }); it('Unknown Property error as property is not present in the file', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} projectPath.web` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} projectPath.web` ).shellOutput; expect(getOutput.stderr).to.deep.equal(`Error (1): [UNKNOWN_PROPERTY] ${errorMessages.UNKNOWN_PROPERTY}\n\n`); }); it('Unknown Property error in json format as property is not present in the file', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} sample --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} sample --json`, { ensureExitCode: 0, } @@ -109,10 +78,10 @@ describe('sf provar config get NUTs', () => { it('value should be returned for provarHome property', () => { const setProvarHome = 'C:/Users/anchal.goel/Downloads/main_win64_e413157177_20240117_0452/'; execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} provarHome=${setProvarHome}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} provarHome=${setProvarHome}` ); const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} provarHome` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} provarHome` ).shellOutput; expect(getOutput.stdout).to.deep.equal(`${setProvarHome}\n`); }); @@ -120,24 +89,24 @@ describe('sf provar config get NUTs', () => { it('value should be returned for projectPath property', () => { const setProjectPath = 'C:/Users/anchal.goel/Desktop/main_win64_e413157177_20240117_0452/'; const output = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} projectPath` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} projectPath` ).shellOutput; expect(output.stdout).to.deep.equal('${PROVAR_PROJECT_PATH}\n'); execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} projectPath=${setProjectPath}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} projectPath=${setProjectPath}` ); const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} "projectPath"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "projectPath"` ).shellOutput; expect(getOutput.stdout).to.deep.equal(`${setProjectPath}\n`); }); it('value should be returned for resultsPath property in json format', () => { execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "resultsPath"="C:/Users/anchal.goel/git/ProvarRegressionqam5/test/provardx/Results"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "resultsPath"="C:/Users/anchal.goel/git/ProvarRegressionqam5/test/provardx/Results"` ); const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} resultsPath --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} resultsPath --json`, { ensureExitCode: 0, } @@ -147,27 +116,27 @@ describe('sf provar config get NUTs', () => { it('value should be returned for smtpPath property', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} "smtpPath"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "smtpPath"` ).shellOutput; expect(getOutput.stdout).to.deep.equal('\n'); }); it('value should be returned for testOutputLevel property', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} testOutputLevel` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} testOutputLevel` ).shellOutput; expect(getOutput.stdout).to.deep.equal('BASIC\n'); }); it('value should be returned for pluginOutputlevel property', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} pluginOutputlevel` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} pluginOutputlevel` ).shellOutput; expect(getOutput.stdout).to.deep.equal('WARNING\n'); }); it('value should be returned for resultsPathDisposition property in json format', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} "resultsPathDisposition" --json` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "resultsPathDisposition" --json` ).jsonOutput; expect(getOutput?.result.success).to.deep.equal(true); expect(getOutput?.result.value).to.deep.equal('Increment'); @@ -175,7 +144,7 @@ describe('sf provar config get NUTs', () => { it('value should be returned for lightningMode property in json format', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} lightningMode --json` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} lightningMode --json` ).jsonOutput; expect(getOutput?.result.success).to.deep.equal(true); expect(getOutput?.result.value).to.deep.equal(true); @@ -183,14 +152,14 @@ describe('sf provar config get NUTs', () => { it('Value should be returned successfully for metdata object', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} metadata` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} metadata` ).shellOutput; expect(getOutput.stdout).to.deep.equal("{ metadataLevel: 'Reuse', cachePath: '../.provarCaches' }\n"); }); it('Value should be returned successfully for environment object in json format', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} environment --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} environment --json`, { ensureExitCode: 0, } @@ -200,21 +169,21 @@ describe('sf provar config get NUTs', () => { it('Value should be returned successfully for testEnvironment property in environment object', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} environment.testEnvironment` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} environment.testEnvironment` ).shellOutput; expect(getOutput.stdout).to.deep.equal('${PROVAR_TEST_ENVIRONMENT}\n'); }); it('Value should be returned successfully for webBrowserDeviceName property in environment object', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} "environment"."webBrowserDeviceName"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "environment"."webBrowserDeviceName"` ).shellOutput; expect(getOutput.stdout).to.deep.equal('Full Screen\n'); }); it('Value should be returned successfully for cachePath property in metadata object', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} metadata.cachePath --json` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} metadata.cachePath --json` ).jsonOutput; expect(getOutput?.result.success).to.deep.equal(true); expect(getOutput?.result.value).to.deep.equal('../.provarCaches'); @@ -222,25 +191,26 @@ describe('sf provar config get NUTs', () => { it('Value should be returned successfully for testprojectSecrets property', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} testprojectSecrets` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} testprojectSecrets` ).shellOutput; expect(getOutput.stdout).to.deep.equal('${PROVAR_TEST_PROJECT_SECRETS}\n'); }); it('Value should be returned successfully for connectionRefreshType property', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} connectionRefreshType` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} connectionRefreshType` ).shellOutput; expect(getOutput.stdout).to.deep.equal('Reload\n'); }); it('value should be returned for new added property', () => { execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "Test Suite"="Multiple Suites"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "Test Suite"="Multiple Suites"` ); const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} "Test Suite"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "Test Suite"` ).shellOutput; expect(getOutput.stdout).to.deep.equal('Multiple Suites\n'); }); + }); diff --git a/test/commands/provar/automation/config/load.nut.ts b/test/commands/provar/automation/config/load.nut.ts index 8df2029d..5b8c1d7d 100644 --- a/test/commands/provar/automation/config/load.nut.ts +++ b/test/commands/provar/automation/config/load.nut.ts @@ -8,9 +8,10 @@ import * as fileSystem from 'node:fs'; import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; import { expect } from 'chai'; -import { errorMessages, commandConstants, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; +import { errorMessages, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; import * as loadConstants from '../../../../assertion/loadConstants.js'; import * as validateConstants from '../../../../assertion/validateConstants.js'; +import { commandConstants } from '../../../../assertion/commandConstants.js'; describe('sf provar config load NUTs', () => { let session: TestSession; diff --git a/test/commands/provar/automation/config/permission.nut.ts b/test/commands/provar/automation/config/permission.nut.ts index 2b0e17fa..1efa73ab 100644 --- a/test/commands/provar/automation/config/permission.nut.ts +++ b/test/commands/provar/automation/config/permission.nut.ts @@ -9,9 +9,10 @@ import * as fileSystem from 'node:fs'; import { exec } from 'node:child_process'; import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; import { expect } from 'chai'; -import { commandConstants, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; +import { SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; import { INSUFFICIENT_PERMISSIONS, INVALID_PATH } from '../../../../assertion/generateConstants.js'; import { errorInsufficientPermissions, errorInvalidFileExtension } from '../../../../assertion/generateConstants.js'; +import { commandConstants } from '../../../../assertion/commandConstants.js'; describe('Handling Insufficient Permissions scenarios as write permission is removed from a folder', () => { let testSession: TestSession; diff --git a/test/commands/provar/automation/config/set.nut.ts b/test/commands/provar/automation/config/set.nut.ts index cc0e1669..3bec69b9 100644 --- a/test/commands/provar/automation/config/set.nut.ts +++ b/test/commands/provar/automation/config/set.nut.ts @@ -1,9 +1,9 @@ import * as fileSystem from 'node:fs'; import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; import { expect } from 'chai'; -import { errorMessages, commandConstants, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; -import * as validateConstants from '../../../../assertion/validateConstants.js'; +import { errorMessages, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; import * as setConstants from '../../../../assertion/setConstants.js'; +import { commandConstants } from '../../../../assertion/commandConstants.js'; describe('sf provar config set NUTs', () => { let session: TestSession; @@ -46,37 +46,6 @@ describe('sf provar config set NUTs', () => { }); }); - it('Missing file error should be thrown when json file is not loaded and return the error', () => { - execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GENERATE_COMMAND} -p ${FILE_PATHS.INVALID_FILE}` - ); - const jsonFilePath = FILE_PATHS.INVALID_FILE; - const data = fileSystem.readFileSync(jsonFilePath, 'utf-8'); - const newData = data.substring(1); - fileSystem.writeFile(jsonFilePath, newData, (error) => { - if (error) { - return; - } - }); - execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_LOAD_COMMAND} -p ${FILE_PATHS.INVALID_FILE}` - ); - const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} provarHome=notDefined` - ).shellOutput; - expect(result.stderr).to.deep.equal(`Error (1): [MISSING_FILE] ${errorMessages.MISSING_FILE_ERROR}\n\n`); - }); - - it('Missing file error should be thrown when json file is not loaded and return the error in json', () => { - const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} resultsPath=path --json`, - { - ensureExitCode: 0, - } - ); - expect(result.jsonOutput).to.deep.equal(validateConstants.missingFileJsonError); - }); - it('Missing property error should be thrown when property is not defined and return the error', () => { execCmd( `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GENERATE_COMMAND} -p ${FILE_PATHS.ERROR_FILE}` @@ -86,28 +55,28 @@ describe('sf provar config set NUTs', () => { ); execCmd(`${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_VALIDATE_COMMAND}`); const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} =Provar` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} =Provar` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [MISSING_PROPERTY] ${errorMessages.MISSING_PROPERTY}\n\n`); }); it('Missing property error should be thrown when property is not defined and return the error', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} ""=MissingProperty` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} ""=MissingProperty` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [MISSING_PROPERTY] ${errorMessages.MISSING_PROPERTY}\n\n`); }); it('Missing property error should be thrown when property is not defined and return the error', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE}` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [MISSING_PROPERTY] ${errorMessages.MISSING_PROPERTY}\n\n`); }); it('Missing property error should be thrown when property is not defined and return the error in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} =MissingProperty --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} =MissingProperty --json`, { ensureExitCode: 0, } @@ -117,21 +86,21 @@ describe('sf provar config set NUTs', () => { it('Missing value error should be thrown when value is not defined and return the error', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} missingValue=` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} missingValue=` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [MISSING_VALUE] ${errorMessages.MISSING_VALUE}\n\n`); }); it('Missing value error should be thrown when value is not defined and return the error', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "missingValue"=""` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} "missingValue"=""` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [MISSING_VALUE] ${errorMessages.MISSING_VALUE}\n\n`); }); it('Missing value error should be thrown when value is not defined and return the error in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} missingValueError= --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} missingValueError= --json`, { ensureExitCode: 0, } @@ -141,21 +110,21 @@ describe('sf provar config set NUTs', () => { it('Invalid argument error should be thrown when property and value is not defined in correct format and return the error', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} invalid = argument` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} invalid = argument` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [INVALID_ARGUMENT] ${errorMessages.INVALID_ARGUMENT}\n\n`); }); it('Invalid argument error should be thrown when property and value is not defined in correct format and return the error', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} attachmentProperties=random value` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} attachmentProperties=random value` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [INVALID_ARGUMENT] ${errorMessages.INVALID_ARGUMENT}\n\n`); }); it('Invalid argument error should be thrown when property and value is not defined in correct format and return the error in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "parsing" = "error" --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} "parsing" = "error" --json`, { ensureExitCode: 0, } @@ -172,7 +141,7 @@ describe('sf provar config set NUTs', () => { ); execCmd(`${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_VALIDATE_COMMAND}`); const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} provarHome=C:/Users/anchal.goel/Downloads/main_win64_e413157177_20240117_0452/ --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} provarHome=C:/Users/anchal.goel/Downloads/main_win64_e413157177_20240117_0452/ --json`, { ensureExitCode: 0, } @@ -182,14 +151,14 @@ describe('sf provar config set NUTs', () => { it('Value should be overwritten successfully for provarHome property in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "provarHome"=${SET_PROVAR_HOME_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "provarHome"=${SET_PROVAR_HOME_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('Value should be set successfully for resultsPath property in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "resultsPath"=${SET_RESULTS_PATH_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "resultsPath"=${SET_RESULTS_PATH_VALUE} --json`, { ensureExitCode: 0, } @@ -199,14 +168,14 @@ describe('sf provar config set NUTs', () => { it('Value should be set successfully for projectPath property in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "projectPath"=${SET_PROJECT_PATH_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "projectPath"=${SET_PROJECT_PATH_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('Value should be set successfully for smtpPath property in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} smtpPath=${SET_SMTP_PATH_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} smtpPath=${SET_SMTP_PATH_VALUE} --json`, { ensureExitCode: 0, } @@ -216,7 +185,7 @@ describe('sf provar config set NUTs', () => { it('Value should be set successfully for resultsPathDisposition property in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} resultsPathDisposition=${SET_RESULTS_PATH_DISPOSITION_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} resultsPathDisposition=${SET_RESULTS_PATH_DISPOSITION_VALUE} --json`, { ensureExitCode: 0, } @@ -226,7 +195,7 @@ describe('sf provar config set NUTs', () => { it('Value should be set successfully for testOutputLevel property in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "testOutputLevel"=${SET_TEST_OUTPUT_LEVEL_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "testOutputLevel"=${SET_TEST_OUTPUT_LEVEL_VALUE} --json`, { ensureExitCode: 0, } @@ -236,28 +205,28 @@ describe('sf provar config set NUTs', () => { it('Value should be set successfully for pluginOutputlevel property in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} pluginOutputlevel=${SET_PLUGIN_OUTPUTLEVEL_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} pluginOutputlevel=${SET_PLUGIN_OUTPUTLEVEL_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('Value should be set successfully for lightningMode property in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} lightningMode=${SET_LIGHTNING_MODE_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} lightningMode=${SET_LIGHTNING_MODE_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('Value should be set successfully for testEnvironment property in environment object in json file', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "environment.testEnvironment"=${SET_TEST_ENVIRONMENT_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "environment.testEnvironment"=${SET_TEST_ENVIRONMENT_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('New property should be set successfully in environment object in json file and return the success result in json format ', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} environment.newEnvironment=${SET_NEW_ENVIRONMENT_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} environment.newEnvironment=${SET_NEW_ENVIRONMENT_VALUE} --json`, { ensureExitCode: 0, } @@ -267,7 +236,7 @@ describe('sf provar config set NUTs', () => { it('Value should be set successfully for metadataLevel property in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "metadata.metadataLevel"=${SET_METADATA_LEVEL_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "metadata.metadataLevel"=${SET_METADATA_LEVEL_VALUE} --json`, { ensureExitCode: 0, } @@ -277,21 +246,21 @@ describe('sf provar config set NUTs', () => { it('Value should be set successfully for metadata cachePath property in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} metadata.cachePath=${SET_CACHE_PATH_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} metadata.cachePath=${SET_CACHE_PATH_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('Multiple properties with values should be set successfully and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} metadata.error=${SET_ERROR_VALUE} environment.key=${SET_KEY_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} metadata.error=${SET_ERROR_VALUE} environment.key=${SET_KEY_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('New property and Value of type array should be set successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "testCases"="[\\"/Test Case 1.testcase\\",\\"/Test Case 2.testcase\\",\\"/Test Case 3.testcase\\"]" --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "testCases"="[\\"/Test Case 1.testcase\\",\\"/Test Case 2.testcase\\",\\"/Test Case 3.testcase\\"]" --json`, { ensureExitCode: 0, } @@ -301,21 +270,21 @@ describe('sf provar config set NUTs', () => { it('New property and Value of type array should be set successfully in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "testcase"="[\\"tests/myTestCase.testcase\\",\\"tests/testSuite1/myTestCase1.testCase\\"]"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "testcase"="[\\"tests/myTestCase.testcase\\",\\"tests/testSuite1/myTestCase1.testCase\\"]"` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('New property and Value of type object should be set successfully in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "emailProperties"="{\\"sendEmail\\":true,\\"primaryRecipients\\":\\"anchal.goel@provartesting.com\\",\\"ccRecipients\\":\\"\\",\\"bccRecipients\\":\\"\\",\\"emailSubject\\":\\"Provar test run report\\",\\"attachExecutionReport\\":true,\\"attachZip\\":false}"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "emailProperties"="{\\"sendEmail\\":true,\\"primaryRecipients\\":\\"anchal.goel@provartesting.com\\",\\"ccRecipients\\":\\"\\",\\"bccRecipients\\":\\"\\",\\"emailSubject\\":\\"Provar test run report\\",\\"attachExecutionReport\\":true,\\"attachZip\\":false}"` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('New property and Value of type string should be set successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} test=${SET_TEST_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} test=${SET_TEST_VALUE} --json`, { ensureExitCode: 0, } @@ -325,7 +294,7 @@ describe('sf provar config set NUTs', () => { it('New property and Value of type string with special char should be set successfully in json file and return the success result in json format ', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "SpecialCharacters"=${SET_SPECIAL_CHARACTERS_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "SpecialCharacters"=${SET_SPECIAL_CHARACTERS_VALUE} --json`, { ensureExitCode: 0, } @@ -335,7 +304,7 @@ describe('sf provar config set NUTs', () => { it('New property and Value of type Boolean should be set successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} booleanValue=false --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} booleanValue=false --json`, { ensureExitCode: 0, } @@ -345,14 +314,14 @@ describe('sf provar config set NUTs', () => { it('New property and Value of type Boolean should be set successfully in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} status=true` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} status=true` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('New property and Value of type Number should be set successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} number=${SET_NUMBER_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} number=${SET_NUMBER_VALUE} --json`, { ensureExitCode: 0, } @@ -362,14 +331,14 @@ describe('sf provar config set NUTs', () => { it('New property and Value of type Number should be set successfully in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} number_Value=${SET_NUMBER_DECIMAL_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} number_Value=${SET_NUMBER_DECIMAL_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('New property and Value of type Null should be set successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} nullProperty=null --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} nullProperty=null --json`, { ensureExitCode: 0, } @@ -379,25 +348,25 @@ describe('sf provar config set NUTs', () => { it('New Object with property and Value should be created successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} world.country=${SET_COUNTRY_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} world.country=${SET_COUNTRY_VALUE} --json`, { ensureExitCode: 0, } ); expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); const resultSet = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} world.state=${SET_STATE_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} world.state=${SET_STATE_VALUE}` ).shellOutput; expect(resultSet.stdout).to.deep.equal(''); const output = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "world.city"=${SET_CITY_VALUE} --json` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "world.city"=${SET_CITY_VALUE} --json` ); expect(output.jsonOutput).to.deep.equal(setConstants.setSuccessJson); }); it('New Object with nested properties and Value should be created successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} company.team.employee.position=${SET_POSITION_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} company.team.employee.position=${SET_POSITION_VALUE} --json`, { ensureExitCode: 0, } diff --git a/test/commands/provar/automation/config/validate.nut.ts b/test/commands/provar/automation/config/validate.nut.ts index fd438fe7..07c22494 100644 --- a/test/commands/provar/automation/config/validate.nut.ts +++ b/test/commands/provar/automation/config/validate.nut.ts @@ -8,9 +8,10 @@ import * as fileSystem from 'node:fs'; import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; import { expect } from 'chai'; -import { errorMessages, commandConstants, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; +import { errorMessages, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; import * as validateConstants from '../../../../assertion/validateConstants.js'; import * as loadConstants from '../../../../assertion/loadConstants.js'; +import { commandConstants } from '../../../../assertion/commandConstants.js'; describe('sf provar config validate NUTs', () => { let session: TestSession; From 7fc54a45adb1dcdd5b63ac710cbef23ff10bce81 Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:06:18 +0530 Subject: [PATCH 10/61] PDX-439: bumped version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index db3a0aa6..2e3b05ce 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@provartesting/provardx-cli", "description": "A plugin for the Salesforce CLI to orchestrate testing activities and report quality metrics to Provar Manager", - "version": "1.3.0", + "version": "1.4.0-vBeta", "license": "BSD-3-Clause", "plugins": [ "@provartesting/provardx-plugins-automation", @@ -18,7 +18,7 @@ "fast-xml-parser": "^4.3.6", "jsonschema": "^1.4.1", "node-stream-zip": "^1.15.0", - "@provartesting/provardx-plugins-utils": "1.1.0", + "@provartesting/provardx-plugins-utils": "1.2.0-vBeta", "@provartesting/provardx-plugins-automation": "1.1.0", "@provartesting/provardx-plugins-manager": "1.1.0", "sync-request": "^6.1.0", From 936c196be6eee713a233193b51229fc9fc053b76 Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:54:20 +0530 Subject: [PATCH 11/61] PDX-439: bumped version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e3b05ce..f367a348 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "node-stream-zip": "^1.15.0", "@provartesting/provardx-plugins-utils": "1.2.0-vBeta", "@provartesting/provardx-plugins-automation": "1.1.0", - "@provartesting/provardx-plugins-manager": "1.1.0", + "@provartesting/provardx-plugins-manager": "1.2.0-vBeta", "sync-request": "^6.1.0", "xml-js": "^1.6.11" }, From e832d0d6c66900ddb23a364f8a039f6ed75dbabe Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:12:23 +0530 Subject: [PATCH 12/61] PDX-439: changes error code and message from missing file to invalid path RCA: error code was missing file instead of invalid path Fix: changes error code and message from missing file to invalid path --- src/commands/provar/config/get.ts | 2 +- src/commands/provar/config/set.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/provar/config/get.ts b/src/commands/provar/config/get.ts index 95a6f4b9..42a38fb0 100644 --- a/src/commands/provar/config/get.ts +++ b/src/commands/provar/config/get.ts @@ -47,7 +47,7 @@ export default class SfProvarConfigGet extends SfCommand let attributeValue = null; if (propertiesFilePath === undefined || !fileSystem.existsSync(propertiesFilePath)) { - this.errorHandler.addErrorsToList('MISSING_FILE', errorMessages.MISSING_FILE_ERROR); + this.errorHandler.addErrorsToList('INVALID_PATH', errorMessages.INVALID_PATH); return populateResult(flags, this.errorHandler, messages, this.log.bind(this)); } try { diff --git a/src/commands/provar/config/set.ts b/src/commands/provar/config/set.ts index 1e10f2c8..331bb4cf 100644 --- a/src/commands/provar/config/set.ts +++ b/src/commands/provar/config/set.ts @@ -47,7 +47,7 @@ export default class SfProvarConfigSet extends SfCommand // eslint-disable-next-line const propertiesFilePath = path.resolve(flags['file-path']); if (propertiesFilePath === undefined || !fileSystem.existsSync(propertiesFilePath)) { - this.errorHandler.addErrorsToList('MISSING_FILE', errorMessages.MISSING_FILE_ERROR); + this.errorHandler.addErrorsToList('INVALID_PATH', errorMessages.INVALID_PATH); return populateResult(flags, this.errorHandler, messages, this.log.bind(this)); } From 8d23997f70b48c7332c416e6dd828ae583e73e9c Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:49:02 +0530 Subject: [PATCH 13/61] PDX-439: bumped version --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index f367a348..ab50b339 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@provartesting/provardx-cli", "description": "A plugin for the Salesforce CLI to orchestrate testing activities and report quality metrics to Provar Manager", - "version": "1.4.0-vBeta", + "version": "1.4.0", "license": "BSD-3-Clause", "plugins": [ "@provartesting/provardx-plugins-automation", @@ -18,9 +18,9 @@ "fast-xml-parser": "^4.3.6", "jsonschema": "^1.4.1", "node-stream-zip": "^1.15.0", - "@provartesting/provardx-plugins-utils": "1.2.0-vBeta", + "@provartesting/provardx-plugins-utils": "1.2.0", "@provartesting/provardx-plugins-automation": "1.1.0", - "@provartesting/provardx-plugins-manager": "1.2.0-vBeta", + "@provartesting/provardx-plugins-manager": "1.2.0", "sync-request": "^6.1.0", "xml-js": "^1.6.11" }, From 5aeef077d3515c6f1078d0950a6277fba68ab6b4 Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Fri, 1 Nov 2024 20:06:40 +0530 Subject: [PATCH 14/61] PDX-439: adding automation config set and get commands back RCA: automation set and get commands were deleted due to confusion RCA: adding the commands back to release 1.4.0 --- messages/sf.provar.config.get.md | 17 ++++ messages/sf.provar.config.set.md | 17 ++++ src/commands/provar/automation/config/get.ts | 74 +++++++++++++++++ src/commands/provar/automation/config/set.ts | 84 ++++++++++++++++++++ 4 files changed, 192 insertions(+) create mode 100644 messages/sf.provar.config.get.md create mode 100644 messages/sf.provar.config.set.md create mode 100644 src/commands/provar/automation/config/get.ts create mode 100644 src/commands/provar/automation/config/set.ts diff --git a/messages/sf.provar.config.get.md b/messages/sf.provar.config.get.md new file mode 100644 index 00000000..a3b84bac --- /dev/null +++ b/messages/sf.provar.config.get.md @@ -0,0 +1,17 @@ +# summary + +Retrieves a value from the loaded properties file. + +# description + +Retrieves a value from the loaded properties file. + +# examples + +- Retrieves a value from the loaded properties file + + <%= config.bin %> <%= command.id %> 'key' + +# error.MultipleFailure + +%s diff --git a/messages/sf.provar.config.set.md b/messages/sf.provar.config.set.md new file mode 100644 index 00000000..51b7b29e --- /dev/null +++ b/messages/sf.provar.config.set.md @@ -0,0 +1,17 @@ +# summary + +Sets a property in the loaded properties file. + +# description + +Sets a property in the loaded properties file. + +# examples + +- Sets a property in the loaded properties file with resp. values + + <%= config.bin %> <%= command.id %> 'key'='value' + +# error.MultipleFailure + +%s diff --git a/src/commands/provar/automation/config/get.ts b/src/commands/provar/automation/config/get.ts new file mode 100644 index 00000000..1c8aa625 --- /dev/null +++ b/src/commands/provar/automation/config/get.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 Provar Limited. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.md file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ + +import * as fileSystem from 'node:fs'; +import { SfCommand } from '@salesforce/sf-plugins-core'; +import { errorMessages, SfProvarCommandResult, populateResult, ErrorHandler, ProvarConfig, checkNestedProperty, getNestedProperty, Messages } from '@provartesting/provardx-plugins-utils'; + + +/** + * Gets the value for specified propertykey under arguments from provardx-properties.json + * laoded under config.json + * + */ + +Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); +const messages = Messages.loadMessages('@provartesting/provardx-cli', 'sf.provar.config.get'); + +export default class SfProvarConfigGet extends SfCommand { + public static readonly summary = messages.getMessage('summary'); + public static readonly description = messages.getMessage('description'); + public static readonly examples = messages.getMessages('examples'); + public static readonly strict = false; + + private errorHandler = new ErrorHandler(); + + public async run(): Promise { + const { argv, flags } = await this.parse(SfProvarConfigGet); + const config: ProvarConfig = await ProvarConfig.loadConfig(this.errorHandler); + const propertiesFilePath = config.get('PROVARDX_PROPERTIES_FILE_PATH')?.toString(); + let attributeValue = null; + + if (propertiesFilePath === undefined || !fileSystem.existsSync(propertiesFilePath)) { + this.errorHandler.addErrorsToList('MISSING_FILE', errorMessages.MISSING_FILE_ERROR); + return populateResult(flags, this.errorHandler, messages, this.log.bind(this)); + } + try { + /* eslint-disable */ + if (!argv.length) { + this.errorHandler.addErrorsToList('MISSING_PROPERTY', errorMessages.MISSING_PROPERTY_GET); + return populateResult(flags, this.errorHandler, messages, this.log.bind(this)); + } + + const data = fileSystem.readFileSync(propertiesFilePath, { encoding: 'utf8' }); + const propertyFileContent = JSON.parse(data); + + const propertyName: string = (argv as string[])[0]; + if (propertyName.includes('.')) { + if (!checkNestedProperty(propertyFileContent, propertyName)) { + this.errorHandler.addErrorsToList('UNKNOWN_PROPERTY', errorMessages.UNKNOWN_PROPERTY); + } else { + attributeValue = getNestedProperty(propertyFileContent, propertyName); + } + } else { + if (!propertyFileContent.hasOwnProperty(propertyName)) { + this.errorHandler.addErrorsToList('UNKNOWN_PROPERTY', errorMessages.UNKNOWN_PROPERTY); + } else { + attributeValue = propertyFileContent[propertyName]; + } + } + } catch (err: any) { + if (err.name === 'SyntaxError') { + this.errorHandler.addErrorsToList('MALFORMED_FILE', errorMessages.MALFORMED_FILE_ERROR); + } else { + throw err; + } + } + + return populateResult(flags, this.errorHandler, messages, this.log.bind(this), attributeValue); + } +} diff --git a/src/commands/provar/automation/config/set.ts b/src/commands/provar/automation/config/set.ts new file mode 100644 index 00000000..c1279cbb --- /dev/null +++ b/src/commands/provar/automation/config/set.ts @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024 Provar Limited. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.md file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ + +import * as fileSystem from 'node:fs'; +import { SfCommand, parseVarArgs } from '@salesforce/sf-plugins-core'; +import { SfProvarCommandResult, populateResult, ErrorHandler, Messages, ProvarConfig, parseJSONString, setNestedProperty, errorMessages } from '@provartesting/provardx-plugins-utils'; + + +/** + * Sets the specified property key and value inside provardx-properties.json + * loaded under config file + * + */ + +Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); +const messages = Messages.loadMessages('@provartesting/provardx-cli', 'sf.provar.config.set'); + +export default class SfProvarConfigSet extends SfCommand { + public static readonly summary = messages.getMessage('summary'); + public static readonly description = messages.getMessage('description'); + public static readonly examples = messages.getMessages('examples'); + public static readonly strict = false; + + private errorHandler = new ErrorHandler(); + + public async run(): Promise { + const { argv, flags } = await this.parse(SfProvarConfigSet); + // eslint-disable-next-line + const config: ProvarConfig = await ProvarConfig.loadConfig(this.errorHandler); + const propertiesFilePath = config.get('PROVARDX_PROPERTIES_FILE_PATH')?.toString(); + + if (propertiesFilePath === undefined || !fileSystem.existsSync(propertiesFilePath)) { + this.errorHandler.addErrorsToList('MISSING_FILE', errorMessages.MISSING_FILE_ERROR); + return populateResult(flags, this.errorHandler, messages, this.log.bind(this)); + } + + try { + /* eslint-disable */ + const parsed: Object = parseVarArgs({}, argv as string[]); + if (Object.keys(parsed).length === 0) { + this.errorHandler.addErrorsToList('MISSING_PROPERTY', errorMessages.MISSING_PROPERTY); + return populateResult(flags, this.errorHandler, messages, this.log.bind(this)); + } + const data = fileSystem.readFileSync(propertiesFilePath, { encoding: 'utf8' }); + const propertyFileContent = JSON.parse(data); + + for (let [propertyName, propertyValue] of Object.entries(parsed)) { + if (!propertyValue) { + this.errorHandler.addErrorsToList('MISSING_VALUE', errorMessages.MISSING_VALUE); + } + if (propertyName.length < 1) { + this.errorHandler.addErrorsToList('MISSING_PROPERTY', errorMessages.MISSING_PROPERTY); + } + try { + propertyValue = parseJSONString(propertyValue); + } catch (err: any) { + this.errorHandler.addErrorsToList('INVALID_VALUE', errorMessages.INVALID_VALUE); + return populateResult(flags, this.errorHandler, messages, this.log.bind(this)); + } + if (propertyName.includes('.')) { + setNestedProperty(propertyFileContent, propertyName, propertyValue); + } else { + propertyFileContent[propertyName] = propertyValue; + } + } + if (this.errorHandler.getErrors().length == 0) { + fileSystem.writeFileSync(propertiesFilePath, JSON.stringify(propertyFileContent, null, 3)); + } + } catch (err: any) { + if (err.name === 'InvalidArgumentFormatError') { + this.errorHandler.addErrorsToList('INVALID_ARGUMENT', errorMessages.INVALID_ARGUMENT); + } else if (err.name === 'SyntaxError') { + this.errorHandler.addErrorsToList('MALFORMED_FILE', errorMessages.MALFORMED_FILE_ERROR); + } else { + throw err; + } + } + return populateResult(flags, this.errorHandler, messages, this.log.bind(this)); + } +} From 7a1dd0d0676975412816539b02047652ab2b47fa Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Fri, 1 Nov 2024 20:08:07 +0530 Subject: [PATCH 15/61] PDX-439: version changes from 1.4.0 to 1.4.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ab50b339..96b30522 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@provartesting/provardx-cli", "description": "A plugin for the Salesforce CLI to orchestrate testing activities and report quality metrics to Provar Manager", - "version": "1.4.0", + "version": "1.4.1", "license": "BSD-3-Clause", "plugins": [ "@provartesting/provardx-plugins-automation", From 0a80e8b4a95080aa52a68fb0dc4d4a6a10b65709 Mon Sep 17 00:00:00 2001 From: Samuel Arroyo Date: Mon, 4 Nov 2024 10:22:19 +0000 Subject: [PATCH 16/61] Update README.md for v1.4.0 --- README.md | 197 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 180 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index f37185a8..5ec492ec 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,11 @@ $ sf plugins uninstall @provartesting/provardx-cli # Commands +- [`sf provar config get`](#sf-provar-config-get) +- [`sf provar config set`](#sf-provar-config-set) - [`sf provar automation config generate`](#sf-provar-automation-config-generate) -- [`sf provar automation config validate`](#sf-provar-automation-config-validate) - [`sf provar automation config load`](#sf-provar-automation-config-load) +- [`sf provar automation config validate`](#sf-provar-automation-config-validate) - [`sf provar automation config get`](#sf-provar-automation-config-get) - [`sf provar automation config set`](#sf-provar-automation-config-set) - [`sf provar automation setup`](#sf-provar-automation-setup) @@ -37,50 +39,88 @@ $ sf plugins uninstall @provartesting/provardx-cli - [`sf provar automation metadata download`](#sf-provar-automation-metadata-download) - [`sf provar automation test run`](#sf-provar-automation-test-run) - [`sf provar manager connect`](#sf-provar-manager-connect) +- [`sf provar manager display`](#sf-provar-manager-display) +- [`sf provar manager open`](#sf-provar-manager-open) - [`sf provar manager testcase retrieve`](#sf-provar-manager-testcase-retrieve) +- [`sf provar manager test run`](#sf-provar-manager-test-run) +- [`sf provar manager test run report`](#sf-provar-manager-test-run-report) -## `sf provar automation config generate` +## `sf provar config get` -Generate a boilerplate ProvarDX properties file. +Retrieve a value from the specified JSON file. ``` USAGE - $ sf provar automation config generate [--json] [-p ] + $ sf provar config get -f [--json] FLAGS - -p, --properties-file= (required) Path to the properties file that will be generated. - -n, --no-prompt Don't prompt to confirm file should be overwritten. + -f, --file-path= (required) File path of the JSON file to get the property value from. GLOBAL FLAGS - --json Format output as json. + --json Format output as json. DESCRIPTION - Generate a boilerplate property file. + Retrieve a value from the specified JSON file. EXAMPLES - Generate a basic properties file named provardx-properties.json: + Get the testEnvironment value within the environment property from the config.json file: - $ sf provar automation config generate -p provardx-properties.json + $ sf provar config get environment.testEnvironment -f config.json ``` -## `sf provar automation config validate` +## `sf provar config set` -Check if the loaded properties file has all the required properties set. +Set one or more properties in the specified JSON file. ``` USAGE - $ sf provar automation config validate [--json] + $ sf provar config set [--json] + +FLAGS + -f, --file-path= (required) File path of the JSON file to get the property value from. GLOBAL FLAGS --json Format output as json. DESCRIPTION - Check if the loaded properties file has all the required properties set. + Set one or more properties in the specified JSON file. EXAMPLES - Check if the loaded properties file has all the required properties set: - - $ sf provar automation config validate + Set the environment to “SIT” in the config.json properties file: + + $ sf provar config set environment.testEnvironment="SIT" -f config.json + + Set the testEnvironment to “SIT” and the webBrowser to “Chrome”, within the environment property. + + $ sf provar config set environment.testEnvironment="SIT" environment.webBrowser="Chrome" -f config.json + + Set testCases to a list of test case paths in the config.json properties file. + + $ sf provar config set testCases='["tests/myTestCase.testcase","tests/testSuite1/myTestCase1.testCase"]' -f config.json +``` + +## `sf provar automation config generate` + +Generate a boilerplate ProvarDX properties file. + +``` +USAGE + $ sf provar automation config generate [--json] [-p ] + +FLAGS + -p, --properties-file= (required) Path to the properties file that will be generated. + -n, --no-prompt Don't prompt to confirm file should be overwritten. + +GLOBAL FLAGS + --json Format output as json. + +DESCRIPTION + Generate a boilerplate property file. + +EXAMPLES + Generate a basic properties file named provardx-properties.json: + + $ sf provar automation config generate -p provardx-properties.json ``` ## `sf provar automation config load` @@ -106,6 +146,26 @@ EXAMPLES $ sf provar automation config load -p myproperties.json ``` +## `sf provar automation config validate` + +Check if the loaded properties file has all the required properties set. + +``` +USAGE + $ sf provar automation config validate [--json] + +GLOBAL FLAGS + --json Format output as json. + +DESCRIPTION + Check if the loaded properties file has all the required properties set. + +EXAMPLES + Check if the loaded properties file has all the required properties set: + + $ sf provar automation config validate +``` + ## `sf provar automation config get` Retrieve a value from the loaded properties file. @@ -263,6 +323,46 @@ EXAMPLES $ sf provar manager connect -o ProvarManager ``` +## `sf provar manager display` + +Display information about the connected Provar Manager org. + +``` +USAGE + $ sf provar manager display [--json] + +GLOBAL FLAGS + --json Format output as json. + +DESCRIPTION + Display information about the connected Provar Manager org. + +EXAMPLES + Display information about the connected Provar Manager org: + + $ sf provar manager display +``` + +## `sf provar manager open` + +Open Provar Manager in a browser. + +``` +USAGE + $ sf provar manager open [--json] + +GLOBAL FLAGS + --json Format output as json. + +DESCRIPTION + Open Provar Manager in a browser. + +EXAMPLES + Open Provar Manager in a browser: + + $ sf provar manager open +``` + ## `sf provar manager testcase retrieve` Retrieve test cases related to the provided user stories (issues) or metadata components, for a given test project. @@ -304,3 +404,66 @@ EXAMPLES base/main/default/objects/Sprint__c/fields/Sprint_Goal__c.field-meta.xml ``` + +## `sf provar manager test run` + +Run tests via Provar Manager. + +``` +USAGE + $ sf provar manager test run -f [--json] [-y] [-w ] [-p ] [-o ] [-r ] + +FLAGS + -f, --configuration-file= (required) Path to the configuration file. + -o, --output= Output to a specific file instead of stdout. + -p, --polling-interval= [default: 60] Sets the polling interval in seconds. Default is 60 seconds. + -r, --result-format= [default: human] Format of the test results. + -w, --wait= Sets the polling timeout in minutes. + -y, --synchronous Runs command synchronously; if not specified, the command is run asynchronously. + +GLOBAL FLAGS + --json Format output as json. + +DESCRIPTION + Run tests via Provar Manager. + +EXAMPLES + Run tests as per the config/run-grid-test.json configuration file, wait 10 minutes, poll every 30 seconds, and store the results as JSON in the results.json file: + + $ sf provar manager test run -f config/run-grid-tests.json -w 10 -p 30 -r json -o results.json + + Run tests as per the config/run-grid-test.json configuration file, wait 20 minutes, and store the results as JUnit in the junit-results.xml file: + + $ sf provar manager test run -f config/run-grid-tests.json -w 20 -r junit -o junit-results.xml + +``` + +## `sf provar manager test run report` + +Check or poll for the status of a test run operation. + +``` +USAGE + $ sf provar manager test run report -i [--json] [-r ] [-o ] + +FLAGS + -i, --test-run= (required) Test run ID. + -o, --output= Output to a specific file instead of stdout. + -r, --result-format= [default: human] Format of the test results. + +GLOBAL FLAGS + --json Format output as json. + +DESCRIPTION + Check or poll for the status of a test run operation. + +EXAMPLES + Retrieve results for test run 45f70417-df21-4917-a667-abc2ee46dc63 and store the results as JSON in the results.json file + + $ sf provar manager test run report -i 45f70417-df21-4917-a667-abc2ee46dc63 -r json -o results.json + + Retrieve results for test run 45f70417-df21-4917-a667-abc2ee46dc63 and store the results as JUnit in the junit-results.xml file: + + $ sf provar manager test run report -i 45f70417-df21-4917-a667-abc2ee46dc63 -r junit -o junit-results.xml + +``` From 22cd454bc1f829138f90f98c9e84bc621d04c234 Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Tue, 5 Nov 2024 12:30:57 +0530 Subject: [PATCH 17/61] PDX-439: adding automation config set and get commands NUTs RCA: automation set and get commands were deleted due to confusion RCA: adding the commands back to release 1.4.0 --- test/assertion/commandConstants.ts | 6 +- .../provar/automation/config/get.nut.ts | 87 ++-- .../provar/automation/config/set.nut.ts | 108 ++-- test/commands/provar/config/get.nut.ts | 216 ++++++++ test/commands/provar/config/set.nut.ts | 463 ++++++++++++++++++ 5 files changed, 812 insertions(+), 68 deletions(-) create mode 100644 test/commands/provar/config/get.nut.ts create mode 100644 test/commands/provar/config/set.nut.ts diff --git a/test/assertion/commandConstants.ts b/test/assertion/commandConstants.ts index 4c4c3f66..a6235d08 100644 --- a/test/assertion/commandConstants.ts +++ b/test/assertion/commandConstants.ts @@ -2,6 +2,8 @@ export enum commandConstants { SF_PROVAR_AUTOMATION_CONFIG_GENERATE_COMMAND = 'provar automation config generate', SF_PROVAR_AUTOMATION_CONFIG_LOAD_COMMAND = 'provar automation config load', SF_PROVAR_AUTOMATION_CONFIG_VALIDATE_COMMAND = 'provar automation config validate', - SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND = 'provar config set', - SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND = 'provar config get', + SF_PROVAR_CONFIG_SET_COMMAND = 'provar config set', + SF_PROVAR_CONFIG_GET_COMMAND = 'provar config get', + SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND = 'provar automation config set', + SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND = 'provar automation config get', } diff --git a/test/commands/provar/automation/config/get.nut.ts b/test/commands/provar/automation/config/get.nut.ts index 1b5aef8b..c72a01b3 100644 --- a/test/commands/provar/automation/config/get.nut.ts +++ b/test/commands/provar/automation/config/get.nut.ts @@ -2,6 +2,7 @@ import * as fileSystem from 'node:fs'; import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; import { expect } from 'chai'; import { errorMessages, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; +import * as validateConstants from '../../../../assertion/validateConstants.js'; import * as getConstants from '../../../../assertion/getConstants.js'; import { commandConstants } from '../../../../assertion/commandConstants.js'; @@ -23,6 +24,37 @@ describe('sf provar config get NUTs', () => { }); }); + it('Missing file error as json file is not loaded', () => { + execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GENERATE_COMMAND} -p ${FILE_PATHS.INVALID_FILE}` + ); + const jsonFilePath = FILE_PATHS.INVALID_FILE; + const data = fileSystem.readFileSync(jsonFilePath, 'utf-8'); + const newData = data.substring(1); + fileSystem.writeFile(jsonFilePath, newData, (error) => { + if (error) { + return; + } + }); + execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_LOAD_COMMAND} -p ${FILE_PATHS.INVALID_FILE}` + ); + const result = execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} provarHome` + ).shellOutput; + expect(result.stderr).to.deep.equal(`Error (1): [MISSING_FILE] ${errorMessages.MISSING_FILE_ERROR}\n\n`); + }); + + it('Missing file error in json format as json file is not loaded', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} resultsPath --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(validateConstants.missingFileJsonError); + }); + it('Missing property error as property name is missing', () => { execCmd( `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GENERATE_COMMAND} -p ${FILE_PATHS.VALUES_FILE}` @@ -32,42 +64,42 @@ describe('sf provar config get NUTs', () => { ); execCmd(`${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_VALIDATE_COMMAND}`); const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND}` ).shellOutput; expect(getOutput.stderr).to.deep.equal(`Error (1): [MISSING_PROPERTY] ${errorMessages.MISSING_PROPERTY_GET}\n\n`); }); it('Missing property error in json format as property name is missing', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} --json` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} --json` ).jsonOutput; expect(getOutput).to.deep.equal(getConstants.missingPropertyGetJson); }); it('Unknown Property error as property is not present in the file', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} metadata.test` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} metadata.test` ).shellOutput; expect(getOutput.stderr).to.deep.equal(`Error (1): [UNKNOWN_PROPERTY] ${errorMessages.UNKNOWN_PROPERTY}\n\n`); }); it('Unknown Property error as property is not present in the file', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} environment.webBrowserProvider` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} environment.webBrowserProvider` ).shellOutput; expect(getOutput.stderr).to.deep.equal(`Error (1): [UNKNOWN_PROPERTY] ${errorMessages.UNKNOWN_PROPERTY}\n\n`); }); it('Unknown Property error as property is not present in the file', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} projectPath.web` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} projectPath.web` ).shellOutput; expect(getOutput.stderr).to.deep.equal(`Error (1): [UNKNOWN_PROPERTY] ${errorMessages.UNKNOWN_PROPERTY}\n\n`); }); it('Unknown Property error in json format as property is not present in the file', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} sample --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} sample --json`, { ensureExitCode: 0, } @@ -78,10 +110,10 @@ describe('sf provar config get NUTs', () => { it('value should be returned for provarHome property', () => { const setProvarHome = 'C:/Users/anchal.goel/Downloads/main_win64_e413157177_20240117_0452/'; execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} provarHome=${setProvarHome}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} provarHome=${setProvarHome}` ); const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} provarHome` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} provarHome` ).shellOutput; expect(getOutput.stdout).to.deep.equal(`${setProvarHome}\n`); }); @@ -89,24 +121,24 @@ describe('sf provar config get NUTs', () => { it('value should be returned for projectPath property', () => { const setProjectPath = 'C:/Users/anchal.goel/Desktop/main_win64_e413157177_20240117_0452/'; const output = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} projectPath` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} projectPath` ).shellOutput; expect(output.stdout).to.deep.equal('${PROVAR_PROJECT_PATH}\n'); execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} projectPath=${setProjectPath}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} projectPath=${setProjectPath}` ); const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "projectPath"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} "projectPath"` ).shellOutput; expect(getOutput.stdout).to.deep.equal(`${setProjectPath}\n`); }); it('value should be returned for resultsPath property in json format', () => { execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "resultsPath"="C:/Users/anchal.goel/git/ProvarRegressionqam5/test/provardx/Results"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "resultsPath"="C:/Users/anchal.goel/git/ProvarRegressionqam5/test/provardx/Results"` ); const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} resultsPath --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} resultsPath --json`, { ensureExitCode: 0, } @@ -116,27 +148,27 @@ describe('sf provar config get NUTs', () => { it('value should be returned for smtpPath property', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "smtpPath"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} "smtpPath"` ).shellOutput; expect(getOutput.stdout).to.deep.equal('\n'); }); it('value should be returned for testOutputLevel property', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} testOutputLevel` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} testOutputLevel` ).shellOutput; expect(getOutput.stdout).to.deep.equal('BASIC\n'); }); it('value should be returned for pluginOutputlevel property', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} pluginOutputlevel` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} pluginOutputlevel` ).shellOutput; expect(getOutput.stdout).to.deep.equal('WARNING\n'); }); it('value should be returned for resultsPathDisposition property in json format', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "resultsPathDisposition" --json` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} "resultsPathDisposition" --json` ).jsonOutput; expect(getOutput?.result.success).to.deep.equal(true); expect(getOutput?.result.value).to.deep.equal('Increment'); @@ -144,7 +176,7 @@ describe('sf provar config get NUTs', () => { it('value should be returned for lightningMode property in json format', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} lightningMode --json` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} lightningMode --json` ).jsonOutput; expect(getOutput?.result.success).to.deep.equal(true); expect(getOutput?.result.value).to.deep.equal(true); @@ -152,14 +184,14 @@ describe('sf provar config get NUTs', () => { it('Value should be returned successfully for metdata object', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} metadata` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} metadata` ).shellOutput; expect(getOutput.stdout).to.deep.equal("{ metadataLevel: 'Reuse', cachePath: '../.provarCaches' }\n"); }); it('Value should be returned successfully for environment object in json format', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} environment --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} environment --json`, { ensureExitCode: 0, } @@ -169,21 +201,21 @@ describe('sf provar config get NUTs', () => { it('Value should be returned successfully for testEnvironment property in environment object', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} environment.testEnvironment` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} environment.testEnvironment` ).shellOutput; expect(getOutput.stdout).to.deep.equal('${PROVAR_TEST_ENVIRONMENT}\n'); }); it('Value should be returned successfully for webBrowserDeviceName property in environment object', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "environment"."webBrowserDeviceName"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} "environment"."webBrowserDeviceName"` ).shellOutput; expect(getOutput.stdout).to.deep.equal('Full Screen\n'); }); it('Value should be returned successfully for cachePath property in metadata object', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} metadata.cachePath --json` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} metadata.cachePath --json` ).jsonOutput; expect(getOutput?.result.success).to.deep.equal(true); expect(getOutput?.result.value).to.deep.equal('../.provarCaches'); @@ -191,26 +223,25 @@ describe('sf provar config get NUTs', () => { it('Value should be returned successfully for testprojectSecrets property', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} testprojectSecrets` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} testprojectSecrets` ).shellOutput; expect(getOutput.stdout).to.deep.equal('${PROVAR_TEST_PROJECT_SECRETS}\n'); }); it('Value should be returned successfully for connectionRefreshType property', () => { const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} connectionRefreshType` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} connectionRefreshType` ).shellOutput; expect(getOutput.stdout).to.deep.equal('Reload\n'); }); it('value should be returned for new added property', () => { execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "Test Suite"="Multiple Suites"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "Test Suite"="Multiple Suites"` ); const getOutput = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "Test Suite"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GET_COMMAND} "Test Suite"` ).shellOutput; expect(getOutput.stdout).to.deep.equal('Multiple Suites\n'); }); - }); diff --git a/test/commands/provar/automation/config/set.nut.ts b/test/commands/provar/automation/config/set.nut.ts index 3bec69b9..327de195 100644 --- a/test/commands/provar/automation/config/set.nut.ts +++ b/test/commands/provar/automation/config/set.nut.ts @@ -2,6 +2,7 @@ import * as fileSystem from 'node:fs'; import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; import { expect } from 'chai'; import { errorMessages, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; +import * as validateConstants from '../../../../assertion/validateConstants.js'; import * as setConstants from '../../../../assertion/setConstants.js'; import { commandConstants } from '../../../../assertion/commandConstants.js'; @@ -46,6 +47,37 @@ describe('sf provar config set NUTs', () => { }); }); + it('Missing file error should be thrown when json file is not loaded and return the error', () => { + execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GENERATE_COMMAND} -p ${FILE_PATHS.INVALID_FILE}` + ); + const jsonFilePath = FILE_PATHS.INVALID_FILE; + const data = fileSystem.readFileSync(jsonFilePath, 'utf-8'); + const newData = data.substring(1); + fileSystem.writeFile(jsonFilePath, newData, (error) => { + if (error) { + return; + } + }); + execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_LOAD_COMMAND} -p ${FILE_PATHS.INVALID_FILE}` + ); + const result = execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} provarHome=notDefined` + ).shellOutput; + expect(result.stderr).to.deep.equal(`Error (1): [MISSING_FILE] ${errorMessages.MISSING_FILE_ERROR}\n\n`); + }); + + it('Missing file error should be thrown when json file is not loaded and return the error in json', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} resultsPath=path --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(validateConstants.missingFileJsonError); + }); + it('Missing property error should be thrown when property is not defined and return the error', () => { execCmd( `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GENERATE_COMMAND} -p ${FILE_PATHS.ERROR_FILE}` @@ -55,28 +87,28 @@ describe('sf provar config set NUTs', () => { ); execCmd(`${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_VALIDATE_COMMAND}`); const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} =Provar` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} =Provar` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [MISSING_PROPERTY] ${errorMessages.MISSING_PROPERTY}\n\n`); }); it('Missing property error should be thrown when property is not defined and return the error', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} ""=MissingProperty` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} ""=MissingProperty` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [MISSING_PROPERTY] ${errorMessages.MISSING_PROPERTY}\n\n`); }); it('Missing property error should be thrown when property is not defined and return the error', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND}` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [MISSING_PROPERTY] ${errorMessages.MISSING_PROPERTY}\n\n`); }); it('Missing property error should be thrown when property is not defined and return the error in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} =MissingProperty --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} =MissingProperty --json`, { ensureExitCode: 0, } @@ -86,21 +118,21 @@ describe('sf provar config set NUTs', () => { it('Missing value error should be thrown when value is not defined and return the error', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} missingValue=` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} missingValue=` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [MISSING_VALUE] ${errorMessages.MISSING_VALUE}\n\n`); }); it('Missing value error should be thrown when value is not defined and return the error', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} "missingValue"=""` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "missingValue"=""` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [MISSING_VALUE] ${errorMessages.MISSING_VALUE}\n\n`); }); it('Missing value error should be thrown when value is not defined and return the error in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} missingValueError= --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} missingValueError= --json`, { ensureExitCode: 0, } @@ -110,21 +142,21 @@ describe('sf provar config set NUTs', () => { it('Invalid argument error should be thrown when property and value is not defined in correct format and return the error', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} invalid = argument` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} invalid = argument` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [INVALID_ARGUMENT] ${errorMessages.INVALID_ARGUMENT}\n\n`); }); it('Invalid argument error should be thrown when property and value is not defined in correct format and return the error', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} attachmentProperties=random value` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} attachmentProperties=random value` ).shellOutput; expect(result.stderr).to.deep.equal(`Error (1): [INVALID_ARGUMENT] ${errorMessages.INVALID_ARGUMENT}\n\n`); }); it('Invalid argument error should be thrown when property and value is not defined in correct format and return the error in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} "parsing" = "error" --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "parsing" = "error" --json`, { ensureExitCode: 0, } @@ -141,7 +173,7 @@ describe('sf provar config set NUTs', () => { ); execCmd(`${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_VALIDATE_COMMAND}`); const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} provarHome=C:/Users/anchal.goel/Downloads/main_win64_e413157177_20240117_0452/ --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} provarHome=C:/Users/anchal.goel/Downloads/main_win64_e413157177_20240117_0452/ --json`, { ensureExitCode: 0, } @@ -151,14 +183,14 @@ describe('sf provar config set NUTs', () => { it('Value should be overwritten successfully for provarHome property in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "provarHome"=${SET_PROVAR_HOME_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "provarHome"=${SET_PROVAR_HOME_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('Value should be set successfully for resultsPath property in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "resultsPath"=${SET_RESULTS_PATH_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "resultsPath"=${SET_RESULTS_PATH_VALUE} --json`, { ensureExitCode: 0, } @@ -168,14 +200,14 @@ describe('sf provar config set NUTs', () => { it('Value should be set successfully for projectPath property in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "projectPath"=${SET_PROJECT_PATH_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "projectPath"=${SET_PROJECT_PATH_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('Value should be set successfully for smtpPath property in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} smtpPath=${SET_SMTP_PATH_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} smtpPath=${SET_SMTP_PATH_VALUE} --json`, { ensureExitCode: 0, } @@ -185,7 +217,7 @@ describe('sf provar config set NUTs', () => { it('Value should be set successfully for resultsPathDisposition property in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} resultsPathDisposition=${SET_RESULTS_PATH_DISPOSITION_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} resultsPathDisposition=${SET_RESULTS_PATH_DISPOSITION_VALUE} --json`, { ensureExitCode: 0, } @@ -195,7 +227,7 @@ describe('sf provar config set NUTs', () => { it('Value should be set successfully for testOutputLevel property in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "testOutputLevel"=${SET_TEST_OUTPUT_LEVEL_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "testOutputLevel"=${SET_TEST_OUTPUT_LEVEL_VALUE} --json`, { ensureExitCode: 0, } @@ -205,28 +237,28 @@ describe('sf provar config set NUTs', () => { it('Value should be set successfully for pluginOutputlevel property in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} pluginOutputlevel=${SET_PLUGIN_OUTPUTLEVEL_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} pluginOutputlevel=${SET_PLUGIN_OUTPUTLEVEL_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('Value should be set successfully for lightningMode property in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} lightningMode=${SET_LIGHTNING_MODE_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} lightningMode=${SET_LIGHTNING_MODE_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('Value should be set successfully for testEnvironment property in environment object in json file', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "environment.testEnvironment"=${SET_TEST_ENVIRONMENT_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "environment.testEnvironment"=${SET_TEST_ENVIRONMENT_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('New property should be set successfully in environment object in json file and return the success result in json format ', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} environment.newEnvironment=${SET_NEW_ENVIRONMENT_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} environment.newEnvironment=${SET_NEW_ENVIRONMENT_VALUE} --json`, { ensureExitCode: 0, } @@ -236,7 +268,7 @@ describe('sf provar config set NUTs', () => { it('Value should be set successfully for metadataLevel property in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "metadata.metadataLevel"=${SET_METADATA_LEVEL_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "metadata.metadataLevel"=${SET_METADATA_LEVEL_VALUE} --json`, { ensureExitCode: 0, } @@ -246,21 +278,21 @@ describe('sf provar config set NUTs', () => { it('Value should be set successfully for metadata cachePath property in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} metadata.cachePath=${SET_CACHE_PATH_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} metadata.cachePath=${SET_CACHE_PATH_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('Multiple properties with values should be set successfully and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} metadata.error=${SET_ERROR_VALUE} environment.key=${SET_KEY_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} metadata.error=${SET_ERROR_VALUE} environment.key=${SET_KEY_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('New property and Value of type array should be set successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "testCases"="[\\"/Test Case 1.testcase\\",\\"/Test Case 2.testcase\\",\\"/Test Case 3.testcase\\"]" --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "testCases"="[\\"/Test Case 1.testcase\\",\\"/Test Case 2.testcase\\",\\"/Test Case 3.testcase\\"]" --json`, { ensureExitCode: 0, } @@ -270,21 +302,21 @@ describe('sf provar config set NUTs', () => { it('New property and Value of type array should be set successfully in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "testcase"="[\\"tests/myTestCase.testcase\\",\\"tests/testSuite1/myTestCase1.testCase\\"]"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "testcase"="[\\"tests/myTestCase.testcase\\",\\"tests/testSuite1/myTestCase1.testCase\\"]"` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('New property and Value of type object should be set successfully in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "emailProperties"="{\\"sendEmail\\":true,\\"primaryRecipients\\":\\"anchal.goel@provartesting.com\\",\\"ccRecipients\\":\\"\\",\\"bccRecipients\\":\\"\\",\\"emailSubject\\":\\"Provar test run report\\",\\"attachExecutionReport\\":true,\\"attachZip\\":false}"` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "emailProperties"="{\\"sendEmail\\":true,\\"primaryRecipients\\":\\"anchal.goel@provartesting.com\\",\\"ccRecipients\\":\\"\\",\\"bccRecipients\\":\\"\\",\\"emailSubject\\":\\"Provar test run report\\",\\"attachExecutionReport\\":true,\\"attachZip\\":false}"` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('New property and Value of type string should be set successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} test=${SET_TEST_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} test=${SET_TEST_VALUE} --json`, { ensureExitCode: 0, } @@ -294,7 +326,7 @@ describe('sf provar config set NUTs', () => { it('New property and Value of type string with special char should be set successfully in json file and return the success result in json format ', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "SpecialCharacters"=${SET_SPECIAL_CHARACTERS_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "SpecialCharacters"=${SET_SPECIAL_CHARACTERS_VALUE} --json`, { ensureExitCode: 0, } @@ -304,7 +336,7 @@ describe('sf provar config set NUTs', () => { it('New property and Value of type Boolean should be set successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} booleanValue=false --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} booleanValue=false --json`, { ensureExitCode: 0, } @@ -314,14 +346,14 @@ describe('sf provar config set NUTs', () => { it('New property and Value of type Boolean should be set successfully in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} status=true` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} status=true` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('New property and Value of type Number should be set successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} number=${SET_NUMBER_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} number=${SET_NUMBER_VALUE} --json`, { ensureExitCode: 0, } @@ -331,14 +363,14 @@ describe('sf provar config set NUTs', () => { it('New property and Value of type Number should be set successfully in json file and return the success result', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} number_Value=${SET_NUMBER_DECIMAL_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} number_Value=${SET_NUMBER_DECIMAL_VALUE}` ).shellOutput; expect(result.stdout).to.deep.equal(''); }); it('New property and Value of type Null should be set successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} nullProperty=null --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} nullProperty=null --json`, { ensureExitCode: 0, } @@ -348,25 +380,25 @@ describe('sf provar config set NUTs', () => { it('New Object with property and Value should be created successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} world.country=${SET_COUNTRY_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} world.country=${SET_COUNTRY_VALUE} --json`, { ensureExitCode: 0, } ); expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); const resultSet = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} world.state=${SET_STATE_VALUE}` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} world.state=${SET_STATE_VALUE}` ).shellOutput; expect(resultSet.stdout).to.deep.equal(''); const output = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "world.city"=${SET_CITY_VALUE} --json` + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} "world.city"=${SET_CITY_VALUE} --json` ); expect(output.jsonOutput).to.deep.equal(setConstants.setSuccessJson); }); it('New Object with nested properties and Value should be created successfully in json file and return the success result in json format', () => { const result = execCmd( - `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} company.team.employee.position=${SET_POSITION_VALUE} --json`, + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_SET_COMMAND} company.team.employee.position=${SET_POSITION_VALUE} --json`, { ensureExitCode: 0, } diff --git a/test/commands/provar/config/get.nut.ts b/test/commands/provar/config/get.nut.ts new file mode 100644 index 00000000..979f1032 --- /dev/null +++ b/test/commands/provar/config/get.nut.ts @@ -0,0 +1,216 @@ +import * as fileSystem from 'node:fs'; +import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; +import { expect } from 'chai'; +import { errorMessages, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; +import * as getConstants from '../../../assertion/getConstants.js'; +import { commandConstants } from '../../../assertion/commandConstants.js'; + +describe('sf provar config get NUTs', () => { + let session: TestSession; + enum FILE_PATHS { + INVALID_FILE = 'getInvalidFile.json', + VALUES_FILE = 'getValues.json', + } + + after(async () => { + await session?.clean(); + Object.values(FILE_PATHS).forEach((filePath) => { + fileSystem.unlink(filePath, (err) => { + if (err) { + return err; + } + }); + }); + }); + + it('Missing property error as property name is missing', () => { + execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GENERATE_COMMAND} -p ${FILE_PATHS.VALUES_FILE}` + ); + execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_LOAD_COMMAND} -p ${FILE_PATHS.VALUES_FILE}` + ); + execCmd(`${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_VALIDATE_COMMAND}`); + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE}` + ).shellOutput; + expect(getOutput.stderr).to.deep.equal(`Error (1): [MISSING_PROPERTY] ${errorMessages.MISSING_PROPERTY_GET}\n\n`); + }); + + it('Missing property error in json format as property name is missing', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} --json` + ).jsonOutput; + expect(getOutput).to.deep.equal(getConstants.missingPropertyGetJson); + }); + + it('Unknown Property error as property is not present in the file', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} metadata.test` + ).shellOutput; + expect(getOutput.stderr).to.deep.equal(`Error (1): [UNKNOWN_PROPERTY] ${errorMessages.UNKNOWN_PROPERTY}\n\n`); + }); + + it('Unknown Property error as property is not present in the file', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} environment.webBrowserProvider` + ).shellOutput; + expect(getOutput.stderr).to.deep.equal(`Error (1): [UNKNOWN_PROPERTY] ${errorMessages.UNKNOWN_PROPERTY}\n\n`); + }); + + it('Unknown Property error as property is not present in the file', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} projectPath.web` + ).shellOutput; + expect(getOutput.stderr).to.deep.equal(`Error (1): [UNKNOWN_PROPERTY] ${errorMessages.UNKNOWN_PROPERTY}\n\n`); + }); + + it('Unknown Property error in json format as property is not present in the file', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} sample --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(getConstants.unknownPropertyJson); + }); + + it('value should be returned for provarHome property', () => { + const setProvarHome = 'C:/Users/anchal.goel/Downloads/main_win64_e413157177_20240117_0452/'; + execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} provarHome=${setProvarHome}` + ); + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} provarHome` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal(`${setProvarHome}\n`); + }); + + it('value should be returned for projectPath property', () => { + const setProjectPath = 'C:/Users/anchal.goel/Desktop/main_win64_e413157177_20240117_0452/'; + const output = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} projectPath` + ).shellOutput; + expect(output.stdout).to.deep.equal('${PROVAR_PROJECT_PATH}\n'); + execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} projectPath=${setProjectPath}` + ); + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "projectPath"` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal(`${setProjectPath}\n`); + }); + + it('value should be returned for resultsPath property in json format', () => { + execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "resultsPath"="C:/Users/anchal.goel/git/ProvarRegressionqam5/test/provardx/Results"` + ); + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} resultsPath --json`, + { + ensureExitCode: 0, + } + ); + expect(getOutput.jsonOutput).to.deep.equal(getConstants.getResultsPathValue); + }); + + it('value should be returned for smtpPath property', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "smtpPath"` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal('\n'); + }); + it('value should be returned for testOutputLevel property', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} testOutputLevel` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal('BASIC\n'); + }); + + it('value should be returned for pluginOutputlevel property', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} pluginOutputlevel` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal('WARNING\n'); + }); + + it('value should be returned for resultsPathDisposition property in json format', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "resultsPathDisposition" --json` + ).jsonOutput; + expect(getOutput?.result.success).to.deep.equal(true); + expect(getOutput?.result.value).to.deep.equal('Increment'); + }); + + it('value should be returned for lightningMode property in json format', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} lightningMode --json` + ).jsonOutput; + expect(getOutput?.result.success).to.deep.equal(true); + expect(getOutput?.result.value).to.deep.equal(true); + }); + + it('Value should be returned successfully for metdata object', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} metadata` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal("{ metadataLevel: 'Reuse', cachePath: '../.provarCaches' }\n"); + }); + + it('Value should be returned successfully for environment object in json format', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} environment --json`, + { + ensureExitCode: 0, + } + ); + expect(getOutput.jsonOutput).to.deep.equal(getConstants.getEnvironmentJsonObject); + }); + + it('Value should be returned successfully for testEnvironment property in environment object', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} environment.testEnvironment` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal('${PROVAR_TEST_ENVIRONMENT}\n'); + }); + + it('Value should be returned successfully for webBrowserDeviceName property in environment object', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "environment"."webBrowserDeviceName"` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal('Full Screen\n'); + }); + + it('Value should be returned successfully for cachePath property in metadata object', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} metadata.cachePath --json` + ).jsonOutput; + expect(getOutput?.result.success).to.deep.equal(true); + expect(getOutput?.result.value).to.deep.equal('../.provarCaches'); + }); + + it('Value should be returned successfully for testprojectSecrets property', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} testprojectSecrets` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal('${PROVAR_TEST_PROJECT_SECRETS}\n'); + }); + + it('Value should be returned successfully for connectionRefreshType property', () => { + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} connectionRefreshType` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal('Reload\n'); + }); + + it('value should be returned for new added property', () => { + execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "Test Suite"="Multiple Suites"` + ); + const getOutput = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_GET_COMMAND} -f ${FILE_PATHS.VALUES_FILE} "Test Suite"` + ).shellOutput; + expect(getOutput.stdout).to.deep.equal('Multiple Suites\n'); + }); + +}); diff --git a/test/commands/provar/config/set.nut.ts b/test/commands/provar/config/set.nut.ts new file mode 100644 index 00000000..0d716246 --- /dev/null +++ b/test/commands/provar/config/set.nut.ts @@ -0,0 +1,463 @@ +import * as fileSystem from 'node:fs'; +import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; +import { expect } from 'chai'; +import { errorMessages, SfProvarCommandResult } from '@provartesting/provardx-plugins-utils'; +import * as setConstants from '../../../assertion/setConstants.js'; +import { commandConstants } from '../../../assertion/commandConstants.js'; + +describe('sf provar config set NUTs', () => { + let session: TestSession; + const SET_PROVAR_HOME_VALUE = '"C:/Users/anchal.goel/Downloads/main_win32_e4145678987_20240117_08768/"'; + const SET_RESULTS_PATH_VALUE = '"C:/Users/anchal.goel/git/ProvarRegressionqam5/test/provardx/Results"'; + const SET_PROJECT_PATH_VALUE = 'C:/Users/anchal.goel/git/ProvarRegression/test'; + const SET_SMTP_PATH_VALUE = '" ../test/user/path"'; + const SET_RESULTS_PATH_DISPOSITION_VALUE = '"some random test"'; + const SET_TEST_OUTPUT_LEVEL_VALUE = 'DIAGNOSTIC'; + const SET_PLUGIN_OUTPUTLEVEL_VALUE = '"FINEST"'; + const SET_LIGHTNING_MODE_VALUE = false; + const SET_TEST_ENVIRONMENT_VALUE = '"SIT"'; + const SET_NEW_ENVIRONMENT_VALUE = 'testingEnv'; + const SET_METADATA_LEVEL_VALUE = '"RefreshedMetadata"'; + const SET_CACHE_PATH_VALUE = '../Users/anchalgoel/test/path'; + const SET_ERROR_VALUE = 'fail'; + const SET_KEY_VALUE = 'KeyTest'; + const SET_TEST_VALUE = 'New_User'; + const SET_SPECIAL_CHARACTERS_VALUE = 'Str#$%in*_g'; + const SET_NUMBER_VALUE = 1_234_567_890; + const SET_NUMBER_DECIMAL_VALUE = 9876.543_21; + const SET_COUNTRY_VALUE = 'India'; + const SET_STATE_VALUE = 'Uttarakhand'; + const SET_CITY_VALUE = '"Roorkee"'; + const SET_POSITION_VALUE = 'Engineer'; + enum FILE_PATHS { + INVALID_FILE = 'setInvalidFile.json', + FILE_MULTIPLE_FILES = 'setMultiplePropertiesValue.json', + ERROR_FILE = 'setErrors.json', + } + + after(async () => { + await session?.clean(); + Object.values(FILE_PATHS).forEach((filePath) => { + fileSystem.unlink(filePath, (err) => { + if (err) { + return err; + } + }); + }); + }); + + it('Missing property error should be thrown when property is not defined and return the error', () => { + execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GENERATE_COMMAND} -p ${FILE_PATHS.ERROR_FILE}` + ); + execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_LOAD_COMMAND} -p ${FILE_PATHS.ERROR_FILE}` + ); + execCmd(`${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_VALIDATE_COMMAND}`); + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} =Provar` + ).shellOutput; + expect(result.stderr).to.deep.equal(`Error (1): [MISSING_PROPERTY] ${errorMessages.MISSING_PROPERTY}\n\n`); + }); + + it('Missing property error should be thrown when property is not defined and return the error', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} ""=MissingProperty` + ).shellOutput; + expect(result.stderr).to.deep.equal(`Error (1): [MISSING_PROPERTY] ${errorMessages.MISSING_PROPERTY}\n\n`); + }); + + it('Missing property error should be thrown when property is not defined and return the error', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE}` + ).shellOutput; + expect(result.stderr).to.deep.equal(`Error (1): [MISSING_PROPERTY] ${errorMessages.MISSING_PROPERTY}\n\n`); + }); + + it('Missing property error should be thrown when property is not defined and return the error in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} =MissingProperty --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.missingPropertyJsonError); + }); + + it('Missing value error should be thrown when value is not defined and return the error', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} missingValue=` + ).shellOutput; + expect(result.stderr).to.deep.equal(`Error (1): [MISSING_VALUE] ${errorMessages.MISSING_VALUE}\n\n`); + }); + + it('Missing value error should be thrown when value is not defined and return the error', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} "missingValue"=""` + ).shellOutput; + expect(result.stderr).to.deep.equal(`Error (1): [MISSING_VALUE] ${errorMessages.MISSING_VALUE}\n\n`); + }); + + it('Missing value error should be thrown when value is not defined and return the error in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} missingValueError= --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.missingValueJsonError); + }); + + it('Invalid argument error should be thrown when property and value is not defined in correct format and return the error', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} invalid = argument` + ).shellOutput; + expect(result.stderr).to.deep.equal(`Error (1): [INVALID_ARGUMENT] ${errorMessages.INVALID_ARGUMENT}\n\n`); + }); + + it('Invalid argument error should be thrown when property and value is not defined in correct format and return the error', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} attachmentProperties=random value` + ).shellOutput; + expect(result.stderr).to.deep.equal(`Error (1): [INVALID_ARGUMENT] ${errorMessages.INVALID_ARGUMENT}\n\n`); + }); + + it('Invalid argument error should be thrown when property and value is not defined in correct format and return the error in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.ERROR_FILE} "parsing" = "error" --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.invalidArgumentJsonError); + }); + + it('Value should be set successfully for provarHome property in json file and return the success result in json format', () => { + execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_GENERATE_COMMAND} -p ${FILE_PATHS.FILE_MULTIPLE_FILES}` + ); + execCmd( + `${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_LOAD_COMMAND} -p ${FILE_PATHS.FILE_MULTIPLE_FILES}` + ); + execCmd(`${commandConstants.SF_PROVAR_AUTOMATION_CONFIG_VALIDATE_COMMAND}`); + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} provarHome=C:/Users/anchal.goel/Downloads/main_win64_e413157177_20240117_0452/ --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('Value should be overwritten successfully for provarHome property in json file and return the success result', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "provarHome"=${SET_PROVAR_HOME_VALUE}` + ).shellOutput; + expect(result.stdout).to.deep.equal(''); + }); + + it('Value should be set successfully for resultsPath property in json file and return the success result in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "resultsPath"=${SET_RESULTS_PATH_VALUE} --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('Value should be set successfully for projectPath property in json file and return the success result', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "projectPath"=${SET_PROJECT_PATH_VALUE}` + ).shellOutput; + expect(result.stdout).to.deep.equal(''); + }); + + it('Value should be set successfully for smtpPath property in json file and return the success result in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} smtpPath=${SET_SMTP_PATH_VALUE} --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('Value should be set successfully for resultsPathDisposition property in json file and return the success result in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} resultsPathDisposition=${SET_RESULTS_PATH_DISPOSITION_VALUE} --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('Value should be set successfully for testOutputLevel property in json file and return the success result in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "testOutputLevel"=${SET_TEST_OUTPUT_LEVEL_VALUE} --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('Value should be set successfully for pluginOutputlevel property in json file and return the success result', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} pluginOutputlevel=${SET_PLUGIN_OUTPUTLEVEL_VALUE}` + ).shellOutput; + expect(result.stdout).to.deep.equal(''); + }); + + it('Value should be set successfully for lightningMode property in json file and return the success result', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} lightningMode=${SET_LIGHTNING_MODE_VALUE}` + ).shellOutput; + expect(result.stdout).to.deep.equal(''); + }); + + it('Value should be set successfully for testEnvironment property in environment object in json file', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "environment.testEnvironment"=${SET_TEST_ENVIRONMENT_VALUE}` + ).shellOutput; + expect(result.stdout).to.deep.equal(''); + }); + + it('New property should be set successfully in environment object in json file and return the success result in json format ', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} environment.newEnvironment=${SET_NEW_ENVIRONMENT_VALUE} --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('Value should be set successfully for metadataLevel property in json file and return the success result in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "metadata.metadataLevel"=${SET_METADATA_LEVEL_VALUE} --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('Value should be set successfully for metadata cachePath property in json file and return the success result', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} metadata.cachePath=${SET_CACHE_PATH_VALUE}` + ).shellOutput; + expect(result.stdout).to.deep.equal(''); + }); + + it('Multiple properties with values should be set successfully and return the success result', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} metadata.error=${SET_ERROR_VALUE} environment.key=${SET_KEY_VALUE}` + ).shellOutput; + expect(result.stdout).to.deep.equal(''); + }); + + it('New property and Value of type array should be set successfully in json file and return the success result in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "testCases"="[\\"/Test Case 1.testcase\\",\\"/Test Case 2.testcase\\",\\"/Test Case 3.testcase\\"]" --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('New property and Value of type array should be set successfully in json file and return the success result', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "testcase"="[\\"tests/myTestCase.testcase\\",\\"tests/testSuite1/myTestCase1.testCase\\"]"` + ).shellOutput; + expect(result.stdout).to.deep.equal(''); + }); + + it('New property and Value of type object should be set successfully in json file and return the success result', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "emailProperties"="{\\"sendEmail\\":true,\\"primaryRecipients\\":\\"anchal.goel@provartesting.com\\",\\"ccRecipients\\":\\"\\",\\"bccRecipients\\":\\"\\",\\"emailSubject\\":\\"Provar test run report\\",\\"attachExecutionReport\\":true,\\"attachZip\\":false}"` + ).shellOutput; + expect(result.stdout).to.deep.equal(''); + }); + + it('New property and Value of type string should be set successfully in json file and return the success result in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} test=${SET_TEST_VALUE} --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('New property and Value of type string with special char should be set successfully in json file and return the success result in json format ', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "SpecialCharacters"=${SET_SPECIAL_CHARACTERS_VALUE} --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('New property and Value of type Boolean should be set successfully in json file and return the success result in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} booleanValue=false --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('New property and Value of type Boolean should be set successfully in json file and return the success result', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} status=true` + ).shellOutput; + expect(result.stdout).to.deep.equal(''); + }); + + it('New property and Value of type Number should be set successfully in json file and return the success result in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} number=${SET_NUMBER_VALUE} --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('New property and Value of type Number should be set successfully in json file and return the success result', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} number_Value=${SET_NUMBER_DECIMAL_VALUE}` + ).shellOutput; + expect(result.stdout).to.deep.equal(''); + }); + + it('New property and Value of type Null should be set successfully in json file and return the success result in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} nullProperty=null --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('New Object with property and Value should be created successfully in json file and return the success result in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} world.country=${SET_COUNTRY_VALUE} --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + const resultSet = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} world.state=${SET_STATE_VALUE}` + ).shellOutput; + expect(resultSet.stdout).to.deep.equal(''); + const output = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} "world.city"=${SET_CITY_VALUE} --json` + ); + expect(output.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('New Object with nested properties and Value should be created successfully in json file and return the success result in json format', () => { + const result = execCmd( + `${commandConstants.SF_PROVAR_CONFIG_SET_COMMAND} -f ${FILE_PATHS.FILE_MULTIPLE_FILES} company.team.employee.position=${SET_POSITION_VALUE} --json`, + { + ensureExitCode: 0, + } + ); + expect(result.jsonOutput).to.deep.equal(setConstants.setSuccessJson); + }); + + it('Verifying values of all properties if those are correctly set in above testcases', () => { + interface PropertyFileJsonData { + [key: string]: string | boolean | PropertyFileJsonData; + } + const jsonData = JSON.parse( + fileSystem.readFileSync(`./${FILE_PATHS.FILE_MULTIPLE_FILES}`, 'utf8') + ) as PropertyFileJsonData; + expect(jsonData.provarHome).to.equal(JSON.parse(SET_PROVAR_HOME_VALUE)); + expect(jsonData.resultsPath).to.equal(JSON.parse(SET_RESULTS_PATH_VALUE)); + expect(jsonData.projectPath).to.equal(SET_PROJECT_PATH_VALUE); + expect(jsonData.smtpPath).to.equal(JSON.parse(SET_SMTP_PATH_VALUE)); + expect(jsonData.resultsPathDisposition).to.equal(JSON.parse(SET_RESULTS_PATH_DISPOSITION_VALUE)); + expect(jsonData.testOutputLevel).to.equal(SET_TEST_OUTPUT_LEVEL_VALUE); + expect(jsonData.pluginOutputlevel).to.equal(JSON.parse(SET_PLUGIN_OUTPUTLEVEL_VALUE)); + expect(jsonData.lightningMode).to.equal(SET_LIGHTNING_MODE_VALUE); + expect(jsonData.test).to.equal(SET_TEST_VALUE); + expect(jsonData.SpecialCharacters).to.equal(SET_SPECIAL_CHARACTERS_VALUE); + expect(jsonData.booleanValue).to.equal(false); + expect(jsonData.status).to.equal(true); + expect(jsonData.number).to.equal(SET_NUMBER_VALUE); + expect(jsonData.number_Value).to.equal(SET_NUMBER_DECIMAL_VALUE); + expect(jsonData.nullProperty).to.equal(null); + expect(jsonData.lightningMode).to.equal(false); + expect(jsonData.testCases).to.have.members([ + '/Test Case 1.testcase', + '/Test Case 2.testcase', + '/Test Case 3.testcase', + ]); + expect(jsonData.testcase).to.have.members(['tests/myTestCase.testcase', 'tests/testSuite1/myTestCase1.testCase']); + }); + + it('Verifying values of all nested properties', () => { + interface PropertyFileJsonData { + metadata: { + metadataLevel: string; + cachePath: string; + error: string; + }; + environment: { + testEnvironment: string; + newEnvironment: string; + key: string; + }; + emailProperties: { + sendEmail: boolean; + primaryRecipients: string; + ccRecipients: string; + bccRecipients: string; + emailSubject: string; + attachExecutionReport: boolean; + attachZip: boolean; + }; + world: { + country: string; + state: string; + city: string; + }; + company: { + team: { + employee: { + position: string; + }; + }; + }; + } + const jsonData = JSON.parse( + fileSystem.readFileSync(`./${FILE_PATHS.FILE_MULTIPLE_FILES}`, 'utf8') + ) as PropertyFileJsonData; + expect(jsonData.metadata.metadataLevel).to.equal(JSON.parse(SET_METADATA_LEVEL_VALUE)); + expect(jsonData.metadata.cachePath).to.equal(SET_CACHE_PATH_VALUE); + expect(jsonData.metadata.error).to.equal(SET_ERROR_VALUE); + expect(jsonData.environment.key).to.equal(SET_KEY_VALUE); + expect(jsonData.environment.testEnvironment).to.equal(JSON.parse(SET_TEST_ENVIRONMENT_VALUE)); + expect(jsonData.environment.newEnvironment).to.equal(SET_NEW_ENVIRONMENT_VALUE); + expect(jsonData.emailProperties.sendEmail).to.equal(true); + expect(jsonData.emailProperties.primaryRecipients).to.equal('anchal.goel@provartesting.com'); + expect(jsonData.emailProperties.ccRecipients).to.equal(''); + expect(jsonData.emailProperties.bccRecipients).to.equal(''); + expect(jsonData.emailProperties.emailSubject).to.equal('Provar test run report'); + expect(jsonData.emailProperties.attachExecutionReport).to.equal(true); + expect(jsonData.emailProperties.attachZip).to.equal(false); + expect(jsonData.world.country).to.equal(SET_COUNTRY_VALUE); + expect(jsonData.world.state).equal(SET_STATE_VALUE); + expect(jsonData.world.city).equal(JSON.parse(SET_CITY_VALUE)); + expect(jsonData.company.team.employee.position).to.equal(SET_POSITION_VALUE); + }); +}); From e69591747ca28507937731ce9ef8d809246337b9 Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:56:53 +0530 Subject: [PATCH 18/61] PDX-445: updating md files --- messages/provar.config.get.md | 8 ++++---- messages/provar.config.set.md | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/messages/provar.config.get.md b/messages/provar.config.get.md index bf255c48..c88dc28a 100644 --- a/messages/provar.config.get.md +++ b/messages/provar.config.get.md @@ -1,16 +1,16 @@ # summary -Retrieves a value from the loaded properties file. +Retrieve a value from the specified JSON file. # description -Retrieves a value from the loaded properties file. +Retrieve a value from the specified JSON file. # examples -- Retrieves a value from the loaded properties file +- Get the testEnvironment value within the environment property from the config.json file: - <%= config.bin %> <%= command.id %> 'key' + $ sf provar config get environment.testEnvironment -f config.json # error.MultipleFailure diff --git a/messages/provar.config.set.md b/messages/provar.config.set.md index c20934b2..5902fb8b 100644 --- a/messages/provar.config.set.md +++ b/messages/provar.config.set.md @@ -1,16 +1,24 @@ # summary -Sets a property in the loaded properties file. +Set one or more properties in the specified JSON file. # description -Sets a property in the loaded properties file. +Set one or more properties in the specified JSON file. # examples -- Sets a property in the loaded properties file with resp. values +- Set the environment to “SIT” in the config.json properties file: - <%= config.bin %> <%= command.id %> 'key'='value' + $ sf provar config set environment.testEnvironment="SIT" -f config.json + +- Set the testEnvironment to “SIT” and the webBrowser to “Chrome”, within the environment property. + + $ sf provar config set environment.testEnvironment="SIT" environment.webBrowser="Chrome" -f config.json + +- Set testCases to a list of test case paths in the config.json properties file. + + $ sf provar config set testCases='["tests/myTestCase.testcase","tests/testSuite1/myTestCase1.testCase"]' -f config.json # error.MultipleFailure From d8cb962f384fa48837c5420d4c402e5826778065 Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Tue, 5 Nov 2024 17:11:49 +0530 Subject: [PATCH 19/61] PDX:445: bumped version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 96b30522..95178294 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@provartesting/provardx-cli", "description": "A plugin for the Salesforce CLI to orchestrate testing activities and report quality metrics to Provar Manager", - "version": "1.4.1", + "version": "1.4.2", "license": "BSD-3-Clause", "plugins": [ "@provartesting/provardx-plugins-automation", @@ -20,7 +20,7 @@ "node-stream-zip": "^1.15.0", "@provartesting/provardx-plugins-utils": "1.2.0", "@provartesting/provardx-plugins-automation": "1.1.0", - "@provartesting/provardx-plugins-manager": "1.2.0", + "@provartesting/provardx-plugins-manager": "1.2.1", "sync-request": "^6.1.0", "xml-js": "^1.6.11" }, From 28dc099517acb3201d096db777f61302ba2980fc Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Mon, 2 Dec 2024 21:21:57 +0530 Subject: [PATCH 20/61] PDX-453: changes spaces from 3 to 4 while writing back to the JSON after setting the required attribute for set commands (#97) make 4 space from 3 while editing the json files in any case after setting the required attribute for set commands. No changes in NUTs required as we are only getting the set values and asserting the values in NUTs and not validating the whole JSON --- src/commands/provar/automation/config/set.ts | 2 +- src/commands/provar/config/set.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/provar/automation/config/set.ts b/src/commands/provar/automation/config/set.ts index c1279cbb..600877df 100644 --- a/src/commands/provar/automation/config/set.ts +++ b/src/commands/provar/automation/config/set.ts @@ -68,7 +68,7 @@ export default class SfProvarConfigSet extends SfCommand } } if (this.errorHandler.getErrors().length == 0) { - fileSystem.writeFileSync(propertiesFilePath, JSON.stringify(propertyFileContent, null, 3)); + fileSystem.writeFileSync(propertiesFilePath, JSON.stringify(propertyFileContent, null, 4)); } } catch (err: any) { if (err.name === 'InvalidArgumentFormatError') { diff --git a/src/commands/provar/config/set.ts b/src/commands/provar/config/set.ts index 331bb4cf..8ba11526 100644 --- a/src/commands/provar/config/set.ts +++ b/src/commands/provar/config/set.ts @@ -81,7 +81,7 @@ export default class SfProvarConfigSet extends SfCommand } } if (this.errorHandler.getErrors().length == 0) { - fileSystem.writeFileSync(propertiesFilePath, JSON.stringify(propertyFileContent, null, 3)); + fileSystem.writeFileSync(propertiesFilePath, JSON.stringify(propertyFileContent, null, 4)); } } catch (err: any) { if (err.name === 'InvalidArgumentFormatError') { From 32b4f7147ce64c0c7c2e1e7b0dd7effd973be7ad Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Tue, 3 Dec 2024 18:38:53 +0530 Subject: [PATCH 21/61] PDX-457: bumped version --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 95178294..09a150fd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@provartesting/provardx-cli", "description": "A plugin for the Salesforce CLI to orchestrate testing activities and report quality metrics to Provar Manager", - "version": "1.4.2", + "version": "1.4.5", "license": "BSD-3-Clause", "plugins": [ "@provartesting/provardx-plugins-automation", @@ -18,9 +18,9 @@ "fast-xml-parser": "^4.3.6", "jsonschema": "^1.4.1", "node-stream-zip": "^1.15.0", - "@provartesting/provardx-plugins-utils": "1.2.0", - "@provartesting/provardx-plugins-automation": "1.1.0", - "@provartesting/provardx-plugins-manager": "1.2.1", + "@provartesting/provardx-plugins-utils": "1.3.0", + "@provartesting/provardx-plugins-automation": "1.2.0", + "@provartesting/provardx-plugins-manager": "1.3.0", "sync-request": "^6.1.0", "xml-js": "^1.6.11" }, From 4db458891bebd09a203acbaface0a43ffca135f2 Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Tue, 3 Dec 2024 18:54:39 +0530 Subject: [PATCH 22/61] PDX-457: bumped version --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 09a150fd..b5880db7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@provartesting/provardx-cli", "description": "A plugin for the Salesforce CLI to orchestrate testing activities and report quality metrics to Provar Manager", - "version": "1.4.5", + "version": "1.4.6", "license": "BSD-3-Clause", "plugins": [ "@provartesting/provardx-plugins-automation", @@ -18,9 +18,9 @@ "fast-xml-parser": "^4.3.6", "jsonschema": "^1.4.1", "node-stream-zip": "^1.15.0", - "@provartesting/provardx-plugins-utils": "1.3.0", - "@provartesting/provardx-plugins-automation": "1.2.0", - "@provartesting/provardx-plugins-manager": "1.3.0", + "@provartesting/provardx-plugins-utils": "1.3.1", + "@provartesting/provardx-plugins-automation": "1.2.1", + "@provartesting/provardx-plugins-manager": "1.3.1", "sync-request": "^6.1.0", "xml-js": "^1.6.11" }, From 5bf99797f3855d7da7e688512e44b4d77ab7c25c Mon Sep 17 00:00:00 2001 From: Samuel Arroyo Date: Wed, 4 Dec 2024 09:39:21 +0000 Subject: [PATCH 23/61] Update README.md with abort command (#100) Update README.md with abort command --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 5ec492ec..e903d77c 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ $ sf plugins uninstall @provartesting/provardx-cli - [`sf provar manager testcase retrieve`](#sf-provar-manager-testcase-retrieve) - [`sf provar manager test run`](#sf-provar-manager-test-run) - [`sf provar manager test run report`](#sf-provar-manager-test-run-report) +- [`sf provar manager test run abort`](#sf-provar-manager-test-run-abort) ## `sf provar config get` @@ -467,3 +468,31 @@ EXAMPLES $ sf provar manager test run report -i 45f70417-df21-4917-a667-abc2ee46dc63 -r junit -o junit-results.xml ``` + +## `sf provar manager test run abort` + +Abort an in-progress test run triggered via Provar Manager. + +``` +USAGE + $ sf provar manager test run abort -i [--json] [-p ] [-w ] + +FLAGS + -i, --test-run= (required) Test run ID. + -p, --polling-interval= [default: 30] Sets the polling interval in + seconds. Default is 30 seconds. + -w, --wait= [default: 2] Sets the polling timeout in + minutes. Default is 2 minutes. + +GLOBAL FLAGS + --json Format output as json. + +DESCRIPTION + Abort an in-progress test run triggered via Provar Manager. + +EXAMPLES + Abort test run with ID 45f70417-df21-4917-a667-abc2ee46dc63 + + $ sf provar manager test run abort -i 45f70417-df21-4917-a667-abc2ee46dc63 + +``` From 561df3ccbbbb753e190f372b7add426b54de67ae Mon Sep 17 00:00:00 2001 From: Palak-Bansal-Provar <89642292+Palak-Bansal-Provar@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:20:29 +0530 Subject: [PATCH 24/61] PDX-457: bumped version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5880db7..577f8f4d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@provartesting/provardx-cli", "description": "A plugin for the Salesforce CLI to orchestrate testing activities and report quality metrics to Provar Manager", - "version": "1.4.6", + "version": "1.4.7", "license": "BSD-3-Clause", "plugins": [ "@provartesting/provardx-plugins-automation", From 814d071b28a14acc5abfc1aaa2f1c5a5175db6ea Mon Sep 17 00:00:00 2001 From: Michael Dailey Date: Tue, 31 Mar 2026 13:25:16 -0500 Subject: [PATCH 25/61] fix: correct fromJSON strategy matrix for PR-triggered runs inputs.OS is undefined on pull_request events, so the old fallback produced invalid JSON when passed to fromJSON. Use a valid JSON array literal as the fallback instead. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/CI_Execution.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI_Execution.yml b/.github/workflows/CI_Execution.yml index a6c33d70..89ade3ca 100644 --- a/.github/workflows/CI_Execution.yml +++ b/.github/workflows/CI_Execution.yml @@ -22,7 +22,7 @@ jobs: provardx-ci-execution: strategy: matrix: - os: ${{ fromJSON(format('[{0}]', inputs.OS || '"ubuntu-latest" || "macos-latest"')) }} + os: ${{ fromJSON(inputs.OS && format('[{0}]', inputs.OS) || '["ubuntu-latest"]') }} nodeversion: [18] runs-on: ${{ matrix.os }} steps: From 3ec0e7c8021bc0f02f97f474f3fe2a8ce4d25965 Mon Sep 17 00:00:00 2001 From: Michael Dailey Date: Tue, 31 Mar 2026 13:53:18 -0500 Subject: [PATCH 26/61] fix: bump deprecated GitHub Actions to current versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - actions/cache v3 → v4 - actions/upload-artifact v3 → v4 Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/CI_Execution.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI_Execution.yml b/.github/workflows/CI_Execution.yml index 89ade3ca..7c43bf36 100644 --- a/.github/workflows/CI_Execution.yml +++ b/.github/workflows/CI_Execution.yml @@ -31,7 +31,7 @@ jobs: with: node-version: ${{ matrix.nodeversion }} - name: 'Cache node_modules' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ matrix.os == 'windows-latest' && 'C:\\Users\\runneradmin\\AppData\\Roaming\\npm-cache' || '~/.npm' }} key: ${{ runner.os }}-node-v${{ matrix.nodeversion }}-${{ hashFiles('**/package.json') }} @@ -119,7 +119,7 @@ jobs: sf plugins link . yarn run test:nuts - name: Archive NUTS results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: nuts-report-${{ matrix.os }} path: mochawesome-report From 5483bd50c0608d110538eb6dba92e699359bc504 Mon Sep 17 00:00:00 2001 From: Michael Dailey Date: Tue, 31 Mar 2026 17:01:47 -0500 Subject: [PATCH 27/61] fix: switch regression repo to provar-manager-regression PM_Grid_AutomationPack Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/CI_Execution.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI_Execution.yml b/.github/workflows/CI_Execution.yml index 7c43bf36..399ccb1d 100644 --- a/.github/workflows/CI_Execution.yml +++ b/.github/workflows/CI_Execution.yml @@ -102,9 +102,9 @@ jobs: - name: Check out Regression repo uses: actions/checkout@v4 with: - repository: ProvarTesting/ProvarRegression + repository: ProvarTesting/provar-manager-regression path: ProvarRegression - ref: AnchalGoel + ref: PM_Grid_AutomationPack token: ${{ secrets.PATREGRESSION }} - name: Change permissions run: | From 23b2f7c5f364c3dc66e0e9a30cae773386e11ec1 Mon Sep 17 00:00:00 2001 From: Michael Dailey Date: Mon, 6 Apr 2026 10:37:28 -0500 Subject: [PATCH 28/61] feat: MCP server, quality-hub aliases, licensing, and project validation - Add \sf provar mcp start\: StdioServerTransport MCP server with 30+ tools - Add MCP tools: page objects, test cases, suites, plans, project validation, ANT build, RCA analysis, properties files, Quality Hub, Automation, defects, test plan management (add/create/remove suite and instance) - Add license validation: IDE auto-detection from ~/Provar/.licenses/, disk cache (2h TTL / 48h offline grace), PROVAR_DEV_WHITELIST_KEYS bypass, ALGAS tag API with 401 retry on expired Cognito token - Add \sf provar quality-hub\ command set (7 commands) aliasing provardx-plugins-manager; bump all provardx-plugins deps to dev tags (1.2.2-dev.0 / 1.3.2-dev.0) which ship subpath exports for bare specifiers - Add \sf provar automation project validate\ command - Refactor projectValidation service to single disk walk (readPlansDir returns coveredPaths directly, eliminating second scan) - Add 490-test unit suite covering all tools, services, and licensing flows - Update CI workflows, add docs/ (mcp.md, mcp-pilot-guide.md, development.md) - Add CLAUDE.md with project conventions and test expectations --- .env.example | 12 + .github/workflows/CIRelease_Tagging.yml | 4 +- .github/workflows/CI_Execution.yml | 2 +- .github/workflows/DeployManual.yml | 13 +- .github/workflows/UnpublishManual.yml | 4 +- .gitignore | 15 +- CLAUDE.md | 33 + README.md | 273 +- docs/development.md | 386 ++ docs/mcp-pilot-guide.md | 352 ++ docs/mcp.md | 1056 ++++++ .../sf.provar.automation.project.validate.md | 52 + messages/sf.provar.mcp.start.md | 34 + package.json | 42 +- .../provar/automation/config/validate.ts | 1 - .../provar/automation/project/validate.ts | 79 + src/commands/provar/mcp/start.ts | 72 + src/commands/provar/quality-hub/connect.ts | 13 + src/commands/provar/quality-hub/display.ts | 13 + src/commands/provar/quality-hub/open.ts | 13 + src/commands/provar/quality-hub/test/run.ts | 13 + .../provar/quality-hub/test/run/abort.ts | 13 + .../provar/quality-hub/test/run/report.ts | 13 + .../provar/quality-hub/testcase/retrieve.ts | 13 + src/mcp/licensing/algasClient.ts | 178 + src/mcp/licensing/ideDetection.ts | 194 + src/mcp/licensing/index.ts | 12 + src/mcp/licensing/licenseCache.ts | 95 + src/mcp/licensing/licenseError.ts | 16 + src/mcp/licensing/licenseValidator.ts | 134 + src/mcp/logging/logger.ts | 23 + .../rules/provar_best_practices_rules.json | 3192 +++++++++++++++++ src/mcp/schemas/common.ts | 43 + src/mcp/security/pathPolicy.ts | 43 + src/mcp/server.ts | 73 + src/mcp/tools/antTools.ts | 829 +++++ src/mcp/tools/automationTools.ts | 467 +++ src/mcp/tools/bestPracticesEngine.ts | 740 ++++ src/mcp/tools/defectTools.ts | 321 ++ src/mcp/tools/hierarchyValidate.ts | 785 ++++ src/mcp/tools/pageObjectGenerate.ts | 192 + src/mcp/tools/pageObjectValidate.ts | 480 +++ src/mcp/tools/projectInspect.ts | 821 +++++ src/mcp/tools/projectValidateFromPath.ts | 194 + src/mcp/tools/propertiesTools.ts | 374 ++ src/mcp/tools/qualityHubTools.ts | 271 ++ src/mcp/tools/rcaTools.ts | 732 ++++ src/mcp/tools/sfSpawn.ts | 16 + src/mcp/tools/testCaseGenerate.ts | 279 ++ src/mcp/tools/testCaseValidate.ts | 279 ++ src/mcp/tools/testPlanTools.ts | 364 ++ src/mcp/tools/testPlanValidate.ts | 92 + src/mcp/tools/testSuiteValidate.ts | 79 + src/services/projectValidation.ts | 842 +++++ test/tsconfig.json | 6 +- .../unit/commands/quality-hub/connect.test.ts | 27 + .../unit/commands/quality-hub/display.test.ts | 21 + test/unit/commands/quality-hub/open.test.ts | 21 + .../quality-hub/test.run.abort.test.ts | 21 + .../quality-hub/test.run.report.test.ts | 21 + .../commands/quality-hub/test.run.test.ts | 21 + .../quality-hub/testcase.retrieve.test.ts | 21 + test/unit/mcp/antTools.test.ts | 690 ++++ test/unit/mcp/automationTools.test.ts | 498 +++ test/unit/mcp/bestPracticesEngine.test.ts | 169 + test/unit/mcp/defectTools.test.ts | 337 ++ test/unit/mcp/hierarchyValidate.test.ts | 591 +++ .../mcp/licensing/licenseValidator.test.ts | 596 +++ test/unit/mcp/pageObjectGenerate.test.ts | 365 ++ test/unit/mcp/pageObjectValidate.test.ts | 135 + test/unit/mcp/pathPolicy.test.ts | 59 + test/unit/mcp/projectValidateFromPath.test.ts | 325 ++ test/unit/mcp/propertiesTools.test.ts | 451 +++ test/unit/mcp/qualityHubTools.test.ts | 249 ++ test/unit/mcp/rcaTools.test.ts | 508 +++ test/unit/mcp/testCaseGenerate.test.ts | 371 ++ test/unit/mcp/testCaseValidate.test.ts | 105 + test/unit/mcp/testPlanTools.test.ts | 621 ++++ test/unit/mcp/testPlanValidate.test.ts | 336 ++ test/unit/mcp/testSuiteValidate.test.ts | 321 ++ test/unit/services/projectValidation.test.ts | 453 +++ yarn.lock | 1448 +++++--- 82 files changed, 23023 insertions(+), 445 deletions(-) create mode 100644 .env.example create mode 100644 CLAUDE.md create mode 100644 docs/development.md create mode 100644 docs/mcp-pilot-guide.md create mode 100644 docs/mcp.md create mode 100644 messages/sf.provar.automation.project.validate.md create mode 100644 messages/sf.provar.mcp.start.md create mode 100644 src/commands/provar/automation/project/validate.ts create mode 100644 src/commands/provar/mcp/start.ts create mode 100644 src/commands/provar/quality-hub/connect.ts create mode 100644 src/commands/provar/quality-hub/display.ts create mode 100644 src/commands/provar/quality-hub/open.ts create mode 100644 src/commands/provar/quality-hub/test/run.ts create mode 100644 src/commands/provar/quality-hub/test/run/abort.ts create mode 100644 src/commands/provar/quality-hub/test/run/report.ts create mode 100644 src/commands/provar/quality-hub/testcase/retrieve.ts create mode 100644 src/mcp/licensing/algasClient.ts create mode 100644 src/mcp/licensing/ideDetection.ts create mode 100644 src/mcp/licensing/index.ts create mode 100644 src/mcp/licensing/licenseCache.ts create mode 100644 src/mcp/licensing/licenseError.ts create mode 100644 src/mcp/licensing/licenseValidator.ts create mode 100644 src/mcp/logging/logger.ts create mode 100644 src/mcp/rules/provar_best_practices_rules.json create mode 100644 src/mcp/schemas/common.ts create mode 100644 src/mcp/security/pathPolicy.ts create mode 100644 src/mcp/server.ts create mode 100644 src/mcp/tools/antTools.ts create mode 100644 src/mcp/tools/automationTools.ts create mode 100644 src/mcp/tools/bestPracticesEngine.ts create mode 100644 src/mcp/tools/defectTools.ts create mode 100644 src/mcp/tools/hierarchyValidate.ts create mode 100644 src/mcp/tools/pageObjectGenerate.ts create mode 100644 src/mcp/tools/pageObjectValidate.ts create mode 100644 src/mcp/tools/projectInspect.ts create mode 100644 src/mcp/tools/projectValidateFromPath.ts create mode 100644 src/mcp/tools/propertiesTools.ts create mode 100644 src/mcp/tools/qualityHubTools.ts create mode 100644 src/mcp/tools/rcaTools.ts create mode 100644 src/mcp/tools/sfSpawn.ts create mode 100644 src/mcp/tools/testCaseGenerate.ts create mode 100644 src/mcp/tools/testCaseValidate.ts create mode 100644 src/mcp/tools/testPlanTools.ts create mode 100644 src/mcp/tools/testPlanValidate.ts create mode 100644 src/mcp/tools/testSuiteValidate.ts create mode 100644 src/services/projectValidation.ts create mode 100644 test/unit/commands/quality-hub/connect.test.ts create mode 100644 test/unit/commands/quality-hub/display.test.ts create mode 100644 test/unit/commands/quality-hub/open.test.ts create mode 100644 test/unit/commands/quality-hub/test.run.abort.test.ts create mode 100644 test/unit/commands/quality-hub/test.run.report.test.ts create mode 100644 test/unit/commands/quality-hub/test.run.test.ts create mode 100644 test/unit/commands/quality-hub/testcase.retrieve.test.ts create mode 100644 test/unit/mcp/antTools.test.ts create mode 100644 test/unit/mcp/automationTools.test.ts create mode 100644 test/unit/mcp/bestPracticesEngine.test.ts create mode 100644 test/unit/mcp/defectTools.test.ts create mode 100644 test/unit/mcp/hierarchyValidate.test.ts create mode 100644 test/unit/mcp/licensing/licenseValidator.test.ts create mode 100644 test/unit/mcp/pageObjectGenerate.test.ts create mode 100644 test/unit/mcp/pageObjectValidate.test.ts create mode 100644 test/unit/mcp/pathPolicy.test.ts create mode 100644 test/unit/mcp/projectValidateFromPath.test.ts create mode 100644 test/unit/mcp/propertiesTools.test.ts create mode 100644 test/unit/mcp/qualityHubTools.test.ts create mode 100644 test/unit/mcp/rcaTools.test.ts create mode 100644 test/unit/mcp/testCaseGenerate.test.ts create mode 100644 test/unit/mcp/testCaseValidate.test.ts create mode 100644 test/unit/mcp/testPlanTools.test.ts create mode 100644 test/unit/mcp/testPlanValidate.test.ts create mode 100644 test/unit/mcp/testSuiteValidate.test.ts create mode 100644 test/unit/services/projectValidation.test.ts diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..483cf232 --- /dev/null +++ b/.env.example @@ -0,0 +1,12 @@ +# Copy this file to .env and fill in real values. +# .env is gitignored and must never be committed. + +# ── Provar Licensing OAuth (Cognito client credentials) ────────────────────── +# Obtain from the Provar platform team. +PROVAR_OAUTH_CLIENT_ID=your-client-id-here +PROVAR_OAUTH_CLIENT_SECRET=your-client-secret-here + +# ── Dev whitelist keys (comma-separated) ───────────────────────────────────── +# Keys that bypass the licensing API entirely (development / CI only). +# Obtain from the Provar platform team. +PROVAR_DEV_WHITELIST_KEYS=your-dev-key-here diff --git a/.github/workflows/CIRelease_Tagging.yml b/.github/workflows/CIRelease_Tagging.yml index f65d60eb..4693b3e1 100644 --- a/.github/workflows/CIRelease_Tagging.yml +++ b/.github/workflows/CIRelease_Tagging.yml @@ -12,10 +12,10 @@ jobs: runs-on: ubuntu-latest if: github.event.pull_request.merged == true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 - name: Install Dependencies run: | yarn diff --git a/.github/workflows/CI_Execution.yml b/.github/workflows/CI_Execution.yml index 399ccb1d..de9d3d95 100644 --- a/.github/workflows/CI_Execution.yml +++ b/.github/workflows/CI_Execution.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: os: ${{ fromJSON(inputs.OS && format('[{0}]', inputs.OS) || '["ubuntu-latest"]') }} - nodeversion: [18] + nodeversion: [20] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/DeployManual.yml b/.github/workflows/DeployManual.yml index 271f1d00..f0eea483 100644 --- a/.github/workflows/DeployManual.yml +++ b/.github/workflows/DeployManual.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: inputs: tag: - description: 'tag name e.g. beta, latest etc.' + description: "tag name e.g. beta, latest etc." jobs: build: runs-on: ubuntu-latest @@ -13,11 +13,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18 - registry-url: 'https://registry.npmjs.org' - scope: '@provartesting' + node-version: 20 + registry-url: "https://registry.npmjs.org" + scope: "@provartesting" - name: Install dependencies and build run: | npm install -g @salesforce/cli @@ -28,6 +28,7 @@ jobs: cat /home/runner/work/_temp/.npmrc cat $NPM_CONFIG_USERCONFIG - name: Publish package on NPM - run: yarn publish --tag ${{ inputs.tag }} + run: npm publish --tag "$TAG" --access public env: + TAG: ${{ github.event.inputs.tag || 'latest' }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/UnpublishManual.yml b/.github/workflows/UnpublishManual.yml index 11beb3e7..e8a52bd7 100644 --- a/.github/workflows/UnpublishManual.yml +++ b/.github/workflows/UnpublishManual.yml @@ -10,9 +10,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 registry-url: 'https://registry.npmjs.org' scope: '@provartesting' - name: Unpublish package from NPM diff --git a/.gitignore b/.gitignore index 1120f09f..0579fcf1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ tmp/ # never checkin npm config .npmrc +# npm lockfile — this project uses yarn; suppress the warning +package-lock.json + # debug logs npm-error.log yarn-error.log @@ -21,13 +24,11 @@ test/lib coverage test_session* -# generated docs -docs - # ignore sfdx-trust files *.tgz *.sig package.json.bak. +.sfdx # -- CLEAN ALL *.tsbuildinfo @@ -46,4 +47,10 @@ oclif.manifest.json #Mocha Report Directory -mochawesome-report \ No newline at end of file +mochawesome-report +.gstack/ + +# Local environment — never commit real credentials +.env +.env.local +.env.*.local diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..f93f1b53 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,33 @@ +# gstack + +Use the `/browse` skill from gstack for all web browsing. Never use `mcp__claude-in-chrome__*` tools. + +If gstack skills aren't working, run `cd .claude/skills/gstack && ./setup` to build the binary and register skills. + +Available gstack skills: +- `/office-hours` - Get help and guidance +- `/plan-ceo-review` - CEO-level plan review +- `/plan-eng-review` - Engineering plan review +- `/plan-design-review` - Design plan review +- `/design-consultation` - Design consultation +- `/review` - Code review +- `/ship` - Ship a feature end-to-end +- `/land-and-deploy` - Land and deploy changes +- `/canary` - Canary deployment +- `/benchmark` - Benchmark performance +- `/browse` - Web browsing (use this for all web browsing) +- `/qa` - QA testing +- `/qa-only` - QA without code changes +- `/design-review` - Design review +- `/setup-browser-cookies` - Set up browser cookies +- `/setup-deploy` - Set up deployment +- `/retro` - Retrospective +- `/investigate` - Investigate an issue +- `/document-release` - Document a release +- `/codex` - Codex agent tasks +- `/cso` - CSO review +- `/careful` - Careful mode for risky changes +- `/freeze` - Freeze deployments +- `/guard` - Guard against regressions +- `/unfreeze` - Unfreeze deployments +- `/gstack-upgrade` - Upgrade gstack diff --git a/README.md b/README.md index e903d77c..b8e766f6 100644 --- a/README.md +++ b/README.md @@ -6,27 +6,58 @@ # What is the ProvarDX CLI? -The Provar DX CLI is a Salesforce CLI plugin for Provar customers who want to automate the execution of tests using Provar Automation, and the reporting of test results and other quality-related metrics to Provar Manager. +The Provar DX CLI is a Salesforce CLI plugin for Provar customers who want to automate the execution of tests using Provar Automation, and the reporting of test results and other quality-related metrics to Provar Quality Hub. # Installation, Update, and Uninstall Install the plugin + ```sh-session $ sf plugins install @provartesting/provardx-cli ``` Update plugins + ```sh-session $ sf plugins update ``` Uninstall the plugin + ```sh-session $ sf plugins uninstall @provartesting/provardx-cli ``` +# MCP Server (AI-Assisted Quality) + +The Provar DX CLI includes a built-in **Model Context Protocol (MCP) server** that connects AI assistants (Claude Desktop, Claude Code, Cursor) directly to your Provar project. Once connected, an AI agent can inspect your project structure, generate Page Objects and test cases, and validate every level of the test hierarchy with quality scores that match the Provar Quality Hub API. + +```sh +sf provar mcp start --allowed-paths /path/to/your/provar/project +``` + +📖 **See [docs/mcp.md](https://github.com/ProvarTesting/provardx-cli/blob/main/docs/mcp.md) for full setup and tool documentation.** + +## License Validation + +The MCP server verifies your Provar license before accepting any connections. Validation is automatic — no extra flags are required for standard usage. + +**How it works:** + +1. **Auto-detection** — the server reads `~/Provar/.licenses/*.properties` (the same files written by Provar's IDE plugins). If a valid, activated license is found the server starts immediately. +2. **Cache** — successful validations are cached at `~/Provar/.licenses/.mcp-license-cache.json` (2 h TTL). Subsequent starts within the TTL window skip the disk scan. +3. **Offline grace** — if validation cannot reach the network and the cache is stale (but ≤ 48 h old), the server starts with a warning on stderr so CI pipelines are not broken by transient connectivity issues. +4. **Fail closed** — if no valid license is detected the command exits with a non-zero exit code and a clear error message. + +**`NODE_ENV=test` fast-path:** + +When `NODE_ENV=test` the validation step is skipped entirely. This is intended only for the plugin's own unit-test suite. + +--- + # Commands +- [`sf provar mcp start`](#sf-provar-mcp-start) - [`sf provar config get`](#sf-provar-config-get) - [`sf provar config set`](#sf-provar-config-set) - [`sf provar automation config generate`](#sf-provar-automation-config-generate) @@ -38,13 +69,90 @@ $ sf plugins uninstall @provartesting/provardx-cli - [`sf provar automation project compile`](#sf-provar-automation-project-compile) - [`sf provar automation metadata download`](#sf-provar-automation-metadata-download) - [`sf provar automation test run`](#sf-provar-automation-test-run) -- [`sf provar manager connect`](#sf-provar-manager-connect) -- [`sf provar manager display`](#sf-provar-manager-display) -- [`sf provar manager open`](#sf-provar-manager-open) -- [`sf provar manager testcase retrieve`](#sf-provar-manager-testcase-retrieve) -- [`sf provar manager test run`](#sf-provar-manager-test-run) -- [`sf provar manager test run report`](#sf-provar-manager-test-run-report) -- [`sf provar manager test run abort`](#sf-provar-manager-test-run-abort) +- [`sf provar quality-hub connect`](#sf-provar-quality-hub-connect) +- [`sf provar quality-hub display`](#sf-provar-quality-hub-display) +- [`sf provar quality-hub open`](#sf-provar-quality-hub-open) +- [`sf provar quality-hub testcase retrieve`](#sf-provar-quality-hub-testcase-retrieve) +- [`sf provar quality-hub test run`](#sf-provar-quality-hub-test-run) +- [`sf provar quality-hub test run report`](#sf-provar-quality-hub-test-run-report) +- [`sf provar quality-hub test run abort`](#sf-provar-quality-hub-test-run-abort) +- [`sf provar manager connect`](#sf-provar-manager-connect) _(deprecated — use `sf provar quality-hub connect`)_ +- [`sf provar manager display`](#sf-provar-manager-display) _(deprecated — use `sf provar quality-hub display`)_ +- [`sf provar manager open`](#sf-provar-manager-open) _(deprecated — use `sf provar quality-hub open`)_ +- [`sf provar manager testcase retrieve`](#sf-provar-manager-testcase-retrieve) _(deprecated — use `sf provar quality-hub testcase retrieve`)_ +- [`sf provar manager test run`](#sf-provar-manager-test-run) _(deprecated — use `sf provar quality-hub test run`)_ +- [`sf provar manager test run report`](#sf-provar-manager-test-run-report) _(deprecated — use `sf provar quality-hub test run report`)_ +- [`sf provar manager test run abort`](#sf-provar-manager-test-run-abort) _(deprecated — use `sf provar quality-hub test run abort`)_ + +## `sf provar mcp start` + +Start a local MCP server for Provar tools over stdio transport. + +``` +USAGE + $ sf provar mcp start [-a ...] + +FLAGS + -a, --allowed-paths=... Allowed base directory paths for file operations. + Defaults to the current working directory. + Repeat the flag to allow multiple paths. + +DESCRIPTION + Launches a stateless MCP (Model Context Protocol) server that exposes Provar tools + to AI assistants (Claude Desktop, Claude Code, Cursor) via stdio transport. All MCP + JSON-RPC communication happens over stdout; all internal logging goes to stderr. + + Note: --json is not available on this command — stdout is reserved for MCP traffic. + +TOOLS EXPOSED + provardx.ping — sanity-check: echo back a message + provar.project.inspect — inspect project folder inventory + provar.pageobject.generate — generate Java Page Object skeleton + provar.pageobject.validate — validate Page Object quality (30+ rules) + provar.testcase.generate — generate XML test case skeleton + provar.testcase.validate — validate test case XML (validity + best-practices scores) + provar.testsuite.validate — validate test suite hierarchy + provar.testplan.validate — validate test plan with metadata completeness checks + provar.project.validate — validate full project: cross-cutting rules, connections, environments + provar.properties.generate — generate provardx-properties.json from the standard template + provar.properties.read — read and parse a provardx-properties.json file + provar.properties.set — update fields in a provardx-properties.json file + provar.properties.validate — validate a provardx-properties.json file against the schema + provar.ant.generate — generate an ANT build.xml for CI/CD pipeline execution + provar.ant.validate — validate an ANT build.xml for structural correctness + provar.qualityhub.connect — connect to a Quality Hub org + provar.qualityhub.display — display connected Quality Hub org info + provar.qualityhub.testrun — trigger a Quality Hub test run + provar.qualityhub.testrun.report — poll test run status + provar.qualityhub.testrun.abort — abort an in-progress test run + provar.qualityhub.testcase.retrieve — retrieve test cases by user story / component + provar.automation.setup — detect or download/install Provar Automation binaries + provar.automation.testrun — trigger a Provar Automation test run (LOCAL) + provar.automation.compile — compile Page Objects after changes + provar.automation.config.load — register a provardx-properties.json as the active config (required before compile/testrun) + provar.automation.metadata.download — download Salesforce metadata into the project + provar.qualityhub.defect.create — create Quality Hub defects from failed test executions + provar.testrun.report.locate — resolve artifact paths (JUnit.xml, HTML reports) for a completed test run + provar.testrun.rca — analyse a completed test run: classify failures, extract page objects, detect pre-existing issues + provar.testplan.add-instance — wire a test case into a plan suite by writing a .testinstance file + provar.testplan.create-suite — create a new test suite directory with .planitem inside a plan + provar.testplan.remove-instance — remove a .testinstance file from a plan suite + +EXAMPLES + Start MCP server (accepts stdio connections from Claude Desktop / Cursor): + + $ sf provar mcp start + + Start with an explicit allowed path: + + $ sf provar mcp start --allowed-paths /workspace/provar + + Allow multiple directories: + + $ sf provar mcp start -a /workspace/project-a -a /workspace/project-b +``` + +📖 **Full tool documentation and client configuration: [docs/mcp.md](https://github.com/ProvarTesting/provardx-cli/blob/main/docs/mcp.md)** ## `sf provar config get` @@ -163,7 +271,7 @@ DESCRIPTION EXAMPLES Check if the loaded properties file has all the required properties set: - + $ sf provar automation config validate ``` @@ -301,6 +409,153 @@ EXAMPLES $ sf provar automation test run ``` +## `sf provar quality-hub connect` + +Connect to a Provar Quality Hub org. + +``` +USAGE + $ sf provar quality-hub connect -o [--json] + +FLAGS + -o, --target-org= (required) Username or alias set in the SF CLI which corresponds to the Provar Quality Hub org. + +GLOBAL FLAGS + --json Format output as json. + +DESCRIPTION + Load the alias or username to be used in subsequent Quality Hub commands. + +EXAMPLES + Connect to the Quality Hub org stored with alias "ProvarQualityHub": + + $ sf provar quality-hub connect -o ProvarQualityHub +``` + +## `sf provar quality-hub display` + +Display information about the connected Provar Quality Hub org. + +``` +USAGE + $ sf provar quality-hub display [--json] + +GLOBAL FLAGS + --json Format output as json. + +EXAMPLES + Display information about the connected Quality Hub org: + + $ sf provar quality-hub display +``` + +## `sf provar quality-hub open` + +Open Provar Quality Hub in a browser. + +``` +USAGE + $ sf provar quality-hub open [--json] + +GLOBAL FLAGS + --json Format output as json. + +EXAMPLES + Open Quality Hub in a browser: + + $ sf provar quality-hub open +``` + +## `sf provar quality-hub testcase retrieve` + +Retrieve test cases related to the provided user stories or metadata components. + +``` +USAGE + $ sf provar quality-hub testcase retrieve -p -t Apex|ProvarAutomation [--json] [-m ] [-f ] [-i ] [-o ] [-n ] [-l ] + +FLAGS + -f, --metadata-file= Path to a text file containing the list of metadata components. + -i, --issues= Comma-separated list of issue IDs or keys. + -l, --test-plan= Test Plan name. Use to retrieve test instance file paths. + -m, --metadata-components= Semicolon-separated list of metadata components. + -n, --ignore-metadata= Semicolon-separated list of metadata types to ignore. + -o, --output= Output to a specific file instead of stdout. + -p, --test-project= (required) Test Project key to filter by. + -t, --test-automation-tool=