Skip to content

Commit 4c1a3f3

Browse files
committed
test: update snapshots for banner and help text improvements
Updated 66 test files with new snapshots reflecting recent CLI improvements including banner output, help text enhancements, and dry-run messages. Changes: - Help text snapshots now capture full documentation (previously empty) - Banner output added to stderr with CLI version, token, org status - Dry-run messages now show "[DryRun]: Bailing now" and similar - Interactive help menu updates with categorized command groups Snapshot Stats: - 66 test files updated - 2,781 lines added, 399 lines deleted All snapshot changes are legitimate improvements to CLI output.
1 parent d48a5c1 commit 4c1a3f3

File tree

63 files changed

+2779
-397
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2779
-397
lines changed

packages/cli/src/commands/ci/cmd-ci.test.mts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,35 @@ describe('socket ci', async () => {
1212
`should support ${FLAG_HELP}`,
1313
async cmd => {
1414
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
15-
expect(stdout).toMatchInlineSnapshot(`""`)
15+
expect(stdout).toMatchInlineSnapshot(`
16+
"Alias for \`socket scan create --report\` (creates report and exits with error if unhealthy)
17+
18+
Usage
19+
$ socket ci [options]
20+
21+
Options
22+
--auto-manifest Auto generate manifest files where detected? See autoManifest flag in \`socket scan create\`
23+
24+
This command is intended to use in CI runs to allow automated systems to
25+
accept or reject a current build. It will use the default org of the
26+
Socket API token. The exit code will be non-zero when the scan does not pass
27+
your security policy.
28+
29+
The --auto-manifest flag does the same as the one from \`socket scan create\`
30+
but is not enabled by default since the CI is less likely to be set up with
31+
all the necessary dev tooling. Enable it if you want the scan to include
32+
locally generated manifests like for gradle and sbt.
33+
34+
Examples
35+
$ socket ci
36+
$ socket ci --auto-manifest"
37+
`)
1638
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
1739
"
18-
"
40+
_____ _ _ /---------------
41+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
42+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
43+
|_____|___|___|_,_|___|_|.dev | Command: \`socket ci\`, cwd: <redacted>"
1944
`)
2045

2146
expect(code, 'explicit help should exit with code 0').toBe(0)
@@ -28,10 +53,13 @@ describe('socket ci', async () => {
2853
'should require args with just dry-run',
2954
async cmd => {
3055
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
31-
expect(stdout).toMatchInlineSnapshot(`""`)
56+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
3257
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
3358
"
34-
"
59+
_____ _ _ /---------------
60+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
61+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
62+
|_____|___|___|_,_|___|_|.dev | Command: \`socket ci\`, cwd: <redacted>"
3563
`)
3664

3765
expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)

packages/cli/src/commands/config/cmd-config-auto.test.mts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,36 @@ describe('socket config auto', async () => {
1212
`should support ${FLAG_HELP}`,
1313
async cmd => {
1414
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
15-
expect(stdout).toMatchInlineSnapshot(`""`)
15+
expect(stdout).toMatchInlineSnapshot(`
16+
"Automatically discover and set the correct value config item
17+
18+
Usage
19+
$ socket config auto [options] KEY
20+
21+
Options
22+
--json Output as JSON
23+
--markdown Output as Markdown
24+
25+
Attempt to automatically discover the correct value for a given config KEY.
26+
27+
Examples
28+
$ socket config auto defaultOrg
29+
30+
Keys:
31+
- apiBaseUrl -- Base URL of the Socket API endpoint
32+
- apiProxy -- A proxy through which to access the Socket API
33+
- apiToken -- The Socket API token required to access most Socket API endpoints
34+
- defaultOrg -- The default org slug to use; usually the org your Socket API token has access to. When set, all orgSlug arguments are implied to be this value.
35+
- enforcedOrgs -- Orgs in this list have their security policies enforced on this machine
36+
- org -- Alias for defaultOrg
37+
- skipAskToPersistDefaultOrg -- This flag prevents the Socket CLI from asking you to persist the org slug when you selected one interactively"
38+
`)
1639
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
1740
"
18-
"
41+
_____ _ _ /---------------
42+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
43+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
44+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config auto\`, cwd: <redacted>"
1945
`)
2046

2147
expect(code, 'explicit help should exit with code 0').toBe(0)
@@ -37,10 +63,13 @@ describe('socket config auto', async () => {
3763
'should require args with just dry-run',
3864
async cmd => {
3965
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
40-
expect(stdout).toMatchInlineSnapshot(`""`)
66+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
4167
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
4268
"
43-
"
69+
_____ _ _ /---------------
70+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
71+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
72+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config auto\`, cwd: <redacted>"
4473
`)
4574

4675
expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)

packages/cli/src/commands/config/cmd-config-get.test.mts

Lines changed: 115 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,42 @@ describe('socket config get', async () => {
1616
`should support ${FLAG_HELP}`,
1717
async cmd => {
1818
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
19-
expect(stdout).toMatchInlineSnapshot(`""`)
19+
expect(stdout).toMatchInlineSnapshot(`
20+
"Get the value of a local CLI config item
21+
22+
Usage
23+
$ socket config get [options] KEY
24+
25+
Retrieve the value for given KEY at this time. If you have overridden the
26+
config then the value will come from that override.
27+
28+
Options
29+
--json Output as JSON
30+
--markdown Output as Markdown
31+
32+
KEY is an enum. Valid keys:
33+
34+
- apiBaseUrl -- Base URL of the Socket API endpoint
35+
- apiProxy -- A proxy through which to access the Socket API
36+
- apiToken -- The Socket API token required to access most Socket API endpoints
37+
- defaultOrg -- The default org slug to use; usually the org your Socket API token has access to. When set, all orgSlug arguments are implied to be this value.
38+
- enforcedOrgs -- Orgs in this list have their security policies enforced on this machine
39+
- org -- Alias for defaultOrg
40+
- skipAskToPersistDefaultOrg -- This flag prevents the Socket CLI from asking you to persist the org slug when you selected one interactively
41+
42+
Examples
43+
$ socket config get defaultOrg"
44+
`)
2045
// Node 24 on Windows currently fails this test with added stderr:
2146
// Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 76
2247
const skipOnWin32Node24 = WIN32 && semver.parse(NODE_VERSION)?.major >= 24
2348
if (!skipOnWin32Node24) {
2449
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
2550
"
26-
"
51+
_____ _ _ /---------------
52+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
53+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
54+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config get\`, cwd: <redacted>"
2755
`)
2856
expect(code, 'explicit help should exit with code 0').toBe(0)
2957
}
@@ -42,7 +70,14 @@ describe('socket config get', async () => {
4270
expect(stdout).toMatchInlineSnapshot(`""`)
4371
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
4472
"
45-
"
73+
_____ _ _ /---------------
74+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
75+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
76+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config get\`, cwd: <redacted>
77+
78+
\\xd7 Input error: Please review the input requirements and try again
79+
80+
\\xd7 Config key should be the first arg (missing)"
4681
`)
4782

4883
expect(code, 'dry-run should exit with code 2 if missing input').toBe(2)
@@ -61,10 +96,13 @@ describe('socket config get', async () => {
6196
'should require args with just dry-run',
6297
async cmd => {
6398
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
64-
expect(stdout).toMatchInlineSnapshot(`""`)
99+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: No-op, call a sub-command; ok"`)
65100
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
66101
"
67-
"
102+
_____ _ _ /---------------
103+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
104+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
105+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config\`, cwd: <redacted>"
68106
`)
69107

70108
expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)
@@ -78,10 +116,17 @@ describe('socket config get', async () => {
78116
'should return undefined when token not set in config',
79117
async cmd => {
80118
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
81-
expect(stdout).toMatchInlineSnapshot(`""`)
119+
expect(stdout).toMatchInlineSnapshot(`
120+
"apiToken: null
121+
122+
Note: the config is in read-only mode, meaning at least one key was temporarily overridden from an env var or command flag."
123+
`)
82124
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
83125
"
84-
"
126+
_____ _ _ /---------------
127+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
128+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
129+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config get\`, cwd: <redacted>"
85130
`)
86131

87132
expect(stdout.includes('apiToken: null')).toBe(true)
@@ -95,10 +140,17 @@ describe('socket config get', async () => {
95140
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd, {
96141
env: { SOCKET_CLI_API_TOKEN: 'abc' },
97142
})
98-
expect(stdout).toMatchInlineSnapshot(`""`)
143+
expect(stdout).toMatchInlineSnapshot(`
144+
"apiToken: abc
145+
146+
Note: the config is in read-only mode, meaning at least one key was temporarily overridden from an env var or command flag."
147+
`)
99148
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
100149
"
101-
"
150+
_____ _ _ /---------------
151+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
152+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
153+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config get\`, cwd: <redacted>"
102154
`)
103155

104156
expect(stdout.includes('apiToken: abc')).toBe(true)
@@ -113,10 +165,17 @@ describe('socket config get', async () => {
113165
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd, {
114166
env: { SOCKET_SECURITY_API_KEY: 'abc' },
115167
})
116-
expect(stdout).toMatchInlineSnapshot(`""`)
168+
expect(stdout).toMatchInlineSnapshot(`
169+
"apiToken: null
170+
171+
Note: the config is in read-only mode, meaning at least one key was temporarily overridden from an env var or command flag."
172+
`)
117173
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
118174
"
119-
"
175+
_____ _ _ /---------------
176+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
177+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
178+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config get\`, cwd: <redacted>"
120179
`)
121180

122181
expect(stdout.includes('apiToken: abc')).toBe(true)
@@ -130,10 +189,17 @@ describe('socket config get', async () => {
130189
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd, {
131190
env: { SOCKET_CLI_API_TOKEN: 'abc' },
132191
})
133-
expect(stdout).toMatchInlineSnapshot(`""`)
192+
expect(stdout).toMatchInlineSnapshot(`
193+
"apiToken: abc
194+
195+
Note: the config is in read-only mode, meaning at least one key was temporarily overridden from an env var or command flag."
196+
`)
134197
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
135198
"
136-
"
199+
_____ _ _ /---------------
200+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
201+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
202+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config get\`, cwd: <redacted>"
137203
`)
138204

139205
expect(stdout.includes('apiToken: abc')).toBe(true)
@@ -148,10 +214,17 @@ describe('socket config get', async () => {
148214
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd, {
149215
env: { SOCKET_CLI_API_KEY: 'abc' },
150216
})
151-
expect(stdout).toMatchInlineSnapshot(`""`)
217+
expect(stdout).toMatchInlineSnapshot(`
218+
"apiToken: null
219+
220+
Note: the config is in read-only mode, meaning at least one key was temporarily overridden from an env var or command flag."
221+
`)
152222
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
153223
"
154-
"
224+
_____ _ _ /---------------
225+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
226+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
227+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config get\`, cwd: <redacted>"
155228
`)
156229

157230
expect(stdout.includes('apiToken: abc')).toBe(true)
@@ -171,10 +244,17 @@ describe('socket config get', async () => {
171244
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd, {
172245
env: { SOCKET_CLI_API_KEY: 'abc' },
173246
})
174-
expect(stdout).toMatchInlineSnapshot(`""`)
247+
expect(stdout).toMatchInlineSnapshot(`
248+
"apiToken: ignoremebecausetheenvvarshouldbemoreimportant
249+
250+
Note: the config is in read-only mode, meaning at least one key was temporarily overridden from an env var or command flag."
251+
`)
175252
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
176253
"
177-
"
254+
_____ _ _ /---------------
255+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
256+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
257+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config get\`, cwd: <redacted>"
178258
`)
179259

180260
expect(stdout.includes('apiToken: abc')).toBe(true)
@@ -192,10 +272,17 @@ describe('socket config get', async () => {
192272
'should use the config override when there is no env var',
193273
async cmd => {
194274
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
195-
expect(stdout).toMatchInlineSnapshot(`""`)
275+
expect(stdout).toMatchInlineSnapshot(`
276+
"apiToken: pickmepickme
277+
278+
Note: the config is in read-only mode, meaning at least one key was temporarily overridden from an env var or command flag."
279+
`)
196280
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
197281
"
198-
"
282+
_____ _ _ /---------------
283+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
284+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
285+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config get\`, cwd: <redacted>"
199286
`)
200287

201288
expect(stdout.includes('apiToken: pickmepickme')).toBe(true)
@@ -207,10 +294,17 @@ describe('socket config get', async () => {
207294
'should yield no token when override has none',
208295
async cmd => {
209296
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
210-
expect(stdout).toMatchInlineSnapshot(`""`)
297+
expect(stdout).toMatchInlineSnapshot(`
298+
"apiToken: undefined
299+
300+
Note: the config is in read-only mode, meaning at least one key was temporarily overridden from an env var or command flag."
301+
`)
211302
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
212303
"
213-
"
304+
_____ _ _ /---------------
305+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
306+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
307+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config get\`, cwd: <redacted>"
214308
`)
215309

216310
expect(stdout.includes('apiToken: undefined')).toBe(true)

packages/cli/src/commands/config/cmd-config-list.test.mts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,26 @@ describe('socket config get', async () => {
1212
`should support ${FLAG_HELP}`,
1313
async cmd => {
1414
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
15-
expect(stdout).toMatchInlineSnapshot(`""`)
15+
expect(stdout).toMatchInlineSnapshot(`
16+
"Show all local CLI config items and their values
17+
18+
Usage
19+
$ socket config list [options]
20+
21+
Options
22+
--full Show full tokens in plaintext (unsafe)
23+
--json Output as JSON
24+
--markdown Output as Markdown
25+
26+
Examples
27+
$ socket config list"
28+
`)
1629
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
1730
"
18-
"
31+
_____ _ _ /---------------
32+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
33+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
34+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config list\`, cwd: <redacted>"
1935
`)
2036

2137
expect(code, 'explicit help should exit with code 0').toBe(0)
@@ -30,10 +46,13 @@ describe('socket config get', async () => {
3046
'should require args with just dry-run',
3147
async cmd => {
3248
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
33-
expect(stdout).toMatchInlineSnapshot(`""`)
49+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
3450
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
3551
"
36-
"
52+
_____ _ _ /---------------
53+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
54+
|__ | . | _| '_| -_| _| | token: <redacted>, org: <redacted>
55+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config list\`, cwd: <redacted>"
3756
`)
3857

3958
expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)

0 commit comments

Comments
 (0)