mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 13:01:56 +00:00
test(ui): trim brittle Lighthouse tests
This commit is contained in:
@@ -1,22 +1,9 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { DecryptedText } from "./decrypted-text";
|
||||
|
||||
describe("DecryptedText", () => {
|
||||
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
||||
const filePath = path.join(currentDir, "decrypted-text.tsx");
|
||||
const source = readFileSync(filePath, "utf8");
|
||||
|
||||
it("delegates effects to local hooks instead of calling useEffect in the component", () => {
|
||||
expect(source).not.toContain("useEffect");
|
||||
expect(source).not.toContain("useEffect(");
|
||||
});
|
||||
|
||||
it("keeps the accessible text stable while the visible text is encrypted", async () => {
|
||||
// Given / When
|
||||
const { container } = render(
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { ProviderIcon } from "./provider-icon";
|
||||
|
||||
vi.mock("@iconify/react", () => ({
|
||||
Icon: ({ icon, className }: { icon: string; className?: string }) => (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={className}
|
||||
data-icon={icon}
|
||||
data-testid="provider-logo"
|
||||
/>
|
||||
),
|
||||
}));
|
||||
|
||||
describe("ProviderIcon", () => {
|
||||
it("renders the provider logo for every Lighthouse v2 provider", () => {
|
||||
const { rerender } = render(<ProviderIcon provider="openai" />);
|
||||
|
||||
expect(screen.getByTestId("provider-logo")).toHaveAttribute(
|
||||
"data-icon",
|
||||
"simple-icons:openai",
|
||||
);
|
||||
|
||||
rerender(<ProviderIcon provider="bedrock" />);
|
||||
|
||||
expect(screen.getByTestId("provider-logo")).toHaveAttribute(
|
||||
"data-icon",
|
||||
"simple-icons:amazonwebservices",
|
||||
);
|
||||
|
||||
rerender(<ProviderIcon provider="openai-compatible" />);
|
||||
|
||||
expect(screen.getByTestId("provider-logo")).toHaveAttribute(
|
||||
"data-icon",
|
||||
"simple-icons:openai",
|
||||
);
|
||||
});
|
||||
});
|
||||
-43
@@ -112,49 +112,6 @@ describe("LighthouseV2SessionHistory", () => {
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("marks the active session with a visible sidebar indicator", () => {
|
||||
// Given / When
|
||||
renderHistory({
|
||||
activeSessionId: "session-active",
|
||||
sessions: [
|
||||
session({
|
||||
id: "session-active",
|
||||
title: "Active chat",
|
||||
updatedAt: "2026-06-25T09:00:00Z",
|
||||
}),
|
||||
session({
|
||||
id: "session-other",
|
||||
title: "Other chat",
|
||||
updatedAt: "2026-06-25T09:00:00Z",
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
// Then
|
||||
const activeSessionButton = screen.getByRole("button", {
|
||||
name: /Active chat.*Today/,
|
||||
});
|
||||
const otherSessionButton = screen.getByRole("button", {
|
||||
name: /Other chat.*Today/,
|
||||
});
|
||||
const activeSessionTitle =
|
||||
within(activeSessionButton).getByText("Active chat");
|
||||
const otherSessionTitle =
|
||||
within(otherSessionButton).getByText("Other chat");
|
||||
|
||||
expect(activeSessionButton.parentElement).toHaveClass(
|
||||
"before:bg-button-primary",
|
||||
"before:absolute",
|
||||
"before:left-0",
|
||||
);
|
||||
expect(activeSessionButton).toHaveClass("text-text-neutral-primary");
|
||||
expect(activeSessionTitle).toHaveClass("font-medium");
|
||||
expect(otherSessionButton.parentElement).not.toHaveClass(
|
||||
"before:bg-button-primary",
|
||||
);
|
||||
expect(otherSessionTitle).not.toHaveClass("font-medium");
|
||||
});
|
||||
|
||||
it("replaces the age label with the archive action on row hover", () => {
|
||||
// Given / When
|
||||
renderHistory({
|
||||
|
||||
Reference in New Issue
Block a user