Task 3-2: Integration Test - Health Check & Slack Alerts
Phase: 3 - Testing Priority: Medium Depends on: task-1-1 Reference: docs/BountyHunter-Backend/details/feature-receiver-service/SPEC.md
Background
Test machine health check events: status update trong DB và Slack notification cho critical events.
Test scenarios
NEW_CONNECTED
- [ ] Publish
{mac_ip: "<macIp>", message_type: "NEW_CONNECTED"} - [ ] Verify:
craneMachineService.newConnectedFromControlServer(macIp)called - [ ] Verify: Machine
status=CONNECTEDtrong DB
DISCONNECTED (via APP_CLOSE)
- [ ] Publish
{message_type: "APP_CLOSE"} - [ ] Verify: Machine status = DISCONNECTED trong DB
- [ ] Verify:
last_ping_timeupdated
CAM_STATUS_REPORT - error
- [ ] Publish
{message_type: "CAM_STATUS_REPORT", data: {cam_position: "TOP", cam_status: "ERROR"}} - [ ] Verify:
craneMachineService.camStatusReport(macIp, "TOP", "ERROR")called - [ ] Verify: Slack notification sent với macIp + camPosition + camStatus
CAM_STATUS_REPORT - OK
- [ ] Publish với
cam_status: "OK" - [ ] Verify:
camStatusReport()called - [ ] Verify: Slack NOT sent (no alert for OK status)
ERROR_REPORT - errorCode 81
- [ ] Publish
{message_type: "ERROR_REPORT", data: {error_code: 81, error_text: "Motor stall"}} - [ ] Verify:
craneMachineService.machineErrorReport(macIp, 81, "Motor stall")called - [ ] Verify:
IGameService.endGameSuccess(macIp, 1, true)called (auto end game with win=1) - [ ] Verify: Slack notification sent
ERROR_REPORT - other errorCode
- [ ] Publish với
error_code: 99 - [ ] Verify:
machineErrorReport()called, Slack sent - [ ] Verify:
endGameSuccess()NOT called (chỉ errorCode 81 trigger này)
PING
- [ ] Publish
{message_type: "PING"} - [ ] Verify:
craneMachineService.pingMachine(macIp)called - [ ] Verify: No Slack notification for PING
Verification / Acceptance Criteria
- [ ] NEW_CONNECTED → DB status updated
- [ ] APP_CLOSE → DB status DISCONNECTED, last_ping updated
- [ ] CAM error → Slack sent; CAM OK → no Slack
- [ ] ERROR_REPORT 81 →
endGameSuccess()called; other codes → NOT called - [ ] PING → handled silently, no Slack
Files to Modify
- Test files trong
receiver-service/src/test/hoặc integration test module