Skip to content

[Feature] Add unit tests for OpenRNUpgradeHelper command #2800

Description

@ConnorQi01

Summary

The OpenRNUpgradeHelper command (src/extension/commands/openRNUpgradeHelper.ts) has no unit tests. It presents a QuickPick with three platform choices (React Native, React Native Windows, React Native MacOS) and opens the corresponding URL via vscode.env.openExternal. The cancellation path (user dismisses the QuickPick) silently returns without opening any URL.

Why this is useful

All four execution paths are untested. Given that the QuickPick cancellation path has historically caused issues in similar commands (e.g. StopLogCatMonitor), having explicit coverage here reduces regression risk and keeps the command test suite consistent with the rest of the codebase.

Suggested scope

  • Add test/extension/commands/openRNUpgradeHelper.test.ts following the proxyquire pattern used in startPackager.test.ts and stopLogCatMonitor.test.ts
  • Cover: "React Native" selected → correct RN URL passed to openExternal
  • Cover: "React Native Windows" selected → correct RNW URL passed to openExternal
  • Cover: "React Native MacOS" selected → correct RNM URL passed to openExternal
  • Cover: QuickPick cancelled (returns undefined) → openExternal never called

Evidence

  • src/extension/commands/openRNUpgradeHelper.ts — four distinct code paths, all currently uncovered
  • test/extension/commands/stopLogCatMonitor.test.ts — reference pattern for stubbing vscode.window.showQuickPick and vscode.env.openExternal
  • Recent trend of focused per-command test PRs: restartPackager, stopLogCatMonitor, prebuildClean, setNewArch, enableHermes, enableExpoHermes

Validation

  • Run npm test / gulp test-unit and confirm all four new test cases pass
  • Confirm openExternal is not called in the cancellation test case

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions