Delete hook barrel files and switch to direct hook imports

This commit is contained in:
2026-04-21 20:02:50 +02:00
parent 1ba82d56e7
commit b6d9c649ca
24 changed files with 35 additions and 48 deletions

View File

@@ -15,7 +15,7 @@ import { FluentProvider, webLightTheme } from "@fluentui/react-components";
import { MemoryRouter, Route, Routes } from "react-router-dom";
import { JailDetailPage } from "../JailDetailPage";
import type { Jail } from "../../types/jail";
import type { UseJailDetailResult } from "../../hooks/useJails";
import type { UseJailDetailResult } from "../../hooks/useJailDetail";
// ---------------------------------------------------------------------------
// Module mocks
@@ -39,8 +39,11 @@ const {
}));
// Mock the jail detail hook — tests control the returned state directly.
vi.mock("../../hooks/useJails", () => ({
vi.mock("../../hooks/useJailDetail", () => ({
useJailDetail: vi.fn(),
}));
vi.mock("../../hooks/useJailBannedIps", () => ({
useJailBannedIps: vi.fn(() => ({
items: [],
total: 0,
@@ -76,7 +79,7 @@ vi.mock("../../components/jail/BannedIpsSection", () => ({
// Helpers
// ---------------------------------------------------------------------------
import { useJailDetail } from "../../hooks/useJails";
import { useJailDetail } from "../../hooks/useJailDetail";
/** Minimal `Jail` fixture. */
function makeJail(): Jail {

View File

@@ -1,6 +1,5 @@
import { describe, expect, it, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { FluentProvider, webLightTheme } from "@fluentui/react-components";
import { MemoryRouter } from "react-router-dom";
import { JailsPage } from "../JailsPage";
@@ -18,7 +17,7 @@ vi.mock("react-router-dom", async () => {
};
});
vi.mock("../hooks/useJails", () => ({
vi.mock("../../hooks/useJailList", () => ({
useJails: () => ({
jails: [
{
@@ -61,14 +60,10 @@ function renderPage() {
}
describe("JailsPage", () => {
it("navigates to Configuration → Jails when a jail is clicked", async () => {
it("renders jail links to the detail page", () => {
renderPage();
const user = userEvent.setup();
const link = screen.getByRole("link", { name: "sshd" });
await user.click(screen.getByText("sshd"));
expect(mockNavigate).toHaveBeenCalledWith("/config", {
state: { tab: "jails", jail: "sshd" },
});
expect(link).toHaveAttribute("href", "/jails/sshd");
});
});