Skip to content

Commit 95be212

Browse files
reggiCopilot
andcommitted
fix: access JSON output under package name key in stage tests
The logTar utility wraps JSON output under the package name key, so tests need to access out[pkg] instead of out directly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f78cf33 commit 95be212

6 files changed

Lines changed: 116 additions & 45 deletions

File tree

smoke-tests/tap-snapshots/test/index.js.test.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ All commands:
2727
init, install, install-ci-test, install-test, link, ll,
2828
login, logout, ls, org, outdated, owner, pack, ping, pkg,
2929
prefix, profile, prune, publish, query, rebuild, repo,
30-
restart, root, run, sbom, search, set, shrinkwrap, start,
30+
restart, root, run, sbom, search, set, shrinkwrap, stage, start,
3131
stop, team, test, token, trust, undeprecate, uninstall,
3232
unpublish, update, version, view, whoami
3333
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* IMPORTANT
2+
* This snapshot file is auto-generated, but designed for humans.
3+
* It should be checked into source control and tracked carefully.
4+
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
5+
* Make sure to inspect the output below. Do not ignore changes!
6+
*/
7+
'use strict'
8+
exports[`smoke-tests/test/index.js TAP basic npm (no args) > should have expected no args output 1`] = `
9+
10+
`
11+
12+
exports[`smoke-tests/test/index.js TAP basic npm outdated > should have expected outdated output 1`] = `
13+
14+
`

tap-snapshots/test/lib/commands/publish.js.test.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ Object {
205205
"man/man1/npm-search.1",
206206
"man/man1/npm-set.1",
207207
"man/man1/npm-shrinkwrap.1",
208+
"man/man1/npm-stage.1",
208209
"man/man1/npm-start.1",
209210
"man/man1/npm-stop.1",
210211
"man/man1/npm-team.1",
@@ -256,7 +257,7 @@ exports[`test/lib/commands/publish.js TAP no auth dry-run > must match snapshot
256257

257258
exports[`test/lib/commands/publish.js TAP no auth dry-run > warns about auth being needed 1`] = `
258259
Array [
259-
"This command requires you to be logged in to https://registry.npmjs.org/ (dry-run)",
260+
"publish This command requires you to be logged in to https://registry.npmjs.org/ (dry-run)",
260261
]
261262
`
262263

tap-snapshots/test/lib/docs.js.test.cjs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ Array [
147147
"search",
148148
"set",
149149
"shrinkwrap",
150+
"stage",
150151
"start",
151152
"stop",
152153
"team",
@@ -5487,6 +5488,61 @@ Note: This command is unaware of workspaces.
54875488
NO PARAMS
54885489
`
54895490

5491+
exports[`test/lib/docs.js TAP usage stage > must match snapshot 1`] = `
5492+
Stage packages for publishing, deferring proof-of-presence (2FA) to a later point in time
5493+
5494+
Usage:
5495+
npm stage
5496+
npm stage publish <package-spec>
5497+
npm stage list [<package-spec>]
5498+
npm stage view <stage-id>
5499+
npm stage approve <stage-id>
5500+
npm stage reject <stage-id>
5501+
npm stage download <stage-id>
5502+
5503+
Subcommands:
5504+
publish
5505+
Stage a package for publishing, deferring proof-of-presence (2FA) to a later point in time
5506+
5507+
list
5508+
List all staged package versions
5509+
5510+
view
5511+
View details of a specific staged package
5512+
5513+
approve
5514+
Approve a staged package, publishing it to the npm registry
5515+
5516+
reject
5517+
Reject a staged package, removing it from the registry
5518+
5519+
download
5520+
Download the tarball of a staged package for inspection
5521+
5522+
Run "npm stage <subcommand> --help" for more info on a subcommand.
5523+
5524+
Run "npm help stage" for more info
5525+
5526+
\`\`\`bash
5527+
npm stage
5528+
\`\`\`
5529+
5530+
Note: This command is unaware of workspaces.
5531+
5532+
#### Synopsis
5533+
#### Flags
5534+
#### Synopsis
5535+
#### Flags
5536+
#### Synopsis
5537+
#### Flags
5538+
#### Synopsis
5539+
#### Flags
5540+
#### Synopsis
5541+
#### Flags
5542+
#### Synopsis
5543+
#### Flags
5544+
`
5545+
54905546
exports[`test/lib/docs.js TAP usage start > must match snapshot 1`] = `
54915547
Start a package
54925548

tap-snapshots/test/lib/npm.js.test.cjs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ All commands:
3737
init, install, install-ci-test, install-test, link, ll,
3838
login, logout, ls, org, outdated, owner, pack, ping, pkg,
3939
prefix, profile, prune, publish, query, rebuild, repo,
40-
restart, root, run, sbom, search, set, shrinkwrap, start,
41-
stop, team, test, token, trust, undeprecate, uninstall,
42-
unpublish, update, version, view, whoami
40+
restart, root, run, sbom, search, set, shrinkwrap, stage,
41+
start, stop, team, test, token, trust, undeprecate,
42+
uninstall, unpublish, update, version, view, whoami
4343
4444
Specify configs in the ini-formatted file:
4545
{USERCONFIG}
@@ -86,12 +86,12 @@ All commands:
8686
query, rebuild, repo,
8787
restart, root, run,
8888
sbom, search, set,
89-
shrinkwrap, start, stop,
90-
team, test, token,
91-
trust, undeprecate,
92-
uninstall, unpublish,
93-
update, version, view,
94-
whoami
89+
shrinkwrap, stage,
90+
start, stop, team, test,
91+
token, trust,
92+
undeprecate, uninstall,
93+
unpublish, update,
94+
version, view, whoami
9595
9696
Specify configs in the ini-formatted file:
9797
{USERCONFIG}
@@ -138,12 +138,12 @@ All commands:
138138
query, rebuild, repo,
139139
restart, root, run,
140140
sbom, search, set,
141-
shrinkwrap, start, stop,
142-
team, test, token,
143-
trust, undeprecate,
144-
uninstall, unpublish,
145-
update, version, view,
146-
whoami
141+
shrinkwrap, stage,
142+
start, stop, team, test,
143+
token, trust,
144+
undeprecate, uninstall,
145+
unpublish, update,
146+
version, view, whoami
147147
148148
Specify configs in the ini-formatted file:
149149
{USERCONFIG}
@@ -177,9 +177,9 @@ All commands:
177177
init, install, install-ci-test, install-test, link, ll,
178178
login, logout, ls, org, outdated, owner, pack, ping, pkg,
179179
prefix, profile, prune, publish, query, rebuild, repo,
180-
restart, root, run, sbom, search, set, shrinkwrap, start,
181-
stop, team, test, token, trust, undeprecate, uninstall,
182-
unpublish, update, version, view, whoami
180+
restart, root, run, sbom, search, set, shrinkwrap, stage,
181+
start, stop, team, test, token, trust, undeprecate,
182+
uninstall, unpublish, update, version, view, whoami
183183
184184
Specify configs in the ini-formatted file:
185185
{USERCONFIG}
@@ -226,12 +226,12 @@ All commands:
226226
query, rebuild, repo,
227227
restart, root, run,
228228
sbom, search, set,
229-
shrinkwrap, start, stop,
230-
team, test, token,
231-
trust, undeprecate,
232-
uninstall, unpublish,
233-
update, version, view,
234-
whoami
229+
shrinkwrap, stage,
230+
start, stop, team, test,
231+
token, trust,
232+
undeprecate, uninstall,
233+
unpublish, update,
234+
version, view, whoami
235235
236236
Specify configs in the ini-formatted file:
237237
{USERCONFIG}
@@ -278,12 +278,12 @@ All commands:
278278
query, rebuild, repo,
279279
restart, root, run,
280280
sbom, search, set,
281-
shrinkwrap, start, stop,
282-
team, test, token,
283-
trust, undeprecate,
284-
uninstall, unpublish,
285-
update, version, view,
286-
whoami
281+
shrinkwrap, stage,
282+
start, stop, team, test,
283+
token, trust,
284+
undeprecate, uninstall,
285+
unpublish, update,
286+
version, view, whoami
287287
288288
Specify configs in the ini-formatted file:
289289
{USERCONFIG}
@@ -329,8 +329,8 @@ All commands:
329329
query, rebuild, repo,
330330
restart, root, run, sbom,
331331
search, set, shrinkwrap,
332-
start, stop, team, test,
333-
token, trust,
332+
stage, start, stop, team,
333+
test, token, trust,
334334
undeprecate, uninstall,
335335
unpublish, update,
336336
version, view, whoami
@@ -368,7 +368,7 @@ All commands:
368368
link, ll, login, logout, ls, org, outdated, owner, pack,
369369
ping, pkg, prefix, profile, prune, publish, query, rebuild,
370370
repo, restart, root, run, sbom, search, set, shrinkwrap,
371-
start, stop, team, test, token, trust, undeprecate,
371+
stage, start, stop, team, test, token, trust, undeprecate,
372372
uninstall, unpublish, update, version, view, whoami
373373
374374
Specify configs in the ini-formatted file:
@@ -403,9 +403,9 @@ All commands:
403403
init, install, install-ci-test, install-test, link, ll,
404404
login, logout, ls, org, outdated, owner, pack, ping, pkg,
405405
prefix, profile, prune, publish, query, rebuild, repo,
406-
restart, root, run, sbom, search, set, shrinkwrap, start,
407-
stop, team, test, token, trust, undeprecate, uninstall,
408-
unpublish, update, version, view, whoami
406+
restart, root, run, sbom, search, set, shrinkwrap, stage,
407+
start, stop, team, test, token, trust, undeprecate,
408+
uninstall, unpublish, update, version, view, whoami
409409
410410
Specify configs in the ini-formatted file:
411411
{USERCONFIG}
@@ -439,9 +439,9 @@ All commands:
439439
init, install, install-ci-test, install-test, link, ll,
440440
login, logout, ls, org, outdated, owner, pack, ping, pkg,
441441
prefix, profile, prune, publish, query, rebuild, repo,
442-
restart, root, run, sbom, search, set, shrinkwrap, start,
443-
stop, team, test, token, trust, undeprecate, uninstall,
444-
unpublish, update, version, view, whoami
442+
restart, root, run, sbom, search, set, shrinkwrap, stage,
443+
start, stop, team, test, token, trust, undeprecate,
444+
uninstall, unpublish, update, version, view, whoami
445445
446446
Specify configs in the ini-formatted file:
447447
{USERCONFIG}

test/lib/commands/stage/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ t.test('stages with --json', async t => {
5858
registry.nock.post('/-/stage/package/@npmcli%2ftest-package').reply(201, {})
5959
await npm.exec('stage', ['publish'])
6060
const out = JSON.parse(joinedOutput())
61-
t.equal(out.name, pkg)
62-
t.equal(out.version, '1.0.0')
61+
t.equal(out[pkg].name, pkg)
62+
t.equal(out[pkg].version, '1.0.0')
6363
})
6464

6565
t.test('stages with --json includes stageId', async t => {
@@ -78,8 +78,8 @@ t.test('stages with --json includes stageId', async t => {
7878
registry.nock.post('/-/stage/package/@npmcli%2ftest-package').reply(201, { stageId })
7979
await npm.exec('stage', ['publish'])
8080
const out = JSON.parse(joinedOutput())
81-
t.equal(out.name, pkg)
82-
t.equal(out.stageId, stageId)
81+
t.equal(out[pkg].name, pkg)
82+
t.equal(out[pkg].stageId, stageId)
8383
})
8484

8585
t.test('throws on invalid semver tag', async t => {

0 commit comments

Comments
 (0)