Files
beacon-web/tests/features/packets/PacketAnalyzerDrawer.test.tsx
T
MrAlders0n ad4e68f817 packets: highlight timer leak, analyzer close desync, dead code
- fresh-row highlights leaked under a steady stream (each new batch
  cancelled the previous batch's clear timer); per-batch timers in a
  small useFreshHashes hook now
- closing the analyzer drops ?hash and the row selection, so the same
  row reopens on the next click and a closed analyzer stays closed
  after reload/share
- sf=path / sf=payload from the URL fall back to hash search (only
  field matchesFilters implements; the UI options were already disabled)
- remove the summary preview line no backend path ever populates
- channel message rows key on packetHash (live WS messages carry no id)
2026-06-10 07:03:16 -04:00

29 lines
1.0 KiB
TypeScript

import { describe, it, expect, vi } from "vitest";
import { render, screen, fireEvent } from "@testing-library/react";
import { MemoryRouter, useLocation } from "react-router-dom";
import { PacketAnalyzerDrawer } from "../../../src/features/packets/PacketAnalyzerDrawer";
function LocationProbe() {
const location = useLocation();
return <div data-testid="search">{location.search}</div>;
}
describe("PacketAnalyzerDrawer close", () => {
it("removes ?hash from the URL and calls onClose", () => {
const onClose = vi.fn();
render(
<MemoryRouter initialEntries={["/?tab=Packets&hash=abc123"]}>
<PacketAnalyzerDrawer detail={undefined} selectedObservationId={null} onClose={onClose} />
<LocationProbe />
</MemoryRouter>,
);
fireEvent.click(screen.getByLabelText("Close analyzer"));
expect(onClose).toHaveBeenCalledOnce();
const search = screen.getByTestId("search").textContent ?? "";
expect(search).not.toContain("hash=");
expect(search).toContain("tab=Packets"); // other params survive
});
});