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 flow for the Time Series panel (#13233)
Abhi kumar0513ab7f1fef
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.test.tsxindex e204c1691e..0f3b0d2014 100644--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.test.tsx+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.test.tsx@@ -131,6 +131,18 @@ describe('ThresholdsSection', () => {expect(screen.queryByTestId('threshold-edit-0')).not.toBeInTheDocument();});+ it('closes the row still in edit mode when another is added', async () => {+ const user = userEvent.setup();+ render(<Harness />);++ await user.click(screen.getByTestId('panel-editor-v2-add-threshold'));+ await user.type(screen.getByTestId('threshold-value-0'), '10');+ await user.click(screen.getByTestId('panel-editor-v2-add-threshold'));++ expect(screen.getByTestId('threshold-value-1')).toBeInTheDocument();+ expect(screen.queryByTestId('threshold-value-0')).not.toBeInTheDocument();+ });+it('flags a threshold unit in a different category than the y-axis unit', async () => {const user = userEvent.setup();render(diff --git a/tests/e2e/drivers/panel-editor/select.ts b/tests/e2e/drivers/panel-editor/select.tsindex bc6d566891..d816262822 100644--- a/tests/e2e/drivers/panel-editor/select.ts+++ b/tests/e2e/drivers/panel-editor/select.ts@@ -7,21 +7,28 @@ import { expect, type Page } from '@playwright/test';import { ownDropdown } from '../../helpers/alert-forms/shared';export interface EditorSelects {- /** Picks an antd Select option, by exact label, by the trigger's testid. */- select(triggerTestId: string, optionLabel: string): Promise<void>;+ /** Picks the panel's own time window, by its exact label. */+ timePreference(label: string): Promise<void>;+}++async function select(+ page: Page,+ triggerTestId: string,+ optionLabel: string,+): Promise<void> {+ const trigger = page.getByTestId(triggerTestId);+ await trigger.click();+ const dropdown = await ownDropdown(page, trigger);+ await expect(dropdown).toBeVisible();+ await dropdown+ .locator('.ant-select-item-option')+ .filter({ has: page.getByText(optionLabel, { exact: true }) })+ .click();}export function selectsAt(page: Page): EditorSelects {return {- async select(triggerTestId, optionLabel) {- const trigger = page.getByTestId(triggerTestId);- await trigger.click();- const dropdown = await ownDropdown(page, trigger);- await expect(dropdown).toBeVisible();- await dropdown- .locator('.ant-select-item-option')- .filter({ has: page.getByText(optionLabel, { exact: true }) })- .click();- },+ timePreference: (label) =>+ select(page, 'panel-editor-v2-time-preference', label),};}diff --git a/tests/e2e/tests/dashboards/kinds/timeseries.spec.ts b/tests/e2e/tests/dashboards/kinds/timeseries.spec.tsnew file mode 100644index 0000000000..a0576181cd--- /dev/null+++ b/tests/e2e/tests/dashboards/kinds/timeseries.spec.ts@@ -0,0 +1,104 @@+import {+ emptyDashboard,+ expect,+ GOLDEN,+ PanelKind,+ PATH,+ QueryRange,+ ramp,+ Section,+ SINGLE_PANEL_ID,+ singlePanelDashboard,+ test,+} from '../../../drivers/panel-config';++// The one full panel flow. Every other kind is trusted to share its editor,+// save and grid plumbing, so their specs stay thin.++const SERIES = QueryRange.timeSeries([+ { labels: { 'service.name': 'adservice' }, points: ramp(24, 10, 80) },+ { labels: { 'service.name': 'cartservice' }, points: ramp(24, 20, 60) },+]);++test.describe('Dashboards — TimeSeries panel', () => {+ test('TC-01 a panel built from the picker saves, renders and survives a reload', async ({+ authedPage: page,+ dashboards,+ queryRange,+ editor,+ newPanel,+ panels,+ config,+ }) => {+ await queryRange.respond(SERIES);+ const id = await dashboards.seed(emptyDashboard());+ await dashboards.openEmpty(id);++ await dashboards.emptyAddPanel().click();+ await newPanel.choose(PanelKind.TimeSeries);+ await editor.title().fill('Calls by service');+ await editor.query.selectMetric(GOLDEN.metrics.calls);+ await editor.query.run();+ await expect(editor.preview.renderer(PanelKind.TimeSeries)).toBeVisible();++ await editor.section.expand(Section.axes);+ await editor.control('soft-max').fill('95');+ await editor.section.expand(Section.legend);+ await editor.setTile('legend-position', 'right');+ await editor.section.expand(Section.thresholds);+ await config.thresholds.addButton().click();+ const row = config.thresholds.row(0);+ await row.value().fill('42');+ await row.label().fill('Too high');+ await row.save().click();+ await editor.save();+ await page.waitForURL(PATH.onDashboard(id));++ const saved = await dashboards.get(id);+ const [panelId] = Object.keys(saved.spec.panels);+ const { plugin } = await config.saved(id, panelId);+ expect(plugin).toMatchObject({+ axes: { softMax: 95 },+ legend: { position: 'right' },+ });+ expect(plugin.thresholds).toEqual([+ expect.objectContaining({ value: 42, label: 'Too high' }),+ ]);++ const target = panels.panel(panelId);+ const expectRendered = async (): Promise<void> => {+ await expect(target.title()).toHaveText('Calls by service');+ await target.waitRendered(PanelKind.TimeSeries);+ // Only a right legend always renders its search box.+ await expect(target.legend.search()).toBeVisible();+ await expect(target.legend.item('adservice')).toBeVisible();+ };+ await expectRendered();++ await dashboards.reload();+ await expectRendered();+ });++ test('TC-02 the panel time preference persists and labels the header pill', async ({+ dashboards,+ editor,+ panels,+ config,+ }) => {+ const id = await dashboards.seedAndEdit(+ singlePanelDashboard(),+ SINGLE_PANEL_ID,+ );++ await editor.section.expand(Section.visualization);+ await editor.timePreference('Last 15 min');+ await editor.save();++ expect((await config.saved(id)).plugin).toMatchObject({+ visualization: { timePreference: 'last_15_min' },+ });+ await expect(panels.panel(SINGLE_PANEL_ID).timePreference()).toHaveText(+ '15m',+ );+ });+});