🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
import { fireEvent, render, screen } from "@testing-library/react";
const automationRow = {
id: "auto-1",
name: "Ping webhook",
trigger: { id: "trig-1" },
action: { type: "WEBHOOK" },
};
const useQueryMock = vi.fn();
vi.mock("next-auth/react", () => ({
useSession: () => ({ data: null, status: "unauthenticated" }),
}));
vi.mock("@/src/utils/api", () => ({
api: {
automations: {
getAutomations: {
useQuery: () => useQueryMock(),
},
},
useUtils: () => ({
automations: { getAutomations: { fetch: vi.fn(async () => []) } },
}),
},
}));
import { MonitorAutomationsPanel } from "./MonitorAutomationsPanel";
describe("MonitorAutomationsPanel stale-id pruning", () => {
it("does not write back while the query is loading", () => {
useQueryMock.mockReturnValue({ data: undefined, isPending: true });
const onTriggerIdsChange = vi.fn();
render(
<MonitorAutomationsPanel
projectId="p1"
triggerIds={["trig-stale"]}
onTriggerIdsChange={onTriggerIdsChange}
/>,
);
expect(onTriggerIdsChange).not.toHaveBeenCalled();
});
it("hides a stale ID on load without writing back", () => {
useQueryMock.mockReturnValue({ data: [automationRow], isPending: false });
const onTriggerIdsChange = vi.fn();
render(
<MonitorAutomationsPanel
projectId="p1"
triggerIds={["trig-1", "trig-stale"]}
onTriggerIdsChange={onTriggerIdsChange}
/>,
);
expect(onTriggerIdsChange).not.toHaveBeenCalled();
});
it("drops the stale ID when the user toggles a row", () => {
useQueryMock.mockReturnValue({ data: [automationRow], isPending: false });
const onTriggerIdsChange = vi.fn();
render(
<MonitorAutomationsPanel
projectId="p1"
triggerIds={["trig-1", "trig-stale"]}
onTriggerIdsChange={onTriggerIdsChange}
/>,
);
fireEvent.click(screen.getByRole("button", { name: /ping webhook/i }));
expect(onTriggerIdsChange).toHaveBeenCalledTimes(1);
expect(onTriggerIdsChange).toHaveBeenCalledWith([]);
});
});