Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add --package-name NUTs, remove sfdx cli referecnes #658

Merged
merged 4 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
"@salesforce/dev-config": "^4.0.1",
"@salesforce/dev-scripts": "^5.4.2",
"@salesforce/plugin-command-reference": "^3.0.2",
"@salesforce/plugin-functions": "^1.21.10",
"@salesforce/plugin-settings": "^1.4.10",
"@salesforce/plugin-source": "^2.10.10",
"@salesforce/plugin-templates": "^55.4.18",
"@salesforce/plugin-user": "^2.3.14",
"@salesforce/prettier-config": "^0.0.3",
"@salesforce/source-testkit": "^2.0.59",
"@salesforce/source-testkit": "^2.1.2",
"@salesforce/ts-sinon": "1.4.7",
"@salesforce/ts-types": "^2.0.2",
"@swc/core": "1.3.39",
Expand Down Expand Up @@ -94,7 +93,6 @@
"@oclif/plugin-help",
"@salesforce/plugin-command-reference",
"@salesforce/plugin-settings",
"@salesforce/plugin-functions",
"@salesforce/plugin-source",
"@salesforce/plugin-user",
"@salesforce/plugin-templates"
Expand Down Expand Up @@ -270,4 +268,4 @@
"output": []
}
}
}
}
2 changes: 1 addition & 1 deletion test/nuts/delete/source.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('project delete source NUTs', () => {
const query = () =>
JSON.parse(
exec(
`sfdx force:data:soql:query -q "SELECT IsNameObsolete FROM SourceMember WHERE MemberType='ApexClass' AND MemberName='${apexName}' LIMIT 1" -t --json`,
`sf data:query -q "SELECT IsNameObsolete FROM SourceMember WHERE MemberType='ApexClass' AND MemberName='${apexName}' LIMIT 1" -t --json`,
{ silent: true }
)
) as { result: { records: Array<{ IsNameObsolete: boolean }> } };
Expand Down
31 changes: 28 additions & 3 deletions test/nuts/retrieve/metadata.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
*/

import * as path from 'path';
import * as fs from 'fs';
import { SourceTestkit } from '@salesforce/source-testkit';
import { exec } from 'shelljs';
import { expect } from 'chai';

const ELECTRON = { id: '04t6A000002zgKSQAY', name: 'ElectronBranding' };

Expand Down Expand Up @@ -76,15 +78,38 @@ describe('retrieve metadata NUTs', () => {

describe('--package-name flag', () => {
it('should retrieve an installed package', async () => {
exec(`sfdx force:package:install --noprompt --package ${ELECTRON.id} --wait 5 --json`, { silent: true });
exec(`sf force:package:install --noprompt --package ${ELECTRON.id} --wait 5 --json`, { silent: true });

await testkit.retrieve({ args: `--package-name "${ELECTRON.name}"` });
await testkit.expect.packagesToBeRetrieved([ELECTRON.name]);
});

it('should retrieve an installed package and directory', async () => {
exec(`sfdx force:package:install --noprompt --package ${ELECTRON.id} --wait 5 --json`, { silent: true });
it('should retrieve an installed package and write to the output dir', async () => {
await testkit.retrieve({ args: `--package-name "${ELECTRON.name}" --target-metadata-dir package-output` });
await testkit.expect.packagesToBeRetrieved([ELECTRON.name]);
expect(fs.existsSync(path.join(testkit.projectDir, 'package-output', 'unpackaged.zip'))).to.be.true;
});

it('should retrieve an installed package and write to the output dir (unzipped)', async () => {
await testkit.retrieve({
args: `--package-name "${ELECTRON.name}" --target-metadata-dir package-output1 --unzip`,
});
await testkit.expect.packagesToBeRetrieved([ELECTRON.name]);
expect(
fs.existsSync(
path.join(
testkit.projectDir,
'package-output1',
'unpackaged',
'ElectronBranding',
'lightningExperienceThemes',
'Electron.lightningExperienceTheme'
)
)
).to.be.true;
});

it('should retrieve an installed package and directory', async () => {
await testkit.retrieve({
args: `--package-name "${ELECTRON.name}" --source-dir "${path.join(
'force-app',
Expand Down
4 changes: 2 additions & 2 deletions test/nuts/seeds/deploy.metadata.manifest.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ context('deploy metadata --manifest NUTs [name: %REPO_NAME%]', () => {
const args = testkit.packageNames.map((p) => `--source-dir ${p}`).join(' ');
await testkit.deploy({ args });
if (REPO.gitUrl.includes('dreamhouse')) {
await testkit.assignPermissionSet({ args: '--permsetname dreamhouse', cli: 'sfdx' });
await testkit.assignPermissionSet({ args: '--permsetname dreamhouse' });
}
});

Expand All @@ -46,7 +46,7 @@ context('deploy metadata --manifest NUTs [name: %REPO_NAME%]', () => {
const paths = testCase.toDeploy.map((t) => path.normalize(t)).join(',');
// This is using the force:source:convert command from plugin-source. Once we have an
// sf equivalent, we should switch it to use that.
await testkit.convert({ args: `--sourcepath ${paths} --outputdir out`, cli: 'sfdx' });
await testkit.convert({ args: `--sourcepath ${paths} --outputdir out` });
const packageXml = path.join('out', 'package.xml');

const deploy = await testkit.deploy<DeployResultJson>({ args: `--manifest ${packageXml}` });
Expand Down
2 changes: 1 addition & 1 deletion test/nuts/seeds/deploy.metadata.metadata-dir.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ context('deploy metadata --metadata-dir NUTs [name: %REPO_NAME%]', () => {
const paths = testCase.toDeploy.map((t) => path.normalize(t)).join(',');
// This is using the force:source:convert command from plugin-source. Once we have an
// sf equivalent, we should switch it to use that.
await testkit.convert({ args: `--sourcepath ${paths} --outputdir out`, cli: 'sfdx' });
await testkit.convert({ args: `--sourcepath ${paths} --outputdir out` });

const deploy = await testkit.deploy<DeployResultJson>({ args: '--metadata-dir out' });
assert(deploy);
Expand Down
4 changes: 2 additions & 2 deletions test/nuts/seeds/deploy.metadata.metadata.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ context('deploy metadata --metadata NUTs [name: %REPO_NAME%]', () => {
const args = testkit.packageNames.map((p) => `--source-dir ${p}`).join(' ');
await testkit.deploy({ args });
if (REPO.gitUrl.includes('dreamhouse')) {
await testkit.assignPermissionSet({ args: '--permsetname dreamhouse', cli: 'sfdx' });
await testkit.assignPermissionSet({ args: '--permsetname dreamhouse' });
}
});

Expand Down Expand Up @@ -56,7 +56,7 @@ context('deploy metadata --metadata NUTs [name: %REPO_NAME%]', () => {
});

it('should not deploy metadata outside of a package directory', async () => {
await testkit.createApexClass({ args: '--outputdir NotAPackage --classname ShouldNotBeDeployed', cli: 'sfdx' });
await testkit.createApexClass({ args: '--outputdir NotAPackage --classname ShouldNotBeDeployed' });
await testkit.deploy({ args: '--metadata ApexClass' });
// this is a glob, so no need for path.join
await testkit.expect.filesToNotBeDeployed(['NotAPackage/**/*']);
Expand Down
2 changes: 1 addition & 1 deletion test/nuts/seeds/deploy.metadata.test-level.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ context('deploy metadata --test-level NUTs [name: %REPO_NAME%]', () => {
const args = testkit.packageNames.map((p) => `--source-dir ${p}`).join(' ');
await testkit.deploy({ args });
if (REPO.gitUrl.includes('dreamhouse')) {
await testkit.assignPermissionSet({ args: '--permsetname dreamhouse', cli: 'sfdx' });
await testkit.assignPermissionSet({ args: '--permsetname dreamhouse' });
}
});

Expand Down
Loading