Files
5d52b00f70 feat(studio): combine function invocations and logs (#50957)
With the unified logs preview on, an edge function's Logs tab renders
the unified logs view scoped to that function (#50954), with its
invocations and runtime output in one list. That replaces the separate
Invocations and Logs tabs.

- `UnifiedLogs` takes a `scope` plus view props: `hasFilterSideBar`,
`offeredFilters` and `columnPreferencesKey`. The function Logs tab turns
the sidebar off, which also drops the filters-toggle shortcut, and saves
its columns and panel layout separately from the Logs page.
- `getEdgeFunctionLogsScope` and `EDGE_FUNCTION_LOGS_VIEW` are the edge
function preset: the scope's fixed filters, the filters the tab offers
and its saved-columns key. It offers date, log type, level and message,
so no user filter, since no function row has a user.
- The Invocations tab and its shortcut are hidden. Old Invocations links
redirect to Logs, converting `its`/`ite`/`log` to `date`/`id`.
- `getEdgeFunctionLogsUrl` builds links into the scoped tab with the
shared params serializer from #50953, and clicking a bar on the
invocations chart uses it.

With the preview off, both tabs work as on master.

### How to test

1. Turn on the unified logs preview and open an edge function's Logs
tab. You should see only that function's invocations and runtime logs,
with the filter bar limited to date, log type, level and message.
2. Filter to Edge Function runtime, then to errors, and check counts and
the chart follow.
3. Open an old `/functions/<slug>/invocations?its=…&ite=…&log=…` link.
It lands on Logs with the same range and log selected.
4. Click a bar on the Overview invocations chart. The Logs tab opens on
that bucket.

### Validation

- URL helper, offered filter and preset tests, plus the scoped query
tests from #50954.
- Studio typecheck, lint ratchet, Prettier and knip pass on this layer.

### Stack

Merge in order:

1. #50953 — reusable logs table building blocks
2. #50954 — function-scoped unified logs queries
3. #50955 — slimmer function detail layout, header on Overview
4. #50957 — Invocations merged into a function-scoped Logs tab
5. #50958 — Overview errors in the shared logs table
6. #52281 — remove the legacy Overview

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2026-10-27 14:54:56 +01:00

54 lines
1.7 KiB
TypeScript

import { screen } from '@testing-library/react'
import { expect, it } from 'vitest'
import { EdgeFunctionInvocationsSection } from './EdgeFunctionInvocationsSection'
import { customRender } from '@/tests/lib/custom-render'
it('announces loading, empty, and failed invocation charts through one persistent polite status', () => {
const props = {
dateTimeFormat: 'HH:mm',
totalInvocationCount: 0,
totalErrorCount: 0,
totalWarningCount: 0,
isLoadingFunction: false,
isErrorFunction: false,
isLoadingChart: true,
isErrorChart: false,
chartData: [],
onChartClick: () => {},
}
const { rerender } = customRender(<EdgeFunctionInvocationsSection {...props} />)
const status = screen.getByRole('status')
expect(status).toHaveAttribute('aria-live', 'polite')
expect(status).toHaveTextContent('Loading invocations')
rerender(<EdgeFunctionInvocationsSection {...props} isLoadingChart={false} />)
expect(screen.getByRole('status')).toBe(status)
expect(status).toHaveTextContent('No invocation data to show')
expect(screen.getByText('No data to show')).toBeVisible()
rerender(
<EdgeFunctionInvocationsSection
{...props}
isLoadingChart={false}
isErrorChart
chartErrorMessage="Request failed"
/>
)
expect(screen.getByRole('status')).toBe(status)
expect(status).toHaveTextContent('Unable to load invocations. Request failed')
expect(screen.getByText('Request failed')).toBeVisible()
rerender(
<EdgeFunctionInvocationsSection
{...props}
isLoadingChart={false}
chartData={[
{ timestamp: '2026-03-20T10:00:00Z', ok_count: 1, warning_count: 0, error_count: 0 },
]}
/>
)
expect(screen.getByRole('status')).toBe(status)
expect(status).toBeEmptyDOMElement()
})