Skip to content

Commit

Permalink
test: testkit type fix (only use deploySuccess)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Aug 20, 2024
1 parent c83ad2e commit a14937e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 16 deletions.
20 changes: 16 additions & 4 deletions test/commands/deploy/metadata/report.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
);
});
});

Expand All @@ -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 () => {
Expand Down Expand Up @@ -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)
);
});
});
});
20 changes: 16 additions & 4 deletions test/commands/deploy/metadata/resume.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, CachedOptions> {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions test/commands/deploy/metadata/validate.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
);
});
});

Expand Down
8 changes: 6 additions & 2 deletions test/nuts/seeds/deploy.metadata.manifest.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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%');
Expand Down Expand Up @@ -52,7 +52,11 @@ context('deploy metadata --manifest NUTs [name: %REPO_NAME%]', () => {

const deploy = await testkit.deploy<DeployResultJson>({ 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)
);
});
}

Expand Down
8 changes: 6 additions & 2 deletions test/nuts/seeds/deploy.metadata.metadata.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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%');
Expand Down Expand Up @@ -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<DeployResultJson>({ 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)
);
});
}

Expand Down
8 changes: 6 additions & 2 deletions test/nuts/seeds/deploy.metadata.source-dir.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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%');
Expand Down Expand Up @@ -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<DeployResultJson>({ 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)
);
});
}

Expand Down

0 comments on commit a14937e

Please sign in to comment.