Test Datei entfernt
This commit is contained in:
@@ -17,7 +17,6 @@ import { ToastContainer, toast } from "react-toastify";
|
||||
import plusRoundIcon from "./PlusRoundIcon.js";
|
||||
import { createAndSetDevices } from "../utils/createAndSetDevices.js";
|
||||
import { restoreMapSettings, checkOverlappingMarkers } from "../utils/mapUtils.js";
|
||||
import { fetchPoiData, fetchUserRights } from "../services/apiService.js";
|
||||
import { APP_VERSION } from "../config/appVersion";
|
||||
import * as layers from "../config/layers.js";
|
||||
import { initializeMap } from "../utils/initializeMap.js";
|
||||
@@ -25,7 +24,6 @@ import addItemsToMapContextMenu from "./useMapContextMenu.js";
|
||||
import useGmaMarkersLayer from "../hooks/layers/useGmaMarkersLayer.js"; // Import the custom hook
|
||||
import useSmsfunkmodemMarkersLayer from "../hooks/layers/useSmsfunkmodemMarkersLayer.js";
|
||||
import useBereicheMarkersLayer from "../hooks/layers/useBereicheMarkersLayer.js";
|
||||
import { fetchGisStationsStaticDistrict, fetchGisStationsStatusDistrict, fetchGisStationsMeasurements, fetchGisSystemStatic } from "../services/fetchData.js";
|
||||
import { setupPolylines } from "../utils/setupPolylines.js";
|
||||
import { setupPOIs } from "../utils/setupPOIs.js";
|
||||
import VersionInfoModal from "./VersionInfoModal.js";
|
||||
@@ -60,6 +58,13 @@ import { selectCurrentPoi, setCurrentPoi, clearCurrentPoi } from "../redux/slice
|
||||
import CoordinateInput from "./CoordinateInput";
|
||||
import CoordinateModal from "./CoordinateModal";
|
||||
import CoordinatePopup from "./CoordinatePopup";
|
||||
//------------------------Daten aus API--------------------
|
||||
import { fetchUserRights } from "../services/api/fetchUserRights.js";
|
||||
import { fetchPoiData } from "../services/api/fetchPoiData.js";
|
||||
import { fetchGisStationsStaticDistrict } from "../services/api/fetchGisStationsStaticDistrict.js";
|
||||
import { fetchGisStationsStatusDistrict } from "../services/api/fetchGisStationsStatusDistrict.js";
|
||||
import { fetchGisStationsMeasurements } from "../services/api/fetchGisStationsMeasurements.js";
|
||||
import { fetchGisSystemStatic } from "../services/api/fetchGisSystemStatic.js";
|
||||
|
||||
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// /config/appVersion
|
||||
export const APP_VERSION = "1.1.4";
|
||||
export const APP_VERSION = "1.1.5";
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
import { useEffect } from "react";
|
||||
import { fetchUserRights } from "../services/apiService";
|
||||
import { fetchUserRights } from "../services/api/fetchUserRights.js";
|
||||
|
||||
export const useFetchUserRights = (
|
||||
setUserRights,
|
||||
setIsRightsLoaded,
|
||||
setHasRights
|
||||
) => {
|
||||
export const useFetchUserRights = (setUserRights, setIsRightsLoaded, setHasRights) => {
|
||||
useEffect(() => {
|
||||
const fetchAndSetUserRights = async () => {
|
||||
try {
|
||||
@@ -14,11 +10,7 @@ export const useFetchUserRights = (
|
||||
setIsRightsLoaded(true);
|
||||
|
||||
// Sicherstellen, dass `rights` ein Array ist, bevor `.includes()` aufgerufen wird
|
||||
setHasRights(
|
||||
localStorage.getItem("editMode") &&
|
||||
Array.isArray(rights) &&
|
||||
rights.includes(56)
|
||||
);
|
||||
setHasRights(localStorage.getItem("editMode") && Array.isArray(rights) && rights.includes(56));
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Abrufen der Benutzerrechte:", error);
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
import axios from "axios";
|
||||
import os from "os"; // Modul zum Ermitteln der IP-Adresse
|
||||
|
||||
// Dynamische Ermittlung der IP-Adresse des Rechners
|
||||
function getLocalIPAddress() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
for (const name of Object.keys(interfaces)) {
|
||||
for (const iface of interfaces[name]) {
|
||||
if (iface.family === "IPv4" && !iface.internal) {
|
||||
return iface.address; // Rückgabe der IPv4-Adresse
|
||||
}
|
||||
}
|
||||
}
|
||||
return "localhost"; // Fallback zu localhost
|
||||
}
|
||||
|
||||
// Basis-URL dynamisch erstellen
|
||||
const BASE_URL = `http://${getLocalIPAddress()}:3000/api/gisStationsMeasurements`;
|
||||
|
||||
describe("Echte API-Integrationstests für gisStationsMeasurements", () => {
|
||||
// Test 1: Erfolgreiche Anfrage mit gültigen Parametern
|
||||
it("gibt JSON-Daten zurück, wenn gültige Parameter übergeben werden", async () => {
|
||||
const params = {
|
||||
m: "12", // Beispiel für idMap
|
||||
};
|
||||
|
||||
// Echte Anfrage an den Server senden
|
||||
const response = await axios.get(BASE_URL, { params });
|
||||
|
||||
// Debugging der Header
|
||||
console.log(response.headers);
|
||||
|
||||
// Statuscode prüfen
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
// Überprüfen, ob die Antwort die erwarteten JSON-Daten enthält
|
||||
expect(response.data).toHaveProperty("Name");
|
||||
expect(response.data).toHaveProperty("Zeitstempel");
|
||||
expect(response.data).toHaveProperty("IdMap");
|
||||
expect(response.data).toHaveProperty("Statis");
|
||||
expect(response.data.Statis).toBeInstanceOf(Array);
|
||||
|
||||
const item = response.data.Statis[0];
|
||||
expect(item).toHaveProperty("IdLD");
|
||||
expect(item).toHaveProperty("IdL");
|
||||
expect(item).toHaveProperty("IdDP");
|
||||
expect(item).toHaveProperty("Na");
|
||||
expect(item).toHaveProperty("Val");
|
||||
expect(item).toHaveProperty("Unit");
|
||||
expect(item).toHaveProperty("Gr");
|
||||
expect(item).toHaveProperty("Area_Name");
|
||||
});
|
||||
|
||||
// Test 2: Fehler bei fehlenden Parametern
|
||||
it("gibt einen Fehler zurück, wenn Parameter fehlen", async () => {
|
||||
try {
|
||||
// Anfrage ohne Parameter
|
||||
await axios.get(BASE_URL);
|
||||
} catch (error) {
|
||||
expect(error.response.status).toBe(400);
|
||||
expect(error.response.data).toHaveProperty("error");
|
||||
|
||||
// Flexibler auf Fehlernachricht prüfen
|
||||
expect(error.response.data.message).toMatch(/Fehlender Parameter|erforderlich/);
|
||||
}
|
||||
});
|
||||
|
||||
// Test 3: Fehler bei ungültigen Parametern
|
||||
it("gibt einen Serverfehler zurück, wenn ungültige Parameter verwendet werden", async () => {
|
||||
try {
|
||||
const params = {
|
||||
m: "invalid", // Ungültige idMap
|
||||
};
|
||||
|
||||
await axios.get(BASE_URL, { params });
|
||||
} catch (error) {
|
||||
expect(error.response.status).toBe(500);
|
||||
expect(error.response.data).toHaveProperty("error");
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,80 +0,0 @@
|
||||
import axios from "axios";
|
||||
import os from "os"; // Modul zum Ermitteln der IP-Adresse
|
||||
|
||||
// Dynamische Ermittlung der IP-Adresse des Rechners
|
||||
function getLocalIPAddress() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
for (const name of Object.keys(interfaces)) {
|
||||
for (const iface of interfaces[name]) {
|
||||
if (iface.family === "IPv4" && !iface.internal) {
|
||||
return iface.address; // Rückgabe der IPv4-Adresse
|
||||
}
|
||||
}
|
||||
}
|
||||
return "localhost"; // Fallback zu localhost
|
||||
}
|
||||
|
||||
// Basis-URL dynamisch erstellen
|
||||
const BASE_URL = `http://${getLocalIPAddress()}:3000/api/gisStationsStaticDistrict`;
|
||||
|
||||
describe("Echte API-Integrationstests für gisStationsStaticDistrict", () => {
|
||||
// Test 1: Erfolgreiche Anfrage mit gültigen Parametern
|
||||
it("gibt JSON-Daten zurück, wenn gültige Parameter übergeben werden", async () => {
|
||||
const params = {
|
||||
m: "12", // Beispiel für idMap
|
||||
u: "484", // Beispiel für idUser
|
||||
};
|
||||
|
||||
// Echte Anfrage an den Server senden
|
||||
const response = await axios.get(BASE_URL, { params });
|
||||
|
||||
// Debugging der Header
|
||||
console.log(response.headers);
|
||||
|
||||
// Statuscode prüfen
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
// Überprüfen, ob die Antwort die erwarteten Daten enthält
|
||||
expect(response.data).toHaveProperty("Name");
|
||||
expect(response.data).toHaveProperty("Points");
|
||||
expect(response.data.Points).toBeInstanceOf(Array);
|
||||
|
||||
const item = response.data.Points[0];
|
||||
expect(item).toHaveProperty("LD_Name");
|
||||
expect(item).toHaveProperty("Device");
|
||||
expect(item).toHaveProperty("Link");
|
||||
expect(item).toHaveProperty("Location_Name");
|
||||
expect(item).toHaveProperty("X");
|
||||
expect(item).toHaveProperty("Y");
|
||||
expect(item).toHaveProperty("Icon");
|
||||
});
|
||||
|
||||
// Test 2: Fehler bei fehlenden Parametern
|
||||
it("gibt einen Fehler zurück, wenn Parameter fehlen", async () => {
|
||||
try {
|
||||
// Anfrage ohne Parameter
|
||||
await axios.get(BASE_URL);
|
||||
} catch (error) {
|
||||
expect(error.response.status).toBe(400);
|
||||
expect(error.response.data).toHaveProperty("error");
|
||||
|
||||
// Flexibler auf Fehlernachricht prüfen
|
||||
expect(error.response.data.message).toMatch(/Fehlende Parameter|erforderlich/);
|
||||
}
|
||||
});
|
||||
|
||||
// Test 3: Fehler bei ungültigen Parametern
|
||||
it("gibt einen Serverfehler zurück, wenn ungültige Parameter verwendet werden", async () => {
|
||||
try {
|
||||
const params = {
|
||||
m: "invalid", // Ungültige idMap
|
||||
u: "invalid", // Ungültige idUser
|
||||
};
|
||||
|
||||
await axios.get(BASE_URL, { params });
|
||||
} catch (error) {
|
||||
expect(error.response.status).toBe(500);
|
||||
expect(error.response.data).toHaveProperty("error");
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,75 +0,0 @@
|
||||
import axios from "axios";
|
||||
import os from "os"; // Modul zum Ermitteln der IP-Adresse
|
||||
|
||||
// Dynamische Ermittlung der IP-Adresse des Rechners
|
||||
function getLocalIPAddress() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
for (const name of Object.keys(interfaces)) {
|
||||
for (const iface of interfaces[name]) {
|
||||
if (iface.family === "IPv4" && !iface.internal) {
|
||||
return iface.address; // Rückgabe der IPv4-Adresse
|
||||
}
|
||||
}
|
||||
}
|
||||
return "localhost"; // Fallback zu localhost
|
||||
}
|
||||
|
||||
// Basis-URL dynamisch erstellen
|
||||
const BASE_URL = `http://${getLocalIPAddress()}:3000/api/gisStationsStatusDistrict`;
|
||||
|
||||
describe("Echte API-Integrationstests für gisStationsStatusDistrict", () => {
|
||||
// Test 1: Erfolgreiche Anfrage mit gültigen Parametern
|
||||
it("gibt JSON-Daten zurück, wenn gültige Parameter übergeben werden", async () => {
|
||||
const params = {
|
||||
m: "12", // Beispiel für idMap
|
||||
u: "484", // Beispiel für idUser
|
||||
};
|
||||
|
||||
// Echte Anfrage an den Server senden
|
||||
const response = await axios.get(BASE_URL, { params });
|
||||
|
||||
// Statuscode prüfen
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
// Antwortdaten prüfen
|
||||
expect(response.data).toHaveProperty("Name");
|
||||
expect(response.data).toHaveProperty("Statis");
|
||||
expect(response.data.Statis).toBeInstanceOf(Array);
|
||||
|
||||
const item = response.data.Statis[0];
|
||||
expect(item).toHaveProperty("IdLD");
|
||||
expect(item).toHaveProperty("Na");
|
||||
expect(item).toHaveProperty("Le");
|
||||
expect(item).toHaveProperty("Co");
|
||||
expect(item).toHaveProperty("Me");
|
||||
expect(item).toHaveProperty("Feld");
|
||||
expect(item).toHaveProperty("Icon");
|
||||
});
|
||||
|
||||
// Test 2: Fehler bei fehlenden Parametern
|
||||
it("gibt einen Fehler zurück, wenn Parameter fehlen", async () => {
|
||||
try {
|
||||
// Anfrage ohne Parameter
|
||||
await axios.get(BASE_URL);
|
||||
} catch (error) {
|
||||
expect(error.response.status).toBe(400);
|
||||
expect(error.response.data).toHaveProperty("error");
|
||||
expect(error.response.data).toHaveProperty("message");
|
||||
}
|
||||
});
|
||||
|
||||
// Test 3: Fehler bei ungültigen Parametern
|
||||
it("gibt einen Serverfehler zurück, wenn ungültige Parameter verwendet werden", async () => {
|
||||
try {
|
||||
const params = {
|
||||
m: "invalid", // Ungültige idMap
|
||||
u: "invalid", // Ungültige idUser
|
||||
};
|
||||
|
||||
await axios.get(BASE_URL, { params });
|
||||
} catch (error) {
|
||||
expect(error.response.status).toBe(500);
|
||||
expect(error.response.data).toHaveProperty("error");
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,81 +0,0 @@
|
||||
import axios from "axios";
|
||||
import os from "os";
|
||||
|
||||
// Dynamische IP-Adresse ermitteln
|
||||
function getLocalIPAddress() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
for (const name of Object.keys(interfaces)) {
|
||||
for (const iface of interfaces[name]) {
|
||||
if (iface.family === "IPv4" && !iface.internal) {
|
||||
return iface.address; // IPv4-Adresse zurückgeben
|
||||
}
|
||||
}
|
||||
}
|
||||
return "localhost"; // Fallback zu localhost
|
||||
}
|
||||
|
||||
// Dynamische Basis-URL
|
||||
const BASE_URL = `http://${getLocalIPAddress()}:3000/api/gisSystemStatic`;
|
||||
//http://localhost:3000/api/gisSystemStatic
|
||||
describe("Echte API-Integrationstests für gisSystemStatic", () => {
|
||||
// Test 1: Erfolgreiche Anfrage mit gültigen Parametern
|
||||
it("gibt JSON-Daten zurück, wenn gültige Parameter übergeben werden", async () => {
|
||||
const params = {
|
||||
m: "12", // Beispiel für idMap
|
||||
u: "484", // Beispiel für idUser
|
||||
};
|
||||
|
||||
// Echte Anfrage an den Server senden
|
||||
const response = await axios.get(BASE_URL, { params });
|
||||
|
||||
// Header sicher loggen
|
||||
console.log("Content-Type:", response.headers["content-type"]);
|
||||
|
||||
// Statuscode prüfen
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
// Überprüfen, ob die Antwort die erwarteten JSON-Daten enthält
|
||||
expect(response.data).toHaveProperty("Name");
|
||||
expect(response.data).toHaveProperty("Zeitstempel");
|
||||
expect(response.data).toHaveProperty("IdMap");
|
||||
expect(response.data).toHaveProperty("Systems");
|
||||
expect(response.data.Systems).toBeInstanceOf(Array);
|
||||
|
||||
// Erster Eintrag prüfen
|
||||
const item = response.data.Systems[0];
|
||||
expect(item).toHaveProperty("IdSystem");
|
||||
expect(item).toHaveProperty("Name");
|
||||
expect(item).toHaveProperty("Longname");
|
||||
expect(item).toHaveProperty("Allow");
|
||||
expect(item).toHaveProperty("Icon");
|
||||
});
|
||||
|
||||
// Test 2: Fehler bei fehlenden Parametern
|
||||
it("gibt einen Fehler zurück, wenn Parameter fehlen", async () => {
|
||||
try {
|
||||
// Anfrage ohne Parameter
|
||||
await axios.get(BASE_URL);
|
||||
} catch (error) {
|
||||
expect(error.response.status).toBe(400);
|
||||
expect(error.response.data).toHaveProperty("error");
|
||||
|
||||
// Flexibler auf Fehlernachricht prüfen
|
||||
expect(error.response.data.message).toMatch(/Fehlende Parameter|erforderlich/);
|
||||
}
|
||||
});
|
||||
|
||||
// Test 3: Fehler bei ungültigen Parametern
|
||||
it("gibt einen Serverfehler zurück, wenn ungültige Parameter verwendet werden", async () => {
|
||||
try {
|
||||
const params = {
|
||||
m: "invalid", // Ungültige idMap
|
||||
u: "invalid", // Ungültige idUser
|
||||
};
|
||||
|
||||
await axios.get(BASE_URL, { params });
|
||||
} catch (error) {
|
||||
expect(error.response.status).toBe(500);
|
||||
expect(error.response.data).toHaveProperty("error");
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,64 +0,0 @@
|
||||
// /pages/api/linesColorApi.js
|
||||
// http://10.10.0.13/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict
|
||||
//In DB gis_lines idLD und idModul anpassen entsprechend
|
||||
|
||||
// /pages/api/linesColorApi.js
|
||||
import NextCors from "nextjs-cors";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
// Run the cors middleware
|
||||
await NextCors(req, res, {
|
||||
// Options
|
||||
methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
|
||||
origin: "*", // Erlauben Sie alle Ursprünge, oder geben Sie spezifische Ursprünge an
|
||||
optionsSuccessStatus: 200, // Legacy-Browser-Unterstützung für 204
|
||||
});
|
||||
|
||||
const response = {
|
||||
Name: "Liste aller Statis der Linien",
|
||||
Zeitstempel: new Date().toISOString(), // Aktuellen Zeitstempel hinzufügen
|
||||
IdMap: "10",
|
||||
Statis: [
|
||||
/* {
|
||||
IdLD: 50922,
|
||||
Modul: 1,
|
||||
DpName: "KUE01_Ausfall",
|
||||
ModulName: "42 Wippershain Sender",
|
||||
// ModulTyp: "nicht vorhanden",
|
||||
ModulTyp: "KÜ705-FO",
|
||||
Message: "KUEG 01: 42 Wippershain Sender Messwerkausfall kommend",
|
||||
Level: 4,
|
||||
PrioColor: "#FFFF00",
|
||||
PrioName: "system",
|
||||
Value: "10 MOhm",
|
||||
},
|
||||
{
|
||||
IdLD: 25440,
|
||||
Modul: 3,
|
||||
DpName: "KUE03_Ausfall",
|
||||
ModulName: "42 Solz Sender",
|
||||
//ModulTyp: "nicht vorhanden",
|
||||
ModulTyp: "KÜSS V2",
|
||||
Message: "KUEG 03: 42 Solz Sender Messwerkausfall kommend",
|
||||
Level: 4,
|
||||
PrioColor: "#FF0000",
|
||||
PrioName: "system",
|
||||
Value: "10 MOhm",
|
||||
},
|
||||
{
|
||||
IdLD: 25440,
|
||||
Modul: 4,
|
||||
DpName: "KUE04_Ausfall",
|
||||
ModulName: "42/13 Bad Hersfeld Gaswerk",
|
||||
ModulTyp: "Kue705-FO",
|
||||
Message: "KUEG 04: 42/13 Bad Hersfeld Gaswerk Messwerkausfall kommend",
|
||||
Level: 4,
|
||||
PrioColor: "#FF00FF",
|
||||
PrioName: "system",
|
||||
Value: "10 MOhm",
|
||||
}, */
|
||||
],
|
||||
};
|
||||
|
||||
res.status(200).json(response);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// utils/setupPOIs.js
|
||||
import { findClosestPoints } from "./geometryUtils";
|
||||
import handlePoiSelect from "./handlePoiSelect";
|
||||
import { updateLocationInDatabase } from "../services/apiService";
|
||||
import { updateLocationInDatabase } from "../services/api/updateLocationInDatabase";
|
||||
import { handleEditPoi, insertNewPOI, removePOI } from "./poiUtils";
|
||||
import { parsePoint } from "./geometryUtils";
|
||||
import circleIcon from "../components/gisPolylines/icons/CircleIcon";
|
||||
|
||||
Reference in New Issue
Block a user