Skip to content

test(verify): cover adapter robustness against transport failures - #4

Merged
andreuSignes merged 1 commit into
mainfrom
verify/1782680160
Jun 28, 2026
Merged

andreuSignes merged 1 commit into
mainfrom
verify/1782680160

Conversation

@andreuSignes

Copy link
Copy Markdown
Owner

Adds unit tests proving SolplanetCgiAdapter.read() NEVER rejects and always resolves to an offline InverterState when the CGI transport fails (4xx, 5xx, timeout, JSON parse error, non-numeric fields).

Covers the spec scenarios in inverter-adapter-interface.md and solplanet-cgi-adapter.md that were previously asserted only by static inspection. Uses nock (already a devDependency) to intercept the HTTP socket.

This PR exists to exercise CI on the verify/ branch — it will be merged to main if all checks pass, then the orchestrator proceeds to sdd-archive.

Adds unit tests proving SolplanetCgiAdapter.read() NEVER rejects and
always resolves to an offline InverterState when the CGI transport
fails. Covers the spec scenarios in inverter-adapter-interface.md
and solplanet-cgi-adapter.md that were previously asserted only by
static inspection.

The tests use nock (already a devDependency, but never imported) to
intercept the HTTP socket. A real axios instance is injected via a
thin HttpService stub so nock actually sees the request.

Test breakdown:
  - HTTP 502, 404          -> offline state, identity preserved
  - JSON parse error       -> offline state
  - Connection refused     -> offline state
  - Adapter timeout        -> offline state (rxjs timeout fires)
  - Non-numeric fields     -> coerced to 0; STATE='FAULT' -> St=7
  - E-Total vs WH          -> E-Total wins when both present
  - toFiniteNumber + mapOperatingState helpers (table-driven)
@andreuSignes
andreuSignes merged commit 0f16b81 into main Jun 28, 2026
2 checks passed
@andreuSignes
andreuSignes deleted the verify/1782680160 branch June 28, 2026 21:01
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.

1 participant