mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 12:31:54 +00:00
test(ui): remove brittle source-string Lighthouse tests
This commit is contained in:
-34
@@ -1,34 +0,0 @@
|
||||
import { render, waitFor } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { SIDEBAR_NAVIGATION_MODE } from "@/hooks/use-sidebar";
|
||||
|
||||
import { LighthouseV2NavigationModeSync } from "./lighthouse-v2-navigation-mode-sync";
|
||||
|
||||
const setNavigationModeMock = vi.fn();
|
||||
|
||||
vi.mock("@/hooks/use-sidebar", () => ({
|
||||
SIDEBAR_NAVIGATION_MODE: {
|
||||
BROWSE: "browse",
|
||||
CHAT: "chat",
|
||||
},
|
||||
useSidebar: (
|
||||
selector: (state: {
|
||||
setNavigationMode: typeof setNavigationModeMock;
|
||||
}) => unknown,
|
||||
) => selector({ setNavigationMode: setNavigationModeMock }),
|
||||
}));
|
||||
|
||||
describe("LighthouseV2NavigationModeSync", () => {
|
||||
it("sets the sidebar navigation mode to chat on mount", async () => {
|
||||
// Given / When
|
||||
render(<LighthouseV2NavigationModeSync />);
|
||||
|
||||
// Then
|
||||
await waitFor(() =>
|
||||
expect(setNavigationModeMock).toHaveBeenCalledWith(
|
||||
SIDEBAR_NAVIGATION_MODE.CHAT,
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,28 +0,0 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("Lighthouse page", () => {
|
||||
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
||||
const pagePath = path.join(currentDir, "page.tsx");
|
||||
const source = readFileSync(pagePath, "utf8");
|
||||
|
||||
it("keys the Cloud chat by the active route conversation", () => {
|
||||
// Given / When / Then
|
||||
expect(source).toContain(
|
||||
'const chatRouteKey = activeSessionId ?? initialPrompt ?? "new";',
|
||||
);
|
||||
expect(source).toContain("key={chatRouteKey}");
|
||||
});
|
||||
|
||||
it("renders the Cloud chat inside the shared application layout", () => {
|
||||
// Given / When / Then
|
||||
expect(source).toContain(
|
||||
'<ContentLayout title="Lighthouse AI" icon={<LighthouseIcon />}>',
|
||||
);
|
||||
expect(source).toContain('className="h-[calc(100dvh-6.5rem)] min-h-0"');
|
||||
expect(source).not.toContain('className="h-dvh min-h-0 p-4 pr-6"');
|
||||
});
|
||||
});
|
||||
@@ -1,18 +0,0 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("Lighthouse settings page", () => {
|
||||
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
||||
const pagePath = path.join(currentDir, "page.tsx");
|
||||
const source = readFileSync(pagePath, "utf8");
|
||||
|
||||
it("uses Settings as the breadcrumb title", () => {
|
||||
// Given / When / Then
|
||||
expect(source).toContain('<ContentLayout title="Settings">');
|
||||
expect(source).not.toContain("contentClassName=");
|
||||
expect(source).not.toContain("Lighthouse Configuration");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user