Add unit tests for invoicing, orders normalization, gateway commands, and department complaints. Update schema bootstraps and improve agent command execution logic.
This commit is contained in:
@@ -15,6 +15,8 @@ function with_edge_gateway_server_state(array $server, callable $callback): void
|
||||
{
|
||||
$originalServer = $_SERVER;
|
||||
$originalPublicApiUrl = getenv('EDGE_PUBLIC_API_URL');
|
||||
$originalBrokerPublicUrl = getenv('EDGE_BROKER_PUBLIC_URL');
|
||||
$originalBrokerPublicPort = getenv('EDGE_BROKER_PUBLIC_PORT');
|
||||
|
||||
$_SERVER = $server;
|
||||
|
||||
@@ -27,6 +29,16 @@ function with_edge_gateway_server_state(array $server, callable $callback): void
|
||||
} else {
|
||||
putenv('EDGE_PUBLIC_API_URL=' . $originalPublicApiUrl);
|
||||
}
|
||||
if ($originalBrokerPublicUrl === false) {
|
||||
putenv('EDGE_BROKER_PUBLIC_URL');
|
||||
} else {
|
||||
putenv('EDGE_BROKER_PUBLIC_URL=' . $originalBrokerPublicUrl);
|
||||
}
|
||||
if ($originalBrokerPublicPort === false) {
|
||||
putenv('EDGE_BROKER_PUBLIC_PORT');
|
||||
} else {
|
||||
putenv('EDGE_BROKER_PUBLIC_PORT=' . $originalBrokerPublicPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,3 +101,44 @@ it('prefers EDGE_PUBLIC_API_URL when explicitly configured', function (): void {
|
||||
expect($manager->buildInstallScriptUrl('token-1'))->toBe('https://edge.example.test/api/edge-agent/install.sh?token=token-1');
|
||||
});
|
||||
});
|
||||
|
||||
it('normalizes public broker overrides to https and browser shell urls to wss', function (): void {
|
||||
with_edge_gateway_server_state([
|
||||
'HTTP_HOST' => 'localhost',
|
||||
'HTTP_X_FORWARDED_PROTO' => 'http',
|
||||
], function (): void {
|
||||
putenv('EDGE_BROKER_PUBLIC_URL=http://api.truckwash.io:4300');
|
||||
|
||||
$manager = new EdgeGatewayManagerUrlHarness();
|
||||
|
||||
expect($manager->getBrokerPublicUrl())->toBe('https://api.truckwash.io:4300');
|
||||
expect($manager->buildBrowserShellWsUrl('shell-token'))->toBe('wss://api.truckwash.io:4300/ws/browser-shell?token=shell-token');
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps localhost broker overrides on plain http and ws for local development', function (): void {
|
||||
with_edge_gateway_server_state([
|
||||
'HTTP_HOST' => 'localhost:5173',
|
||||
'HTTP_X_FORWARDED_PROTO' => 'http',
|
||||
], function (): void {
|
||||
putenv('EDGE_BROKER_PUBLIC_URL=http://localhost:4300');
|
||||
|
||||
$manager = new EdgeGatewayManagerUrlHarness();
|
||||
|
||||
expect($manager->getBrokerPublicUrl())->toBe('http://localhost:4300');
|
||||
expect($manager->buildBrowserShellWsUrl('shell-token'))->toBe('ws://localhost:4300/ws/browser-shell?token=shell-token');
|
||||
});
|
||||
});
|
||||
|
||||
it('includes node-pty build prerequisites in the generated install script', function (): void {
|
||||
with_edge_gateway_server_state([
|
||||
'HTTP_HOST' => 'api.truckwash.io:4433',
|
||||
'HTTP_X_FORWARDED_PROTO' => 'https',
|
||||
], function (): void {
|
||||
$manager = new EdgeGatewayManagerUrlHarness();
|
||||
$script = $manager->buildInstallScript('pty-token');
|
||||
|
||||
expect($script)->toContain('apt-get install -y curl ca-certificates nodejs npm python3 make g++');
|
||||
expect($script)->toContain('npm install --omit=dev');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user