feat: introduce backend url environment variable
ref: N25B-352
This commit is contained in:
@@ -6,6 +6,7 @@ import "@testing-library/jest-dom";
|
||||
import {type LogRecord, useLogs} from "../../../src/components/Logging/useLogs.ts";
|
||||
import {type cell, useCell} from "../../../src/utils/cellStore.ts";
|
||||
import { StrictMode } from "react";
|
||||
import { API_BASE_URL } from "../../../src/config/api.ts";
|
||||
|
||||
jest.mock("../../../src/utils/priorityFiltering.ts", () => ({
|
||||
applyPriorityPredicates: jest.fn((_log, preds: any[]) =>
|
||||
@@ -83,7 +84,7 @@ describe("useLogs (unit)", () => {
|
||||
);
|
||||
const es = (globalThis as any).__es as MockEventSource;
|
||||
expect(es).toBeTruthy();
|
||||
expect(es.url).toBe("http://localhost:8000/logs/stream");
|
||||
expect(es.url).toBe(`${API_BASE_URL}/logs/stream`);
|
||||
|
||||
unmount();
|
||||
expect(es.close).toHaveBeenCalledTimes(1);
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
useExperimentLogger,
|
||||
useStatusLogger
|
||||
} from '../../../src/pages/MonitoringPage/MonitoringPageAPI';
|
||||
import { API_BASE_URL } from '../../../src/config/api.ts';
|
||||
|
||||
// --- MOCK EVENT SOURCE SETUP ---
|
||||
// This mocks the browser's EventSource so we can manually 'push' messages to our hooks
|
||||
@@ -72,7 +73,7 @@ describe('MonitoringPageAPI', () => {
|
||||
await sendAPICall('test_type', 'test_ctx');
|
||||
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith(
|
||||
'http://localhost:8000/button_pressed',
|
||||
`${API_BASE_URL}/button_pressed`,
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -220,4 +221,4 @@ describe('MonitoringPageAPI', () => {
|
||||
expect(consoleSpy).toHaveBeenCalledWith('Status stream error:', expect.any(Error));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// © Copyright Utrecht University (Department of Information and Computing Sciences)
|
||||
import { render, screen, act, cleanup, fireEvent } from '@testing-library/react';
|
||||
import Robot from '../../../src/pages/Robot/Robot';
|
||||
import { API_BASE_URL } from '../../../src/config/api.ts';
|
||||
|
||||
// Mock EventSource
|
||||
const mockInstances: MockEventSource[] = [];
|
||||
@@ -64,7 +65,7 @@ describe('Robot', () => {
|
||||
await act(async () => fireEvent.click(button));
|
||||
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith(
|
||||
'http://localhost:8000/message',
|
||||
`${API_BASE_URL}/message`,
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -83,7 +84,7 @@ describe('Robot', () => {
|
||||
);
|
||||
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith(
|
||||
'http://localhost:8000/message',
|
||||
`${API_BASE_URL}/message`,
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
|
||||
Reference in New Issue
Block a user