Skip to content

Commit eb79fb8

Browse files
authored
Merge pull request #935 from salesforcecli/cd/no-capitalized-record-types
feat: add support for capitalized recordType config
2 parents 8b1fb09 + 927d019 commit eb79fb8

File tree

3 files changed

+102
-11
lines changed

3 files changed

+102
-11
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
88
"@oclif/core": "^3.18.1",
9-
"@salesforce/core": "^6.4.4",
9+
"@salesforce/core": "^6.5.0",
1010
"@salesforce/kit": "^3.0.15",
11-
"@salesforce/sf-plugins-core": "^7.1.3",
11+
"@salesforce/sf-plugins-core": "^7.1.4",
1212
"@salesforce/source-deploy-retrieve": "^10.2.11",
1313
"chalk": "^5.3.0",
1414
"change-case": "^5.4.2",

test/nut/scratchCreate.nut.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import fs from 'node:fs';
88
import path from 'node:path';
99

10+
import { parseJsonMap } from '@salesforce/kit';
1011
import { execCmd, genUniqueString, TestSession } from '@salesforce/cli-plugins-testkit';
1112
import { assert, expect } from 'chai';
1213
import { AuthFields, Messages, Global, StateAggregator } from '@salesforce/core';
@@ -64,6 +65,96 @@ describe('env create scratch NUTs', () => {
6465
describe('successes', () => {
6566
const keys = ['username', 'orgId', 'scratchOrgInfo', 'authFields', 'warnings'];
6667

68+
it('creates an org with capitalized record types if no config var is set', async () => {
69+
const scratchDefJson = parseJsonMap(
70+
await fs.promises.readFile(path.join(session.project.dir, 'config', 'project-scratch-def.json'), 'utf8')
71+
);
72+
scratchDefJson.objectSettings = {
73+
case: {
74+
defaultRecordType: 'Svc_Technical_Support',
75+
},
76+
};
77+
78+
// NOTE: remove this once it starts capitalizing record types by default.
79+
// we are unsetting it here to ensure the warning from sfdx-core is emitted.
80+
await execCmd('config unset org-capitalize-record-types', {
81+
async: true,
82+
cli: 'sf',
83+
ensureExitCode: 0,
84+
});
85+
86+
await fs.promises.writeFile(
87+
path.join(session.project.dir, 'config', 'project-scratch-def-1.json'),
88+
JSON.stringify(scratchDefJson),
89+
'utf-8'
90+
);
91+
92+
const jsonOutput = execCmd<ScratchCreateResponse>(
93+
'org create scratch -d -f config/project-scratch-def-1.json -a dreamhouse --duration-days 1 --json',
94+
{
95+
ensureExitCode: 0,
96+
}
97+
).jsonOutput;
98+
99+
const noConfigVarWarning =
100+
'Record types defined in the scratch org definition file will stop being capitalized by default in a future release.\nSet the `org-capitalize-record-types` config var to `true` to enforce capitalization.';
101+
102+
expect(jsonOutput?.warnings[0] === noConfigVarWarning);
103+
104+
const username = jsonOutput?.result.username;
105+
106+
const recordTypes = execCmd<{ recordTypeInfos: Array<{ name: string }> }>(
107+
`sobject describe --sobject Case --target-org ${username}`,
108+
{
109+
cli: 'sf',
110+
ensureExitCode: 0,
111+
}
112+
).jsonOutput?.result.recordTypeInfos;
113+
114+
expect(recordTypes?.find((rt) => rt.name === 'Svc_Technical_Support'));
115+
});
116+
it('creates an org without capitalized record types', async () => {
117+
const scratchDefJson = parseJsonMap(
118+
await fs.promises.readFile(path.join(session.project.dir, 'config', 'project-scratch-def.json'), 'utf8')
119+
);
120+
scratchDefJson.objectSettings = {
121+
case: {
122+
defaultRecordType: 'Svc_Technical_Support',
123+
},
124+
};
125+
126+
// NOTE: remove this once it starts capitalizing record types by default.
127+
await execCmd('config set org-capitalize-record-types=false', {
128+
async: true,
129+
cli: 'sf',
130+
ensureExitCode: 0,
131+
});
132+
133+
await fs.promises.writeFile(
134+
path.join(session.project.dir, 'config', 'project-scratch-def-1.json'),
135+
JSON.stringify(scratchDefJson),
136+
'utf-8'
137+
);
138+
139+
const jsonOutput = execCmd<ScratchCreateResponse>(
140+
'org create scratch -d -f config/project-scratch-def-1.json -a dreamhouse --duration-days 1 --json',
141+
{
142+
ensureExitCode: 0,
143+
}
144+
).jsonOutput;
145+
146+
const username = jsonOutput?.result.username;
147+
148+
const recordTypes = execCmd<{ recordTypeInfos: Array<{ name: string }> }>(
149+
`sobject describe --sobject Case --target-org ${username}`,
150+
{
151+
cli: 'sf',
152+
ensureExitCode: 0,
153+
}
154+
).jsonOutput?.result.recordTypeInfos;
155+
156+
expect(recordTypes?.find((rt) => rt.name === 'svc_Technical_Support'));
157+
});
67158
it('creates an org from edition flag only and sets tracking to true by default', async () => {
68159
const resp = execCmd<ScratchCreateResponse>('env:create:scratch --edition developer --json --wait 60', {
69160
ensureExitCode: 0,

yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -996,10 +996,10 @@
996996
strip-ansi "6.0.1"
997997
ts-retry-promise "^0.8.0"
998998

999-
"@salesforce/core@^6.4.1", "@salesforce/core@^6.4.4", "@salesforce/core@^6.4.7":
1000-
version "6.4.7"
1001-
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-6.4.7.tgz#f15538380aa5c75de697d3c95a2ddbdabae69dbb"
1002-
integrity sha512-gebjw2xC8Z0gqS3lYRQWz7J+PuGZtybotrnnaJbnzzxdfpBFIp6PjW4nt/235BQW9UWFTLaQh+AwkFgmMTTSkA==
999+
"@salesforce/core@^6.4.1", "@salesforce/core@^6.4.7", "@salesforce/core@^6.5.0":
1000+
version "6.5.0"
1001+
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-6.5.0.tgz#a59666270ee3e135520a29d83211685d56443070"
1002+
integrity sha512-6IwPSvqglX4nUQuIvU5wBX64XS+JxRbxtGLEom/MoAD9QwNXmtU/ZGD/iOvvqV30BL7hzX/xVlJX+cGHsiYg5A==
10031003
dependencies:
10041004
"@salesforce/kit" "^3.0.15"
10051005
"@salesforce/schemas" "^1.6.1"
@@ -1102,15 +1102,15 @@
11021102
chalk "^4"
11031103
inquirer "^8.2.5"
11041104

1105-
"@salesforce/sf-plugins-core@^7.1.3":
1106-
version "7.1.3"
1107-
resolved "https://registry.yarnpkg.com/@salesforce/sf-plugins-core/-/sf-plugins-core-7.1.3.tgz#2d1a15da9e5ebbee435f8699f13cc9aa787df1ca"
1108-
integrity sha512-HaXEjtose1SOgxXsRYl3HA0f6OYIJTUqS1fGdIKgLZQR8tC3a/BnfDUuJRTjesp+GJZEjc6bUxzd92sn51AuGA==
1105+
"@salesforce/sf-plugins-core@^7.1.4":
1106+
version "7.1.4"
1107+
resolved "https://registry.yarnpkg.com/@salesforce/sf-plugins-core/-/sf-plugins-core-7.1.4.tgz#0aca0e243b9880269c3e2712ca14982eb8515f1e"
1108+
integrity sha512-aFV4FhUEz/oyn7JzsoutQp7SBs0Ac07m5uWYI+ngYlhJdd/AC/0IpMqd/BOIBmLzAqos+y6bKR6OqBEqQDaxlw==
11091109
dependencies:
11101110
"@inquirer/confirm" "^2.0.15"
11111111
"@inquirer/password" "^1.1.14"
11121112
"@oclif/core" "^3.18.1"
1113-
"@salesforce/core" "^6.4.7"
1113+
"@salesforce/core" "^6.5.0"
11141114
"@salesforce/kit" "^3.0.15"
11151115
"@salesforce/ts-types" "^2.0.9"
11161116
chalk "^5.3.0"

0 commit comments

Comments
 (0)