diff --git a/test/commands/deploy/metadata/cancel.nut.ts b/test/commands/deploy/metadata/cancel.nut.ts index f7bbfdbd..2c652b46 100644 --- a/test/commands/deploy/metadata/cancel.nut.ts +++ b/test/commands/deploy/metadata/cancel.nut.ts @@ -64,6 +64,31 @@ describe('deploy metadata cancel NUTs', () => { expect(cancel.jsonOutput.name).to.equal('CannotCancelDeployError'); } }); + + it.skip('should cancel most recently started deployment without specifying the flag', () => { + const first = execCmd( + 'deploy:metadata --source-dir force-app --async --ignore-conflicts --json', + { + ensureExitCode: 0, + } + ).jsonOutput?.result; + assert(first); + assert(first.id); + + const cacheBefore = readDeployCache(session.dir); + expect(cacheBefore).to.have.property(first.id); + + const cancel = execCmd('deploy:metadata:cancel --json'); + assert(cancel.jsonOutput); + if (cancel.jsonOutput.status === 0) { + assert(cancel.jsonOutput.result); + assertSuccessfulCancel(session.dir, first, cancel.jsonOutput.result); + } else { + // the deploy likely already finished + expect(cancel.jsonOutput.exitCode).to.equal(1); + expect(cancel.jsonOutput.name).to.equal('CannotCancelDeployError'); + } + }); }); describe('--job-id', () => { diff --git a/test/commands/deploy/metadata/quick.nut.ts b/test/commands/deploy/metadata/quick.nut.ts index d239120e..7bad5ebe 100644 --- a/test/commands/deploy/metadata/quick.nut.ts +++ b/test/commands/deploy/metadata/quick.nut.ts @@ -43,6 +43,23 @@ describe('deploy metadata quick NUTs', () => { assert(deploy); await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']); }); + + it.skip('should deploy previously validated deployment without specifying the flag', async () => { + const validation = await testkit.execute('project:deploy:validate', { + args: '--source-dir force-app', + json: true, + exitCode: 0, + }); + assert(validation); + await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']); + + const deploy = await testkit.execute('project:deploy:quick', { + json: true, + exitCode: 0, + }); + assert(deploy); + await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']); + }); it('should deploy previously validated deployment with metadata format', async () => { execCmd('project:convert:source --source-dir force-app --output-dir metadata'); const validation = await testkit.execute('project:deploy:validate', { diff --git a/test/commands/deploy/metadata/report-mdapi.nut.ts b/test/commands/deploy/metadata/report-mdapi.nut.ts index 5c422b9c..e47af141 100644 --- a/test/commands/deploy/metadata/report-mdapi.nut.ts +++ b/test/commands/deploy/metadata/report-mdapi.nut.ts @@ -44,6 +44,21 @@ describe('deploy metadata report NUTs with source-dir', () => { assert(deploy?.result); expect(deploy.result.success).to.equal(true); }); + + it.skip('should report most recently started deployment without specifying the flag', async () => { + await testkit.execute('project deploy start', { + args: '--metadata-dir mdapiOut --async', + json: true, + exitCode: 0, + }); + + const deploy = await testkit.execute('project deploy report', { + json: true, + exitCode: 0, + }); + assert(deploy?.result); + expect(deploy.result.success).to.equal(true); + }); }); describe('--job-id', () => { diff --git a/test/commands/deploy/metadata/report.nut.ts b/test/commands/deploy/metadata/report.nut.ts index 997b2514..49bb382f 100644 --- a/test/commands/deploy/metadata/report.nut.ts +++ b/test/commands/deploy/metadata/report.nut.ts @@ -5,8 +5,11 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ +import * as fs from 'fs'; +import * as path from 'path'; import { SourceTestkit } from '@salesforce/source-testkit'; import { assert, isObject } from '@salesforce/ts-types'; +import { expect } from 'chai'; import { DeployResultJson } from '../../../../src/utils/types'; describe('deploy metadata report NUTs with source-dir', () => { @@ -39,6 +42,21 @@ describe('deploy metadata report NUTs with source-dir', () => { assert(isObject(deploy)); await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files); }); + + it.skip('should report most recently started deployment without specifying the flag', async () => { + await testkit.execute('deploy:metadata', { + args: '--source-dir force-app --async', + json: true, + exitCode: 0, + }); + + const deploy = await testkit.execute('deploy:metadata:report', { + json: true, + exitCode: 0, + }); + assert(isObject(deploy)); + await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files); + }); }); describe('--job-id', () => { @@ -57,4 +75,28 @@ describe('deploy metadata report NUTs with source-dir', () => { await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files); }); }); + + describe('test flags', () => { + it('should override the --output-dir', async () => { + const first = await testkit.execute('deploy:metadata', { + args: '--source-dir force-app --async --ignore-conflicts --test-level RunAllTestsInOrg --coverage-formatters html --junit --results-dir test-output', + json: true, + exitCode: 0, + }); + const deploy = await testkit.execute('deploy:metadata:report', { + args: `--job-id ${first?.result.id} --coverage-formatters html --coverage-formatters text --junit --results-dir test-output-override`, + json: true, + exitCode: 0, + }); + expect(fs.existsSync(path.join(testkit.projectDir, 'test-output-override'))).to.be.true; + expect(fs.existsSync(path.join(testkit.projectDir, 'test-output-override', 'coverage'))).to.be.true; + expect(fs.existsSync(path.join(testkit.projectDir, 'test-output-override', 'coverage', 'html'))).to.be.true; + expect(fs.existsSync(path.join(testkit.projectDir, 'test-output-override', 'coverage', 'text.txt'))).to.be.true; + expect(fs.existsSync(path.join(testkit.projectDir, 'test-output-override', 'junit'))).to.be.true; + expect(fs.existsSync(path.join(testkit.projectDir, 'test-output-override', 'junit', 'junit.xml'))).to.be.true; + expect(fs.existsSync(path.join(testkit.projectDir, 'test-output'))).to.be.false; + assert(isObject(deploy)); + await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files); + }); + }); }); diff --git a/test/commands/deploy/metadata/resume.nut.ts b/test/commands/deploy/metadata/resume.nut.ts index 48c09245..738c02f0 100644 --- a/test/commands/deploy/metadata/resume.nut.ts +++ b/test/commands/deploy/metadata/resume.nut.ts @@ -57,6 +57,31 @@ describe('deploy metadata resume NUTs', () => { const cacheAfter = readDeployCache(testkit.projectDir); + expect(cacheAfter).to.have.property(first.result.id); + expect(cacheAfter[first.result.id]).have.property('status'); + expect(cacheAfter[first.result.id].status).to.equal(RequestStatus.Succeeded); + }); + it.skip('should resume most recently started deployment without specifying the flag', async () => { + const first = await testkit.execute('deploy:metadata', { + args: '--source-dir force-app --async', + json: true, + exitCode: 0, + }); + assert(first); + assert(first.result.id); + + const cacheBefore = readDeployCache(testkit.projectDir); + expect(cacheBefore).to.have.property(first.result.id); + + const deploy = await testkit.execute('deploy:metadata:resume', { + json: true, + exitCode: 0, + }); + assert(deploy); + await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files); + + const cacheAfter = readDeployCache(testkit.projectDir); + expect(cacheAfter).to.have.property(first.result.id); expect(cacheAfter[first.result.id]).have.property('status'); expect(cacheAfter[first.result.id].status).to.equal(RequestStatus.Succeeded); diff --git a/test/commands/deploy/metadata/validate.nut.ts b/test/commands/deploy/metadata/validate.nut.ts index bb36bedb..39265330 100644 --- a/test/commands/deploy/metadata/validate.nut.ts +++ b/test/commands/deploy/metadata/validate.nut.ts @@ -5,9 +5,11 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ +import * as path from 'path'; import { SourceTestkit } from '@salesforce/source-testkit'; import { isObject } from '@salesforce/ts-types'; -import { assert } from 'chai'; +import { assert, expect } from 'chai'; +import { execCmd } from '@salesforce/cli-plugins-testkit'; import { DeployResultJson } from '../../../../src/utils/types'; describe('deploy metadata validate NUTs', () => { @@ -35,4 +37,33 @@ describe('deploy metadata validate NUTs', () => { await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files); }); }); + + describe('destructive flags', () => { + it('should validate deploy with destructive changes', async () => { + // create package.xml + execCmd('project generate manifest -p force-app'); + + // create preDestructiveChanges.xml + execCmd(`project generate manifest -p ${path.join('my-app', 'apex')} --type pre`); + + const deploy = await testkit.execute('project:deploy:validate', { + args: '--manifest package.xml --pre-destructive-changes destructiveChangesPre.xml', + json: true, + exitCode: 0, + }); + expect(deploy?.result.success).to.be.true; + expect(deploy?.result.numberComponentsDeployed).to.equal(12); + expect(deploy?.result.checkOnly).to.be.true; + + // ensure the post-destructive-changes flag works as well + const deployPost = await testkit.execute('project:deploy:validate', { + args: '--manifest package.xml --post-destructive-changes destructiveChangesPre.xml', + json: true, + exitCode: 0, + }); + expect(deployPost?.result.success).to.be.true; + expect(deployPost?.result.numberComponentsDeployed).to.equal(12); + expect(deployPost?.result.checkOnly).to.be.true; + }); + }); });