Display BanGUI version in dashboard and server config UI
This commit is contained in:
@@ -352,6 +352,12 @@ export function ServerHealthSection(): React.JSX.Element {
|
||||
<Text className={styles.statValue}>{status.version}</Text>
|
||||
</div>
|
||||
)}
|
||||
{status.bangui_version && (
|
||||
<div className={styles.statCard}>
|
||||
<Text className={styles.statLabel}>BanGUI</Text>
|
||||
<Text className={styles.statValue}>{status.bangui_version}</Text>
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.statCard}>
|
||||
<Text className={styles.statLabel}>Active Jails</Text>
|
||||
<Text className={styles.statValue}>{status.jail_count}</Text>
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { FluentProvider, webLightTheme } from "@fluentui/react-components";
|
||||
import { ServerHealthSection } from "../ServerHealthSection";
|
||||
|
||||
vi.mock("../../../api/config");
|
||||
|
||||
import { fetchFail2BanLog, fetchServiceStatus } from "../../../api/config";
|
||||
|
||||
const mockedFetchServiceStatus = vi.mocked(fetchServiceStatus);
|
||||
const mockedFetchFail2BanLog = vi.mocked(fetchFail2BanLog);
|
||||
|
||||
describe("ServerHealthSection", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("shows the BanGUI version in the service health panel", async () => {
|
||||
mockedFetchServiceStatus.mockResolvedValue({
|
||||
online: true,
|
||||
version: "1.2.3",
|
||||
bangui_version: "1.2.3",
|
||||
jail_count: 2,
|
||||
total_bans: 5,
|
||||
total_failures: 1,
|
||||
log_level: "INFO",
|
||||
log_target: "STDOUT",
|
||||
});
|
||||
|
||||
mockedFetchFail2BanLog.mockResolvedValue({
|
||||
log_path: "/var/log/fail2ban.log",
|
||||
lines: ["2026-01-01 fail2ban[123]: INFO Test"],
|
||||
total_lines: 1,
|
||||
log_level: "INFO",
|
||||
log_target: "STDOUT",
|
||||
});
|
||||
|
||||
render(
|
||||
<FluentProvider theme={webLightTheme}>
|
||||
<ServerHealthSection />
|
||||
</FluentProvider>,
|
||||
);
|
||||
|
||||
// The service health panel should render and include the BanGUI version.
|
||||
const banGuiLabel = await screen.findByText("BanGUI");
|
||||
expect(banGuiLabel).toBeInTheDocument();
|
||||
|
||||
const banGuiCard = banGuiLabel.closest("div");
|
||||
expect(banGuiCard).toHaveTextContent("1.2.3");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user