SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
test(dashboards): e2e for panel and editor flows (#12410)
Abhi kumar120da85b496a
diff --git a/tests/e2e/drivers/panel-config.ts b/tests/e2e/drivers/panel-config.tsindex b741365482..66c3689e4c 100644--- a/tests/e2e/drivers/panel-config.ts+++ b/tests/e2e/drivers/panel-config.ts@@ -36,13 +36,7 @@ export interface ContextLinks {label(): Locator;url(): Locator;save(): Locator;- cancel(): Locator;- addParam(): Locator;- paramKey(index: number): Locator;- paramValue(index: number): Locator;item(index: number): Locator;- edit(index: number): Locator;- remove(index: number): Locator;/*** Closes the URL field's suggestion popover, which otherwise keeps the* dialog reflowing so buttons never settle. Escape would dismiss the whole@@ -82,13 +76,7 @@ function panelConfigDriver(page: Page): PanelConfig {label: contextLinkLabel,url: () => page.getByTestId('context-link-url'),save: () => page.getByTestId('context-link-save'),- cancel: () => page.getByTestId('context-link-cancel'),- addParam: () => page.getByTestId('context-link-add-param'),- paramKey: (index) => page.getByTestId(`context-link-param-key-${index}`),- paramValue: (index) => page.getByTestId(`context-link-param-value-${index}`),item: (index) => page.getByTestId(`context-link-item-${index}`),- edit: (index) => page.getByTestId(`context-link-edit-${index}`),- remove: (index) => page.getByTestId(`context-link-remove-${index}`),async blurFields() {await contextLinkLabel().focus();},diff --git a/tests/e2e/drivers/panel-editor/picker.ts b/tests/e2e/drivers/panel-editor/picker.tsindex 1b77e16beb..c359c23ee4 100644--- a/tests/e2e/drivers/panel-editor/picker.ts+++ b/tests/e2e/drivers/panel-editor/picker.ts@@ -9,44 +9,6 @@ import { PATH } from '../dashboards';const NEW_PANEL_DRAWER = 'panel-type-drawer';-/** The type browser's catalog, in render order. */-export const PANEL_TYPE_TILES: {- kind: PanelKind;- label: string;- category: string;-}[] = [- {- kind: PanelKind.TimeSeries,- label: 'Time Series',- category: 'Trends over time',- },- {- kind: PanelKind.AreaChart,- label: 'Area Chart',- category: 'Trends over time',- },- {- kind: PanelKind.BarChart,- label: 'Bar Chart',- category: 'Compare & rank',- },- {- kind: PanelKind.PieChart,- label: 'Pie Chart',- category: 'Compare & rank',- },- {- kind: PanelKind.Histogram,- label: 'Histogram',- category: 'Distributions',- },- { kind: PanelKind.Heatmap, label: 'Heatmap', category: 'Distributions' },- { kind: PanelKind.Number, label: 'Number', category: 'Single values' },- { kind: PanelKind.Table, label: 'Table', category: 'Raw records' },- { kind: PanelKind.List, label: 'List', category: 'Raw records' },- { kind: PanelKind.Text, label: 'Text', category: 'Documentation' },-];-/*** The New panel drawer every Add panel trigger opens. A tile click only selects* (TimeSeries is preselected); the confirm button navigates to the editor.@@ -54,14 +16,6 @@ export const PANEL_TYPE_TILES: {export interface NewPanelPicker {root(): Locator;tile(kind: PanelKind): Locator;- /** Visible tiles, in render order. */- tiles(): Locator;- /** Visible group headings, in render order. */- groups(): Locator;- search(): Locator;- /** A category chip; its accessible name carries the count. */- category(label: string): Locator;- emptyState(): Locator;/** Reads "Add panel", or "Add to <section>" once there is a choice. */confirmButton(): Locator;/** Selects without confirming. */@@ -79,20 +33,10 @@ export interface NewPanelPicker {export function newPanelDriver(page: Page): NewPanelPicker {const root = (): Locator => page.getByTestId(NEW_PANEL_DRAWER);- const tiles = (): Locator =>- root().locator('[data-testid^="panel-type-signoz/"]');const picker: NewPanelPicker = {root,tile: (kind) => root().getByTestId(`panel-type-${kind}`),- tiles,- groups: () => root().locator('section > span:first-child'),- search: () => root().getByTestId('panel-type-search'),- category: (label) =>- root()- .locator('button[aria-pressed]:not([data-testid])')- .filter({ hasText: new RegExp(`^${escapeRegExp(label)}\\d+$`) }),- emptyState: () => root().getByText(/No panel types match/),confirmButton: () => root().getByTestId('panel-type-confirm'),async pick(kind) {await picker.tile(kind).click();@@ -120,7 +64,3 @@ export function newPanelDriver(page: Page): NewPanelPicker {};return picker;}--function escapeRegExp(text: string): string {- return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');-}diff --git a/tests/e2e/drivers/panels.ts b/tests/e2e/drivers/panels.tsindex b1c2b3a362..2c97c9ef35 100644--- a/tests/e2e/drivers/panels.ts+++ b/tests/e2e/drivers/panels.ts@@ -92,6 +92,8 @@ export interface Panels {item(testId: string): Locator;back(menu: 'breakout' | 'var'): Locator;breakoutSearch(): Locator;+ /** The panel's saved context links, by label. */+ contextLinks(): Locator;/** A page-level Escape does nothing: the handler needs the backdrop. */dismiss(): Promise<void>;};@@ -180,6 +182,7 @@ function panelsDriver(page: Page): Panels {),back: (submenu) => page.getByTestId(`drilldown-${submenu}-back`),breakoutSearch: () => page.getByPlaceholder('Search breakout options...'),+ contextLinks: () => page.getByTestId('drilldown-context-link'),async dismiss() {// A corner, since the menu opens over the clicked point.await pagediff --git a/tests/e2e/drivers/panels/grid.ts b/tests/e2e/drivers/panels/grid.tsindex 54f42fa984..d4ce2723f2 100644--- a/tests/e2e/drivers/panels/grid.ts+++ b/tests/e2e/drivers/panels/grid.ts@@ -14,10 +14,14 @@ import { boxOf, dragBy } from './dom';export interface PanelGrid {/** The grid item's rendered size in px. */size(): Promise<{ width: number; height: number }>;+ /** The grid item's rendered top-left corner in px. */+ position(): Promise<{ x: number; y: number }>;/** Drags RGL's south-east grip by the given offset. */resize(dx: number, dy: number): Promise<void>;/** Drags the header handle across its own width. */dragByHeader(): Promise<void>;+ /** The same drag, started on the ⋮ actions button inside the handle. */+ dragByActionsButton(): Promise<void>;}export function gridAt(page: Page, root: () => Locator): PanelGrid {@@ -29,6 +33,10 @@ export function gridAt(page: Page, root: () => Locator): PanelGrid {const { width, height } = await boxOf(gridItem(), 'the grid item');return { width, height };},+ async position() {+ const { x, y } = await boxOf(gridItem(), 'the grid item');+ return { x, y };+ },async resize(dx, dy) {const grip = await boxOf(gridItem().locator('.react-resizable-handle'),@@ -54,5 +62,22 @@ export function gridAt(page: Page, root: () => Locator): PanelGrid {15,);},+ async dragByActionsButton() {+ const bar = await boxOf(+ root().locator('.panel-drag-handle').first(),+ 'the drag handle',+ );+ // The trigger only appears on hover.+ await root().hover();+ const button = await boxOf(+ root().locator('[data-testid^="panel-actions-"]'),+ 'the actions button',+ );+ const from = {+ x: button.x + button.width / 2,+ y: button.y + button.height / 2,+ };+ await dragBy(page, from, { x: from.x + bar.width, y: from.y }, 15);+ },};}diff --git a/tests/e2e/testdata/dashboards/panels.ts b/tests/e2e/testdata/dashboards/panels.tsindex c99cddf8b0..e8a02e3e0e 100644--- a/tests/e2e/testdata/dashboards/panels.ts+++ b/tests/e2e/testdata/dashboards/panels.ts@@ -231,22 +231,3 @@ export function variablesDashboard(],});}--/** Invalid on purpose: Text must carry `queries: []`; the server rejects this. */-export function textPanelWithQueryDashboard(): PostableDashboard {- const text = panel(PanelKind.Text, { name: 'Notes' });- return buildDashboard({- title: `e2e-text-with-query-${Date.now()}-${uniqueSuffix()}`,- sections: [- {- title: 'Section',- panels: {- [SINGLE_PANEL_ID]: {- ...text,- spec: { ...text.spec, queries: [metricsQuery()] },- },- },- },- ],- });-}diff --git a/tests/e2e/tests/dashboards/editor/capabilities.spec.ts b/tests/e2e/tests/dashboards/editor/capabilities.spec.tsnew file mode 100644index 0000000000..f188182181--- /dev/null+++ b/tests/e2e/tests/dashboards/editor/capabilities.spec.ts@@ -0,0 +1,35 @@+import {+ expect,+ metricsQuery,+ PanelKind,+ SINGLE_PANEL_ID,+ singlePanelDashboard,+ test,+} from '../../../drivers/panel-editor';++// Scope: how the editor explains a disabled kind.++test.describe('Dashboards — editor capabilities', () => {+ test('TC-01 a disabled option explains itself in a tooltip', async ({+ dashboards,+ editor,+ panels,+ }) => {+ await dashboards.seedAndEdit(+ singlePanelDashboard({ query: metricsQuery() }),+ SINGLE_PANEL_ID,+ );++ await editor.openTypeSwitcher();+ await expect(editor.typeOption(PanelKind.List)).toHaveAttribute(+ 'aria-disabled',+ 'true',+ );+ await editor.typeOption(PanelKind.List).hover();++ // The wording is the contract users read.+ await expect(+ panels.tooltip.text("List doesn't support metrics data"),+ ).toBeVisible();+ });+});diff --git a/tests/e2e/tests/dashboards/editor/context-links.spec.ts b/tests/e2e/tests/dashboards/editor/context-links.spec.tsnew file mode 100644index 0000000000..db148a2b25--- /dev/null+++ b/tests/e2e/tests/dashboards/editor/context-links.spec.ts@@ -0,0 +1,79 @@+import {+ expect,+ PanelKind,+ PATH,+ QueryRange,+ ramp,+ Section,+ SINGLE_PANEL_ID,+ singlePanelDashboard,+ test,+} from '../../../drivers/panel-config';++// Scope: a link saved in the editor reaching `panel.spec.links` and the+// drilldown menu. The dialog itself is covered by ContextLinksSection.test.tsx.++test.describe('Dashboards — editor context links', () => {+ test('TC-01 a saved link persists and shows in the drilldown menu', async ({+ authedPage: page,+ dashboards,+ editor,+ config,+ panels,+ queryRange,+ }) => {+ // Mocked so the drilldown click lands on a known series.+ await queryRange.respond(+ QueryRange.timeSeries([+ { labels: { 'service.name': 'adservice' }, points: ramp(12, 2, 8) },+ ]),+ );+ const links = config.contextLinks;+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard(),+ SINGLE_PANEL_ID,+ );++ await editor.section.expand(Section.contextLinks);+ await links.addButton().click();+ await links.label().fill('Runbook');+ await links.url().fill('https://example.com/runbook');+ await links.blurFields();+ await links.save().click();+ await expect(links.item(0)).toBeVisible();+ await editor.save();++ const saved = (await config.saved(id)).links;+ expect(saved).toHaveLength(1);+ // "Label" persists as `name` (Perses link model).+ expect(saved[0]).toMatchObject({+ name: 'Runbook',+ url: 'https://example.com/runbook',+ });++ await page.waitForURL(PATH.onDashboard(id));+ const target = panels.panel(SINGLE_PANEL_ID);+ await expect(target.renderer(PanelKind.TimeSeries)).toBeVisible();+ await target.chart.clickPoint();+ await expect(panels.drilldown.menu()).toBeVisible();+ await expect(panels.drilldown.contextLinks()).toHaveText(['Runbook']);+ });++ test('TC-02 the header quick-add opens the dialog from a collapsed section', async ({+ dashboards,+ editor,+ config,+ }) => {+ await dashboards.seedAndEdit(singlePanelDashboard(), SINGLE_PANEL_ID);++ // One click must expand AND add (pendingAction hop).+ await editor.section.collapse(Section.contextLinks);+ await config.contextLinks.headerAdd().click();++ await expect(editor.section.toggle(Section.contextLinks)).toHaveAttribute(+ 'aria-expanded',+ 'true',+ );+ await expect(config.contextLinks.dialog()).toBeVisible();+ });+});diff --git a/tests/e2e/tests/dashboards/editor/picker.spec.ts b/tests/e2e/tests/dashboards/editor/picker.spec.tsnew file mode 100644index 0000000000..46c982e3e9--- /dev/null+++ b/tests/e2e/tests/dashboards/editor/picker.spec.ts@@ -0,0 +1,211 @@+import {+ compactDashboard,+ emptyDashboard,+ expect,+ PanelKind,+ PATH,+ singlePanelDashboard,+ SINGLE_PANEL_ID,+ test,+} from '../../../drivers/panel-editor';++// Scope: creating a panel — the New panel drawer, the route it hands off to,+// and the JSON-Patch a save emits.+//+// The subtlety: a tile click only selects; the confirm button carries the+// target section, and the editor route carries it on as `layoutIndex`.++test.describe('Dashboards — panel picker', () => {+ test('TC-01 with one section a tile click selects and Add panel creates', async ({+ authedPage: page,+ dashboards,+ editor,+ newPanel,+ }) => {+ const id = await dashboards.seed(emptyDashboard());+ await dashboards.openEmpty(id);++ await dashboards.emptyAddPanel().click();+ // No section to choose, so the confirm names none.+ await expect(newPanel.confirmButton()).toHaveText('Add panel');++ await newPanel.pick(PanelKind.Table);+ await expect(page).toHaveURL(PATH.onDashboard(id));+ await expect(newPanel.root()).toBeVisible();++ await newPanel.confirm();+ expect(dashboards.param('panelKind')).toBe(PanelKind.Table);+ await expect(editor.root()).toBeVisible();+ });++ test('TC-02 with several sections the confirm names its target section', async ({+ dashboards,+ newPanel,+ }) => {+ await dashboards.seedAndOpen(compactDashboard());++ await dashboards.headerAddPanel().click();+ await expect(newPanel.root()).toBeVisible();++ // Every section is titled, so the toolbar trigger defaults to a new root.+ await expect(newPanel.confirmButton()).toHaveText('Add to Dashboard (root)');+ await expect(newPanel.tile(PanelKind.TimeSeries)).toHaveAttribute(+ 'aria-pressed',+ 'true',+ );++ await newPanel.choose(PanelKind.Number);+ expect(dashboards.param('panelKind')).toBe(PanelKind.Number);+ expect(dashboards.param('layoutIndex')).toBe('root');+ });++ test('TC-03 the chosen section becomes the new panel layoutIndex', async ({+ dashboards,+ newPanel,+ }) => {+ await dashboards.seedAndOpen(compactDashboard());++ await dashboards.headerAddPanel().click();+ await newPanel.pick(PanelKind.Number);+ await newPanel.chooseSection('1');+ await expect(newPanel.confirmButton()).toHaveText('Add to Tabular');+ await newPanel.confirm();++ expect(dashboards.param('layoutIndex')).toBe('1');+ });++ test('TC-04 creating from an empty section targets that section', async ({+ dashboards,+ newPanel,+ }) => {+ const dashboard = compactDashboard();++ dashboard.spec.layouts.push({+ kind: 'Grid',+ spec: { display: { title: 'Empty' }, items: [] },+ });+ await dashboards.seedAndOpen(dashboard);++ await newPanel.sectionAddPanel().scrollIntoViewIfNeeded();+ await newPanel.sectionAddPanel().click();++ await expect(newPanel.root()).toBeVisible();+ await expect(newPanel.confirmButton()).toHaveText('Add to Empty');+ await newPanel.choose(PanelKind.TimeSeries);+ expect(dashboards.param('layoutIndex')).toBe('2');+ });++ test('TC-05 saving a new panel emits add-panel and add-layout-item ops', async ({+ dashboards,+ editor,+ newPanel,+ }) => {+ await dashboards.seedAndOpen(singlePanelDashboard());++ const patches = editor.capturePatches();++ await dashboards.headerAddPanel().click();+ // List: its seeded query passes validation (see TC-06).+ await newPanel.choose(PanelKind.List);+ await expect(editor.root()).toBeVisible();++ await editor.title().fill('Created from the modal');+ await editor.save();++ // Targeted adds for panel AND grid item — a replace would clobber edits.+ expect(patches.length).toBeGreaterThan(0);+ const ops = patches[patches.length - 1];+ const panelAdd = ops.find((op) => /^\/spec\/panels\/[^/]+$/.test(op.path));+ expect(panelAdd?.op).toBe('add');+ expect(+ ops.some((op) => /^\/spec\/layouts\/\d+\/spec\/items\/-$/.test(op.path)),+ ).toBe(true);+ });++ test('TC-06 the created panel lands on the dashboard and persists', async ({+ authedPage: page,+ dashboards,+ editor,+ newPanel,+ panels,+ }) => {+ const id = await dashboards.seedAndOpen(singlePanelDashboard());++ const before = await dashboards.get(id);+ const beforeCount = Object.keys(before.spec.panels).length;++ await dashboards.headerAddPanel().click();+ // List is the one kind whose seeded query saves as-is (logs `count()`);+ // metrics kinds are rejected until a metric is chosen — see TC-07.+ await newPanel.choose(PanelKind.List);+ await expect(editor.root()).toBeVisible();+ await editor.title().fill('Fresh list panel');+ await editor.save();++ await page.waitForURL(PATH.onDashboard(id));+ await expect(+ panels.titles().filter({ hasText: 'Fresh list panel' }),+ ).toBeVisible();++ const after = await dashboards.get(id);+ expect(Object.keys(after.spec.panels)).toHaveLength(beforeCount + 1);+ });++ test('TC-07 saving a metrics panel with no metric chosen is rejected', async ({+ dashboards,+ editor,+ newPanel,+ }) => {+ await dashboards.seedAndOpen(singlePanelDashboard());++ await dashboards.headerAddPanel().click();+ await newPanel.choose(PanelKind.Number);+ await expect(editor.root()).toBeVisible();++ // Metrics kinds seed an empty aggregation, so the editor must stay open and+ // surface the reason rather than dropping the panel.+ const { ok, body } = await editor.trySave();+ expect(ok).toBe(false);+ expect(body).toContain('metric name is required');++ await expect(editor.root()).toBeVisible();+ });++ test('TC-08 the editor route redirects when panelKind is missing', async ({+ authedPage: page,+ dashboards,+ panels,+ }) => {+ const id = await dashboards.seed(singlePanelDashboard());++ // No kind to seed, so the page bounces back.+ await dashboards.visit(PATH.editor(id, 'new'));+ await page.waitForURL(PATH.onDashboard(id));+ await expect(panels.panel(SINGLE_PANEL_ID).root()).toBeVisible();+ });++ test('TC-09 a new section from the picker is created on save', async ({+ authedPage: page,+ dashboards,+ editor,+ newPanel,+ }) => {+ const id = await dashboards.seedAndOpen(singlePanelDashboard());++ await dashboards.headerAddPanel().click();+ await newPanel.pick(PanelKind.List);+ await newPanel.newSection('Fresh section');+ await expect(newPanel.confirmButton()).toHaveText('Add to new section');+ await newPanel.confirm();+ expect(dashboards.param('newSection')).toBe('Fresh section');++ await editor.save();+ await page.waitForURL(PATH.onDashboard(id));++ const after = await dashboards.get(id);+ const section = after.spec.layouts.find(+ (layout) => layout.spec.display?.title === 'Fresh section',+ );+ expect(section?.spec.items).toHaveLength(1);+ });+});diff --git a/tests/e2e/tests/dashboards/editor/query.spec.ts b/tests/e2e/tests/dashboards/editor/query.spec.tsnew file mode 100644index 0000000000..8d8f0484f9--- /dev/null+++ b/tests/e2e/tests/dashboards/editor/query.spec.ts@@ -0,0 +1,142 @@+import {+ expect,+ GOLDEN,+ logsCountQuery,+ PanelKind,+ PATH,+ QueryTab,+ SINGLE_PANEL_ID,+ singlePanelDashboard,+ test,+} from '../../../drivers/panel-editor';++// Scope: the query pane and its commit semantics.+//+// The rule worth pinning: editing the builder does NOT move the preview (only+// Run, or a structural change, commits into the draft) — but Save serialises+// the LIVE query anyway, so an unrun edit still persists. Contradictory-looking+// and easy to "fix" into a regression.++test.describe('Dashboards — panel editor query pane', () => {+ test('TC-01 Run Query issues a fresh query_range', async ({+ dashboards,+ editor,+ }) => {+ await dashboards.seedAndEdit(singlePanelDashboard(), SINGLE_PANEL_ID);+ await expect(editor.preview.renderer(PanelKind.TimeSeries)).toBeVisible();++ await editor.query.run();+ });++ test('TC-02 the run keyboard shortcut works from inside the builder', async ({+ dashboards,+ editor,+ }) => {+ await dashboards.seedAndEdit(singlePanelDashboard(), SINGLE_PANEL_ID);+ await expect(editor.preview.renderer(PanelKind.TimeSeries)).toBeVisible();++ // Bound with onKeyDownCapture, so it fires from inside inputs too.+ await editor.query.runShortcut();+ });++ test('TC-03 switching query type re-renders the pane and marks the panel dirty', async ({+ dashboards,+ editor,+ }) => {+ await dashboards.seedAndEdit(singlePanelDashboard(), SINGLE_PANEL_ID);+ await expect(editor.unsavedBadge()).toHaveCount(0);++ await editor.query.tab(QueryTab.promql).click();+ await expect(editor.query.tab(QueryTab.promql)).toHaveAttribute(+ 'aria-selected',+ 'true',+ );++ // Structural change: auto-commits without Run.+ await expect(editor.unsavedBadge()).toBeVisible();+ });++ test('TC-04 choosing a metric makes a new panel savable', async ({+ authedPage: page,+ dashboards,+ editor,+ newPanel,+ }) => {+ // create → configure → save. A new metrics panel seeds an empty+ // aggregation and is rejected until a metric is picked (picker TC-07).+ const id = await dashboards.seedAndOpen(singlePanelDashboard());++ await dashboards.headerAddPanel().click();+ await newPanel.choose(PanelKind.TimeSeries);+ await expect(editor.root()).toBeVisible();++ await editor.query.selectMetric(GOLDEN.metrics.calls);+ await editor.title().fill('Configured then saved');+ await editor.save();++ await page.waitForURL(PATH.onDashboard(id));++ const after = await dashboards.get(id);+ const saved = Object.values(after.spec.panels).find(+ (candidate) => candidate.spec.display.name === 'Configured then saved',+ );+ expect(saved).toBeDefined();+ expect(JSON.stringify(saved?.spec.queries)).toContain(GOLDEN.metrics.calls);+ });++ test('TC-05 an unrun query edit is still persisted by Save', async ({+ dashboards,+ editor,+ }) => {+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard(),+ SINGLE_PANEL_ID,+ );++ // No Run: `buildSaveSpec` serialises the live query, so the edit must+ // survive — otherwise saving without running loses work.+ await editor.query.selectMetric(GOLDEN.metrics.latencyCount);+ await editor.save();++ await expect+ .poll(async () => {+ const after = await dashboards.get(id);+ return JSON.stringify(+ after.spec.panels[SINGLE_PANEL_ID].spec.queries,+ ).includes(GOLDEN.metrics.latencyCount);+ })+ .toBe(true);+ });++ test('TC-06 the in-editor query survives a reload', async ({+ dashboards,+ editor,+ }) => {+ await dashboards.seedAndEdit(singlePanelDashboard(), SINGLE_PANEL_ID);++ await editor.query.selectMetric(GOLDEN.metrics.latencySum);+ await editor.query.run();++ // No forceReset, so the URL query wins and survives a refresh.+ await dashboards.reload();+ await expect(editor.root()).toBeVisible();+ await expect(editor.query.metricInput()).toHaveValue(+ GOLDEN.metrics.latencySum,+ );+ });++ test('TC-07 a logs panel runs without needing a metric', async ({+ dashboards,+ editor,+ }) => {+ await dashboards.seedAndEdit(+ singlePanelDashboard({ query: logsCountQuery() }),+ SINGLE_PANEL_ID,+ );++ // Logs aggregate by expression, so there's no metric to fill.+ await expect(editor.preview.renderer(PanelKind.TimeSeries)).toBeVisible();+ await editor.query.run();+ await editor.save();+ });+});diff --git a/tests/e2e/tests/dashboards/editor/shell.spec.ts b/tests/e2e/tests/dashboards/editor/shell.spec.tsnew file mode 100644index 0000000000..8034579304--- /dev/null+++ b/tests/e2e/tests/dashboards/editor/shell.spec.ts@@ -0,0 +1,184 @@+import {+ EditorText,+ expect,+ PATH,+ SINGLE_PANEL_ID,+ singlePanelDashboard,+ test,+} from '../../../drivers/panel-editor';++// Scope: the editor shell — editing, dirty badge, save, discard guard, locking.+//+// Two counter-intuitive behaviours are pinned so a "cleanup" doesn't change+// them: Save is NOT gated on dirty state (Header.test.tsx), and only the in-app+// close button guards unsaved edits — there is no beforeunload blocker (TC-06).++test.describe('Dashboards — panel editor shell', () => {+ test('TC-01 the editor opens on the panel with its saved title', async ({+ dashboards,+ editor,+ }) => {+ await dashboards.seedAndEdit(singlePanelDashboard(), SINGLE_PANEL_ID);++ await expect(editor.heading()).toBeVisible();+ await expect(editor.title()).toHaveValue('Solo panel');+ await expect(editor.preview.root()).toBeVisible();+ await expect(editor.query.builder()).toBeVisible();+ });++ test('TC-02 editing the title marks the editor dirty', async ({+ dashboards,+ editor,+ }) => {+ await dashboards.seedAndEdit(singlePanelDashboard(), SINGLE_PANEL_ID);++ await expect(editor.unsavedBadge()).toHaveCount(0);+ await editor.title().fill('Renamed panel');+ await expect(editor.unsavedBadge()).toBeVisible();+ });++ test('TC-03 saving persists the title and returns to the dashboard', async ({+ authedPage: page,+ dashboards,+ editor,+ }) => {+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard(),+ SINGLE_PANEL_ID,+ );+ const patches = editor.capturePatches();++ await editor.title().fill('Renamed via editor');+ await editor.description().fill('Edited in the E2E suite');+ await editor.save();++ await page.waitForURL(PATH.onDashboard(id));++ const after = await dashboards.get(id);+ expect(after.spec.panels[SINGLE_PANEL_ID].spec.display.name).toBe(+ 'Renamed via editor',+ );++ // A single targeted add at the panel's spec pointer.+ const ops = patches[patches.length - 1];+ expect(ops).toHaveLength(1);+ expect(ops[0].path).toBe(`/spec/panels/${SINGLE_PANEL_ID}/spec`);+ expect(ops[0].op).toBe('add');+ });++ test('TC-04 closing a pristine editor leaves immediately', async ({+ authedPage: page,+ dashboards,+ editor,+ }) => {+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard(),+ SINGLE_PANEL_ID,+ );++ await editor.close();+ await page.waitForURL(PATH.onDashboard(id));+ await expect(editor.discardModal()).toHaveCount(0);+ });++ test('TC-05 closing a dirty editor asks before discarding', async ({+ authedPage: page,+ dashboards,+ editor,+ }) => {+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard(),+ SINGLE_PANEL_ID,+ );++ await editor.title().fill('Throwaway edit');+ await expect(editor.unsavedBadge()).toBeVisible();++ await editor.close({ expectDirty: true, keepEditing: true });+ await expect(editor.root()).toBeVisible();+ await expect(editor.title()).toHaveValue('Throwaway edit');++ await editor.close({ expectDirty: true });+ await page.waitForURL(PATH.onDashboard(id));++ const after = await dashboards.get(id);+ expect(after.spec.panels[SINGLE_PANEL_ID].spec.display.name).toBe(+ 'Solo panel',+ );+ });++ test('TC-06 unsaved edits hold a refresh, but an in-app route change drops them', async ({+ authedPage: page,+ dashboards,+ editor,+ panels,+ }) => {+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard(),+ SINGLE_PANEL_ID,+ );+ expect(await editor.blocksUnload()).toBe(false);++ await editor.title().fill('Never saved');+ await expect(editor.unsavedBadge()).toBeVisible();+ expect(await editor.blocksUnload()).toBe(true);++ // Known behaviour, not endorsed: a refresh or tab close prompts, but there+ // is no router blocker. If one is added, update this test, don't delete it.+ // The editor offers no link out, and Back only replays its own query sync.+ await dashboards.navigateInApp(PATH.dashboard(id));+ await page.waitForURL(PATH.onDashboard(id));+ await expect(editor.discardModal()).toHaveCount(0);+ await expect(panels.panel(SINGLE_PANEL_ID).title()).toHaveText('Solo panel');++ const after = await dashboards.get(id);+ expect(after.spec.panels[SINGLE_PANEL_ID].spec.display.name).toBe(+ 'Solo panel',+ );+ });++ test('TC-07 a locked dashboard disables Save and says why', async ({+ dashboards,+ editor,+ panels,+ }) => {+ const id = await dashboards.seed(singlePanelDashboard());+ await dashboards.setLocked(id, true);++ await dashboards.openEditor(id, SINGLE_PANEL_ID);++ const save = editor.saveButton();+ await expect(save).toBeDisabled();++ await editor.hoverSave();+ await expect(panels.tooltip.text(EditorText.lockedReason)).toBeVisible();+ });++ test('TC-08 an unknown panel id redirects back to the dashboard', async ({+ authedPage: page,+ dashboards,+ editor,+ }) => {+ const id = await dashboards.seed(singlePanelDashboard());++ await dashboards.visit(PATH.editor(id, 'does-not-exist'));+ await page.waitForURL(PATH.onDashboard(id));+ await expect(editor.root()).toHaveCount(0);+ });++ test('TC-09 Switch to View Mode hands off to the View modal', async ({+ authedPage: page,+ dashboards,+ editor,+ panels,+ }) => {+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard(),+ SINGLE_PANEL_ID,+ );++ await editor.switchToView().click();+ await page.waitForURL(PATH.onDashboardWithParams(id));+ await expect(panels.view.content()).toBeVisible();+ });+});diff --git a/tests/e2e/tests/dashboards/editor/type-switch.spec.ts b/tests/e2e/tests/dashboards/editor/type-switch.spec.tsnew file mode 100644index 0000000000..2f5c98ce0f--- /dev/null+++ b/tests/e2e/tests/dashboards/editor/type-switch.spec.ts@@ -0,0 +1,167 @@+import {+ expect,+ logsCountQuery,+ PanelKind,+ Section,+ SINGLE_PANEL_ID,+ singlePanelDashboard,+ test,+} from '../../../drivers/panel-editor';++// Scope: switching kind mid-edit — what the session cache restores, and which+// config survives a first-visit transfer. Config only carries when the TARGET+// kind declares that control (buildPluginSpec).++test.describe('Dashboards — panel type switching', () => {+ test('TC-01 switching kind re-renders the preview', async ({+ dashboards,+ editor,+ }) => {+ await dashboards.seedAndEdit(singlePanelDashboard(), SINGLE_PANEL_ID);+ await expect(editor.preview.renderer(PanelKind.TimeSeries)).toBeVisible();++ await editor.switchType(PanelKind.Table);+ await expect(editor.preview.renderer(PanelKind.Table)).toBeVisible();+ await expect(editor.preview.renderer(PanelKind.TimeSeries)).toHaveCount(0);+ });++ test('TC-02 switching marks the editor dirty but does not persist', async ({+ dashboards,+ editor,+ }) => {+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard(),+ SINGLE_PANEL_ID,+ );+ await editor.switchType(PanelKind.Number);++ await expect(editor.unsavedBadge()).toBeVisible();+ const after = await dashboards.get(id);+ expect(after.spec.panels[SINGLE_PANEL_ID].spec.plugin.kind).toBe(+ PanelKind.TimeSeries,+ );+ });++ test('TC-03 switching back restores the original kind and its settings from the session cache', async ({+ dashboards,+ editor,+ }) => {+ // Logs, because List rejects metrics; time_series-shaped, because Table+ // can't read `raw`.+ await dashboards.seedAndEdit(+ singlePanelDashboard({ kind: PanelKind.Table, query: logsCountQuery() }),+ SINGLE_PANEL_ID,+ );+ await expect(editor.preview.renderer(PanelKind.Table)).toBeVisible();+ await editor.section.expand(Section.formatting);+ await editor.setTile('decimals', '3');++ // Not the default, so a freshly built Table would not have it.+ await editor.switchType(PanelKind.List);+ await expect(editor.preview.renderer(PanelKind.List)).toBeVisible();++ await editor.switchType(PanelKind.Table);+ await expect(editor.preview.renderer(PanelKind.Table)).toBeVisible();+ await editor.section.expand(Section.formatting);+ await expect(editor.tileInput('decimals', '3')).toBeChecked();+ });++ test('TC-04 the session cache does not survive a reload', async ({+ dashboards,+ editor,+ }) => {+ await dashboards.seedAndEdit(singlePanelDashboard(), SINGLE_PANEL_ID);+ await editor.switchType(PanelKind.Table);+ await expect(editor.preview.renderer(PanelKind.Table)).toBeVisible();++ // The cache is a ref on the mounted editor, so a reload drops it. Reload+ // alone — a redundant goto afterwards crashed the page on WebKit.+ await dashboards.reload();+ await expect(editor.root()).toBeVisible();+ await expect(editor.preview.renderer(PanelKind.TimeSeries)).toBeVisible();+ });++ test('TC-05 a saved switch persists the new kind', async ({+ dashboards,+ editor,+ }) => {+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard(),+ SINGLE_PANEL_ID,+ );+ await editor.switchType(PanelKind.BarChart);+ await editor.save();++ const after = await dashboards.get(id);+ expect(after.spec.panels[SINGLE_PANEL_ID].spec.plugin.kind).toBe(+ PanelKind.BarChart,+ );+ });++ test('TC-06 a panel-wide unit fans out into per-column units on Table', async ({+ dashboards,+ editor,+ }) => {+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard({ pluginSpec: { formatting: { unit: 'ms' } } }),+ SINGLE_PANEL_ID,+ );++ await editor.switchType(PanelKind.Table);+ await editor.save();++ // Table has no panel-wide unit, so it fans out to columns — one-way.+ const after = await dashboards.get(id);+ const formatting =+ after.spec.panels[SINGLE_PANEL_ID].spec.plugin.spec.formatting;+ expect(formatting?.unit).toBeUndefined();+ expect(Object.values(formatting?.columnUnits ?? {})).toContain('ms');+ });++ test('TC-07 custom legend colours are dropped on a first-visit switch', async ({+ dashboards,+ editor,+ }) => {+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard({+ pluginSpec: {+ legend: { position: 'bottom', customColors: { adservice: '#ff0000' } },+ },+ }),+ SINGLE_PANEL_ID,+ );++ await editor.switchType(PanelKind.BarChart);+ await editor.save();++ // Keyed by series label, which the new kind may not reproduce, so dropped.+ // Round-trips as null rather than being omitted.+ const after = await dashboards.get(id);+ const { customColors } =+ after.spec.panels[SINGLE_PANEL_ID].spec.plugin.spec.legend ?? {};+ expect(customColors ?? undefined).toBeUndefined();+ });++ test('TC-08 axis bounds survive a switch between kinds that both declare them', async ({+ dashboards,+ editor,+ }) => {+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard(),+ SINGLE_PANEL_ID,+ );++ await editor.section.expand(Section.axes);+ await editor.control('soft-min').fill('5');+ await editor.control('soft-max').fill('50');++ // Bar Chart also declares minMax, so the bounds must carry over.+ await editor.switchType(PanelKind.BarChart);+ await editor.save();++ const after = await dashboards.get(id);+ const axes = after.spec.panels[SINGLE_PANEL_ID].spec.plugin.spec.axes;+ expect(axes?.softMin).toBe(5);+ expect(axes?.softMax).toBe(50);+ });+});diff --git a/tests/e2e/tests/dashboards/page/actions.spec.ts b/tests/e2e/tests/dashboards/page/actions.spec.tsnew file mode 100644index 0000000000..556f4de016--- /dev/null+++ b/tests/e2e/tests/dashboards/page/actions.spec.ts@@ -0,0 +1,142 @@+import {+ COMPACT_PANELS,+ PanelAction,+ PanelKind,+ QueryRange,+ SINGLE_PANEL_ID,+ compactDashboard,+ expect,+ singlePanelDashboard,+ test,+} from '../../../drivers/panels';++// Scope: what the panel ⋮ menu's actions do — new-tab alert, download, and the+// mutating ones reaching the spec — plus the dashboard lock gating them.+//+// Items carry no testid, so everything matches role + visible label.++test.describe('Dashboards — panel actions', () => {+ test('TC-01 Create Alerts opens the alert builder in a new tab', async ({+ dashboards,+ panels,+ }) => {+ await dashboards.seedAndOpen(compactDashboard());++ const popup = panels.nextTab();+ await panels+ .panel(COMPACT_PANELS.timeseries)+ .actions.run(PanelAction.createAlert);+ const alertTab = await popup;+ await expect(alertTab).toHaveURL(/\/alerts\/new/);+ await alertTab.close();+ });++ // Chromium-only: headless Firefox/WebKit don't surface the canvas blob as a+ // Playwright download event. CSV and SVG are unaffected.+ test('TC-02 Download as PNG produces a file', async ({+ dashboards,+ panels,+ browserName,+ }) => {+ test.skip(+ browserName !== 'chromium',+ 'headless Firefox/WebKit do not emit a download event for the canvas blob',+ );+ await dashboards.seedAndOpen(compactDashboard());+ const target = panels.panel(COMPACT_PANELS.timeseries);+ await target.scrollIntoView();++ const download = panels.nextDownload();+ await target.actions.download('PNG');+ const file = await download;+ expect(file.suggestedFilename()).toMatch(/\.png$/);+ });++ test('TC-03 Clone adds a second panel and persists it', async ({+ dashboards,+ panels,+ }) => {+ const id = await dashboards.seedAndOpen(compactDashboard());++ const before = await dashboards.get(id);+ const beforeCount = Object.keys(before.spec.panels).length;++ await panels.panel(COMPACT_PANELS.timeseries).actions.run(PanelAction.clone);++ await expect+ .poll(async () => Object.keys((await dashboards.get(id)).spec.panels).length)+ .toBe(beforeCount + 1);+ });++ test('TC-04 Delete panel removes the panel and its layout item', async ({+ dashboards,+ panels,+ }) => {+ const id = await dashboards.seedAndOpen(compactDashboard());++ const list = panels.panel(COMPACT_PANELS.list);+ await list.actions.run(PanelAction.delete);+ await expect(dashboards.text('Delete panel?')).toBeVisible();+ await dashboards.confirmDelete().click();++ await expect(list.root()).toHaveCount(0);++ // Optimistic: the panel leaves the DOM before the PATCH lands.+ await expect+ .poll(+ async () => (await dashboards.get(id)).spec.panels[COMPACT_PANELS.list],+ )+ .toBeUndefined();++ // The grid item must go too, or a dangling $ref renders an empty tile.+ const after = await dashboards.get(id);+ const refs = after.spec.layouts.flatMap((layout) =>+ layout.spec.items.map((item) => item.content.$ref),+ );+ expect(refs).not.toContain(`#/spec/panels/${COMPACT_PANELS.list}`);+ });++ test('TC-05 Move to section relocates the panel between sections', async ({+ dashboards,+ panels,+ }) => {+ const id = await dashboards.seedAndOpen(compactDashboard());++ await panels.panel(COMPACT_PANELS.timeseries).actions.moveTo('Tabular');++ const ref = `#/spec/panels/${COMPACT_PANELS.timeseries}`;+ await expect+ .poll(async () => {+ const { spec } = await dashboards.get(id);+ return spec.layouts+ .filter((layout) =>+ layout.spec.items.some((item) => item.content.$ref === ref),+ )+ .map((layout) => layout.spec.display.title);+ })+ .toEqual(['Tabular']);+ });++ // An empty table exports nothing, so the rows are mocked.+ test('TC-06 Download as CSV on a Table panel produces a file', async ({+ dashboards,+ panels,+ queryRange,+ }) => {+ await queryRange.respond(+ QueryRange.scalar({+ groupColumns: ['service.name'],+ aggregationColumns: ['A'],+ rows: [['adservice', 10]],+ }),+ );+ await dashboards.seedAndOpen(singlePanelDashboard({ kind: PanelKind.Table }));+ const table = panels.panel(SINGLE_PANEL_ID);+ await table.waitRendered(PanelKind.Table);++ const download = panels.nextDownload();+ await table.actions.download('CSV');+ const file = await download;+ expect(file.suggestedFilename()).toMatch(/\.csv$/);+ });+});diff --git a/tests/e2e/tests/dashboards/page/drilldown.spec.ts b/tests/e2e/tests/dashboards/page/drilldown.spec.tsnew file mode 100644index 0000000000..a1a6240c3e--- /dev/null+++ b/tests/e2e/tests/dashboards/page/drilldown.spec.ts@@ -0,0 +1,212 @@+import {+ type Dashboards,+ PanelKind,+ type Panels,+ QUERY_TYPE_PANELS,+ QueryRange,+ type QueryRangeMock,+ SINGLE_PANEL_ID,+ VARIABLE_NAMES,+ VARIABLE_PANEL_ID,+ expect,+ metricsQuery,+ queryTypesDashboard,+ ramp,+ singlePanelDashboard,+ test,+ variablesDashboard,+} from '../../../drivers/panels';++// Scope: the drilldown ContextMenu — dismissal, navigation, variables, and+// the query types deliberately excluded. Mocked so a click lands on a known series.++const ONE_SERIES = QueryRange.timeSeries([+ { labels: { 'service.name': 'adservice' }, points: ramp(12, 2, 8) },+]);++async function openChartDrilldown(+ panels: Panels,+ panelId: string,+): Promise<void> {+ await panels.panel(panelId).chart.clickPoint();+ await expect(panels.drilldown.menu()).toBeVisible();+}++async function seedChartPanel({+ dashboards,+ queryRange,+ panels,+}: {+ dashboards: Dashboards;+ queryRange: QueryRangeMock;+ panels: Panels;+}): Promise<string> {+ await queryRange.respond(ONE_SERIES);+ const id = await dashboards.seedAndOpen(singlePanelDashboard());+ await expect(+ panels.panel(SINGLE_PANEL_ID).renderer(PanelKind.TimeSeries),+ ).toBeVisible();+ return id;+}++test.describe('Dashboards — panel drilldown', () => {+ test('TC-01 clicking the backdrop closes the menu', async ({+ dashboards,+ queryRange,+ panels,+ }) => {+ await seedChartPanel({ dashboards, queryRange, panels });+ await openChartDrilldown(panels, SINGLE_PANEL_ID);++ // Backdrop click. Escape only works when the backdrop holds focus.+ await panels.drilldown.dismiss();+ await expect(panels.drilldown.menu()).toHaveCount(0);+ });++ test('TC-02 View in Logs navigates to the logs explorer', async ({+ authedPage: page,+ dashboards,+ queryRange,+ panels,+ }) => {+ await seedChartPanel({ dashboards, queryRange, panels });+ await openChartDrilldown(panels, SINGLE_PANEL_ID);++ // Disabled while the drilldown query resolves.+ const viewLogs = panels.drilldown.item('drilldown-view-logs');+ await expect(viewLogs).toBeEnabled();++ // safeNavigate uses `{ newTab: true }`, so the dashboard stays put.+ const popup = panels.nextTab();+ await viewLogs.click();+ const logsTab = await popup;++ await logsTab.waitForURL(/\/logs\/logs-explorer/);+ // The clicked series carries across as a composite query.+ expect(+ new URL(logsTab.url()).searchParams.get('compositeQuery'),+ ).toBeTruthy();+ await logsTab.close();++ await expect(page).toHaveURL(/\/dashboard\//);+ });++ test('TC-03 Breakout opens a submenu and the back arrow returns', async ({+ dashboards,+ queryRange,+ panels,+ }) => {+ await seedChartPanel({ dashboards, queryRange, panels });+ await openChartDrilldown(panels, SINGLE_PANEL_ID);++ await panels.drilldown.item('drilldown-breakout').click();+ const back = panels.drilldown.back('breakout');+ await expect(back).toBeVisible();+ await expect(panels.drilldown.breakoutSearch()).toBeVisible();++ // Back returns to the aggregate menu.+ await back.click();+ await expect(panels.drilldown.item('drilldown-view-logs')).toBeVisible();+ });++ test('TC-04 the Dashboard Variables submenu offers set and create', async ({+ dashboards,+ queryRange,+ panels,+ }) => {+ await queryRange.respond(ONE_SERIES);+ await dashboards.seedAndOpen(variablesDashboard());+ await expect(+ panels.panel(VARIABLE_PANEL_ID).renderer(PanelKind.TimeSeries),+ ).toBeVisible();++ await openChartDrilldown(panels, VARIABLE_PANEL_ID);+ await panels.drilldown.item('drilldown-dashboard-variables').click();++ // `service.name` is grouped-by and already has a variable, so Set is offered.+ await expect(panels.drilldown.item('drilldown-var-set')).toBeVisible();+ await expect(panels.drilldown.back('var')).toBeVisible();+ });++ test('TC-05 setting a variable from the menu updates the variables bar', async ({+ dashboards,+ queryRange,+ panels,+ }) => {+ await queryRange.respond(ONE_SERIES);+ await dashboards.seedAndOpen(variablesDashboard());+ await expect(+ panels.panel(VARIABLE_PANEL_ID).renderer(PanelKind.TimeSeries),+ ).toBeVisible();++ // Set binds the clicked group-by field, so it targets the dynamic+ // variable on `service.name`; the custom one already defaults to adservice.+ const dynamic = dashboards.variable(VARIABLE_NAMES.dynamic);+ await expect(dynamic).not.toContainText('adservice');++ await openChartDrilldown(panels, VARIABLE_PANEL_ID);+ await panels.drilldown.item('drilldown-dashboard-variables').click();+ await panels.drilldown.item('drilldown-var-set').click();++ await expect(dynamic).toContainText('adservice');+ });++ test('TC-06 creating a variable from the menu patches the dashboard spec', async ({+ dashboards,+ queryRange,+ panels,+ }) => {+ await queryRange.respond(+ QueryRange.timeSeries([+ {+ labels: { 'k8s.namespace.name': 'signoz-adservice' },+ points: ramp(12, 2, 8),+ },+ ]),+ );+ // No matching variable for this field, so the menu offers Create.+ const id = await dashboards.seedAndOpen(+ variablesDashboard(+ undefined,+ metricsQuery({ groupBy: ['k8s.namespace.name'] }),+ ),+ );+ await expect(+ panels.panel(VARIABLE_PANEL_ID).renderer(PanelKind.TimeSeries),+ ).toBeVisible();++ await openChartDrilldown(panels, VARIABLE_PANEL_ID);+ await panels.drilldown.item('drilldown-dashboard-variables').click();+ await panels.drilldown.item('drilldown-var-create').click();++ // Create persists a DYNAMIC variable into spec.variables.+ await expect+ .poll(async () =>+ (await dashboards.get(id)).spec.variables.some(+ (variable) => variable.spec.name === 'k8s.namespace.name',+ ),+ )+ .toBe(true);+ });++ test('TC-07 a non-builder query opens no menu', async ({+ dashboards,+ queryRange,+ panels,+ }) => {+ await queryRange.respond(ONE_SERIES);+ await dashboards.seedAndOpen(queryTypesDashboard());++ const promql = panels.panel(QUERY_TYPE_PANELS.promql);+ const builder = panels.panel(QUERY_TYPE_PANELS.builder);+ await expect(promql.renderer(PanelKind.TimeSeries)).toBeVisible();+ await expect(builder.renderer(PanelKind.TimeSeries)).toBeVisible();++ // Gated to QUERY_BUILDER queries. A menu opened by the first click would+ // swallow the second as a backdrop click, so the builder menu proves it.+ await promql.chart.clickPoint();+ await expect(panels.drilldown.menu()).toHaveCount(0);+ await builder.chart.clickPoint();+ await expect(panels.drilldown.menu()).toBeVisible();+ });+});diff --git a/tests/e2e/tests/dashboards/page/from-scratch.spec.ts b/tests/e2e/tests/dashboards/page/from-scratch.spec.tsnew file mode 100644index 0000000000..e5f46a8fb5--- /dev/null+++ b/tests/e2e/tests/dashboards/page/from-scratch.spec.ts@@ -0,0 +1,111 @@+import {+ expect,+ GOLDEN,+ PanelKind,+ PATH,+ test,+} from '../../../drivers/dashboard-list';++// Scope: a dashboard built entirely through the UI — the list page's Blank+// create flow, its first panel, and deletion from the list.++function uniqueName(label: string): string {+ return `e2e ${label} ${Date.now()}-${Math.floor(Math.random() * 1e6)}`;+}++test.describe('Dashboards — dashboard from scratch', () => {+ test('TC-01 a blank dashboard is created from the list page', async ({+ authedPage: page,+ dashboardList,+ dashboards,+ }) => {+ const name = uniqueName('blank');+ await dashboardList.open();++ const id = await dashboardList.create({+ name,+ description: 'Built through the UI',+ tags: ['team:e2e', 'env:test'],+ });++ await expect(page).toHaveURL(PATH.onDashboard(id));+ await expect(dashboards.title()).toHaveText(name);+ await expect(dashboards.emptyAddPanel()).toBeVisible();++ const saved = await dashboards.get(id);+ expect(saved.spec.display.name).toBe(name);+ expect(saved.spec.display.description).toBe('Built through the UI');+ expect(saved.tags).toEqual(+ expect.arrayContaining([+ { key: 'team', value: 'e2e' },+ { key: 'env', value: 'test' },+ ]),+ );+ expect(saved.tags).toHaveLength(2);+ expect(Object.keys(saved.spec.panels)).toHaveLength(0);+ });++ test('TC-02 Create is disabled until the dashboard has a name', async ({+ dashboardList,+ }) => {+ await dashboardList.open();+ await dashboardList.newDashboardButton().click();++ await dashboardList.nameInput().fill(' ');+ await expect(dashboardList.submit()).toBeDisabled();++ await dashboardList.nameInput().fill(uniqueName('named'));+ await expect(dashboardList.submit()).toBeEnabled();+ });++ test('TC-03 a panel added to the new dashboard persists', async ({+ authedPage: page,+ dashboardList,+ dashboards,+ editor,+ newPanel,+ panels,+ }) => {+ await dashboardList.open();+ const id = await dashboardList.create({ name: uniqueName('first panel') });++ await dashboards.emptyAddPanel().click();+ await newPanel.choose(PanelKind.TimeSeries);+ await editor.title().fill('First panel');+ await editor.query.selectMetric(GOLDEN.metrics.calls);+ await editor.save();+ await page.waitForURL(PATH.onDashboard(id));++ await dashboards.reload();+ await expect(panels.titles()).toHaveText(['First panel']);++ const saved = await dashboards.get(id);+ const persisted = Object.values(saved.spec.panels);+ expect(persisted.map((panel) => panel.spec.plugin.kind)).toEqual([+ PanelKind.TimeSeries,+ ]);+ expect(persisted[0].spec.queries).toHaveLength(1);+ expect(+ saved.spec.layouts.flatMap((layout) => layout.spec.items),+ ).toHaveLength(1);+ });++ test('TC-04 a dashboard is deleted from the list and disappears', async ({+ dashboardList,+ dashboards,+ }) => {+ const name = uniqueName('doomed');+ await dashboardList.open();+ const id = await dashboardList.create({ name });++ await dashboardList.open(name);+ await expect(dashboardList.rowTitle(name)).toBeVisible();++ await dashboardList.delete(name);+ await expect(dashboardList.rowTitle(name)).toHaveCount(0);++ await dashboardList.open(name);+ await expect(dashboardList.rowTitle(name)).toHaveCount(0);+ await expect(dashboards.get(id)).rejects.toThrow(/404/);+ });+});diff --git a/tests/e2e/tests/dashboards/page/layout.spec.ts b/tests/e2e/tests/dashboards/page/layout.spec.tsnew file mode 100644index 0000000000..7562ed0223--- /dev/null+++ b/tests/e2e/tests/dashboards/page/layout.spec.ts@@ -0,0 +1,108 @@+import {+ COMPACT_PANELS,+ PanelKind,+ compactDashboard,+ expect,+ test,+} from '../../../drivers/panels';++// Scope: grid layout mutations — drag, resize, and the guarantee that the+// header's action cluster never starts a drag.++test.describe('Dashboards — grid layout', () => {+ test('TC-01 resizing a panel persists its new size', async ({+ dashboards,+ panels,+ }) => {+ const id = await dashboards.seedAndOpen(compactDashboard());++ const target = panels.panel(COMPACT_PANELS.timeseries);+ await expect(target.renderer(PanelKind.TimeSeries)).toBeVisible();+ const before = await dashboards.gridItem(id, COMPACT_PANELS.timeseries);++ await target.grid.resize(60, 90);++ // The grid persists on resize-stop, so the spec is the source of truth+ // rather than the rendered pixel size.+ await expect+ .poll(async () => {+ const after = await dashboards.gridItem(id, COMPACT_PANELS.timeseries);+ return after.height > before.height || after.width > before.width;+ })+ .toBe(true);+ });++ test('TC-02 a resized layout survives a reload', async ({+ dashboards,+ panels,+ }) => {+ const id = await dashboards.seedAndOpen(compactDashboard());++ const target = panels.panel(COMPACT_PANELS.timeseries);+ await expect(target.renderer(PanelKind.TimeSeries)).toBeVisible();++ await target.grid.resize(0, 90);++ await expect+ .poll(+ async () =>+ (await dashboards.gridItem(id, COMPACT_PANELS.timeseries)).height,+ )+ .toBeGreaterThan(6);++ const persisted = await dashboards.gridItem(id, COMPACT_PANELS.timeseries);+ const rendered = await target.grid.size();+ await dashboards.reload();+ await expect(target.renderer(PanelKind.TimeSeries)).toBeVisible();+ expect(await dashboards.gridItem(id, COMPACT_PANELS.timeseries)).toEqual(+ persisted,+ );+ // The page must lay out from the saved size, not a stale default.+ await expect+ .poll(async () => (await target.grid.size()).height)+ .toBeCloseTo(rendered.height, -1);+ });++ test('TC-03 dragging from the actions button does not move the panel', async ({+ dashboards,+ panels,+ }) => {+ const id = await dashboards.seedAndOpen(compactDashboard());++ const target = panels.panel(COMPACT_PANELS.timeseries);+ await expect(target.renderer(PanelKind.TimeSeries)).toBeVisible();+ const before = await dashboards.gridItem(id, COMPACT_PANELS.timeseries);+ const rendered = await target.grid.position();++ // The ⋮ button sits inside the drag handle but is marked `panel-no-drag`,+ // so the same drag that moves the panel from the header (TC-04) must not.+ await target.grid.dragByActionsButton();+ await target.actions.close();++ expect(await target.grid.position()).toEqual(rendered);+ expect(await dashboards.gridItem(id, COMPACT_PANELS.timeseries)).toEqual(+ before,+ );+ });++ test('TC-04 dragging by the header moves the panel within its section', async ({+ dashboards,+ panels,+ }) => {+ const id = await dashboards.seedAndOpen(compactDashboard());++ const target = panels.panel(COMPACT_PANELS.timeseries);+ await expect(target.renderer(PanelKind.TimeSeries)).toBeVisible();+ const before = await dashboards.gridItem(id, COMPACT_PANELS.timeseries);++ // A full tile-width right, so the swap is unambiguous.+ await target.grid.dragByHeader();++ await expect+ .poll(async () => {+ const after = await dashboards.gridItem(id, COMPACT_PANELS.timeseries);+ return after.x !== before.x || after.y !== before.y;+ })+ .toBe(true);+ });+});diff --git a/tests/e2e/tests/dashboards/page/states.spec.ts b/tests/e2e/tests/dashboards/page/states.spec.tsnew file mode 100644index 0000000000..ba615b5891--- /dev/null+++ b/tests/e2e/tests/dashboards/page/states.spec.ts@@ -0,0 +1,87 @@+import {+ PanelKind,+ PanelMessageText,+ QueryRange,+ SINGLE_PANEL_ID,+ expect,+ ramp,+ singlePanelDashboard,+ test,+} from '../../../drivers/panels';++// Mock-only: a healthy stack always returns data. Every kind shares these+// states, so they are covered once, on TimeSeries.++const SERIES = QueryRange.timeSeries([+ { labels: { 'service.name': 'adservice' }, points: ramp(12, 2, 8) },+]);++test.describe('Dashboards — panel states', () => {+ test('TC-01 an empty result offers Extend time range, which widens the window', async ({+ dashboards,+ queryRange,+ panels,+ }) => {+ await queryRange.respond(QueryRange.empty());+ const windows = queryRange.recordWindows();+ await dashboards.seedAndOpen(singlePanelDashboard());++ const target = panels.panel(SINGLE_PANEL_ID);+ await expect(target.noData()).toBeVisible();+ await expect(target.text(PanelMessageText.noDataTitle)).toBeVisible();+ await expect(target.noDataAction()).toHaveText(PanelMessageText.extendAction);+ await expect(target.noDataSecondaryAction()).toHaveText(+ PanelMessageText.retryAction,+ );++ const span = (w: { start: number; end: number }): number => w.end - w.start;+ const before = Math.max(...windows.map(span));+ expect(before).toBeGreaterThan(0);++ // Widening walks the URL-backed zoom-out ladder, so the refetch asks for a+ // longer window than the one the panel loaded with.+ await target.noDataAction().click();+ await expect.poll(() => windows.some((w) => span(w) > before)).toBe(true);+ });++ test('TC-02 a failing query shows the error state and Retry refetches', async ({+ dashboards,+ queryRange,+ panels,+ }) => {+ // Fail every call, then swap to success before Retry: react-query retries+ // on its own, so "fail once then succeed" never surfaces the error state.+ await queryRange.fail('querier exploded');+ await dashboards.seedAndOpen(singlePanelDashboard());++ const target = panels.panel(SINGLE_PANEL_ID);+ await expect(target.error()).toBeVisible();+ await expect(target.statusError()).toBeVisible();+ await expect(target.text(PanelMessageText.errorTitle)).toBeVisible();+ await expect(target.text('querier exploded')).toBeVisible();++ await queryRange.reset();+ await queryRange.respond(SERIES);++ await target.errorAction().click();+ await expect(target.error()).toHaveCount(0);+ await expect(target.renderer(PanelKind.TimeSeries)).toBeVisible();+ });++ test('TC-03 an in-flight first query shows the loading state', async ({+ dashboards,+ queryRange,+ panels,+ }) => {+ // The loading state, not `panel-refetching`, which needs prior data.+ const held = await queryRange.hold(SERIES);+ await dashboards.seedAndOpen(singlePanelDashboard());++ const target = panels.panel(SINGLE_PANEL_ID);+ await expect(target.loading()).toBeVisible();++ held.release();+ await expect(target.renderer(PanelKind.TimeSeries)).toBeVisible();+ await expect(target.loading()).toHaveCount(0);+ });+});diff --git a/tests/e2e/tests/dashboards/page/view-modal.spec.ts b/tests/e2e/tests/dashboards/page/view-modal.spec.tsnew file mode 100644index 0000000000..72731683b6--- /dev/null+++ b/tests/e2e/tests/dashboards/page/view-modal.spec.ts@@ -0,0 +1,187 @@+import {+ PATH,+ PanelAction,+ PanelKind,+ QueryRange,+ SINGLE_PANEL_ID,+ expect,+ ramp,+ singlePanelDashboard,+ test,+} from '../../../drivers/panel-editor';++// Scope: the View modal, and its two-way handoff with the panel editor.+//+// Both directions carry LIVE, unsaved state — modal → editor via router state+// (`editSpec`), editor → modal via sessionStorage + `compositeQuery`. Losing+// either silently discards in-progress work, so TC-08/TC-09 assert the carried+// state AND that nothing was persisted.++const onEditor = (id: string): RegExp => new RegExp(`/dashboard/${id}/panel/`);++test.describe('Dashboards — View modal', () => {+ test('TC-01 View opens the modal and reflects it in the URL', async ({+ dashboards,+ panels,+ }) => {+ await dashboards.seedAndOpen(singlePanelDashboard());+ const modal = await panels.view.open(SINGLE_PANEL_ID);++ await expect(modal).toBeVisible();+ await expect(panels.view.refresh()).toBeVisible();+ expect(dashboards.param('expandedWidgetId')).toBe(SINGLE_PANEL_ID);+ });++ test('TC-02 the modal opens directly from a deep link', async ({+ dashboards,+ panels,+ }) => {+ const id = await dashboards.seedAndOpen(singlePanelDashboard());++ await dashboards.visit(+ `${PATH.dashboard(id)}?expandedWidgetId=${SINGLE_PANEL_ID}&graphType=graph`,+ );+ await expect(panels.view.content()).toBeVisible();+ });++ test('TC-03 Refresh re-issues the query', async ({+ dashboards,+ queryRange,+ panels,+ }) => {+ await queryRange.respond(+ QueryRange.timeSeries([+ { labels: { 'service.name': 'adservice' }, points: ramp(12, 2, 8) },+ ]),+ );+ await dashboards.seedAndOpen(singlePanelDashboard());+ await panels.view.open(SINGLE_PANEL_ID);+ // The modal's own first query must land before Refresh is measured.+ await expect(panels.view.chart.plotArea()).toBeVisible();++ const windows = queryRange.recordWindows();+ await panels.view.refresh().click();++ await expect.poll(() => windows.length).toBeGreaterThan(0);+ expect(windows[0].end).toBeGreaterThan(windows[0].start);+ });++ test('TC-04 switching the panel type in the modal does not persist', async ({+ dashboards,+ panels,+ }) => {+ const id = await dashboards.seedAndOpen(singlePanelDashboard());+ await panels.view.open(SINGLE_PANEL_ID);++ await panels.view.switchType('Table');+ await expect(panels.view.renderer(PanelKind.Table)).toBeVisible();++ await panels.back();+ const after = await dashboards.get(id);+ expect(after.spec.panels[SINGLE_PANEL_ID].spec.plugin.kind).toBe(+ 'signoz/TimeSeriesPanel',+ );+ });++ test('TC-05 Switch to Edit Mode hands off to the panel editor', async ({+ authedPage: page,+ dashboards,+ panels,+ editor,+ }) => {+ const id = await dashboards.seedAndOpen(singlePanelDashboard());+ await panels.view.open(SINGLE_PANEL_ID);++ await panels.view.switchToEdit().click();++ await page.waitForURL(onEditor(id));+ await expect(editor.root()).toBeVisible();+ });++ test('TC-06 a locked panel opens in View but offers no Switch to Edit', async ({+ dashboards,+ panels,+ }) => {+ // `canSwitchToEdit = canEditDashboard && !isLocked`, but View itself is not+ // role-gated — so the modal opens and only the handoff button is disabled.+ const id = await dashboards.seed(singlePanelDashboard());+ await dashboards.setLocked(id, true);+ await dashboards.open(id);++ await panels.panel(SINGLE_PANEL_ID).actions.run(PanelAction.view);+ await expect(panels.view.content()).toBeVisible();+ await expect(panels.view.switchToEdit()).toBeDisabled();+ await expect(panels.view.refresh()).toBeVisible();+ });++ test('TC-07 View → Edit → View round-trips with no changes', async ({+ authedPage: page,+ dashboards,+ panels,+ editor,+ }) => {+ const id = await dashboards.seedAndOpen(+ singlePanelDashboard({ panelName: 'Round trip' }),+ );+ await panels.view.open(SINGLE_PANEL_ID);++ await panels.view.switchToEdit().click();+ await page.waitForURL(onEditor(id));+ await expect(editor.title()).toHaveValue('Round trip');+ await expect(editor.unsavedBadge()).toHaveCount(0);++ await editor.switchToView().click();+ await expect(panels.view.content()).toBeVisible();++ const after = await dashboards.get(id);+ expect(after.spec.panels[SINGLE_PANEL_ID].spec.display.name).toBe(+ 'Round trip',+ );+ });++ test('TC-08 an unsaved change in the modal carries into the editor', async ({+ authedPage: page,+ dashboards,+ panels,+ editor,+ }) => {+ const id = await dashboards.seedAndOpen(singlePanelDashboard());+ await panels.view.open(SINGLE_PANEL_ID);++ await panels.view.switchType('Table');+ await expect(panels.view.renderer(PanelKind.Table)).toBeVisible();++ await panels.view.switchToEdit().click();+ await page.waitForURL(onEditor(id));++ // Editor opens on the MODIFIED panel, and still nothing is committed.+ await expect(editor.preview.renderer(PanelKind.Table)).toBeVisible();+ const after = await dashboards.get(id);+ expect(after.spec.panels[SINGLE_PANEL_ID].spec.plugin.kind).toBe(+ 'signoz/TimeSeriesPanel',+ );+ });++ test('TC-09 an unsaved change in the editor carries back into the modal', async ({+ dashboards,+ panels,+ editor,+ }) => {+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard(),+ SINGLE_PANEL_ID,+ );++ await editor.title().fill('Edited but not saved');+ await expect(editor.unsavedBadge()).toBeVisible();++ await editor.switchToView().click();+ await expect(panels.view.content()).toBeVisible();+ await expect(panels.view.dialog()).toContainText('Edited but not saved');++ const after = await dashboards.get(id);+ expect(after.spec.panels[SINGLE_PANEL_ID].spec.display.name).toBe(+ 'Solo panel',+ );+ });+});diff --git a/tests/e2e/tests/dashboards/page/zoom.spec.ts b/tests/e2e/tests/dashboards/page/zoom.spec.tsnew file mode 100644index 0000000000..19ad9f3b76--- /dev/null+++ b/tests/e2e/tests/dashboards/page/zoom.spec.ts@@ -0,0 +1,188 @@+import {+ COMPACT_PANELS,+ PanelKind,+ QueryRange,+ SINGLE_PANEL_ID,+ compactDashboard,+ expect,+ ramp,+ singlePanelDashboard,+ test,+} from '../../../drivers/panels';++// Scope: brush-select zoom and the window it writes to.+//+// Mocked, not golden-backed: these need a rendered CANVAS to drag across, and a+// query issued before ClickHouse has the re-seeded rows queryable returns empty+// — "No Data", no canvas, intermittent timeout. Nothing here asserts a value.++/**+ * WebKit only, for the tests that need a drag to actually ZOOM.+ *+ * Mid-drag under WebKit the live uPlot instance shows `cursor.left` updating+ * (mousemove arrives) but `cursor.drag._x === false` and `select.width === 0` —+ * the synthetic mousedown never starts a drag. Chromium and Firefox zoom fine,+ * so this looks like input synthesis rather than the app, though unproven.+ * TC-03 still runs here: it asserts NO zoom, which stays meaningful.+ */+function skipDragZoomOnWebkit(browserName: string): void {+ test.skip(+ browserName === 'webkit',+ 'WebKit: synthetic mousedown does not start a uPlot drag (cursor.drag._x stays false)',+ );+}++const ZOOM_SERIES = [+ { labels: { 'service.name': 'adservice' }, points: ramp(24, 2, 9) },+];++test.describe('Dashboards — panel zoom', () => {+ test.beforeEach(async ({ queryRange }) => {+ await queryRange.respond(QueryRange.timeSeries(ZOOM_SERIES));+ });++ test('TC-01 brush-select writes an absolute window into the URL', async ({+ dashboards,+ panels,+ browserName,+ }) => {+ skipDragZoomOnWebkit(browserName);+ await dashboards.seedAndOpen(singlePanelDashboard());+ const target = panels.panel(SINGLE_PANEL_ID);+ await expect(target.renderer(PanelKind.TimeSeries)).toBeVisible();+ const xSpan = async (): Promise<number> => {+ const { x } = await target.chart.scales();+ return (x.max ?? 0) - (x.min ?? 0);+ };+ const before = await xSpan();+ expect(before).toBeGreaterThan(0);++ await target.chart.drag(0.3, 0.7);++ // An absolute range in the URL is what makes the zoom shareable.+ await expect+ .poll(() =>+ Boolean(dashboards.param('startTime') && dashboards.param('endTime')),+ )+ .toBe(true);++ expect(Number(dashboards.param('endTime'))).toBeGreaterThan(+ Number(dashboards.param('startTime')),+ );++ // The chart must actually show the narrower window, not just the URL. The+ // drag covers 40% of the plot, so the visible span shrinks well below 60%.+ await expect.poll(xSpan).toBeLessThan(before * 0.6);+ expect(await xSpan()).toBeGreaterThan(0);+ });++ test('TC-02 zooming one panel refetches every panel with the zoomed window', async ({+ dashboards,+ queryRange,+ panels,+ browserName,+ }) => {+ skipDragZoomOnWebkit(browserName);+ await dashboards.seedAndOpen(compactDashboard());+ const ids = Object.values(COMPACT_PANELS);+ for (const id of ids) {+ const target = panels.panel(id);+ await target.scrollIntoView();+ await expect(target.visibility()).toHaveAttribute(+ 'data-panel-visible',+ 'true',+ );+ await expect(target.loading()).toHaveCount(0);+ }+ const target = panels.panel(COMPACT_PANELS.timeseries);+ await expect(target.renderer(PanelKind.TimeSeries)).toBeVisible();++ // uPlot's x scale is in seconds; query windows are in ms.+ const { x } = await target.chart.scales();+ const beforeMs = ((x.max ?? 0) - (x.min ?? 0)) * 1000;+ expect(beforeMs).toBeGreaterThan(0);++ const windows = queryRange.recordWindows();+ await target.chart.drag(0.25, 0.75);+ await expect+ .poll(() =>+ Boolean(dashboards.param('startTime') && dashboards.param('endTime')),+ )+ .toBe(true);++ // Zoom updates the global window, so every panel re-queries with a narrower+ // one. A panel may refetch more than once, so panels are counted by their+ // query; the drag covers half the plot, so a zoomed window is well under 80%.+ const zoomedPanels = (): number =>+ new Set(+ windows.filter((w) => w.end - w.start < beforeMs * 0.8).map((w) => w.query),+ ).size;+ await expect.poll(zoomedPanels).toBe(ids.length);+ });++ test('TC-03 a zero-width drag does not zoom', async ({+ dashboards,+ panels,+ }) => {+ await dashboards.seedAndOpen(singlePanelDashboard());+ const target = panels.panel(SINGLE_PANEL_ID);+ await expect(target.renderer(PanelKind.TimeSeries)).toBeVisible();++ // A width-0 selection is dropped, so click-to-drilldown never zooms.+ await target.chart.drag(0.5, 0.5);++ expect(dashboards.param('startTime')).toBeNull();+ expect(dashboards.param('endTime')).toBeNull();+ });++ test('TC-04 the global Zoom out button widens the visible range again', async ({+ dashboards,+ panels,+ browserName,+ }) => {+ skipDragZoomOnWebkit(browserName);+ await dashboards.seedAndOpen(singlePanelDashboard());+ const target = panels.panel(SINGLE_PANEL_ID);+ await expect(target.renderer(PanelKind.TimeSeries)).toBeVisible();+ const xSpan = async (): Promise<number> => {+ const { x } = await target.chart.scales();+ return (x.max ?? 0) - (x.min ?? 0);+ };+ const before = await xSpan();++ await target.chart.drag(0.35, 0.65);+ await expect.poll(xSpan).toBeLessThan(before * 0.6);+ const zoomed = await xSpan();++ // No per-panel reset — zoom-out is global only.+ const zoomOut = dashboards.zoomOut();+ await expect(zoomOut).toBeVisible();+ await zoomOut.click();++ await expect.poll(xSpan).toBeGreaterThan(zoomed);+ });++ test('TC-05 zooming inside the View modal leaves the dashboard window alone', async ({+ dashboards,+ panels,+ browserName,+ }) => {+ skipDragZoomOnWebkit(browserName);+ await dashboards.seedAndOpen(singlePanelDashboard());++ await panels.view.open(SINGLE_PANEL_ID);+ await expect(panels.view.chart.plotArea()).toBeVisible();+ const xSpan = async (): Promise<number> => {+ const { x } = await panels.view.chart.scales();+ return (x.max ?? 0) - (x.min ?? 0);+ };+ const before = await xSpan();++ await panels.view.chart.drag(0.3, 0.7);+ await expect.poll(xSpan).toBeLessThan(before * 0.6);++ // The modal keeps its own window.+ expect(dashboards.param('startTime')).toBeNull();+ expect(dashboards.param('endTime')).toBeNull();+ });+});