From 66f055b20cd2a40296a8b903509bad5afb626db7 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Fri, 22 Mar 2024 11:23:50 -0600 Subject: [PATCH] test: add delete specific NUTs --- package.json | 2 +- .../destructive/destructiveChanges.nut.ts | 62 +++++++++- yarn.lock | 112 ++++++------------ 3 files changed, 96 insertions(+), 80 deletions(-) diff --git a/package.json b/package.json index 4e672d66..ca2f671b 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "@salesforce/kit": "^3.0.15", "@salesforce/plugin-info": "^3.0.28", "@salesforce/sf-plugins-core": "^7.1.15", - "@salesforce/source-deploy-retrieve": "^10.5.3", + "@salesforce/source-deploy-retrieve": "^10.5.5", "@salesforce/source-tracking": "^5.1.18", "@salesforce/ts-types": "^2.0.9", "chalk": "^5.3.0" diff --git a/test/nuts/destructive/destructiveChanges.nut.ts b/test/nuts/destructive/destructiveChanges.nut.ts index 4f528df2..1560b994 100644 --- a/test/nuts/destructive/destructiveChanges.nut.ts +++ b/test/nuts/destructive/destructiveChanges.nut.ts @@ -6,11 +6,14 @@ */ import * as path from 'node:path'; +import { writeFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; -import { expect } from 'chai'; +import { assert, expect } from 'chai'; import { execCmd } from '@salesforce/cli-plugins-testkit'; import { SourceTestkit } from '@salesforce/source-testkit'; import { AuthInfo, Connection } from '@salesforce/core'; +import { DeployMessage } from '@salesforce/source-deploy-retrieve'; +import { DeployResultJson } from '../../../src/utils/types.js'; const isNameObsolete = async (username: string, memberType: string, memberName: string): Promise => { const connection = await Connection.create({ @@ -99,6 +102,63 @@ describe('project deploy start --destructive NUTs', () => { expect(deleted).to.be.true; }); + it('should delete and deploy the same component', async () => { + const { apexName } = createApexClass(); + let deleted = await isNameObsolete(testkit.username, 'ApexClass', apexName); + + expect(deleted).to.be.false; + createManifest(`ApexClass:${apexName}`, 'pre'); + + const result = execCmd( + 'project:deploy:start --json --manifest destructiveChangesPre.xml --pre-destructive-changes destructiveChangesPre.xml', + { + ensureExitCode: 0, + } + ); + + deleted = await isNameObsolete(testkit.username, 'ApexClass', apexName); + expect(deleted).to.be.false; + + const successes = result?.jsonOutput?.result.details?.componentSuccesses as DeployMessage[]; + assert(successes); + // 1 package, 2 of the same apex classes + expect(successes.length).to.equal(3); + expect(successes.filter((c) => c.fullName === 'a').some((c) => c.deleted === true)).to.be.true; + expect(successes.filter((c) => c.fullName === 'a').some((c) => c.deleted === false)).to.be.true; + }); + + it('should delete and get file information with an empty deploy package', async () => { + const { apexName } = createApexClass(); + let deleted = await isNameObsolete(testkit.username, 'ApexClass', apexName); + + expect(deleted).to.be.false; + createManifest(`ApexClass:${apexName}`, 'pre'); + + writeFileSync( + path.join(testkit.projectDir, 'package.xml'), + '\n' + + '\n' + + ' 59.0\n' + + '' + ); + + const result = execCmd( + 'project:deploy:start --json --manifest package.xml --pre-destructive-changes destructiveChangesPre.xml', + { + ensureExitCode: 0, + } + ); + + deleted = await isNameObsolete(testkit.username, 'ApexClass', apexName); + expect(deleted).to.be.true; + + const files = result?.jsonOutput?.result.files; + assert(files); + // 1 .cls, 1 .cls-meta.xml + expect(files.length).to.equal(2); + expect(files.filter((c) => c.fullName === 'a').every((c) => c.filePath !== undefined)).to.be.true; + }); + it('should delete an ApexClass and then deploy a class with --purge-on-delete', async () => { const { apexName } = createApexClass(); let deleted = await isNameObsolete(testkit.username, 'ApexClass', apexName); diff --git a/yarn.lock b/yarn.lock index 47a0d334..9c36489c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1865,41 +1865,7 @@ wordwrap "^1.0.0" wrap-ansi "^7.0.0" -"@oclif/core@^3.11.0", "@oclif/core@^3.15.1", "@oclif/core@^3.18.1", "@oclif/core@^3.18.2", "@oclif/core@^3.19.1", "@oclif/core@^3.19.2", "@oclif/core@^3.20.0", "@oclif/core@^3.23.0": - version "3.23.0" - resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.23.0.tgz#d0ccc5f99c376e4bcfce04e8e94efae8417a53f8" - integrity sha512-giQ/8Ft8yXWg4IyPVtynPb7ihoQsa3A/1Q53UIJIhh+8k+EedE3lJ01yn6sq6Ha35IGqsG1WhkeHzlJIuldEaw== - dependencies: - "@types/cli-progress" "^3.11.5" - ansi-escapes "^4.3.2" - ansi-styles "^4.3.0" - cardinal "^2.1.1" - chalk "^4.1.2" - clean-stack "^3.0.1" - cli-progress "^3.12.0" - color "^4.2.3" - debug "^4.3.4" - ejs "^3.1.9" - get-package-type "^0.1.0" - globby "^11.1.0" - hyperlinker "^1.0.0" - indent-string "^4.0.0" - is-wsl "^2.2.0" - js-yaml "^3.14.1" - minimatch "^9.0.3" - natural-orderby "^2.0.3" - object-treeify "^1.1.33" - password-prompt "^1.1.3" - slice-ansi "^4.0.0" - string-width "^4.2.3" - strip-ansi "^6.0.1" - supports-color "^8.1.1" - supports-hyperlinks "^2.2.0" - widest-line "^3.1.0" - wordwrap "^1.0.0" - wrap-ansi "^7.0.0" - -"@oclif/core@^3.25.2": +"@oclif/core@^3.11.0", "@oclif/core@^3.15.1", "@oclif/core@^3.18.1", "@oclif/core@^3.18.2", "@oclif/core@^3.19.1", "@oclif/core@^3.19.2", "@oclif/core@^3.20.0", "@oclif/core@^3.23.0", "@oclif/core@^3.25.2": version "3.25.3" resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.25.3.tgz#dac0e604c33267f879d3233cd4d0730146db4793" integrity sha512-2TLZmqnDZos9h73KbrdKqvUQEXIPpUfEzgIfqdQRZwszfk1RtiHAb/7ihtnJICnRRVXlD4XLDmUlY4cFJ0ka4g== @@ -2280,29 +2246,10 @@ "@salesforce/ts-types" "^2.0.9" chalk "^5.3.0" -"@salesforce/source-deploy-retrieve@^10.0.0", "@salesforce/source-deploy-retrieve@^10.5.1": - version "10.5.1" - resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-10.5.1.tgz#4afa68b715d269764f995a79b224b4f848f670ff" - integrity sha512-4xeVhKzi0wpzlwKj06hAL3EjJaRuMyx7xZsTr8T0/GFaEfsML14aUV3imMd0V3DcZRJ2oo+a9UrUYy5KnP76Kw== - dependencies: - "@salesforce/core" "^6.7.0" - "@salesforce/kit" "^3.0.15" - "@salesforce/ts-types" "^2.0.9" - fast-levenshtein "^3.0.0" - fast-xml-parser "^4.3.5" - got "^11.8.6" - graceful-fs "^4.2.11" - ignore "^5.3.1" - jszip "^3.10.1" - mime "2.6.0" - minimatch "^5.1.6" - proxy-agent "^6.4.0" - ts-retry-promise "^0.7.1" - -"@salesforce/source-deploy-retrieve@^10.5.3": - version "10.5.3" - resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-10.5.3.tgz#c994a5522ce187bfc59bbdb76edfb550453a8025" - integrity sha512-gw28Co2twQ6GSIF94DdWxx6htBLWKIsMhaKlydfymoAp3kZrFmALRPh8Dj8RDQWV8wrSmzWqDFX9iGoldHZDbg== +"@salesforce/source-deploy-retrieve@^10.0.0", "@salesforce/source-deploy-retrieve@^10.5.1", "@salesforce/source-deploy-retrieve@^10.5.3", "@salesforce/source-deploy-retrieve@^10.5.5": + version "10.5.5" + resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-10.5.5.tgz#c2680de777e4b392a5f02631ca1cd385cad72c93" + integrity sha512-o+c/qD9QojXIPMOuteUSdrbx/GI9HS0jFv49NcVrZX1Rzm/ZUk5JHkLzJtiUVQOEnBg4VVnFh2rBarPh0x6dWg== dependencies: "@salesforce/core" "^6.7.0" "@salesforce/kit" "^3.0.15" @@ -2334,22 +2281,7 @@ shelljs "^0.8.4" sinon "^10.0.0" -"@salesforce/source-tracking@^5.0.0": - version "5.1.14" - resolved "https://registry.yarnpkg.com/@salesforce/source-tracking/-/source-tracking-5.1.14.tgz#ae2c02d687099e68508e327545f3b123a71dced2" - integrity sha512-wrxFM5Wz4GekH4R+eAd+h780K4qNIU7/77Frua5HDHvORcj07zGR8prJ2zG2/bbYwaclojexH9zHi0RHe2LMoA== - dependencies: - "@oclif/core" "^3.23.0" - "@salesforce/core" "^6.7.0" - "@salesforce/kit" "^3.0.15" - "@salesforce/source-deploy-retrieve" "^10.5.1" - "@salesforce/ts-types" "^2.0.9" - fast-xml-parser "^4.2.5" - graceful-fs "^4.2.11" - isomorphic-git "1.23.0" - ts-retry-promise "^0.8.0" - -"@salesforce/source-tracking@^5.1.18": +"@salesforce/source-tracking@^5.0.0", "@salesforce/source-tracking@^5.1.18": version "5.1.18" resolved "https://registry.yarnpkg.com/@salesforce/source-tracking/-/source-tracking-5.1.18.tgz#aea622c04ac199b2288b3a94c6b8e8f207c438f7" integrity sha512-V8itdxwfP72Kq26psNdxi3JI3tQRdxzViKUQM5w33B6vahWJS3P3nBOzIFJGu+J9/SMDUHRpPYTwUL84yXdoyA== @@ -9458,7 +9390,16 @@ ssri@^9.0.0: dependencies: minipass "^3.1.1" -"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -9517,7 +9458,14 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@6.0.1, strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@6.0.1, strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -10247,8 +10195,7 @@ workerpool@6.2.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: - name wrap-ansi-cjs +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -10266,6 +10213,15 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"