Skip to content

Commit 0494b54

Browse files
authored
chore: use latest testkit (#450)
* chore: use latest testkit * chore: fix nuts
1 parent 78230ba commit 0494b54

File tree

8 files changed

+99
-58
lines changed

8 files changed

+99
-58
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
"tslib": "^2"
1515
},
1616
"devDependencies": {
17-
"@oclif/dev-cli": "^1",
1817
"@oclif/plugin-command-snapshot": "^3.2.0",
1918
"@oclif/test": "^2.2.1",
20-
"@salesforce/cli-plugins-testkit": "^2.5.2",
19+
"@salesforce/cli-plugins-testkit": "^3.0.3",
2120
"@salesforce/dev-config": "^3.1.0",
2221
"@salesforce/dev-scripts": "^2.0.4",
2322
"@salesforce/plugin-command-reference": "^1.3.0",
@@ -119,4 +118,4 @@
119118
"publishConfig": {
120119
"access": "public"
121120
}
122-
}
121+
}

test/nut/commands/force/org/beta/create.nut.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe('org:create command', () => {
1717
project: {
1818
name: 'orgCreateNut',
1919
},
20+
devhubAuthStrategy: 'AUTO',
2021
});
2122
});
2223

test/nut/commands/force/org/delete.org.nut.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Licensed under the BSD 3-Clause license.
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
7+
import { join } from 'path';
78
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
8-
import { AnyJson, getString, isArray } from '@salesforce/ts-types';
99
import { expect } from '@salesforce/command/lib/test';
1010
// these NUTs are separated from org.nuts.ts because deleting orgs may interfere with the other NUTs
1111
describe('Delete Orgs', () => {
@@ -19,18 +19,28 @@ describe('Delete Orgs', () => {
1919
before(async () => {
2020
session = await TestSession.create({
2121
project: { name: 'forceOrgList' },
22-
setupCommands: [
23-
'sfdx force:org:create -f config/project-scratch-def.json --setdefaultusername --wait 10',
24-
'sfdx force:org:create -f config/project-scratch-def.json --setalias anAlias --wait 10',
22+
devhubAuthStrategy: 'AUTO',
23+
scratchOrgs: [
24+
{
25+
executable: 'sfdx',
26+
setDefault: true,
27+
wait: 10,
28+
config: join('config', 'project-scratch-def.json'),
29+
},
30+
{
31+
executable: 'sfdx',
32+
alias: 'anAlias',
33+
wait: 10,
34+
config: join('config', 'project-scratch-def.json'),
35+
},
2536
],
2637
});
2738

28-
if (isArray<AnyJson>(session.setup)) {
29-
defaultUsername = getString(session.setup[0], 'result.username');
30-
defaultUserOrgId = getString(session.setup[0], 'result.orgId');
31-
aliasedUsername = getString(session.setup[1], 'result.username');
32-
aliasUserOrgId = getString(session.setup[1], 'result.orgId');
33-
}
39+
defaultUsername = session.orgs.get('default').username;
40+
defaultUserOrgId = session.orgs.get('default').orgId;
41+
42+
aliasedUsername = session.orgs.get('anAlias').username;
43+
aliasUserOrgId = session.orgs.get('anAlias').orgId;
3444
});
3545

3646
after(async () => {

test/nut/commands/force/org/open.nut.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8+
import { join } from 'path';
89
import { TestSession, execCmd } from '@salesforce/cli-plugins-testkit';
910
import { expect } from 'chai';
1011

@@ -14,7 +15,15 @@ describe('test org:open command', () => {
1415
before(async () => {
1516
session = await TestSession.create({
1617
project: { name: 'forceOrgList' },
17-
setupCommands: ['sfdx force:org:create -f config/project-scratch-def.json --setdefaultusername --wait 10'],
18+
devhubAuthStrategy: 'AUTO',
19+
scratchOrgs: [
20+
{
21+
executable: 'sfdx',
22+
config: join('config', 'project-scratch-def.json'),
23+
setDefault: true,
24+
wait: 10,
25+
},
26+
],
1827
});
1928
});
2029

test/nut/commands/force/org/org.nut.ts

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8+
import { join } from 'path';
89
import * as querystring from 'querystring';
910
import { expect } from '@salesforce/command/lib/test';
1011
import { TestSession } from '@salesforce/cli-plugins-testkit';
1112
import { execCmd } from '@salesforce/cli-plugins-testkit';
12-
import { asDictionary, AnyJson, Dictionary, getString, isArray, ensureString } from '@salesforce/ts-types';
13+
import { asDictionary, Dictionary, getString } from '@salesforce/ts-types';
1314

1415
let hubOrgUsername: string;
1516

@@ -50,28 +51,34 @@ describe('Org Command NUT', () => {
5051
before(async () => {
5152
session = await TestSession.create({
5253
project: { name: 'forceOrgList' },
53-
setupCommands: [
54-
'sfdx force:org:create -f config/project-scratch-def.json --setdefaultusername --wait 10',
55-
'sfdx force:org:create -f config/project-scratch-def.json --setalias anAlias --wait 10',
56-
'sfdx config:get defaultdevhubusername --json',
54+
devhubAuthStrategy: 'AUTO',
55+
scratchOrgs: [
56+
{
57+
executable: 'sfdx',
58+
config: join('config', 'project-scratch-def.json'),
59+
setDefault: true,
60+
wait: 10,
61+
},
62+
{
63+
executable: 'sfdx',
64+
config: join('config', 'project-scratch-def.json'),
65+
alias: 'anAlias',
66+
wait: 10,
67+
},
5768
],
5869
});
5970

60-
// get default devhub username
61-
if (isArray<AnyJson>(session.setup)) {
62-
hubOrgUsername = ensureString(
63-
(session.setup[2] as { result: [{ key: string; value: string }] }).result.find(
64-
(config) => config.key === 'defaultdevhubusername'
65-
)?.value
66-
);
67-
}
71+
const hubOrg = execCmd<[{ key: string; value: string }]>('config:get defaultdevhubusername --json', {
72+
cli: 'sfdx',
73+
ensureExitCode: 0,
74+
});
75+
hubOrgUsername = hubOrg.jsonOutput.result[0].value;
76+
77+
defaultUsername = session.orgs.get('default').username;
78+
defaultUserOrgId = session.orgs.get('default').orgId;
6879

69-
if (isArray<AnyJson>(session.setup)) {
70-
defaultUsername = getString(session.setup[0], 'result.username');
71-
defaultUserOrgId = getString(session.setup[0], 'result.orgId');
72-
aliasedUsername = getString(session.setup[1], 'result.username');
73-
aliasUserOrgId = getString(session.setup[1], 'result.orgId');
74-
}
80+
aliasedUsername = session.orgs.get('anAlias').username;
81+
aliasUserOrgId = session.orgs.get('anAlias').orgId;
7582
});
7683

7784
after(async () => {

test/nut/commands/force/org/sandbox.sandboxNut.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
88
import { Lifecycle, Messages, SandboxEvents, SandboxProcessObject, StatusEvent } from '@salesforce/core';
9-
import { isArray, AnyJson, ensureString } from '@salesforce/ts-types';
109
import { expect } from 'chai';
1110

1211
Messages.importMessagesDirectory(__dirname);
@@ -19,17 +18,14 @@ describe('Sandbox Orgs', () => {
1918

2019
before(async () => {
2120
session = await TestSession.create({
22-
setupCommands: ['sfdx config:get defaultdevhubusername --json'],
2321
project: { name: 'sandboxCreate' },
2422
});
25-
// get default devhub username
26-
if (isArray<AnyJson>(session.setup)) {
27-
hubOrgUsername = ensureString(
28-
(session.setup[0] as { result: [{ key: string; value: string }] }).result.find(
29-
(config) => config.key === 'defaultdevhubusername'
30-
)?.value
31-
);
32-
}
23+
24+
const hubOrg = execCmd<[{ key: string; value: string }]>('config:get defaultdevhubusername --json', {
25+
cli: 'sfdx',
26+
ensureExitCode: 0,
27+
});
28+
hubOrgUsername = hubOrg.jsonOutput.result[0].value;
3329
});
3430

3531
it('will create a sandbox, verify it can be opened, and then attempt to delete it', async () => {

test/nut/commands/force/org/status.sandboxNut.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { TestSession, execCmd } from '@salesforce/cli-plugins-testkit';
1010
import { expect } from 'chai';
1111
import * as shell from 'shelljs';
1212
import { AuthInfo, Connection, SandboxProcessObject } from '@salesforce/core';
13-
import { isArray, AnyJson, ensureString } from '@salesforce/ts-types';
1413

1514
let session: TestSession;
1615
let sandboxName: string;
@@ -43,19 +42,16 @@ function logoutSandbox(username: string) {
4342
describe('test sandbox status command', () => {
4443
before(async () => {
4544
session = await TestSession.create({
46-
setupCommands: ['sfdx config:get defaultdevhubusername --json'],
4745
project: {
4846
sourceDir: path.join(process.cwd(), 'test', 'nut', 'commands', 'force', 'org'),
4947
},
5048
});
51-
// get default devhub username
52-
if (isArray<AnyJson>(session.setup)) {
53-
hubOrgUsername = ensureString(
54-
(session.setup[0] as { result: [{ key: string; value: string }] }).result.find(
55-
(config) => config.key === 'defaultdevhubusername'
56-
)?.value
57-
);
58-
}
49+
const hubOrg = execCmd<[{ key: string; value: string }]>('config:get defaultdevhubusername --json', {
50+
cli: 'sfdx',
51+
ensureExitCode: 0,
52+
});
53+
hubOrgUsername = hubOrg.jsonOutput.result[0].value;
54+
5955
const queryStr =
6056
"SELECT SandboxName FROM SandboxProcess WHERE Status != 'E' and Status != 'D' ORDER BY CreatedDate DESC LIMIT 1";
6157
const connection = await Connection.create({

yarn.lock

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,12 +1015,12 @@
10151015
mv "~2"
10161016
safe-json-stringify "~1"
10171017

1018-
"@salesforce/cli-plugins-testkit@^2.5.2":
1019-
version "2.5.2"
1020-
resolved "https://registry.yarnpkg.com/@salesforce/cli-plugins-testkit/-/cli-plugins-testkit-2.5.2.tgz#7d066d70b35e7e311346d53ca10c24690ee6aa59"
1021-
integrity sha512-YwHRVVqJP4+YNVm0asjqbFYpT41Fx3F3Em/QkzbUwnDpsDFKoycb6nMNQrLrAocgU4FB1JJ1hlqTLUGGfdd1GA==
1018+
"@salesforce/cli-plugins-testkit@^3.0.3":
1019+
version "3.0.3"
1020+
resolved "https://registry.yarnpkg.com/@salesforce/cli-plugins-testkit/-/cli-plugins-testkit-3.0.3.tgz#1a174653a33c919b19990353c67900507d1c87b3"
1021+
integrity sha512-buXtuKvbO65bwbZSU8o9o135w4eEcel5XwbN/dUnsdBfra64KkVP6uqyFo/HDNsEC5QJ5S8MBwWT/AcQ2L3Dew==
10221022
dependencies:
1023-
"@salesforce/core" "^3.30.8"
1023+
"@salesforce/core" "^3.30.9"
10241024
"@salesforce/kit" "^1.6.1"
10251025
"@salesforce/ts-types" "^1.5.21"
10261026
"@types/shelljs" "^0.8.11"
@@ -1066,6 +1066,29 @@
10661066
jsonwebtoken "8.5.1"
10671067
ts-retry-promise "^0.6.0"
10681068

1069+
"@salesforce/core@^3.30.9":
1070+
version "3.30.9"
1071+
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-3.30.9.tgz#a2a577db60f1276d08b81e185d49161a75b54d76"
1072+
integrity sha512-dZFr2QS0joxl/FgdR+ZYhIVTEsJ7t+u02eaZCXLOqug/rzBq9xFoGPQaBboXx4CSf7k71Ox/Ty0sMSZNzkXb0A==
1073+
dependencies:
1074+
"@salesforce/bunyan" "^2.0.0"
1075+
"@salesforce/kit" "^1.5.41"
1076+
"@salesforce/schemas" "^1.1.0"
1077+
"@salesforce/ts-types" "^1.5.20"
1078+
"@types/graceful-fs" "^4.1.5"
1079+
"@types/semver" "^7.3.9"
1080+
ajv "^8.11.0"
1081+
archiver "^5.3.0"
1082+
change-case "^4.1.2"
1083+
debug "^3.2.7"
1084+
faye "^1.4.0"
1085+
form-data "^4.0.0"
1086+
graceful-fs "^4.2.9"
1087+
js2xmlparser "^4.0.1"
1088+
jsforce beta
1089+
jsonwebtoken "8.5.1"
1090+
ts-retry-promise "^0.6.0"
1091+
10691092
"@salesforce/dev-config@^3.0.0", "@salesforce/dev-config@^3.1.0":
10701093
version "3.1.0"
10711094
resolved "https://registry.yarnpkg.com/@salesforce/dev-config/-/dev-config-3.1.0.tgz#8eb5b35860ff60d1c1dc3fd9329b01a28475d5b9"

0 commit comments

Comments
 (0)