Skip to content

fix: run test chains that never executed and await runUpdate in udate - #731

Open
arjankowski wants to merge 2 commits into
mainfrom
fix-tests-that-never-run
Open

arjankowski wants to merge 2 commits into
mainfrom
fix-tests-that-never-run

Conversation

@arjankowski

@arjankowski arjankowski commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

42 @oclif/test chains were nested inside mocha it blocks (via await or return) or had no .it(), so they were never scheduled and passed regardless of the code. Move them directly under describe, configure stubs in .do(), and fix assertions that surfaced once they ran:

  • read stderr instead of stdout for messages printed with this.info and errors handled by BoxCommand.catch
  • use a port supported by the Official Box CLI app in the login fallback test
  • accept unset autoUpdate/force flags as falsy in update tests
  • drop update channel tests; channel support was removed from the command

The re-enabled update tests exposed two bugs in the update command:

  • runUpdate was not awaited, so a failed update surfaced as an unhandled promise rejection instead of going through oclif's error handling
  • box update crashed on Node 18 with SyntaxError: Invalid regular expression flags: @oclif/table >= 0.5.5 depends on string-width@8, which requires Node 20. Pin @oclif/table to 0.5.4 and import it only for --available.

@arjankowski
arjankowski requested a review from a team October 23, 2026 10:57
@arjankowski
arjankowski force-pushed the fix-tests-that-never-run branch from f2ab91c to d9e7cfc Compare October 23, 2026 11:19
@socket-security

socket-security Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​oclif/​table@​0.5.9 ⏵ 0.5.499 +110010090100

View full report

@coveralls

coveralls commented Oct 23, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 39964600876

Coverage increased (+2.1%) to 87.047%

Details

  • Coverage increased (+2.1%) from the base build.
  • Patch coverage: 3 of 3 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 6061
Covered Lines: 5499
Line Coverage: 90.73%
Relevant Branches: 2153
Covered Branches: 1651
Branch Coverage: 76.68%
Branches in Coverage %: Yes
Coverage Strength: 645.6 hits per line

💛 - Coveralls

Comment thread src/commands/update.js Outdated
class GithubUpdatecommand extends UpdateCommand {
async run() {
const { printTable } = await import('@oclif/table');
const { flags } = await this.parse(UpdateCommand);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.parse(UpdateCommand) still uses the parent arg schema from @oclif/plugin-update, which accepts an optional channel. box update stable therefore parses, then runUpdate is called without that channel. GithubUpdatecommand.args = [] only changes the help text. Parse GithubUpdatecommand so a positional channel is rejected as an unexpected argument.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread test/commands/login.test.js Outdated
'--default-box-app',
'--code',
'--port',
'4000',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--code still reaches app.listen. This test binds port 4000, which is often already taken locally, and then fails before it can see Please open. The other callback tests in this file use high ports. Walk SUPPORTED_DEFAULT_APP_PORTS and bind the first free port.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread package.json
"@oclif/plugin-update": "3.2.4",
"@oclif/plugin-version": "^2.2.36",
"@oclif/table": "^0.5.8",
"@oclif/table": "0.5.4",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oclif/table is pinned to 0.5.4 with no note in the repo. A later bump to ^0.5.x pulls string-width@8, which throws SyntaxError: Invalid regular expression flags on Node 18 when box update --available loads the table. Maybe we should document this? Here or where the import is defined src/commands/update.js:13.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

42 `@oclif/test` chains were nested inside mocha `it` blocks (via `await`
or `return`) or had no `.it()`, so they were never scheduled and passed
regardless of the code. Move them directly under `describe`, configure
stubs in `.do()`, and fix assertions that surfaced once they ran:

- read `stderr` instead of `stdout` for messages printed with `this.info`
  and errors handled by `BoxCommand.catch`
- use a port supported by the Official Box CLI app in the login fallback test
- accept unset `autoUpdate`/`force` flags as falsy in update tests
- drop update channel tests; channel support was removed from the command

The re-enabled update tests exposed two bugs in the `update` command:

- `runUpdate` was not awaited, so a failed update surfaced as an unhandled
  promise rejection instead of going through oclif's error handling
- `box update` crashed on Node 18 with `SyntaxError: Invalid regular
  expression flags`: `@oclif/table` >= 0.5.5 depends on `string-width@8`,
  which requires Node 20. Pin `@oclif/table` to 0.5.4 and import it only
  for `--available`.
…n test

- parse `GithubUpdatecommand` instead of the plugin's `UpdateCommand`, so
  `box update stable` fails with "Unexpected argument" instead of silently
  ignoring the channel
- bind the first free port from `SUPPORTED_DEFAULT_APP_PORTS` in the
  `--code` login test instead of hardcoding 4000
- document why `@oclif/table` is pinned to 0.5.4
@arjankowski
arjankowski force-pushed the fix-tests-that-never-run branch from aaec1b7 to f2c1a23 Compare October 23, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants