]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
test(ui-common): cover buildStatusNotificationPayload 1.6/2.0.x branches (#1834)...
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 15 Jun 2026 19:34:42 +0000 (21:34 +0200)
committerGitHub <noreply@github.com>
Mon, 15 Jun 2026 19:34:42 +0000 (21:34 +0200)
commitf9e8ddfabec327b1ef2d0b76652fed9b1f334408
tree6f920b631f4edbbfe83e4962af59b6e1e2555ec7
parent225159487916788c59a9276f474826ccdcb372e1
test(ui-common): cover buildStatusNotificationPayload 1.6/2.0.x branches (#1834) (#1904)

* test(ui-common): cover buildStatusNotificationPayload 1.6/2.0.x branches (#1834)

Audit pass over the describe('buildStatusNotificationPayload') block
added by PR #1902. Adds the only two production-callsite-tied cases the
existing 9 tests miss. No production code change.

T2.1 — OCPP 1.6 with errorCode and evseId together:
- Tied to ui/cli/src/commands/ocpp.ts:191-203 (1.6 requires --error-code,
  passes evseId) and ui/web/src/skins/classic/components/charging-stations
  /CSConnector.vue:172-173 (selectedErrorCode defaults to NO_ERROR).
- Existing tests cover errorCode-without-evseId and evseId-without-
  errorCode but never both flags together — the actual production path.

T2.2 — undefined ocppVersion with errorCode and evseId:
- Tied to ui/web/src/core/UIClient.ts:141-155 +
  ui/web/src/shared/composables/useConnectorActions.ts:113-122 where
  setConnectorStatus is unconditionally invoked with both options even
  when props.ocppVersion is OCPPVersion | undefined.
- Existing 'undefined version' test omits both options; this asserts the
  1.6 fallthrough preserves them.

3-angle audit found other proposals (cross-enum mismatch guard, marking
existing cases [SYNTHETIC], structural refactor into nested describes)
but they did not survive cross-validation: the first requires a runtime
guard in payloadBuilders.ts (out of scope per task spec), the second is
subjective, the third is cosmetic per AGENTS.md 'small verifiable
changes'.

* test(ui-common): align buildStatusNotificationPayload test names with style guide

Address review feedback on #1904.

Both new test names violated tests/TEST_STYLE_GUIDE.md "should [verb]
in lowercase" describing observable behavior:
- T2.1 carried a callsite traceability annotation
  '(CLI + Web UI 1.6 path)' in the title.
- T2.2 used the implementation-internal term 'fall through' plus a
  '(Web UI undefined-version path)' annotation.

Renamed to mirror the existing sibling tests in the same describe
block:
- T2.1: 'should pass errorCode and evseId through for OCPP 1.6 when
  both are provided' (mirrors 'should pass evseId through for OCPP 1.6
  without errorCode').
- T2.2: 'should default to OCPP 1.6 shape with errorCode and evseId
  when ocppVersion is undefined' (mirrors 'should default to OCPP 1.6
  shape when ocppVersion is undefined').

Callsite traceability lives in the commit message + PR body, not the
test title — matches the convention of all 9 prior cases in the same
describe. No assertion change. 116/116 tests pass.
ui/common/tests/payloadBuilders.test.ts