test(dashboard): prove /observability/logs opens the application page

The list page shows the same "Loading…" text as the detail page, so the
previous check could not tell which route matched. A missing instance
makes only the detail page answer with its own name, and the GET it
issues names the plural and the application.

Assisted-by: LLM
Signed-off-by: ZverGuy <maximbel2003@gmail.com>
This commit is contained in:
ZverGuy committed 2026-11-10 00:41:10 +07:00
1 parent 2e5a3bd6a7
commit 4be80657be
1 file changed
+14 -2
@@ -98,14 +98,26 @@ describe("ConsolePage routing", () => {
// No ApplicationDefinition plural or application name can be "-", so only
// routes under it are safe from shadowing an application's own pages.
it("leaves /observability/logs to an application named logs of kind observability", async () => {
const client = makeClient()
vi.mocked(client.list).mockImplementation(async (_g, _v, plural) => ({
apiVersion: "v1",
kind: `${plural}List`,
metadata: {},
items:
plural === "tenantnamespaces"
? [{ apiVersion: "core.cozystack.io/v1alpha1", kind: "TenantNamespace", metadata: { name: "tenant-root" } }]
: [],
}) as K8sList<unknown>)
const get = vi.spyOn(client, "get").mockRejectedValue(new Error("not found"))
renderWithK8sProvider(
<TenantProvider>
<ConsolePage />
</TenantProvider>,
{ client: makeClient(), initialRoute: "/observability/logs" },
{ client, initialRoute: "/observability/logs" },
)
expect(await screen.findByText("Loading…")).toBeInTheDocument()
expect(await screen.findByText(/^Application/)).toHaveTextContent("Application logs not found.")
expect(get).toHaveBeenCalledWith(expect.anything(), expect.anything(), "observability", "logs", expect.anything())
expect(screen.queryByText(/^Every application in/)).toBeNull()
})
})