Skip to content

Commit 8e1cecf

Browse files
authored
fix: run test chains that never executed and await runUpdate in update (#731)
1 parent 34d7517 commit 8e1cecf

9 files changed

Lines changed: 505 additions & 798 deletions

File tree

‎package-lock.json‎

Lines changed: 5 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@oclif/plugin-not-found": "^3.2.73",
3636
"@oclif/plugin-update": "3.2.4",
3737
"@oclif/plugin-version": "^2.2.36",
38-
"@oclif/table": "^0.5.8",
38+
"@oclif/table": "0.5.4",
3939
"@octokit/rest": "^22.0.0",
4040
"archiver": "^8.0.0",
4141
"box-node-sdk": "^4.11.1",

‎src/commands/login.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ OAuthLoginCommand.flags = {
531531

532532
module.exports = OAuthLoginCommand;
533533
module.exports._test = {
534+
SUPPORTED_DEFAULT_APP_PORTS,
534535
promptForAuthMethod,
535536
promptForPlatformAppCredentials,
536537
setOAuthCallbackTimeoutMs(timeoutMs) {

‎src/commands/update.js‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ const UpdateCommand =
77

88
class GithubUpdatecommand extends UpdateCommand {
99
async run() {
10-
const { printTable } = await import('@oclif/table');
11-
const { flags } = await this.parse(UpdateCommand);
10+
const { flags } = await this.parse(GithubUpdatecommand);
1211
const updater = new GitHubUpdater(this.config);
1312
if (flags.available) {
13+
// @oclif/table is pinned to 0.5.4: later versions depend on string-width@8,
14+
// which requires Node 20 and fails to load on Node 18.
15+
const { printTable } = await import('@oclif/table');
1416
const index = await updater.fetchVersionIndex();
1517
const allVersions = sort(Object.keys(index)).reverse();
1618
const localVersions = await updater.findLocalVersions();
@@ -30,7 +32,7 @@ class GithubUpdatecommand extends UpdateCommand {
3032
return;
3133
}
3234

33-
updater.runUpdate({
35+
await updater.runUpdate({
3436
autoUpdate: flags.autoupdate,
3537
force: flags.force,
3638
version: flags.interactive

‎test/commands/configure-environments.test.js‎

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('Configure environments masking', function () {
3030
sandbox.restore();
3131
});
3232

33-
it('configure:environments:get should not print raw client secrets', function () {
33+
test.do(() => {
3434
getEnvironmentsStub.resolves({
3535
default: 'dev',
3636
environments: {
@@ -40,18 +40,18 @@ describe('Configure environments masking', function () {
4040
},
4141
},
4242
});
43-
44-
return test
45-
.stub(BoxCommand.prototype, 'getEnvironments', getEnvironmentsStub)
46-
.stdout()
47-
.command(['configure:environments:get'])
48-
.it('masks clientSecret in output', (ctx) => {
43+
})
44+
.stdout()
45+
.command(['configure:environments:get'])
46+
.it(
47+
'configure:environments:get should not print raw client secrets',
48+
(ctx) => {
4949
assert.notInclude(ctx.stdout, RAW_SECRET);
5050
assert.include(ctx.stdout, MASKED_SECRET);
51-
});
52-
});
51+
}
52+
);
5353

54-
it('configure:environments:update should not print raw client secrets', function () {
54+
test.do(() => {
5555
getEnvironmentsStub.resolves({
5656
default: 'dev',
5757
environments: {
@@ -61,19 +61,14 @@ describe('Configure environments masking', function () {
6161
},
6262
},
6363
});
64-
65-
return test
66-
.stub(BoxCommand.prototype, 'getEnvironments', getEnvironmentsStub)
67-
.stub(
68-
BoxCommand.prototype,
69-
'updateEnvironments',
70-
updateEnvironmentsStub
71-
)
72-
.stdout()
73-
.command(['configure:environments:update'])
74-
.it('masks clientSecret in output', (ctx) => {
64+
})
65+
.stdout()
66+
.command(['configure:environments:update'])
67+
.it(
68+
'configure:environments:update should not print raw client secrets',
69+
(ctx) => {
7570
assert.notInclude(ctx.stdout, RAW_SECRET);
7671
assert.include(ctx.stdout, MASKED_SECRET);
77-
});
78-
});
72+
}
73+
);
7974
});

‎test/commands/hubs.test.js‎

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -421,22 +421,23 @@ describe('Hubs', function () {
421421
assert.deepEqual(JSON.parse(context.stdout), response);
422422
});
423423

424-
it('rejects unsupported hub collaboration roles on create', async function () {
425-
return test
426-
.command([
427-
'hubs:collaborations:create',
428-
'12345',
429-
'--role=owner',
430-
'--user-id=22222',
431-
'--token=test',
432-
])
433-
.catch((error) => {
424+
test.stderr()
425+
.command([
426+
'hubs:collaborations:create',
427+
'12345',
428+
'--role=owner',
429+
'--user-id=22222',
430+
'--token=test',
431+
])
432+
.it(
433+
'rejects unsupported hub collaboration roles on create',
434+
(context) => {
434435
assert.include(
435-
error.message,
436+
context.stderr,
436437
'Expected --role=owner to be one of: editor, viewer, co-owner'
437438
);
438-
});
439-
});
439+
}
440+
);
440441
});
441442

442443
describe('hubs:collaborations:get', function () {
@@ -483,21 +484,22 @@ describe('Hubs', function () {
483484
assert.deepEqual(JSON.parse(context.stdout), response);
484485
});
485486

486-
it('rejects unsupported hub collaboration roles on update', async function () {
487-
return test
488-
.command([
489-
'hubs:collaborations:update',
490-
'99999',
491-
'--role=owner',
492-
'--token=test',
493-
])
494-
.catch((error) => {
487+
test.stderr()
488+
.command([
489+
'hubs:collaborations:update',
490+
'99999',
491+
'--role=owner',
492+
'--token=test',
493+
])
494+
.it(
495+
'rejects unsupported hub collaboration roles on update',
496+
(context) => {
495497
assert.include(
496-
error.message,
498+
context.stderr,
497499
'Expected --role=owner to be one of: editor, viewer, co-owner'
498500
);
499-
});
500-
});
501+
}
502+
);
501503
});
502504

503505
describe('hubs:collaborations:delete', function () {

0 commit comments

Comments
 (0)