<?php

it('synchronizes machine relay from visible services during session synchronization', function (): void {
    $washFlow = file_get_contents(app_path('modules/selfserve/classes/selfserve_wash_flow.php'));

    expect($washFlow)->not->toBeFalse();
    expect($washFlow)->toContain('bool $syncRelayState = true');
    expect($washFlow)->toContain('if ($syncRelayState) {');
    expect($washFlow)->toContain('$this->syncMachineRelayFromVisibleServices($snapshot, $session, $activateMachine);');
    expect($washFlow)->toContain('protected function syncMachineRelayFromVisibleServices');
    expect($washFlow)->toContain('$lane->syncMachineRelayFromVisibleServices(');
    expect($washFlow)->toContain('$session->markRelayDisabled();');
    expect($washFlow)->toContain('$session->updateStatus($this->deriveCurrentStatus($snapshot, $session));');
});

it('adds explicit relay disable session helper for visibility-driven OFF transitions', function (): void {
    $sessionsObject = file_get_contents(app_path('objects/selfserve_wash_sessions_o.php'));

    expect($sessionsObject)->not->toBeFalse();
    expect($sessionsObject)->toContain('public function markRelayDisabled(): void');
    expect($sessionsObject)->toContain('$this->machine_relay_enabled->set(false);');
    expect($sessionsObject)->toContain('$this->machine_relay_enabled_at->set(null);');
});
