Auto-disable department self-serve at opening (#323)

Auto-disable department self-serve at opening
This commit is contained in:
Jeppe B
2026-07-28 18:03:05 +02:00
committed by GitHub
parent 3c13892366
commit da0113e3ed
10 changed files with 541 additions and 70 deletions
@@ -6,16 +6,28 @@ it('syncs lane relay states when department self-serve enabled flag changes', fu
expect($routeContent)->not->toBeFalse();
expect($routeContent)->toContain('/departments/self-serve/enabled');
expect($routeContent)->toContain('$this->syncDepartmentSelfServeRelayStates((int)$department->id, $enabled);');
expect($routeContent)->toContain('department_variables_o::withSelfServeTransitionLock');
expect($routeContent)->toContain('if (!$enabled) {');
expect($routeContent)->toContain('// Self-serve disabled: restore normal/manual relay operation.');
expect($routeContent)->toContain('setMachineProgramPickerRelayStatusHard(true)');
expect($routeContent)->toContain('setMachineRelayStatusHard(true)');
expect($routeContent)->toContain('setMachineProgramPickerRelayStatusForDepartmentOperation(true)');
expect($routeContent)->toContain('setMachineRelayStatusForDepartmentOperation(true)');
expect($routeContent)->toContain('!$department_lane->isSelfServeEnabled()');
expect($routeContent)->toContain('setMachineProgramPickerRelayStatus(false)');
expect($routeContent)->toContain('setMachineCleanerRelayStatusHard(true)');
expect($routeContent)->toContain('setMachineCleanerRelayStatusForDepartmentOperation(true)');
expect($routeContent)->toContain('setMachineRelayStatus(false)');
expect($routeContent)->not->toContain('setMachineProgramPickerRelayStatusHard(false)');
expect($routeContent)->not->toContain('setMachineCleanerRelayStatusHard(false)');
expect($routeContent)->not->toContain('setMachineRelayStatusHard(false)');
expect($routeContent)->not->toContain('setMachineCleanerRelayStatus(false)');
});
it('uses the supported prepared database API for the department transition lock', function (): void {
$variableObject = file_get_contents(app_path('objects/department_variables_o.php'));
expect($variableObject)->not->toBeFalse()
->and($variableObject)->not->toContain('$database->selectOne')
->and($variableObject)->toContain("\$db->prepare('SELECT GET_LOCK(?, ?) AS acquired')")
->and($variableObject)->toContain("\$statement->bind_param('si', \$lockName, \$timeoutSeconds)")
->and($variableObject)->toContain("\$db->prepare('SELECT RELEASE_LOCK(?) AS released')")
->and($variableObject)->toContain("\$statement->bind_param('s', \$lockName)");
});