Skip to content

Commit

Permalink
fix: allow deploy report on validated deploys
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Apr 4, 2024
1 parent b0760a9 commit 9d3f0b9
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/commands/project/deploy/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { Messages, Org, SfProject } from '@salesforce/core';
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
import { ComponentSet, DeployResult, MetadataApiDeploy } from '@salesforce/source-deploy-retrieve';
import { ComponentSet, DeployResult, MetadataApiDeploy, RequestStatus } from '@salesforce/source-deploy-retrieve';
import { buildComponentSet } from '../../../utils/deploy.js';
import { DeployProgress } from '../../../utils/progressBar.js';
import { DeployCache } from '../../../utils/deployCache.js';
Expand Down Expand Up @@ -82,7 +82,7 @@ export default class DeployMetadataReport extends SfCommand<DeployResultJson> {
// if we're using mdapi we won't have a component set
let componentSet = new ComponentSet();
if (!deployOpts?.isMdapi) {
if (!cache.maybeGet(jobId)) {
if (!deployOpts) {
// If the cache file isn't there, use the project package directories for the CompSet
try {
this.project = await SfProject.resolve();
Expand All @@ -91,7 +91,8 @@ export default class DeployMetadataReport extends SfCommand<DeployResultJson> {
} catch (err) {
// ignore the error. this was just to get improved command output.
}
} else {
} else if (deployOpts.status !== RequestStatus.Succeeded) {
// if it's succeeded, the deployOpts can't be used to build a CS - nor do we need one
componentSet = await buildComponentSet({ ...deployOpts, wait });
}
}
Expand Down
58 changes: 58 additions & 0 deletions test/nuts/deploy/report.nut.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import * as path from 'node:path';
import { assert, expect } from 'chai';
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
import { DeployResultJson } from '../../../src/utils/types.js';

describe('project deploy report', () => {
let testkit: TestSession;

before(async () => {
testkit = await TestSession.create({
project: { gitClone: 'https://github.com/trailheadapps/dreamhouse-lwc' },
scratchOrgs: [{ setDefault: true, config: path.join('config', 'project-scratch-def.json') }],
devhubAuthStrategy: 'AUTO',
});
execCmd<DeployResultJson>('project deploy start', {
ensureExitCode: 0,
});
});

after(async () => {
await testkit?.clean();
});

it('can validate / deploy quick / report', () => {
const validate = execCmd<DeployResultJson>('project deploy validate --metadata ApexClass --json', {
ensureExitCode: 0,
}).jsonOutput;
assert(validate);
expect(validate.result.checkOnly).to.be.true;
expect(validate.result.done).to.be.true;
expect(validate.result.success).to.be.true;
const validateId = validate.result.id;

const quick = execCmd<DeployResultJson>(`project deploy quick --job-id ${validateId} --json`, {
ensureExitCode: 0,
}).jsonOutput;
assert(quick);
expect(quick.result.checkOnly).to.be.false;
expect(quick.result.done).to.be.true;
expect(quick.result.success).to.be.true;
const quickId = quick.result.id;

const report = execCmd<DeployResultJson>(`project deploy report --job-id ${quickId} --json`, {
ensureExitCode: 0,
}).jsonOutput;
assert(report);
expect(report.result.checkOnly).to.be.false;
expect(report.result.done).to.be.true;
expect(report.result.success).to.be.true;
});
});

0 comments on commit 9d3f0b9

Please sign in to comment.