Skip to content

Commit 2cfe5f4

Browse files
feat: add checkDeployStatus for REST (#1529)
* fix: add checkDeployStatus for REST * chore: bump jsforce * test: fix UTs --------- Co-authored-by: Cristian Dominguez <[email protected]>
1 parent 5ad5347 commit 2cfe5f4

File tree

5 files changed

+45
-13
lines changed

5 files changed

+45
-13
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"node": ">=18.0.0"
2626
},
2727
"dependencies": {
28-
"@salesforce/core": "^8.8.5",
28+
"@salesforce/core": "^8.8.7",
2929
"@salesforce/kit": "^3.2.3",
3030
"@salesforce/ts-types": "^2.0.12",
3131
"@salesforce/types": "^1.3.0",
@@ -42,7 +42,7 @@
4242
"yaml": "^2.7.0"
4343
},
4444
"devDependencies": {
45-
"@jsforce/jsforce-node": "^3.6.6",
45+
"@jsforce/jsforce-node": "^3.7.0",
4646
"@salesforce/cli-plugins-testkit": "^5.3.39",
4747
"@salesforce/dev-scripts": "^10.2.12",
4848
"@types/deep-equal-in-any-order": "^1.0.1",

src/client/metadataApiDeploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export class MetadataApiDeploy extends MetadataTransfer<
152152
}
153153
const connection = await this.getConnection();
154154
// Recasting to use the project's version of the type
155-
return connection.metadata.checkDeployStatus(this.id, true) as unknown as MetadataApiDeployStatus;
155+
return connection.metadata.checkDeployStatus(this.id, true, this.isRestDeploy) as unknown as MetadataApiDeployStatus;
156156
}
157157

158158
/**

test/client/metadataApiDeploy.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { AnyJson, ensureString, getString } from '@salesforce/ts-types';
1111
import { envVars, Lifecycle, Messages, PollingClient, StatusResult } from '@salesforce/core';
1212
import { Duration } from '@salesforce/kit';
1313
import deepEqualInAnyOrder from 'deep-equal-in-any-order';
14+
import * as sinon from 'sinon';
1415
import {
1516
ComponentSet,
1617
ComponentStatus,
@@ -317,6 +318,33 @@ describe('MetadataApiDeploy', () => {
317318
expect(e.message).to.equal(expectedError.message);
318319
}
319320
});
321+
322+
it('should pass isRestDeploy=true to checkDeployStatus', async () => {
323+
const options = {
324+
id: MOCK_ASYNC_RESULT.id,
325+
apiOptions: { rest: true },
326+
components: new ComponentSet(),
327+
};
328+
const { operation, checkStatusStub } = await stubMetadataDeploy($$, testOrg, options);
329+
await operation.checkStatus();
330+
expect(checkStatusStub.calledOnce).to.be.true;
331+
expect(checkStatusStub.firstCall.firstArg).to.equal(MOCK_ASYNC_RESULT.id);
332+
expect(checkStatusStub.firstCall.args[1]).to.equal(true);
333+
expect(checkStatusStub.firstCall.args[2]).to.equal(true);
334+
});
335+
336+
it('should pass isRestDeploy=false to checkDeployStatus', async () => {
337+
const options = {
338+
id: MOCK_ASYNC_RESULT.id,
339+
components: new ComponentSet(),
340+
};
341+
const { operation, checkStatusStub } = await stubMetadataDeploy($$, testOrg, options);
342+
await operation.checkStatus();
343+
expect(checkStatusStub.calledOnce).to.be.true;
344+
expect(checkStatusStub.firstCall.firstArg).to.equal(MOCK_ASYNC_RESULT.id);
345+
expect(checkStatusStub.firstCall.args[1]).to.equal(true);
346+
expect(checkStatusStub.firstCall.args[2]).to.equal(false);
347+
});
320348
});
321349

322350
describe('deployRecentValidation', () => {

test/mock/client/transferOperations.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { PollingClient } from '@salesforce/core';
1313
import { match, SinonSpy, SinonStub } from 'sinon';
1414
import type { AsyncResult } from '@jsforce/jsforce-node/lib/api/metadata';
1515
import { ensureString } from '@salesforce/ts-types';
16+
import * as sinon from 'sinon';
1617
import {
1718
ComponentSet,
1819
ConvertOutputConfig,
@@ -118,7 +119,7 @@ export async function stubMetadataDeploy(
118119
status.done = true;
119120
const checkStatusStub = sandbox.stub(connection.metadata, 'checkDeployStatus');
120121
// @ts-ignore
121-
checkStatusStub.withArgs(MOCK_ASYNC_RESULT.id, true).resolves(status);
122+
checkStatusStub.withArgs(MOCK_ASYNC_RESULT.id, true, sinon.match.any).resolves(status);
122123

123124
// @ts-ignore
124125
const invokeStub = sandbox.stub(connection.metadata, '_invoke');
@@ -141,6 +142,9 @@ export async function stubMetadataDeploy(
141142
usernameOrConnection: connection,
142143
components: options.components,
143144
id: options.id,
145+
apiOptions: {
146+
rest: options.apiOptions?.rest,
147+
},
144148
}),
145149
response: status as MetadataApiDeployStatus,
146150
};

yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,10 @@
588588
"@jridgewell/resolve-uri" "^3.1.0"
589589
"@jridgewell/sourcemap-codec" "^1.4.14"
590590

591-
"@jsforce/jsforce-node@^3.6.5", "@jsforce/jsforce-node@^3.6.6":
592-
version "3.6.6"
593-
resolved "https://registry.yarnpkg.com/@jsforce/jsforce-node/-/jsforce-node-3.6.6.tgz#26fe2fc9f4f3671ca8bfb0c98a728cb8a0219265"
594-
integrity sha512-WdIo2lLbrz6nkfiaz2UynyaNiM8o+fEjaRev7zA4KKSaQYB1MJ66xHubeI5Iheq8WgkY9XGwWKAwPDhuV+GROQ==
591+
"@jsforce/jsforce-node@^3.7.0":
592+
version "3.7.0"
593+
resolved "https://registry.yarnpkg.com/@jsforce/jsforce-node/-/jsforce-node-3.7.0.tgz#aaa317eef3207489db90498f79e96c5bd9f53469"
594+
integrity sha512-v9pc3lPM5RMuB81Gasz5/NKcjktE1LLEACRFopB9LiXRafb4K9bStSMl3nLEHq7+OFdtxfQB3Sx2rYXJGG4DKw==
595595
dependencies:
596596
"@sindresorhus/is" "^4"
597597
base64url "^3.0.1"
@@ -646,12 +646,12 @@
646646
strip-ansi "6.0.1"
647647
ts-retry-promise "^0.8.1"
648648

649-
"@salesforce/core@^8.8.0", "@salesforce/core@^8.8.3", "@salesforce/core@^8.8.5":
650-
version "8.8.5"
651-
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-8.8.5.tgz#4004e22523e4e45b42631733d06dc8aec9fdc23d"
652-
integrity sha512-eCiiO4NptvKkz04A4ivBVLzEBy/6IIFmaXoZ4tnF1FcD5MESvC+Xuc+0RFSRiYmPi5oloKNl6njrfVCKAho2zQ==
649+
"@salesforce/core@^8.8.0", "@salesforce/core@^8.8.3", "@salesforce/core@^8.8.7":
650+
version "8.8.7"
651+
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-8.8.7.tgz#ac307e8f10934affa7bcf33ccb65993669cd8f12"
652+
integrity sha512-AuPSmb/GZ7F8eV5GO6NcfFq3YSOVnPL4sssEQEvKduOSJMs8RTJ92kEefrId/tgFBYfw4b7UzndjFtdgrGGeoA==
653653
dependencies:
654-
"@jsforce/jsforce-node" "^3.6.5"
654+
"@jsforce/jsforce-node" "^3.7.0"
655655
"@salesforce/kit" "^3.2.2"
656656
"@salesforce/schemas" "^1.9.0"
657657
"@salesforce/ts-types" "^2.0.10"

0 commit comments

Comments
 (0)