Skip to content

[Feature] Add unit tests for NetworkInspectorServer internal logic #2694

@ConnorQi01

Description

@ConnorQi01

Summary

NetworkInspectorServer still has no direct unit test coverage on origin/master. Its internal logic - certificate exchange medium resolution, device connection mapping, async client initialization, and start/stop error propagation - is currently exercised only through integration paths or adjacent command/manager tests.

This issue supersedes #2702.

Current coverage already in place

Those cover the command and manager portions originally mentioned here. The remaining gap is server-level coverage for src/extension/networkInspector/networkInspectorServer.ts.

Suggested scope

  • Add test/extension/networkInspector/networkInspectorServer.test.ts using sinon + proxyquire, matching existing test style.
  • Cover transformCertificateExchangeMediumToType for medium values 1, 2, and unknown/undefined fallback.
  • Cover start() failure propagation when secure server config or server startup fails.
  • Cover addConnection / removeConnection map management, including the async client.init() lifecycle where the client is returned before initialization completes and then inserted into connections.
  • Cover disconnection during initialization so the lifecycle behavior is explicit and regression-tested.

Evidence

  • origin/master contains test/extension/networkInspector/networkInspectorManager.test.ts and test/extension/networkInspector/startStopCommands.test.ts.
  • origin/master does not contain test/extension/networkInspector/networkInspectorServer.test.ts.
  • src/extension/networkInspector/networkInspectorServer.ts still contains untested branches around transformCertificateExchangeMediumToType, initialisePromise, addConnection, and removeConnection.

Validation

  • npm test should include the new server test file and pass.
  • Server tests should run without a live device or real network inspector connection.

Closes #2702

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions