Skip to content

Commit edd63e8

Browse files
authored
fix(deps): bump apex library (#513)
* fix(deps): bump core everywhere * fix(deps): current core and apex lib * test: remove dynamic bin to drop oclif/core requirement, static run for UT * chore: deps for test * chore: cleaner deps with later yarn * chore: dev deps for glob yarn1 problem * chore: bump apex-node to remove glob
1 parent a7d6531 commit edd63e8

File tree

12 files changed

+1033
-1276
lines changed

12 files changed

+1033
-1276
lines changed

messages/runtest.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ NOTE: The testRunCoverage value (JSON and JUnit result formats) is a percentage
3535
<%= config.bin %> <%= command.id %> --test-level RunLocalTests --output-dir <path to outputdir> --target-org me@my.org
3636

3737
- Run all tests in the org asynchronously:
38-
38+
3939
<%= config.bin %> <%= command.id %> --target-org myscratch
4040

4141
- Run all tests synchronously; the command waits to display the test results until all tests finish:
42-
42+
4343
<%= config.bin %> <%= command.id %> --synchronous
4444

4545
- Run specific tests using the --test-level flag:
@@ -51,13 +51,12 @@ NOTE: The testRunCoverage value (JSON and JUnit result formats) is a percentage
5151
<%= config.bin %> <%= command.id %> --class-names TestA --class-names TestB --result-format tap --code-coverage
5252

5353
- Run Apex tests on methods specified using the standard Class.method notation; if you specify a test class without a method, the command runs all methods in the class:
54-
54+
5555
<%= config.bin %> <%= command.id %> --tests TestA.excitingMethod --tests TestA.boringMethod --tests TestB
5656

5757
- Run Apex tests on methods specified using the standard Class.method notation with a namespace:
58-
58+
5959
<%= config.bin %> <%= command.id %> --tests ns.TestA.excitingMethod --tests ns.TestA.boringMethod --tests ns.TestB
60-
6160

6261
# flags.class-names.summary
6362

@@ -144,7 +143,7 @@ Encountered an error when processing test results
144143

145144
# apexTestReportFormatHint
146145

147-
Run "%s apex get test %s --result-format <format>" to retrieve test results in a different format.
146+
Run "sf apex get test %s --result-format <format>" to retrieve test results in a different format.
148147

149148
# outputDirHint
150149

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
8-
"@oclif/core": "^4",
9-
"@salesforce/apex-node": "^6.1.2",
10-
"@salesforce/core": "^7.4.1",
8+
"@salesforce/apex-node": "^7.0.3",
9+
"@salesforce/core": "^8.1.0",
1110
"@salesforce/kit": "^3.1.6",
12-
"@salesforce/sf-plugins-core": "^11.1.0",
11+
"@salesforce/sf-plugins-core": "^11.1.2",
1312
"ansis": "^3.2.0"
1413
},
1514
"devDependencies": {
15+
"@oclif/core": "^4.0.8",
1616
"@oclif/plugin-command-snapshot": "^5.2.3",
1717
"@salesforce/cli-plugins-testkit": "^5.3.17",
18-
"@salesforce/dev-scripts": "^10.2.0",
19-
"@salesforce/plugin-command-reference": "^3.1.2",
20-
"eslint-plugin-sf-plugin": "^1.18.9",
21-
"oclif": "^4.13.10",
18+
"@salesforce/dev-scripts": "^10.2.2",
19+
"@salesforce/plugin-command-reference": "^3.1.8",
20+
"eslint-plugin-sf-plugin": "^1.18.10",
21+
"oclif": "^4.13.12",
2222
"ts-node": "^10.9.2",
2323
"typescript": "^5.5.2"
2424
},

src/commands/apex/get/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default class Test extends SfCommand<RunResult> {
5858
const testService = new TestService(conn);
5959
const result = await testService.reportAsyncResults(flags['test-run-id'], flags['code-coverage']);
6060

61-
const testReporter = new TestReporter(new Ux({ jsonEnabled: this.jsonEnabled() }), conn, this.config.bin);
61+
const testReporter = new TestReporter(new Ux({ jsonEnabled: this.jsonEnabled() }), conn);
6262

6363
return testReporter.report(result, {
6464
'output-dir': flags['output-dir'],

src/commands/apex/run/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default class Test extends SfCommand<RunCommandResult> {
136136
}
137137

138138
if ('summary' in result) {
139-
const testReporter = new TestReporter(new Ux({ jsonEnabled: this.jsonEnabled() }), conn, this.config.bin);
139+
const testReporter = new TestReporter(new Ux({ jsonEnabled: this.jsonEnabled() }), conn);
140140
return testReporter.report(result, flags);
141141
} else {
142142
// Tests were ran asynchronously or the --wait timed out.

src/reporters/testReporter.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ export class TestReporter {
3131
*
3232
* @param ux a new Ux instance based on if the command is in json mode
3333
* @param connection a connection to the org the tests are being run against - used for getting username for hints
34-
* @param bin the bin of the cli, used for providing suggestions in the users cli
3534
*/
36-
public constructor(private readonly ux: Ux, private readonly connection: Connection, private readonly bin: string) {}
35+
public constructor(private readonly ux: Ux, private readonly connection: Connection) {}
3736

3837
public async report(
3938
result: TestResult,
@@ -208,6 +207,6 @@ export class TestReporter {
208207
if (username) {
209208
reportArgs += ` -o ${username}`;
210209
}
211-
return messages.getMessage('apexTestReportFormatHint', [this.bin, reportArgs]);
210+
return messages.getMessage('apexTestReportFormatHint', [reportArgs]);
212211
}
213212
}

test/commands/apex/get/log.test.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import fs from 'node:fs';
8-
import { Config } from '@oclif/core';
98
import sinon from 'sinon';
109
import { LogService } from '@salesforce/apex-node';
1110
import { expect } from 'chai';
12-
import { SfCommand } from '@salesforce/sf-plugins-core';
11+
import { stubSfCommandUx } from '@salesforce/sf-plugins-core';
1312
import { Org } from '@salesforce/core';
1413
import ansis from 'ansis';
1514
import Log, { LogGetResult } from '../../../../src/commands/apex/get/log.js';
@@ -18,14 +17,12 @@ const strip = new ansis.Ansis().strip;
1817
const logStripper = (log: LogGetResult[number]) => (typeof log === 'string' ? strip(log) : { log: strip(log.log) });
1918

2019
describe('apex:log:get', () => {
21-
let config: Config;
2220
let sandbox: sinon.SinonSandbox;
23-
let logStub: sinon.SinonStub;
21+
let uxStub: ReturnType<typeof stubSfCommandUx>;
2422

2523
beforeEach(async () => {
26-
config = await Config.load(import.meta.url);
2724
sandbox = sinon.createSandbox();
28-
logStub = sandbox.stub(SfCommand.prototype, 'log');
25+
uxStub = stubSfCommandUx(sandbox);
2926
sandbox.stub(Org, 'create').resolves({ getConnection: () => ({}) } as Org);
3027
});
3128

@@ -42,38 +39,38 @@ describe('apex:log:get', () => {
4239

4340
it('0 logs to get', async () => {
4441
sandbox.stub(LogService.prototype, 'getLogs').resolves([]);
45-
const result = await Log.run([], config);
42+
const result = await Log.run([]);
4643
expect(result).to.deep.equal([]);
47-
expect(logStub.firstCall.args[0]).to.equal('No results found');
44+
expect(uxStub.log.firstCall.args[0]).to.equal('No results found');
4845
});
4946

5047
it('outputdir will write to fs', async () => {
5148
sandbox.stub(LogService.prototype, 'getLogs').resolves([{ log: 'myLog' }]);
52-
const result = await new Log(['--output-dir', 'myDirectory'], config).run();
49+
const result = await Log.run(['--output-dir', 'myDirectory']);
5350
expect(result).to.deep.equal(['myLog']);
54-
expect(logStub.firstCall.args[0]).to.equal('Log files written to myDirectory');
51+
expect(uxStub.log.firstCall.args[0]).to.equal('Log files written to myDirectory');
5552
});
5653

5754
it('outputdir will write to fs --json', async () => {
5855
sandbox.stub(LogService.prototype, 'getLogs').resolves([{ log: 'myLog' }]);
59-
const result = await new Log(['--outputdir', 'myDirectory', '--json'], config).run();
56+
const result = await Log.run(['--outputdir', 'myDirectory', '--json']);
6057
expect(result).to.deep.equal(['myLog']);
61-
expect(logStub.firstCall.args[0]).to.equal('Log files written to myDirectory');
58+
expect(uxStub.log.firstCall.args[0]).to.equal('Log files written to myDirectory');
6259
});
6360

6461
it('multiple results', async () => {
6562
sandbox.stub(LogService.prototype, 'getLogs').resolves([{ log: 'myLog' }, { log: 'myLog2' }]);
66-
const result = (await new Log([], config).run()).map(logStripper);
63+
const result = (await Log.run([])).map(logStripper);
6764
expect(result).to.deep.equal([{ log: 'myLog' }, { log: 'myLog2' }]);
68-
expect(logStripper(logStub.firstCall.args[0] as string)).to.equal('myLog');
69-
expect(logStripper(logStub.secondCall.args[0] as string)).to.equal('myLog2');
65+
expect(logStripper(uxStub.log.firstCall.args[0] as string)).to.equal('myLog');
66+
expect(logStripper(uxStub.log.secondCall.args[0] as string)).to.equal('myLog2');
7067
});
7168

7269
it('multiple results --json', async () => {
7370
sandbox.stub(LogService.prototype, 'getLogs').resolves([{ log: 'myLog' }, { log: 'myLog2' }]);
74-
const result = (await new Log(['--json'], config).run()).map(logStripper);
71+
const result = (await Log.run(['--json'])).map(logStripper);
7572
expect(result).to.deep.equal([{ log: 'myLog' }, { log: 'myLog2' }]);
76-
expect(logStripper(logStub.firstCall.args[0] as string)).to.equal('myLog');
77-
expect(logStripper(logStub.secondCall.args[0] as string)).to.equal('myLog2');
73+
expect(logStripper(uxStub.log.firstCall.args[0] as string)).to.equal('myLog');
74+
expect(logStripper(uxStub.log.secondCall.args[0] as string)).to.equal('myLog2');
7875
});
7976
});

test/commands/apex/get/test.test.ts

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,24 @@
77
import fs from 'node:fs';
88
import { Connection, Org } from '@salesforce/core';
99
import sinon from 'sinon';
10-
import { Ux } from '@salesforce/sf-plugins-core';
11-
import { Config } from '@oclif/core';
12-
import { expect } from 'chai';
10+
import { Ux, stubSfCommandUx } from '@salesforce/sf-plugins-core';
11+
import { expect, config } from 'chai';
1312
import { TestService } from '@salesforce/apex-node';
1413
import Test from '../../../../src/commands/apex/get/test.js';
1514
import { runWithFailures, testRunSimple, testRunSimpleResult, testRunWithFailuresResult } from '../../../testData.js';
1615

16+
config.truncateThreshold = 0;
17+
1718
let logStub: sinon.SinonStub;
1819
let styledJsonStub: sinon.SinonStub;
1920

2021
describe('apex:test:report', () => {
2122
let sandbox: sinon.SinonSandbox;
22-
let config: Config;
23+
let uxStub: ReturnType<typeof stubSfCommandUx>;
2324

2425
beforeEach(async () => {
25-
config = await Config.load(import.meta.url);
2626
sandbox = sinon.createSandbox();
27+
uxStub = stubSfCommandUx(sandbox);
2728
logStub = sandbox.stub(Ux.prototype, 'log');
2829
styledJsonStub = sandbox.stub(Ux.prototype, 'styledJSON');
2930
sandbox.stub(Connection.prototype, 'getUsername').returns('test@example.com');
@@ -46,19 +47,20 @@ describe('apex:test:report', () => {
4647
it('should return a success human format message with async', async () => {
4748
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(runWithFailures);
4849

49-
const result = await new Test(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'human'], config).run();
50+
const result = await Test.run(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'human']);
5051

5152
expect(result).to.deep.equal(testRunWithFailuresResult);
5253
expect(logStub.firstCall.args[0]).to.include('=== Test Summary');
5354
expect(logStub.firstCall.args[0]).to.include('=== Test Results');
5455
expect(logStub.firstCall.args[0]).to.include('Test Run Id 707xx0000AUS2gH');
5556
expect(logStub.firstCall.args[0]).to.include('MyApexTests.testConfig Fail');
57+
expect(uxStub.log.callCount).to.equal(0);
5658
});
5759

5860
it('should return a success tap format message with async', async () => {
5961
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(runWithFailures);
6062

61-
const result = await new Test(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'tap'], config).run();
63+
const result = await Test.run(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'tap']);
6264

6365
expect(result).to.deep.equal(testRunWithFailuresResult);
6466
expect(logStub.firstCall.args[0]).to.include('1..1');
@@ -68,7 +70,7 @@ describe('apex:test:report', () => {
6870

6971
it('should return a success junit format message with async', async () => {
7072
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(runWithFailures);
71-
const result = await new Test(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'junit'], config).run();
73+
const result = await Test.run(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'junit']);
7274
expect(result).to.deep.equal(testRunWithFailuresResult);
7375
expect(logStub.firstCall.args[0]).to.include('<property name="failRate" value="50%"/>');
7476
expect(logStub.firstCall.args[0]).to.include('<property name="outcome" value="Failed"/>');
@@ -77,33 +79,30 @@ describe('apex:test:report', () => {
7779

7880
it('should return a success json format message with async', async () => {
7981
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(runWithFailures);
80-
const result = await new Test(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'json'], config).run();
82+
const result = await Test.run(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'json']);
8183
expect(result).to.deep.equal(testRunWithFailuresResult);
8284
expect(styledJsonStub.firstCall.args[0]).to.deep.equal({ result: testRunWithFailuresResult, status: 100 });
8385
});
8486

8587
it('should return a success --json format message with sync', async () => {
8688
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(runWithFailures);
8789
sandbox.stub(Org.prototype, 'getUsername').returns('test@user.com');
88-
const result = await new Test(['--test-run-id', '707xxxxxxxxxxxx', '--json'], config).run();
90+
const result = await Test.run(['--test-run-id', '707xxxxxxxxxxxx', '--json']);
8991
expect(result).to.deep.equal(testRunWithFailuresResult);
9092
expect(styledJsonStub.notCalled).to.be.true;
9193
});
9294

9395
it('should return a success human format with synchronous', async () => {
9496
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(runWithFailures);
95-
await new Test(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'human'], config).run();
97+
await Test.run(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'human']);
9698
expect(logStub.firstCall.args[0]).to.contain('Test Summary');
9799
expect(logStub.firstCall.args[0]).to.contain('Test Results');
98100
expect(logStub.firstCall.args[0]).to.not.contain('Apex Code Coverage by Class');
99101
});
100102

101103
it('should warn when using --outputdir', async () => {
102104
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(runWithFailures);
103-
await new Test(
104-
['--output-dir', 'myDirectory', '--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'human'],
105-
config
106-
).run();
105+
await Test.run(['--output-dir', 'myDirectory', '--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'human']);
107106
expect(logStub.firstCall.args[0]).to.contain('Test result files written to myDirectory');
108107
});
109108
});
@@ -112,7 +111,7 @@ describe('apex:test:report', () => {
112111
it('should return a success human format message with async', async () => {
113112
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(testRunSimple);
114113

115-
const result = await new Test(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'human'], config).run();
114+
const result = await Test.run(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'human']);
116115

117116
expect(result).to.deep.equal(testRunSimpleResult);
118117
expect(logStub.firstCall.args[0]).to.include('=== Test Summary');
@@ -124,7 +123,7 @@ describe('apex:test:report', () => {
124123
it('should return a success tap format message with async', async () => {
125124
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(testRunSimple);
126125

127-
const result = await new Test(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'tap'], config).run();
126+
const result = await Test.run(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'tap']);
128127

129128
expect(result).to.deep.equal(testRunSimpleResult);
130129
expect(logStub.firstCall.args[0]).to.include('1..1');
@@ -134,7 +133,7 @@ describe('apex:test:report', () => {
134133

135134
it('should return a success junit format message with async', async () => {
136135
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(testRunSimple);
137-
const result = await new Test(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'junit'], config).run();
136+
const result = await Test.run(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'junit']);
138137
expect(result).to.deep.equal(testRunSimpleResult);
139138
expect(logStub.firstCall.args[0]).to.contain('<testcase name="testConfig" classname="MyApexTests" time="0.05">');
140139
expect(logStub.firstCall.args[0]).to.contain('<property name="testsRan" value="1"/>');
@@ -143,33 +142,30 @@ describe('apex:test:report', () => {
143142
it('should return a success json format message with async', async () => {
144143
process.exitCode = 0;
145144
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(testRunSimple);
146-
const result = await new Test(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'json'], config).run();
145+
const result = await Test.run(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'json']);
147146
expect(result).to.deep.equal(testRunSimpleResult);
148147
expect(styledJsonStub.firstCall.args[0]).to.deep.equal({ result: testRunSimpleResult, status: 0 });
149148
});
150149

151150
it('should return a success --json format message with sync', async () => {
152151
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(testRunSimple);
153152
sandbox.stub(Org.prototype, 'getUsername').returns('test@user.com');
154-
const result = await new Test(['--test-run-id', '707xxxxxxxxxxxx', '--json'], config).run();
153+
const result = await Test.run(['--test-run-id', '707xxxxxxxxxxxx', '--json']);
155154
expect(result).to.deep.equal(testRunSimpleResult);
156155
expect(styledJsonStub.notCalled).to.be.true;
157156
});
158157

159158
it('should return a success human format with synchronous', async () => {
160159
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(testRunSimple);
161-
await new Test(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'human'], config).run();
160+
await Test.run(['--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'human']);
162161
expect(logStub.firstCall.args[0]).to.contain('Test Summary');
163162
expect(logStub.firstCall.args[0]).to.contain('Test Results');
164163
expect(logStub.firstCall.args[0]).to.not.contain('Apex Code Coverage by Class');
165164
});
166165

167166
it('should warn when using --outputdir', async () => {
168167
sandbox.stub(TestService.prototype, 'reportAsyncResults').resolves(testRunSimple);
169-
await new Test(
170-
['--output-dir', 'myDirectory', '--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'human'],
171-
config
172-
).run();
168+
await Test.run(['--output-dir', 'myDirectory', '--test-run-id', '707xxxxxxxxxxxx', '--result-format', 'human']);
173169
expect(logStub.firstCall.args[0]).to.contain('Test result files written to myDirectory');
174170
});
175171
});

0 commit comments

Comments
 (0)