fix: Install web subdirectory dependencies, set NODE_ENV for tests, and standardize hostname in server tests.
Some checks failed
Deploy to Production / test (push) Failing after 47s
Deploy to Production / build (push) Has been skipped
Deploy to Production / deploy (push) Has been skipped

This commit is contained in:
syntaxbullet
2026-01-30 16:46:16 +01:00
parent 95f1b4e04a
commit e252d6e00a
2 changed files with 12 additions and 7 deletions

View File

@@ -43,7 +43,9 @@ jobs:
bun-version: latest bun-version: latest
- name: Install Dependencies - name: Install Dependencies
run: bun install --frozen-lockfile run: |
bun install --frozen-lockfile
cd web && bun install --frozen-lockfile
- name: Create Config File - name: Create Config File
run: | run: |
@@ -96,6 +98,8 @@ jobs:
LOG_LEVEL="error" LOG_LEVEL="error"
EOF EOF
bash shared/scripts/test-sequential.sh bash shared/scripts/test-sequential.sh
env:
NODE_ENV: test
# ========================================================================== # ==========================================================================
# Build Job # Build Job

View File

@@ -58,6 +58,7 @@ mock.module("../../bot/lib/clientStats", () => ({
describe("WebServer Security & Limits", () => { describe("WebServer Security & Limits", () => {
const port = 3001; const port = 3001;
const hostname = "127.0.0.1";
let serverInstance: WebServerInstance | null = null; let serverInstance: WebServerInstance | null = null;
afterAll(async () => { afterAll(async () => {
@@ -67,8 +68,8 @@ describe("WebServer Security & Limits", () => {
}); });
test("should reject more than 10 concurrent WebSocket connections", async () => { test("should reject more than 10 concurrent WebSocket connections", async () => {
serverInstance = await createWebServer({ port, hostname: "localhost" }); serverInstance = await createWebServer({ port, hostname });
const wsUrl = `ws://localhost:${port}/ws`; const wsUrl = `ws://${hostname}:${port}/ws`;
const sockets: WebSocket[] = []; const sockets: WebSocket[] = [];
try { try {
@@ -95,9 +96,9 @@ describe("WebServer Security & Limits", () => {
test("should return 200 for health check", async () => { test("should return 200 for health check", async () => {
if (!serverInstance) { if (!serverInstance) {
serverInstance = await createWebServer({ port, hostname: "localhost" }); serverInstance = await createWebServer({ port, hostname });
} }
const response = await fetch(`http://localhost:${port}/api/health`); const response = await fetch(`http://${hostname}:${port}/api/health`);
expect(response.status).toBe(200); expect(response.status).toBe(200);
const data = (await response.json()) as { status: string }; const data = (await response.json()) as { status: string };
expect(data.status).toBe("ok"); expect(data.status).toBe("ok");
@@ -105,7 +106,7 @@ describe("WebServer Security & Limits", () => {
describe("Administrative Actions", () => { describe("Administrative Actions", () => {
test("should allow administrative actions without token", async () => { test("should allow administrative actions without token", async () => {
const response = await fetch(`http://localhost:${port}/api/actions/reload-commands`, { const response = await fetch(`http://${hostname}:${port}/api/actions/reload-commands`, {
method: "POST" method: "POST"
}); });
// Should be 200 (OK) or 500 (if underlying service fails, but NOT 401) // Should be 200 (OK) or 500 (if underlying service fails, but NOT 401)
@@ -114,7 +115,7 @@ describe("WebServer Security & Limits", () => {
}); });
test("should reject maintenance mode with invalid payload", async () => { test("should reject maintenance mode with invalid payload", async () => {
const response = await fetch(`http://localhost:${port}/api/actions/maintenance-mode`, { const response = await fetch(`http://${hostname}:${port}/api/actions/maintenance-mode`, {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"