Guard machine relay set status

This commit is contained in:
Jeppe B
2026-06-02 00:21:32 +02:00
parent fbad5f767f
commit a96f40cf13
2 changed files with 13 additions and 2 deletions
@@ -621,6 +621,14 @@ it('is a safe no-op when MACHINE relay is not configured', function (): void {
expect($harness->getShellyCallCount('/v2/devices/api/set/switch'))->toBe(0);
});
it('blocks setMachineRelayStatus from enabling MACHINE when MACHINE is not allowed', function (): void {
$harness = selfserve_lane_shelly_test_harness();
expect(fn() => $harness->setMachineRelayStatus(true))
->toThrow(\Exception::class, 'MACHINE relay is not allowed to be enabled at this time');
expect($harness->getShellyCallCount('/v2/devices/api/set/switch'))->toBe(0);
});
it('uses local demo responses and skips Shelly cloud calls for demo relay ids', function (): void {
$harness = selfserve_lane_shelly_test_harness();
$harness->department_lane = new SelfserveDepartmentLaneRelayFake(
@@ -628,6 +636,7 @@ it('uses local demo responses and skips Shelly cloud calls for demo relay ids',
programPickerRelayId: 'demo-program',
cleanerRelayId: 'demo-cleaner'
);
$harness->setLaneCache($harness->id, $harness::CACHE_SELFSERVE_LANE_KEY_ALLOWED_SERVICES, ['MACHINE']);
$result = $harness->setMachineRelayStatus(true);
$status = $harness->getMachineRelayStatus();