feat: make production deploy test level configurable - #467
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 027752add6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| protected async getDeploymentStartOptions(): Promise<DeployOptions> { | ||
| const options: DeployOptions = { ignoreWarnings: true }; | ||
| if (await this.salesforce.isProductionOrg()) { | ||
| options.testLevel = this.vlocode.config.salesforce.productionDeployTestLevel ?? 'RunRelevantTests'; |
There was a problem hiding this comment.
Use a supported Metadata API test level
For production orgs that retain the new default, this sends RunRelevantTests directly to connection.metadata.deploy via SalesforceDeployment.start (packages/salesforce/src/salesforceDeployment.ts:176). That is not a Metadata API test-level value: the project's generated TestLevel definition permits only NoTestRun, RunSpecifiedTests, RunLocalTests, and RunAllTestsInOrg (packages/salesforce/src/types/metadata.ts:823). Consequently, every default production metadata deployment is rejected for an invalid testLevel; use a supported default such as RunLocalTests.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
Adds a VS Code configuration knob to control the Apex test execution level used during production Salesforce metadata deployments, while keeping non-production deploy behavior unchanged. It also extends deploy option typing in @vlocode/salesforce and adds focused unit tests around the option selection.
Changes:
- Introduces
vlocity.salesforce.productionDeployTestLeveland wires it intoDeployMetadataCommandonly for production org deployments. - Extends
DeployOptions.testLeveltyping and adds unit tests validating production vs non-production option shaping. - Updates extension configuration schema to expose the new setting.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/vscode-extension/src/lib/vlocodeConfiguration.ts | Adds a typed config property for the production deploy test level. |
| packages/vscode-extension/src/commands/metadata/deployMetadataCommand.ts | Applies the configured production-only deploy start options (including test level). |
| packages/vscode-extension/src/commands/metadata/tests/deployMetadataCommand.test.ts | Adds unit coverage for production/non-production deploy option selection. |
| packages/vscode-extension/package.json | Contributes the new VS Code setting (enum + default + descriptions). |
| packages/salesforce/src/connection/metadata/types/deployResult.ts | Extends deploy option typing to include the new test level value. |
| * _Note: Apex tests that run as part of a deployment always run synchronously and serially._ | ||
| */ | ||
| testLevel?: 'NoTestRun' | 'RunSpecifiedTests' | 'RunLocalTests' | 'RunAllTestsInOrg'; | ||
| testLevel?: 'NoTestRun' | 'RunRelevantTests' | 'RunSpecifiedTests' | 'RunLocalTests' | 'RunAllTestsInOrg'; |
| protected async getDeploymentStartOptions(): Promise<DeployOptions> { | ||
| const options: DeployOptions = { ignoreWarnings: true }; | ||
| if (await this.salesforce.isProductionOrg()) { | ||
| options.testLevel = this.vlocode.config.salesforce.productionDeployTestLevel ?? 'RunRelevantTests'; | ||
| } | ||
| return options; | ||
| } |
| enabled: boolean; | ||
| deployOnSave: boolean; | ||
| apiVersion: string; | ||
| productionDeployTestLevel: 'RunRelevantTests' | 'RunLocalTests' | 'RunAllTestsInOrg'; |
| "vlocity.salesforce.productionDeployTestLevel": { | ||
| "type": "string", | ||
| "enum": [ | ||
| "RunRelevantTests", | ||
| "RunLocalTests", | ||
| "RunAllTestsInOrg" | ||
| ], | ||
| "default": "RunRelevantTests", | ||
| "enumDescriptions": [ | ||
| "Run tests that Salesforce determines are relevant to the deployed metadata.", | ||
| "Run all local Apex tests in the production org.", | ||
| "Run all Apex tests in the production org, including managed package tests." | ||
| ], | ||
| "markdownDescription": "Apex test level used for Salesforce metadata deployments to production orgs. `NoTestRun` is not available in production." | ||
| }, |
| public execute() { | ||
| return undefined; | ||
| } |
| it('defaults production deployments to RunRelevantTests', async () => { | ||
| await expect(new TestDeployMetadataCommand(true).getOptions()).resolves.toEqual({ | ||
| ignoreWarnings: true, | ||
| testLevel: 'RunRelevantTests' | ||
| }); | ||
| }); |
vlocity.salesforce.productionDeployTestLevelwithRunRelevantTestsas the default production metadata deploy level.Validation:
pnpm buildpnpm jest packages/vscode-extension/src/commands/metadata/__tests__/deployMetadataCommand.test.ts -i --coverage=falsepnpm exec eslint packages/vscode-extension/src/commands/metadata/deployMetadataCommand.ts packages/vscode-extension/src/commands/metadata/__tests__/deployMetadataCommand.test.ts packages/vscode-extension/src/lib/vlocodeConfiguration.ts packages/salesforce/src/connection/metadata/types/deployResult.ts --no-error-on-unmatched-patterngit diff --check