Fix API CI broker and transport fixtures
This commit is contained in:
@@ -228,7 +228,7 @@ jobs:
|
||||
set -euo pipefail
|
||||
cp .github/ci.env .env
|
||||
cp .github/ci.env.staging .env.staging
|
||||
printf '\nEDGE_PUBLIC_BROKER_URL=http://localhost:%s/edge-broker\n' "$EDGE_BROKER_CI_PORT" >> .env
|
||||
printf '\nEDGE_PUBLIC_BROKER_URL=http://edge-broker:4300/edge-broker\n' >> .env
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
|
||||
@@ -102,6 +102,15 @@ function isLocalHost(hostname) {
|
||||
function resolveBrokerWebSocketUrl(rawUrl, apiBaseUrl) {
|
||||
const websocketUrl = new URL(String(rawUrl));
|
||||
const apiUrl = new URL(normalizeBaseUrl(apiBaseUrl));
|
||||
const ciBrokerPort = String(process.env.EDGE_BROKER_CI_PORT || "").trim();
|
||||
|
||||
if (isLocalHost(apiUrl.hostname) && websocketUrl.hostname === "edge-broker" && ciBrokerPort !== "") {
|
||||
websocketUrl.protocol = apiUrl.protocol === "https:" ? "wss:" : "ws:";
|
||||
websocketUrl.hostname = apiUrl.hostname;
|
||||
websocketUrl.port = ciBrokerPort;
|
||||
websocketUrl.pathname = websocketUrl.pathname.replace(/^\/edge-broker(?=\/|$)/, "") || "/";
|
||||
return websocketUrl.toString();
|
||||
}
|
||||
|
||||
if (apiUrl.hostname === "caddy" && websocketUrl.hostname === "caddy") {
|
||||
websocketUrl.hostname = "edge-broker";
|
||||
|
||||
@@ -727,6 +727,10 @@ final class BrokerWebSocketClient
|
||||
throw new RuntimeException('Invalid broker websocket URL: ' . $socketUrl);
|
||||
}
|
||||
|
||||
if ($host === 'edge-broker' && str_starts_with($path, '/edge-broker/')) {
|
||||
$path = substr($path, strlen('/edge-broker'));
|
||||
}
|
||||
|
||||
return [
|
||||
'scheme' => strtolower((string)($parts['scheme'] ?? 'ws')),
|
||||
'host' => (string)$parts['host'],
|
||||
|
||||
@@ -186,21 +186,12 @@ final class ApiFixtures
|
||||
throw new RuntimeException('Invalid Shelly transport fixture mode.');
|
||||
}
|
||||
|
||||
$this->cleanupDeleteWhere('department_variables', [
|
||||
$conditions = [
|
||||
'department_id' => $departmentId,
|
||||
'variable' => 'shelly_transport_mode',
|
||||
]);
|
||||
|
||||
$existingIds = $this->fetchIntColumnWhere('department_variables', 'id', [
|
||||
'department_id' => $departmentId,
|
||||
'variable' => 'shelly_transport_mode',
|
||||
]);
|
||||
if ($existingIds !== []) {
|
||||
$this->updateById('department_variables', (int)$existingIds[0], [
|
||||
'value' => $mode,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
];
|
||||
$this->deleteWhereIfPossible('department_variables', $conditions);
|
||||
$this->cleanupDeleteWhere('department_variables', $conditions);
|
||||
|
||||
$variableId = $this->insertRowWithExistingColumns('department_variables', [
|
||||
'department_id' => $departmentId,
|
||||
|
||||
Reference in New Issue
Block a user