Skip to content

Commit

Permalink
test: cli in more places for source:* not found
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Nov 7, 2023
1 parent c747067 commit 8715a4f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 7 deletions.
12 changes: 6 additions & 6 deletions test/nuts/delete/source.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('CustomLabels', () => {
scratchOrgs: [{ setDefault: true, config: path.join('config', 'project-scratch-def.json') }],
devhubAuthStrategy: 'AUTO',
});
execCmd('force:source:deploy --sourcepath force-app', { ensureExitCode: 0 });
execCmd('project:deploy:start --source-dir force-app', { ensureExitCode: 0 });
});

after(async () => {
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('project delete source NUTs', () => {
ensureExitCode: 0,
cli: 'sf',
});
execCmd(`force:source:deploy -m ApexClass:${apexName}`, { ensureExitCode: 0 });
execCmd(`project:deploy:start -m ApexClass:${apexName}`, { ensureExitCode: 0 });
return { apexName, output, pathToClass };
};

Expand All @@ -112,7 +112,7 @@ describe('project delete source NUTs', () => {
nut: __filename,
repository: 'https://github.com/trailheadapps/dreamhouse-lwc.git',
});
execCmd('force:source:deploy --sourcepath force-app', { ensureExitCode: 0 });
execCmd('project:deploy:start --source-dir force-app', { ensureExitCode: 0 });
});

after(async () => {
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('project delete source NUTs', () => {
// use the brokerCard LWC
const lwcPath = path.join(testkit.projectDir, 'force-app', 'main', 'default', 'lwc', 'brokerCard', 'helper.js');
fs.writeFileSync(lwcPath, '//', { encoding: 'utf8' });
execCmd(`force:source:deploy -p ${lwcPath}`);
execCmd(`project:deploy:start --source-dir ${lwcPath}`, { cli: 'sf', ensureExitCode: 0 });
const deleteResult = execCmd<{ deletedSource: [FileResponse] }>(
`project:delete:source -p ${lwcPath} --no-prompt --json`
).jsonOutput?.result;
Expand All @@ -259,7 +259,7 @@ describe('project delete source NUTs', () => {
const lwcPath2 = path.join(testkit.projectDir, 'force-app', 'main', 'default', 'lwc', 'daysOnMarket', 'helper.js');
fs.writeFileSync(lwcPath1, '//', { encoding: 'utf8' });
fs.writeFileSync(lwcPath2, '//', { encoding: 'utf8' });
execCmd(`force:source:deploy -p ${lwcPath1},${lwcPath2}`);
execCmd(`project:deploy:start --source-dir ${lwcPath1} --source-dir ${lwcPath2}`);
// delete both helper.js files at the same time
const deleteResult = execCmd<{ deletedSource: FileResponse[] }>(
// eslint-disable-next-line sf-plugin/no-execcmd-double-quotes
Expand All @@ -285,7 +285,7 @@ describe('project delete source NUTs', () => {
const lwcPath = path.join(testkit.projectDir, 'force-app', 'main', 'default', 'lwc');
const mylwcPath = path.join(lwcPath, 'mylwc');
execCmd(`force:lightning:component:create -n mylwc --type lwc -d ${lwcPath}`, { cli: 'sf', ensureExitCode: 0 });
execCmd(`force:source:deploy -p ${mylwcPath}`);
execCmd(`project:deploy:start --source-dir ${mylwcPath}`);
expect(await isNameObsolete(testkit.username, 'LightningComponentBundle', 'mylwc')).to.be.false;
const deleteResult = execCmd<{ deletedSource: [FileResponse] }>(
`project:delete:source -p ${mylwcPath} --no-prompt --json`
Expand Down
10 changes: 10 additions & 0 deletions test/nuts/tracking/basics.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('detects the initial metadata status', () => {
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
assert(Array.isArray(result));
// the fields should be populated
Expand Down Expand Up @@ -92,11 +93,13 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('sees no local changes (all were committed from push), but profile updated in remote', () => {
const localResult = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(localResult?.filter(filterIgnored)).to.deep.equal([]);

const remoteResult = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(remoteResult?.some((item) => item.type === 'Profile')).to.equal(true);
});
Expand All @@ -110,6 +113,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('sf sees no remote changes (all were committed from push) except Profile', () => {
const remoteResult = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(remoteResult?.some((item) => item.type === 'Profile')).to.equal(true);
});
Expand All @@ -127,6 +131,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('sees no local or remote changes', () => {
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result?.filter((r) => r.type === 'Profile').filter(filterIgnored), JSON.stringify(result)).to.have.length(
0
Expand Down Expand Up @@ -155,6 +160,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
]);
const result = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result?.filter(filterIgnored)).to.deep.equal([
{
Expand Down Expand Up @@ -199,6 +205,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('does not see any change in remote status', () => {
const result = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(
result?.filter((r) => r.fullName === 'TestOrderController'),
Expand All @@ -224,6 +231,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('sees no local changes', () => {
const result = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result?.filter(filterIgnored), JSON.stringify(result)).to.be.an.instanceof(Array).with.length(0);
});
Expand All @@ -243,6 +251,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
assert(hubUsername, 'hubUsername should be defined');
const failure = execCmd(`force:source:status -u ${hubUsername} --remote --json`, {
ensureExitCode: 1,
cli: 'sf',
}).jsonOutput as unknown as { name: string };
// command5 is removing `Error` from the end of the error names.
expect(failure.name).to.include('NonSourceTrackedOrg');
Expand Down Expand Up @@ -281,6 +290,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('sees no local changes', () => {
const result = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result?.filter(filterIgnored), JSON.stringify(result)).to.be.an.instanceof(Array).with.length(2);
});
Expand Down
2 changes: 2 additions & 0 deletions test/nuts/tracking/conflicts.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ describe('conflict detection and resolution', () => {
});
const result = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(
result?.filter((r) => r.type === 'CustomApplication'),
Expand All @@ -99,6 +100,7 @@ describe('conflict detection and resolution', () => {
it('can see the conflict in status', () => {
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result.filter((app) => app.type === 'CustomApplication');
// json is not sorted. This relies on the implementation of getConflicts()
expect(result).to.deep.equal([
Expand Down
3 changes: 2 additions & 1 deletion test/nuts/tracking/deleteResetTracking.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('reset and clear tracking', () => {
it('runs status to start tracking', () => {
const result = execCmd('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result).to.have.length.greaterThan(100); // ebikes is big
});
Expand Down Expand Up @@ -109,7 +110,7 @@ describe('reset and clear tracking', () => {
}
});
// gets tracking files from server
execCmd('force:source:status --json --remote', { ensureExitCode: 0 });
execCmd('force:source:status --json --remote', { ensureExitCode: 0, cli: 'sf' });
const revisions = await getRevisionsAsArray();
const revisionFile = JSON.parse(
await fs.promises.readFile(path.join(trackingFileFolder, 'maxRevision.json'), 'utf8')
Expand Down
2 changes: 2 additions & 0 deletions test/nuts/tracking/forceIgnore.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe('forceignore changes', () => {
it('shows the file in status as ignored', () => {
const output = execCmd<StatusResult>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(output, JSON.stringify(output)).to.deep.include({
state: 'Local Add',
Expand Down Expand Up @@ -157,6 +158,7 @@ describe('forceignore changes', () => {
// gets file into source tracking
const statusOutput = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(statusOutput?.some((result) => result.fullName === 'CreatedClass')).to.equal(true);
});
Expand Down
6 changes: 6 additions & 0 deletions test/nuts/tracking/lwc.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('lwc', () => {
);
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result?.find((r) => r.filePath === cssPathRelative)).to.have.property('actualState', 'Changed');
});
Expand Down Expand Up @@ -87,6 +88,7 @@ describe('lwc', () => {
it('sfdx sees no local changes', () => {
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
})
.jsonOutput?.result.filter((r) => r.origin === 'Local')
.filter(filterIgnored);
Expand All @@ -106,6 +108,7 @@ describe('lwc', () => {
await fs.promises.rm(cssPathAbsolute);
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
})
.jsonOutput?.result.filter(filterIgnored)
.find((r) => r.filePath === cssPathRelative);
Expand Down Expand Up @@ -137,6 +140,7 @@ describe('lwc', () => {
it('sees no local changes', () => {
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
})
.jsonOutput?.result.filter((r) => r.origin === 'Local')
.filter(filterIgnored);
Expand Down Expand Up @@ -167,6 +171,7 @@ describe('lwc', () => {
);
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result.filter((r) => r.origin === 'Local');
assert(result);
expect(result.filter(filterIgnored)).to.have.length(4);
Expand All @@ -190,6 +195,7 @@ describe('lwc', () => {
it('sees no local changes', () => {
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
})
.jsonOutput?.result.filter((r) => r.origin === 'Local')
.filter(filterIgnored);
Expand Down
8 changes: 8 additions & 0 deletions test/nuts/tracking/remoteChanges.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('remote changes', () => {
it('sees no local changes (all were committed from deploy)', () => {
const localResult = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(localResult?.filter(filterIgnored)).to.deep.equal([]);
});
Expand Down Expand Up @@ -108,6 +109,7 @@ describe('remote changes', () => {
it('sfdx can see the delete in status', () => {
const result = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
// it shows up as one class on the server, but 2 files when pulled
expect(
Expand All @@ -125,6 +127,7 @@ describe('remote changes', () => {
it('sfdx does not see any change in local status', () => {
const result = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result?.filter(filterIgnored)).to.deep.equal([]);
});
Expand Down Expand Up @@ -159,11 +162,13 @@ describe('remote changes', () => {
it('sees correct local and remote status', () => {
const remoteResult = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(remoteResult?.filter((r) => r.state.includes('Remote Deleted'))).to.deep.equal([]);

const localStatus = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(localStatus?.filter(filterIgnored)).to.deep.equal([]);
});
Expand Down Expand Up @@ -197,6 +202,7 @@ describe('remote changes', () => {
it('can see the add in status', () => {
const result = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(
result?.some((r) => r.fullName === className),
Expand Down Expand Up @@ -224,6 +230,7 @@ describe('remote changes', () => {
it('sfdx sees correct remote status', () => {
const remoteResult = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(
remoteResult?.filter((r) => r.fullName === className),
Expand All @@ -233,6 +240,7 @@ describe('remote changes', () => {
it('sfdx sees correct local status', () => {
const localStatus = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(localStatus?.filter(filterIgnored)).to.deep.equal([]);
});
Expand Down

0 comments on commit 8715a4f

Please sign in to comment.