From a14937ea0389d17825da867096cde5a5b51c35aa Mon Sep 17 00:00:00 2001 From: mshanemc Date: Tue, 20 Aug 2024 14:28:54 -0500 Subject: [PATCH] test: testkit type fix (only use deploySuccess) --- test/commands/deploy/metadata/report.nut.ts | 20 +++++++++++++++---- test/commands/deploy/metadata/resume.nut.ts | 20 +++++++++++++++---- test/commands/deploy/metadata/validate.nut.ts | 8 ++++++-- .../seeds/deploy.metadata.manifest.seed.ts | 8 ++++++-- .../seeds/deploy.metadata.metadata.seed.ts | 8 ++++++-- .../seeds/deploy.metadata.source-dir.seed.ts | 8 ++++++-- 6 files changed, 56 insertions(+), 16 deletions(-) diff --git a/test/commands/deploy/metadata/report.nut.ts b/test/commands/deploy/metadata/report.nut.ts index a4ce3620..4d0f10aa 100644 --- a/test/commands/deploy/metadata/report.nut.ts +++ b/test/commands/deploy/metadata/report.nut.ts @@ -11,7 +11,7 @@ import { fileURLToPath } from 'node:url'; import { SourceTestkit } from '@salesforce/source-testkit'; import { assert, isObject } from '@salesforce/ts-types'; import { expect } from 'chai'; -import { DeployResultJson } from '../../../../src/utils/types.js'; +import { DeployResultJson, isSdrSuccess } from '../../../../src/utils/types.js'; describe('[project deploy report] NUTs with source-dir', () => { let testkit: SourceTestkit; @@ -44,7 +44,11 @@ describe('[project deploy report] NUTs with source-dir', () => { exitCode: 0, }); assert(isObject(deploy)); - await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files); + await testkit.expect.filesToBeDeployedViaResult( + ['force-app/**/*'], + ['force-app/test/**/*'], + deploy.result.files.filter(isSdrSuccess) + ); }); }); @@ -61,7 +65,11 @@ describe('[project deploy report] NUTs with source-dir', () => { exitCode: 0, }); assert(isObject(deploy)); - await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files); + await testkit.expect.filesToBeDeployedViaResult( + ['force-app/**/*'], + ['force-app/test/**/*'], + deploy.result.files.filter(isSdrSuccess) + ); }); it('should report from specified target-org and job-id without deploy cache', async () => { @@ -106,7 +114,11 @@ describe('[project deploy report] NUTs with source-dir', () => { expect(existsSync(join(testkit.projectDir, 'test-output-override', 'junit', 'junit.xml'))).to.be.true; expect(existsSync(join(testkit.projectDir, 'test-output'))).to.be.false; assert(isObject(deploy)); - await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files); + await testkit.expect.filesToBeDeployedViaResult( + ['force-app/**/*'], + ['force-app/test/**/*'], + deploy.result.files.filter(isSdrSuccess) + ); }); }); }); diff --git a/test/commands/deploy/metadata/resume.nut.ts b/test/commands/deploy/metadata/resume.nut.ts index 8afa3c6f..524c636a 100644 --- a/test/commands/deploy/metadata/resume.nut.ts +++ b/test/commands/deploy/metadata/resume.nut.ts @@ -12,7 +12,7 @@ import { strict as assert } from 'node:assert'; import { SourceTestkit } from '@salesforce/source-testkit'; import { expect } from 'chai'; import { RequestStatus } from '@salesforce/source-deploy-retrieve'; -import { DeployResultJson } from '../../../../src/utils/types.js'; +import { DeployResultJson, isSdrSuccess } from '../../../../src/utils/types.js'; import { CachedOptions } from '../../../../src/utils/deploy.js'; function readDeployCache(projectDir: string): Record { @@ -54,7 +54,11 @@ describe('[project deploy resume] NUTs', () => { exitCode: 0, }); assert(deploy); - await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files); + await testkit.expect.filesToBeDeployedViaResult( + ['force-app/**/*'], + ['force-app/test/**/*'], + deploy.result.files.filter(isSdrSuccess) + ); const cacheAfter = readDeployCache(testkit.projectDir); @@ -87,7 +91,11 @@ describe('[project deploy resume] NUTs', () => { }); assert(deploy); - await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files); + await testkit.expect.filesToBeDeployedViaResult( + ['force-app/**/*'], + ['force-app/test/**/*'], + deploy.result.files.filter(isSdrSuccess) + ); const cacheAfter = readDeployCache(testkit.projectDir); expect(cacheAfter).to.have.property(deployId); expect(cacheAfter[deployId]).have.property('status'); @@ -122,7 +130,11 @@ describe('[project deploy resume] NUTs', () => { }); assert(deploy); - await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files); + await testkit.expect.filesToBeDeployedViaResult( + ['force-app/**/*'], + ['force-app/test/**/*'], + deploy.result.files.filter(isSdrSuccess) + ); const cacheAfter = readDeployCache(testkit.projectDir); expect(cacheAfter).to.have.property(first.result.id); diff --git a/test/commands/deploy/metadata/validate.nut.ts b/test/commands/deploy/metadata/validate.nut.ts index 5fa12870..93e9892f 100644 --- a/test/commands/deploy/metadata/validate.nut.ts +++ b/test/commands/deploy/metadata/validate.nut.ts @@ -11,7 +11,7 @@ import { SourceTestkit } from '@salesforce/source-testkit'; import { isObject } from '@salesforce/ts-types'; import { assert, expect } from 'chai'; import { execCmd } from '@salesforce/cli-plugins-testkit'; -import { DeployResultJson } from '../../../../src/utils/types.js'; +import { DeployResultJson, isSdrSuccess } from '../../../../src/utils/types.js'; describe('deploy metadata validate NUTs', () => { let testkit: SourceTestkit; @@ -35,7 +35,11 @@ describe('deploy metadata validate NUTs', () => { exitCode: 0, }); assert(isObject(deploy)); - await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files); + await testkit.expect.filesToBeDeployedViaResult( + ['force-app/**/*'], + ['force-app/test/**/*'], + deploy.result.files.filter(isSdrSuccess) + ); }); }); diff --git a/test/nuts/seeds/deploy.metadata.manifest.seed.ts b/test/nuts/seeds/deploy.metadata.manifest.seed.ts index 9305f609..7cb676a0 100644 --- a/test/nuts/seeds/deploy.metadata.manifest.seed.ts +++ b/test/nuts/seeds/deploy.metadata.manifest.seed.ts @@ -10,7 +10,7 @@ import { fileURLToPath } from 'node:url'; import { SourceTestkit } from '@salesforce/source-testkit'; import { assert } from 'chai'; import { TEST_REPOS_MAP } from '../testMatrix.js'; -import { DeployResultJson } from '../../../src/utils/types.js'; +import { DeployResultJson, isSdrSuccess } from '../../../src/utils/types.js'; // DO NOT TOUCH. generateNuts.ts will insert these values const REPO = TEST_REPOS_MAP.get('%REPO_URL%'); @@ -52,7 +52,11 @@ context('deploy metadata --manifest NUTs [name: %REPO_NAME%]', () => { const deploy = await testkit.deploy({ args: `--manifest ${packageXml}` }); assert(deploy); - await testkit.expect.filesToBeDeployedViaResult(testCase.toVerify, testCase.toIgnore, deploy.result.files); + await testkit.expect.filesToBeDeployedViaResult( + testCase.toVerify, + testCase.toIgnore, + deploy.result.files.filter(isSdrSuccess) + ); }); } diff --git a/test/nuts/seeds/deploy.metadata.metadata.seed.ts b/test/nuts/seeds/deploy.metadata.metadata.seed.ts index f28f85c8..b9793697 100644 --- a/test/nuts/seeds/deploy.metadata.metadata.seed.ts +++ b/test/nuts/seeds/deploy.metadata.metadata.seed.ts @@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url'; import { SourceTestkit } from '@salesforce/source-testkit'; import { assert } from 'chai'; import { TEST_REPOS_MAP } from '../testMatrix.js'; -import { DeployResultJson } from '../../../src/utils/types.js'; +import { DeployResultJson, isSdrSuccess } from '../../../src/utils/types.js'; // DO NOT TOUCH. generateNuts.ts will insert these values const REPO = TEST_REPOS_MAP.get('%REPO_URL%'); @@ -46,7 +46,11 @@ context('deploy metadata --metadata NUTs [name: %REPO_NAME%]', () => { const args = testCase.toDeploy.map((t) => `--metadata ${t}`).join(' '); const deploy = await testkit.deploy({ args }); assert(deploy); - await testkit.expect.filesToBeDeployedViaResult(testCase.toVerify, testCase.toIgnore, deploy.result.files); + await testkit.expect.filesToBeDeployedViaResult( + testCase.toVerify, + testCase.toIgnore, + deploy.result.files.filter(isSdrSuccess) + ); }); } diff --git a/test/nuts/seeds/deploy.metadata.source-dir.seed.ts b/test/nuts/seeds/deploy.metadata.source-dir.seed.ts index 179bb337..867515ee 100644 --- a/test/nuts/seeds/deploy.metadata.source-dir.seed.ts +++ b/test/nuts/seeds/deploy.metadata.source-dir.seed.ts @@ -10,7 +10,7 @@ import { fileURLToPath } from 'node:url'; import { assert } from 'chai'; import { SourceTestkit } from '@salesforce/source-testkit'; import { TEST_REPOS_MAP } from '../testMatrix.js'; -import { DeployResultJson } from '../../../src/utils/types.js'; +import { DeployResultJson, isSdrSuccess } from '../../../src/utils/types.js'; // DO NOT TOUCH. generateNuts.ts will insert these values const REPO = TEST_REPOS_MAP.get('%REPO_URL%'); @@ -41,7 +41,11 @@ context('deploy metadata --source-dir NUTs [name: %REPO_NAME%]', () => { const args = testCase.toDeploy.map((t) => `--source-dir ${path.normalize(t)}`).join(' '); const deploy = await testkit.deploy({ args }); assert(deploy); - await testkit.expect.filesToBeDeployedViaResult(testCase.toVerify, testCase.toIgnore, deploy.result.files); + await testkit.expect.filesToBeDeployedViaResult( + testCase.toVerify, + testCase.toIgnore, + deploy.result.files.filter(isSdrSuccess) + ); }); }