diff --git a/packages/system/dashboard/images/console/apps/console/src/components/observability/LogsView.test.tsx b/packages/system/dashboard/images/console/apps/console/src/components/observability/LogsView.test.tsx index fe73e4164..a0df67c68 100644 --- a/packages/system/dashboard/images/console/apps/console/src/components/observability/LogsView.test.tsx +++ b/packages/system/dashboard/images/console/apps/console/src/components/observability/LogsView.test.tsx @@ -62,6 +62,26 @@ describe("LogsView with the production query defaults", () => { expect((await screen.findAllByRole("option")).map((o) => o.textContent)).toEqual(["All"]) }) + it("starts the next tenant with no filter, pod or container of the previous one", async () => { + const { client, raw } = clientWith(defaultHandler) + const { switchTo } = renderWithProductionDefaults(client, "tenant-reset-a") + await userEvent.type(screen.getByLabelText("LogsQL filter"), "error{Enter}") + await userEvent.click(screen.getByRole("combobox", { name: "Pod" })) + await userEvent.click(await screen.findByRole("option", { name: "db-1" })) + await waitFor(() => + expect(raw.mock.calls.some(([p]) => new URL(p, "http://x").searchParams.get("query") === '{kubernetes_pod_name="db-1"} (error)')).toBe(true), + ) + + switchTo("tenant-reset-b") + + await waitFor(() => expect(raw.mock.calls.some(([p]) => p.includes("/tenant-reset-b/") && p.includes("select/logsql/query?"))).toBe(true)) + const first = raw.mock.calls.find(([p]) => p.includes("/tenant-reset-b/") && p.includes("select/logsql/query?"))! + expect(new URL(first[0], "http://x").searchParams.get("query")).toBe("*") + expect(screen.getByRole("combobox", { name: "Pod" })).toHaveTextContent("All") + expect(screen.getByRole("combobox", { name: "Container" })).toHaveTextContent("All") + expect(screen.getByLabelText("LogsQL filter")).toHaveValue("") + }) + it("keeps the current lines while a new filter in the same tenant loads", async () => { const { client } = clientWith((endpoint, params) => endpoint.endsWith("query") && params.get("query") === "slow" ? new Promise(() => {}) : defaultHandler(endpoint, params), diff --git a/packages/system/dashboard/images/console/apps/console/src/components/observability/LogsView.tsx b/packages/system/dashboard/images/console/apps/console/src/components/observability/LogsView.tsx index c2dc8ca5c..8c05a8743 100644 --- a/packages/system/dashboard/images/console/apps/console/src/components/observability/LogsView.tsx +++ b/packages/system/dashboard/images/console/apps/console/src/components/observability/LogsView.tsx @@ -81,9 +81,14 @@ function placeholderFor({ follow, stopped, loading, failed, longestRange, retry return } +// Filter, pod and container belong to one scope; a new tenant or application starts clean. export function LogsView({ scope }: { scope: ObservabilityScope }) { - const client = useK8sClient() const root = logsRoot(scope) + return +} + +function ScopedLogsView({ root }: { root: string }) { + const client = useK8sClient() const [range, setRange] = useState("1h") const [draft, setDraft] = useState("") const [filter, setFilter] = useState("")