Skip to content

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.

test(dashboards): e2e for viewing, sections, time range, variables and settings (#13264)

Abhi kumar4daf425a194d
diff --git a/tests/e2e/drivers/dashboard-page.ts b/tests/e2e/drivers/dashboard-page.ts
new file mode 100644
index 0000000000..653544bf8f
--- /dev/null
+++ b/tests/e2e/drivers/dashboard-page.ts
@@ -0,0 +1,314 @@
+/**
+ * AI-owned. Generated and maintained by coding agents alongside the specs that
+ * use it. Do not hand-edit: regenerate it with the spec that needs the change.
+ */
+import { expect, type Locator, type Page } from '@playwright/test';
+
+import { driver } from './kit';
+import { test as panelsTest } from './panels';
+
+// The dashboard page chrome around the grid: breadcrumb, title, toolbar, the
+// Actions menu, the JSON drawer and the section headers.
+
+/** Suffixes of the `dashboard-action-<key>` testids on the Actions menu items. */
+export const DashboardAction = {
+ rename: 'rename',
+ clone: 'clone',
+ lock: 'lock',
+ fullScreen: 'fullscreen',
+ newSection: 'new-section',
+ delete: 'delete',
+} as const;
+
+export type DashboardAction =
+ (typeof DashboardAction)[keyof typeof DashboardAction];
+
+/** Section menu items carry no testid; their label is the contract. */
+export const SectionAction = {
+ addPanel: 'Add panel',
+ rename: 'Rename section',
+ clone: 'Clone section',
+ delete: 'Delete section',
+} as const;
+
+export interface SectionHandle {
+ root(): Locator;
+ /** The header button, named by the title; it toggles collapse. */
+ toggle(): Locator;
+ /** Panel roots mounted in the section: none while collapsed. */
+ panels(): Locator;
+ collapse(): Promise<void>;
+ expand(): Promise<void>;
+ openMenu(): Promise<Locator>;
+ menuItem(label: string): Locator;
+ /** Opens the rename modal and leaves it open. */
+ startRename(): Promise<void>;
+ rename(title: string): Promise<void>;
+ delete(): Promise<void>;
+}
+
+export interface Toolbar {
+ actions(): Locator;
+ configure(): Locator;
+ json(): Locator;
+ newPanel(): Locator;
+ timePicker(): Locator;
+ /** No testid or accessible name: matched by its wrapper class. */
+ refresh(): Locator;
+ autoRefresh(): Locator;
+ feedback(): Locator;
+ share(): Locator;
+}
+
+/** The toolbar's controls, shared with the time picker and settings drivers. */
+export function toolbarAt(page: Page): Toolbar {
+ return {
+ actions: () => page.getByTestId('options'),
+ configure: () => page.getByTestId('show-drawer'),
+ json: () => page.getByTestId('edit-json'),
+ newPanel: () => page.getByTestId('add-panel-header'),
+ timePicker: () => page.getByTestId('dropDown'),
+ refresh: () => page.locator('.refresh-btn button'),
+ autoRefresh: () => page.getByRole('button', { name: 'Set auto refresh' }),
+ feedback: () => page.getByRole('button', { name: 'Feedback' }),
+ share: () => page.getByRole('button', { name: 'Share' }),
+ };
+}
+
+export interface DashboardPage {
+ /** The confirm dialog's Cancel, which carries no testid. */
+ cancelDelete(): Locator;
+ breadcrumb(): Locator;
+ /** The breadcrumb's link back to the list. */
+ breadcrumbHome(): Locator;
+ title(): Locator;
+ documentTitle(): Promise<string>;
+ tags(): Locator;
+ tagsOverflow(): Locator;
+ toolbar: Toolbar;
+ actions: {
+ open(): Promise<Locator>;
+ close(): Promise<void>;
+ item(action: DashboardAction): Locator;
+ run(action: DashboardAction): Promise<void>;
+ };
+ rename: {
+ input(): Locator;
+ save(): Locator;
+ cancel(): Locator;
+ /** Through Actions → Rename, saved with the check button. */
+ to(name: string): Promise<void>;
+ };
+ /** Header icon, rendered once the dashboard has been locked. */
+ lockToggle(): Locator;
+ lock(): Promise<void>;
+ isFullScreen(): Promise<boolean>;
+ exitFullScreen(): Promise<void>;
+ json: {
+ open(): Promise<void>;
+ /** Returns what the Copy button put on the clipboard. */
+ copy(): Promise<string>;
+ /** Resolves with the suggested filename of the downloaded file. */
+ download(): Promise<string>;
+ };
+ section(title: string): SectionHandle;
+ sectionTitles(): Locator;
+ sectionModal: {
+ input(): Locator;
+ submit(): Locator;
+ cancel(): Locator;
+ };
+ /** Through Actions → New section. */
+ addSection(title: string): Promise<void>;
+ /** A variable's selector, which shows its current value. */
+ variableValue(name: string): Locator;
+ /** Shown in place of the page when the dashboard fetch fails. No testid. */
+ loadError(): Locator;
+ navigateSideNav(label: string): Promise<void>;
+ /** The dashboards list, identified by its create button. */
+ listPage(): Locator;
+ /** Collects `pageerror`s from now on. */
+ collectPageErrors(): { readonly errors: Error[] };
+}
+
+function sectionHandle(page: Page, title: string): SectionHandle {
+ const toggle = (): Locator =>
+ page.getByRole('button', { name: title, exact: true });
+ const root = (): Locator =>
+ page.locator('[data-section-layout-index]').filter({ has: toggle() });
+ const menu = (): Locator => page.getByRole('menu');
+ const menuItem = (label: string): Locator =>
+ menu().getByRole('menuitem', { name: label, exact: true });
+ const modal = (): Locator => page.getByRole('dialog');
+
+ const section: SectionHandle = {
+ root,
+ toggle,
+ panels: () => root().locator('[data-panel-root]'),
+ async collapse() {
+ await expect(section.panels().first()).toBeAttached();
+ await toggle().click();
+ await expect(section.panels()).toHaveCount(0);
+ },
+ async expand() {
+ await expect(section.panels()).toHaveCount(0);
+ await toggle().click();
+ await expect(section.panels().first()).toBeAttached();
+ },
+ async openMenu() {
+ await root().locator('[data-testid^="dashboard-section-actions-"]').click();
+ await expect(menu()).toBeVisible();
+ return menu();
+ },
+ menuItem,
+ async startRename() {
+ await section.openMenu();
+ await menuItem(SectionAction.rename).click();
+ await expect(modal()).toBeVisible();
+ },
+ async rename(next) {
+ await section.startRename();
+ await page.getByTestId('section-title-input').fill(next);
+ await page.getByTestId('section-title-submit').click();
+ await expect(modal()).toBeHidden();
+ },
+ async delete() {
+ await section.openMenu();
+ await menuItem(SectionAction.delete).click();
+ await page.getByTestId('confirm-delete').click();
+ await expect(root()).toHaveCount(0);
+ },
+ };
+ return section;
+}
+
+function dashboardPageDriver(page: Page): DashboardPage {
+ const breadcrumb = (): Locator =>
+ page.getByRole('navigation', { name: 'breadcrumb' });
+ const actionsMenu = (): Locator => page.getByRole('menu');
+ const actionItem = (action: DashboardAction): Locator =>
+ page.getByTestId(`dashboard-action-${action}`);
+ const jsonDrawer = (): Locator =>
+ page.getByRole('dialog').filter({ hasText: 'Dashboard JSON' });
+
+ const dashboardPage: DashboardPage = {
+ cancelDelete: () =>
+ page.getByRole('dialog').getByRole('button', { name: 'Cancel' }),
+ breadcrumb,
+ breadcrumbHome: () =>
+ breadcrumb().getByRole('link', { name: 'Dashboard', exact: true }),
+ title: () => page.getByTestId('dashboard-title'),
+ documentTitle: () => page.title(),
+ tags: () => page.getByTestId('dashboard-tags'),
+ tagsOverflow: () => page.getByTestId('dashboard-tags-overflow'),
+ toolbar: toolbarAt(page),
+ actions: {
+ async open() {
+ await dashboardPage.actions.close();
+ await dashboardPage.toolbar.actions().click();
+ await expect(actionsMenu()).toBeVisible();
+ return actionsMenu();
+ },
+ async close() {
+ if ((await actionsMenu().count()) === 0) {
+ return;
+ }
+ await page.keyboard.press('Escape');
+ await expect(actionsMenu()).toHaveCount(0);
+ },
+ item: actionItem,
+ async run(action) {
+ await dashboardPage.actions.open();
+ await actionItem(action).click();
+ },
+ },
+ rename: {
+ input: () => page.getByTestId('dashboard-title-input'),
+ save: () => page.getByTestId('dashboard-title-save'),
+ cancel: () => page.getByTestId('dashboard-title-cancel'),
+ async to(name) {
+ await dashboardPage.actions.run(DashboardAction.rename);
+ await dashboardPage.rename.input().fill(name);
+ await dashboardPage.rename.save().click();
+ await expect(dashboardPage.title()).toHaveText(name);
+ },
+ },
+ lockToggle: () => page.getByTestId('dashboard-lock'),
+ async lock() {
+ await dashboardPage.actions.run(DashboardAction.lock);
+ await expect(dashboardPage.lockToggle()).toHaveAccessibleName(
+ 'Unlock dashboard',
+ );
+ },
+ isFullScreen: () => page.evaluate(() => !!document.fullscreenElement),
+ async exitFullScreen() {
+ await page.evaluate(() => document.exitFullscreen());
+ },
+ json: {
+ async open() {
+ await dashboardPage.toolbar.json().click();
+ await expect(jsonDrawer()).toBeVisible();
+ },
+ async copy() {
+ await page
+ .context()
+ .grantPermissions(['clipboard-read', 'clipboard-write']);
+ await page.getByTestId('json-editor-copy').click();
+ await expect(page.getByText('JSON copied to clipboard')).toBeVisible();
+ return page.evaluate(() =>
+ (
+ globalThis as unknown as {
+ navigator: { clipboard: { readText(): Promise<string> } };
+ }
+ ).navigator.clipboard.readText(),
+ );
+ },
+ async download() {
+ const [file] = await Promise.all([
+ page.waitForEvent('download'),
+ page.getByTestId('json-editor-download').click(),
+ ]);
+ return file.suggestedFilename();
+ },
+ },
+ section: (title) => sectionHandle(page, title),
+ sectionTitles: () =>
+ page.locator('[data-testid^="dashboard-section-toggle-"]'),
+ sectionModal: {
+ input: () => page.getByTestId('section-title-input'),
+ submit: () => page.getByTestId('section-title-submit'),
+ cancel: () => page.getByTestId('section-title-cancel'),
+ },
+ async addSection(title) {
+ await dashboardPage.actions.run(DashboardAction.newSection);
+ await dashboardPage.sectionModal.input().fill(title);
+ await dashboardPage.sectionModal.submit().click();
+ await expect(dashboardPage.section(title).toggle()).toBeVisible();
+ },
+ variableValue: (name) => page.getByTestId(`variable-select-${name}`),
+ loadError: () =>
+ page.getByRole('heading', { name: 'Failed to load dashboard' }),
+ async navigateSideNav(label) {
+ await page
+ .locator('.nav-item')
+ .filter({ hasText: new RegExp(`^${label}$`) })
+ .click();
+ },
+ listPage: () => page.getByTestId('new-dashboard-cta'),
+ collectPageErrors() {
+ const collected = { errors: [] as Error[] };
+ page.on('pageerror', (error) => collected.errors.push(error));
+ return collected;
+ },
+ };
+
+ return dashboardPage;
+}
+
+const withDashboardPage = driver('dashboardPage', ({ page }) =>
+ dashboardPageDriver(page),
+);
+
+export const test = withDashboardPage(panelsTest);
+
+export * from './panels';
diff --git a/tests/e2e/drivers/dashboard-settings.ts b/tests/e2e/drivers/dashboard-settings.ts
new file mode 100644
index 0000000000..131be7761d
--- /dev/null
+++ b/tests/e2e/drivers/dashboard-settings.ts
@@ -0,0 +1,614 @@
+/**
+ * AI-owned. Generated and maintained by coding agents alongside the specs that
+ * use it. Do not hand-edit: regenerate it with the spec that needs the change.
+ */
+import { expect, type Locator, type Page } from '@playwright/test';
+
+import { buildDashboard, panel, PanelKind } from '../helpers/dashboard-spec';
+import type {
+ PostableDashboard,
+ Signal,
+ Variable,
+} from '../helpers/dashboard-spec.types';
+
+import { toolbarAt } from './dashboard-page';
+import { boxOf, dragBy, openSelectOption } from './panels/dom';
+import { PATH } from './dashboards';
+import { driver } from './kit';
+import { test as panelsTest } from './panels';
+
+// The dashboard toolbar: time picker, variables bar and the Configure drawer.
+
+// ─── Variable fixtures ───────────────────────────────────────────────────
+
+export function textVariable(name: string, value: string): Variable {
+ return { kind: 'TextVariable', spec: { name, display: { name }, value } };
+}
+
+export function customVariable(
+ name: string,
+ values: string[],
+ options: { multi?: boolean; all?: boolean } = {},
+): Variable {
+ return listVariable(name, options, {
+ kind: 'signoz/CustomVariable',
+ spec: { customValue: values.join(',') },
+ });
+}
+
+/** `queryValue` is ClickHouse SQL; `{{.name}}` references another variable. */
+export function queryVariable(
+ name: string,
+ queryValue: string,
+ options: { multi?: boolean; all?: boolean } = {},
+): Variable {
+ return listVariable(name, options, {
+ kind: 'signoz/QueryVariable',
+ spec: { queryValue },
+ });
+}
+
+export function dynamicVariable(
+ name: string,
+ attribute: string,
+ signal: Signal,
+): Variable {
+ return listVariable(
+ name,
+ { multi: true, all: true },
+ { kind: 'signoz/DynamicVariable', spec: { name: attribute, signal } },
+ 'alphabetical-asc',
+ );
+}
+
+function listVariable(
+ name: string,
+ options: { multi?: boolean; all?: boolean },
+ plugin: Extract<Variable, { kind: 'ListVariable' }>['spec']['plugin'],
+ sort: 'none' | 'alphabetical-asc' = 'none',
+): Variable {
+ return {
+ kind: 'ListVariable',
+ spec: {
+ name,
+ display: { name },
+ allowAllValue: options.all ?? false,
+ allowMultiple: options.multi ?? false,
+ sort,
+ plugin,
+ },
+ };
+}
+
+export const EMPTY_VARIABLE_QUERY = "SELECT 'none' WHERE 1 = 0";
+
+export const BAR_VARIABLES = {
+ textEnv: 'tb_env',
+ textService: 'tb_service',
+ single: 'cu_single',
+ all: 'cu_all',
+ multi: 'cu_multi',
+ queryParent: 'q_env',
+ queryChild: 'q_service',
+ queryEmpty: 'q_empty',
+ dynamic: 'd_service',
+} as const;
+
+export const BAR_VALUES = {
+ textEnv: 'otel-demo',
+ textService: 'frontend',
+ envs: ['otel-demo', 'mq-kafka', 'production'],
+ services: ['adservice', 'frontend', 'checkout'],
+ // Short enough that the child's chip is not truncated.
+ queryEnvs: ['prod', 'stage'],
+} as const;
+
+/** Each child option is its parent's value plus this suffix. */
+export const QUERY_CHILD_SUFFIX = '-svc';
+
+/** One variable per control the bar renders, in spec order. */
+export function variablesBarDashboard(
+ options: { dynamicAttribute?: string } = {},
+): PostableDashboard {
+ const v = BAR_VARIABLES;
+ return buildDashboard({
+ title: `e2e-variables-bar-${Date.now()}-${process.pid}`,
+ variables: [
+ textVariable(v.textEnv, BAR_VALUES.textEnv),
+ textVariable(v.textService, BAR_VALUES.textService),
+ customVariable(v.single, [...BAR_VALUES.envs]),
+ customVariable(v.all, [...BAR_VALUES.envs], { multi: true, all: true }),
+ customVariable(v.multi, [...BAR_VALUES.services], { multi: true }),
+ queryVariable(
+ v.queryParent,
+ `SELECT arrayJoin(['${BAR_VALUES.queryEnvs.join("', '")}'])`,
+ ),
+ queryVariable(
+ v.queryChild,
+ `SELECT concat({{.${v.queryParent}}}, '${QUERY_CHILD_SUFFIX}')`,
+ { multi: true },
+ ),
+ queryVariable(v.queryEmpty, EMPTY_VARIABLE_QUERY, { multi: true }),
+ dynamicVariable(
+ v.dynamic,
+ options.dynamicAttribute ?? 'service.name',
+ 'metrics',
+ ),
+ ],
+ // Queryless, so opening the dashboard issues no panel query.
+ sections: [
+ {
+ title: 'Notes',
+ panels: { notes: panel(PanelKind.Text, { name: 'Notes' }) },
+ },
+ ],
+ });
+}
+
+// ─── Time picker ─────────────────────────────────────────────────────────
+
+export const REFRESH_INTERVALS = [
+ '5 seconds',
+ '10 seconds',
+ '30 seconds',
+ '1 minute',
+ '5 minutes',
+ '10 minutes',
+ '30 minutes',
+ '1 hour',
+ '2 hours',
+ '1 day',
+] as const;
+
+export type RefreshInterval = (typeof REFRESH_INTERVALS)[number];
+
+export interface TimePicker {
+ /** Its accessible name is the selected range's label. */
+ input(): Locator;
+ /** The offset badge, e.g. 'UTC + 9:00'. */
+ timezoneBadge(): Locator;
+ open(): Promise<void>;
+ /** `value` is the preset's key, e.g. '1h'. */
+ selectPreset(value: string): Promise<void>;
+ /** Picks two days of the previous month, then applies. */
+ selectPreviousMonthRange(fromDay: number, toDay: number): Promise<void>;
+ /** Picks the first zone matching `search`. */
+ selectTimezone(search: string, name: string): Promise<void>;
+ refresh(): Locator;
+ autoRefresh: {
+ open(): Promise<void>;
+ checkbox(): Locator;
+ interval(label: RefreshInterval): Locator;
+ /** The interval carrying the check mark. */
+ selected(): Locator;
+ };
+}
+
+function ordinal(day: number): string {
+ const tens = day % 100;
+ if (tens >= 11 && tens <= 13) {
+ return `${day}th`;
+ }
+ const suffix = { 1: 'st', 2: 'nd', 3: 'rd' }[day % 10] ?? 'th';
+ return `${day}${suffix}`;
+}
+
+function timePickerDriver(page: Page): TimePicker {
+ const toolbar = toolbarAt(page);
+ const input = (): Locator => toolbar.timePicker();
+ const options = (): Locator => page.locator('.date-time-popover');
+ // The timezone footer sits outside `.date-time-popover`.
+ const popover = (): Locator => page.locator('.date-time-root');
+ const autoRefreshMenu = (): Locator => page.locator('.auto-refresh-menu');
+
+ const picker: TimePicker = {
+ input,
+ timezoneBadge: () => page.locator('.timezone-badge'),
+ async open() {
+ // A click before the picker is interactive is dropped silently.
+ await expect(async () => {
+ if (!(await options().isVisible())) {
+ await input().click();
+ }
+ await expect(options()).toBeVisible({ timeout: 3_000 });
+ }).toPass({ timeout: 30_000 });
+ },
+ async selectPreset(value) {
+ const option = page.getByTestId(`time-option-${value}`);
+ // A click on a popover still animating closed is dropped, so retry.
+ await expect(async () => {
+ await picker.open();
+ await option.click();
+ await expect(option).toBeHidden({ timeout: 3_000 });
+ }).toPass({ timeout: 30_000 });
+ },
+ async selectPreviousMonthRange(fromDay, toDay) {
+ await picker.open();
+ await page.getByTestId('time-option-custom').click();
+ await popover()
+ .getByRole('button', { name: 'Go to the Previous Month' })
+ .click();
+ const day = (n: number): Locator =>
+ popover()
+ .getByRole('gridcell', { name: new RegExp(`\\b${ordinal(n)}\\b`) })
+ .first();
+ await day(fromDay).click();
+ await day(toDay).click();
+ await popover().getByRole('button', { name: 'Apply' }).click();
+ await expect(options()).toBeHidden();
+ },
+ async selectTimezone(search, name) {
+ await picker.open();
+ await popover().getByRole('button', { name: 'Change Timezone' }).click();
+ await popover().getByPlaceholder('Search timezones...').fill(search);
+ await popover()
+ .getByRole('button', { name: new RegExp(`^${name}\\b`) })
+ .click();
+ },
+ refresh: () => toolbar.refresh(),
+ autoRefresh: {
+ async open() {
+ await toolbar.autoRefresh().click();
+ await expect(autoRefreshMenu()).toBeVisible();
+ },
+ checkbox: () =>
+ autoRefreshMenu().getByRole('checkbox', { name: 'Auto Refresh' }),
+ interval: (label) =>
+ autoRefreshMenu().getByRole('button', { name: label, exact: true }),
+ selected: () =>
+ autoRefreshMenu()
+ .locator('.refresh-interval-btns')
+ .filter({
+ has: page.locator('svg'),
+ }),
+ },
+ };
+ return picker;
+}
+
+// ─── Variables bar ───────────────────────────────────────────────────────
+
+export type SharedSelection = Record<string, string | string[]>;
+
+export interface VariablesBar {
+ root(): Locator;
+ /** Overflowing variables stay hidden until the bar is expanded. */
+ expand(): Promise<void>;
+ /**
+ * Opens the dashboard through a share link's `?variables=`, as a returning
+ * visitor: on a first visit the auto-selected defaults overwrite the link's
+ * values (see `firstVisitWith`).
+ */
+ openWith(id: string, selection: SharedSelection): Promise<void>;
+ /** The share link as a first-time visitor opens it. */
+ firstVisitWith(id: string, selection: SharedSelection): Promise<void>;
+ /** The `$name` labels in render order. */
+ names(): Promise<string[]>;
+ label(name: string): Locator;
+ variable(name: string): Locator;
+ textbox(name: string): Locator;
+ /** Commits on Enter. */
+ type(name: string, value: string): Promise<void>;
+ select(name: string): Locator;
+ open(name: string): Promise<void>;
+ /** Multi-selects commit when the dropdown closes. */
+ close(name: string): Promise<void>;
+ listbox(): Locator;
+ option(label: string): Locator;
+ /** Hovers the variable's info icon and returns its tooltip. */
+ info(name: string): Promise<Locator>;
+ /** Resolves once a query variable's options for `query` come back. */
+ optionsFetched(query: string): Promise<void>;
+ /** Single-select: picks one option. */
+ pick(name: string, value: string): Promise<void>;
+ /** Multi-select: toggles each value, then closes to commit. */
+ toggle(name: string, values: string[]): Promise<void>;
+ chip(name: string, value: string): Locator;
+ /** The selection a share link carries when variables are included. */
+ shared(): Promise<SharedSelection>;
+ /**
+ * Writes one sample per value under a metric label, for a dynamic variable
+ * to resolve. The golden dataset leaves the attribute metadata empty.
+ */
+ seedMetricLabel(label: string, values: string[]): Promise<void>;
+}
+
+function variablesBarDriver(page: Page): VariablesBar {
+ const root = (): Locator => page.getByTestId('dashboard-variables-bar');
+ const variable = (name: string): Locator =>
+ page.getByTestId(`variable-${name}`);
+ const select = (name: string): Locator =>
+ page.getByTestId(`variable-select-${name}`);
+ const listbox = (): Locator =>
+ page.getByRole('listbox').locator('visible=true');
+ const more = (): Locator => page.getByTestId('dashboard-variables-more');
+
+ const bar: VariablesBar = {
+ root,
+ async expand() {
+ await expect(root()).toBeVisible();
+ if ((await more().getAttribute('aria-expanded')) !== 'true') {
+ await more().click();
+ }
+ await expect(more()).toHaveAttribute('aria-expanded', 'true');
+ },
+ async openWith(id, selection) {
+ await page.goto(PATH.dashboard(id));
+ await expect(root()).toBeVisible();
+ await bar.firstVisitWith(id, selection);
+ },
+ async firstVisitWith(id, selection) {
+ const search = new URLSearchParams({
+ relativeTime: '30m',
+ variables: JSON.stringify(selection),
+ });
+ await page.goto(`${PATH.dashboard(id)}?${search.toString()}`);
+ await expect(root()).toBeVisible();
+ },
+ async names() {
+ await expect(root()).toBeVisible();
+ return root().locator('[title^="$"]').allTextContents();
+ },
+ label: (name) => variable(name).getByTitle(`$${name}`, { exact: true }),
+ variable,
+ textbox: (name) => page.getByTestId(`variable-input-${name}`),
+ async type(name, value) {
+ const input = bar.textbox(name);
+ await input.fill(value);
+ await input.press('Enter');
+ },
+ select,
+ async open(name) {
+ await select(name).click();
+ await expect(listbox()).toBeVisible();
+ },
+ async close(name) {
+ // The multi-select swallows Escape, so click outside it.
+ await bar.label(name).click();
+ await expect(listbox()).toBeHidden();
+ },
+ listbox,
+ option: (label) =>
+ listbox().getByRole('option', { name: label, exact: true }),
+ async info(name) {
+ // The icon is a bare lucide svg: no testid or accessible name.
+ await variable(name).locator('svg[class*="infoIcon"]').hover();
+ const tooltip = page.getByRole('tooltip');
+ await expect(tooltip).toBeVisible();
+ return tooltip;
+ },
+ async optionsFetched(query) {
+ await page.waitForResponse(
+ (r) =>
+ r.url().includes('/variables/query') &&
+ (r.request().postDataJSON() as { query?: string } | null)?.query === query,
+ );
+ },
+ async pick(name, value) {
+ await bar.open(name);
+ await bar.option(value).click();
+ await expect(listbox()).toBeHidden();
+ },
+ async toggle(name, values) {
+ await bar.open(name);
+ for (const value of values) {
+ await bar.option(value).click();
+ }
+ await bar.close(name);
+ },
+ chip: (name, value) =>
+ variable(name).getByRole('button', {
+ name: `Remove tag ${value}`,
+ exact: true,
+ }),
+ async shared() {
+ // The link is copied through a transient selection, never shown.
+ await page.evaluate(() => {
+ document.addEventListener(
+ 'copy',
+ () => {
+ (globalThis as { e2eCopied?: string }).e2eCopied = String(
+ globalThis.getSelection(),
+ );
+ },
+ { capture: true, once: true },
+ );
+ });
+ await toolbarAt(page).share().click();
+ const modal = page.locator('.share-modal-content');
+ const include = modal
+ .locator('.absolute-relative-time-toggler-container')
+ .filter({ hasText: 'Include variables' })
+ .getByRole('switch');
+ await include.click();
+ await expect(include).toBeChecked();
+ await modal.getByRole('button', { name: 'Copy page link' }).click();
+ const link = await page.evaluate(
+ () => (globalThis as { e2eCopied?: string }).e2eCopied ?? '',
+ );
+ const raw = new URL(link).searchParams.get('variables');
+ expect(raw, `no variables in the shared link ${link}`).not.toBeNull();
+ return JSON.parse(raw as string) as SharedSelection;
+ },
+ async seedMetricLabel(label, values) {
+ const timestamp = new Date(Date.now() - 60_000).toISOString();
+ const seeder = process.env.SIGNOZ_E2E_SEEDER_URL;
+ expect(seeder, 'SIGNOZ_E2E_SEEDER_URL is not set').toBeTruthy();
+ const res = await page.request.post(`${seeder}/telemetry/metrics`, {
+ data: values.map((value) => ({
+ metric_name: 'e2e_dynamic_variable',
+ labels: { [label]: value },
+ timestamp,
+ value: 1,
+ temporality: 'Cumulative',
+ type_: 'Sum',
+ is_monotonic: true,
+ })),
+ });
+ expect(res.ok(), `seeder POST ${res.status()}`).toBe(true);
+ },
+ };
+ return bar;
+}
+
+// ─── Configure drawer ────────────────────────────────────────────────────
+
+export type SettingsTab = 'Overview' | 'Variables' | 'Publish';
+export type VariableTypeTab = 'dynamic' | 'textbox' | 'custom' | 'query';
+
+export interface DashboardSettings {
+ configure(): Locator;
+ open(): Promise<void>;
+ close(): Promise<void>;
+ dialog(): Locator;
+ heading(): Locator;
+ tab(name: SettingsTab): Locator;
+ openTab(name: SettingsTab): Promise<void>;
+ panel(): Locator;
+ overview: {
+ name(): Locator;
+ description(): Locator;
+ tagInput(): Locator;
+ addTag(tag: string): Promise<void>;
+ unsaved(): Locator;
+ save(): Locator;
+ discard(): Locator;
+ };
+ variables: {
+ list(): Locator;
+ row(name: string): Locator;
+ add(): Locator;
+ edit(name: string): Promise<void>;
+ /** Confirms inline. */
+ remove(name: string): Promise<void>;
+ /** Drags `name`'s grip onto `target`'s row. */
+ reorder(name: string, target: string): Promise<void>;
+ };
+ form: {
+ name(): Locator;
+ type(type: VariableTypeTab): Locator;
+ customValues(): Locator;
+ /** Searches the dynamic variable's field select and picks `field`. */
+ dynamicField(field: string): Promise<void>;
+ textDefault(): Locator;
+ queryEditor(): Locator;
+ error(text: string): Locator;
+ save(): Locator;
+ discard(): Locator;
+ };
+ publish: {
+ text(text: string): Locator;
+ timeRange(): Locator;
+ publish(): Locator;
+ };
+}
+
+function settingsDriver(page: Page): DashboardSettings {
+ const dialog = (): Locator =>
+ page.getByRole('dialog').filter({ hasText: 'Dashboard Configuration' });
+ const panelLocator = (): Locator => dialog().getByRole('tabpanel').first();
+
+ const settings: DashboardSettings = {
+ configure: () => toolbarAt(page).configure(),
+ async open() {
+ await settings.configure().click();
+ await expect(dialog()).toBeVisible();
+ },
+ async close() {
+ await dialog().getByRole('button', { name: 'Close' }).click();
+ await expect(dialog()).toBeHidden();
+ },
+ dialog,
+ heading: () => dialog().getByText('Dashboard Configuration'),
+ tab: (name) => dialog().getByRole('tab', { name, exact: true }),
+ async openTab(name) {
+ await settings.tab(name).click();
+ await expect(settings.tab(name)).toHaveAttribute('aria-selected', 'true');
+ },
+ panel: panelLocator,
+ overview: {
+ name: () => dialog().getByTestId('dashboard-name'),
+ description: () => dialog().getByTestId('dashboard-desc'),
+ tagInput: () => dialog().getByTestId('tag-key-value-input'),
+ async addTag(tag) {
+ const input = settings.overview.tagInput();
+ await input.fill(tag);
+ await input.press('Enter');
+ await expect(
+ dialog().getByTestId('tag-key-value-input-chip').filter({ hasText: tag }),
+ ).toBeVisible();
+ },
+ unsaved: () => dialog().getByText(/unsaved changes?$/),
+ save: () => dialog().getByTestId('save-dashboard-config'),
+ discard: () => dialog().getByRole('button', { name: 'Discard' }),
+ },
+ variables: {
+ list: () => dialog().getByTestId('variables-list'),
+ row: (name) => dialog().getByTestId(`variable-row-${name}`),
+ add: () => dialog().getByTestId('add-variable'),
+ async edit(name) {
+ await dialog().getByTestId(`variable-edit-${name}`).click();
+ await expect(settings.form.name()).toBeVisible();
+ },
+ async remove(name) {
+ await dialog().getByTestId(`variable-delete-${name}`).click();
+ await dialog().getByTestId(`variable-delete-confirm-${name}`).click();
+ await expect(settings.variables.row(name)).toHaveCount(0);
+ },
+ async reorder(name, target) {
+ const grip = await boxOf(
+ settings.variables
+ .row(name)
+ .getByRole('button', { name: 'Reorder variable' }),
+ 'the reorder grip',
+ );
+ const to = await boxOf(settings.variables.row(target), 'the target row');
+ // dnd-kit's pointer sensor activates on the first move.
+ await dragBy(
+ page,
+ { x: grip.x + grip.width / 2, y: grip.y + grip.height / 2 },
+ { x: grip.x + grip.width / 2, y: to.y + to.height / 4 },
+ 20,
+ );
+ },
+ },
+ form: {
+ name: () => dialog().getByTestId('variable-name'),
+ type: (type) => dialog().getByTestId(`variable-type-${type}`),
+ customValues: () => dialog().getByTestId('variable-custom-input'),
+ async dynamicField(field) {
+ const select = dialog().getByTestId('variable-field-select');
+ await select.click();
+ await page.keyboard.type(field);
+ await openSelectOption(page, field).click();
+ await expect(select).toContainText(field);
+ },
+ textDefault: () => dialog().getByTestId('variable-text-input'),
+ // Monaco renders a textbox named "Editor content" with no test id.
+ queryEditor: () => dialog().locator('.monaco-editor'),
+ error: (text) => dialog().getByText(text),
+ save: () => dialog().getByTestId('variable-save'),
+ discard: () => dialog().getByRole('button', { name: 'Discard' }),
+ },
+ publish: {
+ text: (text) => panelLocator().getByText(text),
+ timeRange: () =>
+ panelLocator().getByRole('switch', { name: 'Enable time range' }),
+ publish: () =>
+ panelLocator().getByRole('button', { name: 'Publish Dashboard' }),
+ },
+ };
+ return settings;
+}
+
+const withTimePicker = driver('timePicker', ({ page }) =>
+ timePickerDriver(page),
+);
+const withVariablesBar = driver('variablesBar', ({ page }) =>
+ variablesBarDriver(page),
+);
+const withSettings = driver('settings', ({ page }) => settingsDriver(page));
+
+export const test = withSettings(withVariablesBar(withTimePicker(panelsTest)));
+
+export * from './panels';
diff --git a/tests/e2e/helpers/dashboard-spec.types.ts b/tests/e2e/helpers/dashboard-spec.types.ts
index 4dd461f455..b7c893dd7b 100644
--- a/tests/e2e/helpers/dashboard-spec.types.ts
+++ b/tests/e2e/helpers/dashboard-spec.types.ts
@@ -198,7 +198,7 @@ export type Variable =
kind: 'ListVariable';
spec: {
name: string;
- display: { name: string };
+ display: { name: string; description?: string };
allowAllValue: boolean;
allowMultiple: boolean;
sort: 'none' | 'alphabetical-asc' | 'alphabetical-desc';
@@ -213,7 +213,11 @@ export type Variable =
}
| {
kind: 'TextVariable';
- spec: { name: string; display: { name: string }; value: string };
+ spec: {
+ name: string;
+ display: { name: string; description?: string };
+ value: string;
+ };
};
// ─── Dashboard ───────────────────────────────────────────────────────────
diff --git a/tests/e2e/tests/dashboards/page/edge-cases.spec.ts b/tests/e2e/tests/dashboards/page/edge-cases.spec.ts
new file mode 100644
index 0000000000..685aac1cb7
--- /dev/null
+++ b/tests/e2e/tests/dashboards/page/edge-cases.spec.ts
@@ -0,0 +1,98 @@
+import {
+ SINGLE_PANEL_ID,
+ compactDashboard,
+ expect,
+ singlePanelDashboard,
+ test,
+} from '../../../drivers/dashboard-page';
+
+const MISSING_ID = 'nonexistent-id-99999';
+
+// 2023-01-01, one minute: long before any golden telemetry.
+const FAR_PAST = '?startTime=1672531200000&endTime=1672531260000';
+
+test.describe('Dashboards — edge cases', () => {
+ test('TC-01 panels show their empty state for a far-past range', async ({
+ dashboards,
+ dashboardPage,
+ panels,
+ }) => {
+ const collected = dashboardPage.collectPageErrors();
+ const id = await dashboards.seed(singlePanelDashboard());
+
+ await dashboards.visit(`/dashboard/${id}${FAR_PAST}`);
+
+ const target = panels.panel(SINGLE_PANEL_ID);
+ await target.scrollIntoView();
+ await expect(target.noData()).toBeVisible();
+ expect(collected.errors).toEqual([]);
+ });
+
+ test('TC-02 a nonexistent dashboard id shows a load error', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ await dashboards.visit(`/dashboard/${MISSING_ID}`);
+
+ // The fetch retries before giving up.
+ await expect(dashboardPage.loadError()).toBeVisible({ timeout: 20_000 });
+ await expect(dashboardPage.breadcrumb()).toHaveCount(0);
+ });
+
+ test('TC-03 the side nav still works after a nonexistent dashboard', async ({
+ dashboards,
+ dashboardPage,
+ authedPage: page,
+ }) => {
+ await dashboards.visit(`/dashboard/${MISSING_ID}`);
+ await expect(dashboardPage.loadError()).toBeVisible({ timeout: 20_000 });
+
+ await dashboardPage.navigateSideNav('Dashboards');
+
+ await expect(page).toHaveURL(/\/dashboard(\?|$)/);
+ await expect(dashboardPage.listPage()).toBeVisible();
+ });
+
+ test('TC-04 an inverted time range does not crash the dashboard', async ({
+ dashboards,
+ dashboardPage,
+ panels,
+ }) => {
+ const collected = dashboardPage.collectPageErrors();
+ const fixture = singlePanelDashboard();
+ const id = await dashboards.seed(fixture);
+
+ await dashboards.visit(`/dashboard/${id}?startTime=999999&endTime=999998`);
+
+ await expect(dashboardPage.title()).toHaveText(fixture.spec.display.name);
+ // The title renders before the query returns; the errors only count once
+ // the inverted range has reached the panel.
+ const target = panels.panel(SINGLE_PANEL_ID);
+ await expect(target.noData().or(target.error())).toBeVisible();
+ expect(collected.errors).toEqual([]);
+ });
+
+ test('TC-05 a name at the 128-character limit keeps the toolbar on screen', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ const longName = `LongName-${'x'.repeat(119)}`;
+ await dashboards.seedAndOpen(compactDashboard(longName));
+
+ await expect(dashboardPage.title()).toHaveText(longName);
+ await expect(dashboardPage.toolbar.configure()).toBeInViewport();
+ await expect(dashboardPage.toolbar.newPanel()).toBeInViewport();
+ });
+
+ test('TC-06 special characters in the name round-trip unescaped', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ const trickyName = `Spec & Chars / "${Date.now()}" — émoji 🎯`;
+ await dashboards.seedAndOpen(compactDashboard(trickyName));
+
+ await expect(dashboardPage.title()).toHaveText(trickyName);
+ await expect(dashboardPage.breadcrumb()).toContainText(trickyName);
+ await expect.poll(() => dashboardPage.documentTitle()).toBe(trickyName);
+ });
+});
diff --git a/tests/e2e/tests/dashboards/page/edit-mode.spec.ts b/tests/e2e/tests/dashboards/page/edit-mode.spec.ts
new file mode 100644
index 0000000000..a69e4d6f31
--- /dev/null
+++ b/tests/e2e/tests/dashboards/page/edit-mode.spec.ts
@@ -0,0 +1,193 @@
+import {
+ COMPACT_PANELS,
+ DashboardAction,
+ PanelAction,
+ PATH,
+ compactDashboard,
+ expect,
+ test,
+} from '../../../drivers/dashboard-page';
+
+test.describe('Dashboards — edit mode', () => {
+ test('TC-01 the Actions menu lists every dashboard action', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ await dashboards.seedAndOpen(compactDashboard());
+
+ await dashboardPage.actions.open();
+
+ for (const action of Object.values(DashboardAction)) {
+ await expect(dashboardPage.actions.item(action)).toBeEnabled();
+ }
+ await expect(dashboardPage.actions.item(DashboardAction.lock)).toHaveText(
+ 'Lock dashboard',
+ );
+ });
+
+ test('TC-02 locking disables the edit affordances and persists', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ const id = await dashboards.seedAndOpen(compactDashboard());
+
+ await dashboardPage.lock();
+
+ await expect(dashboardPage.toolbar.configure()).toBeDisabled();
+ await expect(dashboardPage.toolbar.newPanel()).toBeDisabled();
+ await dashboardPage.actions.open();
+ for (const action of [
+ DashboardAction.rename,
+ DashboardAction.newSection,
+ DashboardAction.delete,
+ ]) {
+ await expect(dashboardPage.actions.item(action)).toBeDisabled();
+ }
+ await expect.poll(async () => (await dashboards.get(id)).locked).toBe(true);
+ });
+
+ test('TC-03 renaming updates the title and breadcrumb and survives a reload', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ const id = await dashboards.seedAndOpen(compactDashboard());
+ const renamed = `Renamed-${Date.now()}`;
+
+ await dashboardPage.rename.to(renamed);
+
+ await expect(dashboardPage.breadcrumb()).toContainText(renamed);
+ await expect
+ .poll(async () => (await dashboards.get(id)).spec.display.name)
+ .toBe(renamed);
+
+ await dashboards.reload();
+ await expect(dashboardPage.title()).toHaveText(renamed);
+ await expect.poll(() => dashboardPage.documentTitle()).toBe(renamed);
+ });
+
+ test('TC-04 cancelling a rename leaves the name unchanged', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ const fixture = compactDashboard();
+ const original = fixture.spec.display.name;
+ await dashboards.seedAndOpen(fixture);
+
+ await dashboardPage.actions.run(DashboardAction.rename);
+ await dashboardPage.rename.input().fill('Should Not Be Saved');
+ await dashboardPage.rename.cancel().click();
+
+ await expect(dashboardPage.title()).toHaveText(original);
+ await expect(dashboardPage.breadcrumb()).toContainText(original);
+ });
+
+ test('TC-05 the JSON drawer downloads the dashboard as .json', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ await dashboards.seedAndOpen(compactDashboard());
+
+ await dashboardPage.json.open();
+
+ expect(await dashboardPage.json.download()).toMatch(/\.json$/);
+ });
+
+ test('TC-06 the JSON drawer copies the dashboard JSON', async ({
+ dashboards,
+ dashboardPage,
+ browserName,
+ }) => {
+ test.skip(
+ browserName !== 'chromium',
+ 'clipboard-read is a Chromium-only permission',
+ );
+ const fixture = compactDashboard();
+ await dashboards.seedAndOpen(fixture);
+
+ await dashboardPage.json.open();
+ const copied = JSON.parse(await dashboardPage.json.copy()) as {
+ spec?: { display?: { name?: string } };
+ };
+
+ expect(copied.spec?.display?.name).toBe(fixture.spec.display.name);
+ });
+
+ test('TC-07 Full screen shows only the grid and exits cleanly', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ const collected = dashboardPage.collectPageErrors();
+ await dashboards.seedAndOpen(compactDashboard());
+
+ await dashboardPage.actions.run(DashboardAction.fullScreen);
+
+ await expect.poll(() => dashboardPage.isFullScreen()).toBe(true);
+ await expect(dashboardPage.title()).toBeHidden();
+ await expect(dashboardPage.section('Charts').panels()).toHaveCount(1);
+
+ await dashboardPage.exitFullScreen();
+
+ await expect(dashboardPage.title()).toBeVisible();
+ expect(collected.errors).toEqual([]);
+ });
+
+ test('TC-08 lock then unlock restores the edit affordances', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ const id = await dashboards.seedAndOpen(compactDashboard());
+
+ await dashboardPage.lock();
+ await dashboardPage.actions.open();
+ await expect(dashboardPage.actions.item(DashboardAction.lock)).toHaveText(
+ 'Unlock dashboard',
+ );
+ await dashboardPage.actions.item(DashboardAction.lock).click();
+ await expect(dashboardPage.lockToggle()).toHaveAccessibleName(
+ 'Lock dashboard',
+ );
+
+ await expect(dashboardPage.toolbar.newPanel()).toBeEnabled();
+ await dashboardPage.actions.open();
+ await expect(
+ dashboardPage.actions.item(DashboardAction.rename),
+ ).toBeEnabled();
+ await expect(
+ dashboardPage.actions.item(DashboardAction.newSection),
+ ).toBeEnabled();
+ await expect.poll(async () => (await dashboards.get(id)).locked).toBe(false);
+ });
+
+ test('TC-09 Edit panel opens that panel in the editor', async ({
+ authedPage: page,
+ dashboards,
+ panels,
+ }) => {
+ const id = await dashboards.seedAndOpen(compactDashboard());
+
+ await panels.panel(COMPACT_PANELS.table).actions.run(PanelAction.edit);
+
+ await expect(page).toHaveURL(
+ new RegExp(`${PATH.editor(id, COMPACT_PANELS.table)}(\\?|$)`),
+ );
+ });
+
+ test('TC-10 cancelling a panel delete keeps the panel', async ({
+ dashboards,
+ dashboardPage,
+ panels,
+ }) => {
+ const id = await dashboards.seedAndOpen(compactDashboard());
+ const list = panels.panel(COMPACT_PANELS.list);
+
+ await list.actions.run(PanelAction.delete);
+ await expect(dashboards.confirmDelete()).toBeVisible();
+ await dashboardPage.cancelDelete().click();
+
+ await expect(dashboards.confirmDelete()).toBeHidden();
+ await expect(list.root()).toBeVisible();
+ expect(
+ (await dashboards.get(id)).spec.panels[COMPACT_PANELS.list],
+ ).toBeDefined();
+ });
+});
diff --git a/tests/e2e/tests/dashboards/page/sections.spec.ts b/tests/e2e/tests/dashboards/page/sections.spec.ts
new file mode 100644
index 0000000000..22514ad069
--- /dev/null
+++ b/tests/e2e/tests/dashboards/page/sections.spec.ts
@@ -0,0 +1,105 @@
+import {
+ COMPACT_PANELS,
+ SectionAction,
+ compactDashboard,
+ expect,
+ test,
+} from '../../../drivers/dashboard-page';
+
+// Collapse is a per-user preference kept in the browser, not in the spec;
+// rename, add and delete are patches to the spec.
+
+test.describe('Dashboards — sections', () => {
+ test('TC-01 a collapsed section unmounts its panels and stays collapsed after a reload', async ({
+ dashboards,
+ dashboardPage,
+ panels,
+ }) => {
+ await dashboards.seedAndOpen(compactDashboard());
+ const tabular = dashboardPage.section('Tabular');
+
+ await tabular.collapse();
+ await expect(tabular.toggle()).toBeVisible();
+ await expect(tabular.panels()).toHaveCount(0);
+ await expect(panels.panel(COMPACT_PANELS.timeseries).root()).toHaveCount(1);
+
+ await dashboards.reload();
+ await expect(panels.panel(COMPACT_PANELS.timeseries).root()).toHaveCount(1);
+ await expect(tabular.panels()).toHaveCount(0);
+
+ await tabular.expand();
+ await expect(tabular.panels()).toHaveCount(2);
+ });
+
+ test('TC-02 the section menu offers add, rename, clone and delete', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ await dashboards.seedAndOpen(compactDashboard());
+ const charts = dashboardPage.section('Charts');
+
+ await charts.openMenu();
+
+ for (const label of Object.values(SectionAction)) {
+ await expect(charts.menuItem(label)).toBeEnabled();
+ }
+ });
+
+ test('TC-03 renaming a section updates its header and persists', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ const id = await dashboards.seedAndOpen(compactDashboard());
+ const renamed = `Renamed ${Date.now()}`;
+
+ await dashboardPage.section('Charts').rename(renamed);
+
+ await expect(dashboardPage.section(renamed).toggle()).toBeVisible();
+ await expect(dashboardPage.section('Charts').root()).toHaveCount(0);
+ await expect
+ .poll(async () =>
+ (await dashboards.get(id)).spec.layouts.map(
+ (layout) => layout.spec.display.title,
+ ),
+ )
+ .toEqual([renamed, 'Tabular']);
+ });
+
+ test('TC-04 cancelling a section rename leaves the title unchanged', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ await dashboards.seedAndOpen(compactDashboard());
+ const tabular = dashboardPage.section('Tabular');
+
+ await tabular.startRename();
+ await dashboardPage.sectionModal.input().fill('Should not be applied');
+ await dashboardPage.sectionModal.cancel().click();
+
+ await expect(dashboardPage.sectionModal.input()).toBeHidden();
+ await expect(tabular.toggle()).toBeVisible();
+ await expect(
+ dashboardPage.section('Should not be applied').root(),
+ ).toHaveCount(0);
+ });
+
+ test('TC-05 a section added from the Actions menu can be deleted', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ const id = await dashboards.seedAndOpen(compactDashboard());
+ const title = `Temp section ${Date.now()}`;
+
+ await dashboardPage.addSection(title);
+ await expect
+ .poll(async () => (await dashboards.get(id)).spec.layouts.length)
+ .toBe(3);
+
+ await dashboardPage.section(title).delete();
+
+ await expect(dashboardPage.sectionTitles()).toHaveText(['Charts', 'Tabular']);
+ await expect
+ .poll(async () => (await dashboards.get(id)).spec.layouts.length)
+ .toBe(2);
+ });
+});
diff --git a/tests/e2e/tests/dashboards/page/settings.spec.ts b/tests/e2e/tests/dashboards/page/settings.spec.ts
new file mode 100644
index 0000000000..b804a6438a
--- /dev/null
+++ b/tests/e2e/tests/dashboards/page/settings.spec.ts
@@ -0,0 +1,407 @@
+import {
+ BAR_VALUES,
+ BAR_VARIABLES as V,
+ type Dashboards,
+ emptyDashboard,
+ expect,
+ test,
+ variablesBarDashboard,
+} from '../../../drivers/dashboard-settings';
+
+// Scope: the Configure drawer — Overview, Variables and Publish tabs.
+
+function savedNames(
+ dashboards: Dashboards,
+ id: string,
+): () => Promise<string[]> {
+ return async () =>
+ (await dashboards.get(id)).spec.variables.map(
+ (variable) => variable.spec.name,
+ );
+}
+
+test.describe('Dashboards — settings drawer', () => {
+ test('TC-01 Configure opens on Overview with every tab', async ({
+ dashboards,
+ settings,
+ }) => {
+ await dashboards.seedAndOpen(variablesBarDashboard());
+
+ await settings.open();
+
+ await expect(settings.heading()).toBeVisible();
+ for (const tab of ['Overview', 'Variables', 'Publish'] as const) {
+ await expect(settings.tab(tab)).toBeVisible();
+ }
+ await expect(settings.tab('Overview')).toHaveAttribute(
+ 'aria-selected',
+ 'true',
+ );
+ await expect(settings.overview.name()).toBeVisible();
+
+ await settings.close();
+ });
+
+ test('TC-02 name, description and tag save and survive a reload', async ({
+ dashboards,
+ settings,
+ }) => {
+ const id = await dashboards.seedAndOpen(variablesBarDashboard());
+ const name = `e2e-configured-${Date.now()}`;
+
+ await settings.open();
+ await settings.overview.name().fill(name);
+ await settings.overview.description().fill('Configured by e2e');
+ await settings.overview.addTag('team:e2e');
+ await expect(settings.overview.unsaved()).toHaveText('3 unsaved changes');
+ await settings.overview.save().click();
+ await expect(settings.overview.unsaved()).toBeHidden();
+ await settings.close();
+
+ await dashboards.reload();
+ await expect(dashboards.title()).toHaveText(name);
+ const saved = await dashboards.get(id);
+ expect(saved.spec.display.description).toBe('Configured by e2e');
+ expect(saved.tags).toContainEqual({ key: 'team', value: 'e2e' });
+ });
+
+ test('TC-03 Discard reverts unsaved Overview changes', async ({
+ dashboards,
+ settings,
+ }) => {
+ const dashboard = variablesBarDashboard();
+ await dashboards.seedAndOpen(dashboard);
+ await settings.open();
+ const original = dashboard.spec.display.name;
+ await expect(settings.overview.name()).toHaveValue(original);
+
+ await settings.overview.name().fill('Temporary name');
+ await settings.overview.discard().click();
+
+ await expect(settings.overview.name()).toHaveValue(original);
+ await expect(settings.overview.save()).toBeHidden();
+ });
+
+ test('TC-04 the Variables tab lists every variable', async ({
+ dashboards,
+ settings,
+ }) => {
+ await dashboards.seedAndOpen(variablesBarDashboard());
+
+ await settings.open();
+ await settings.openTab('Variables');
+
+ for (const name of Object.values(V)) {
+ await expect(settings.variables.row(name)).toBeVisible();
+ }
+ });
+
+ test('TC-05 an added textbox variable joins the bar and takes a value', async ({
+ dashboards,
+ settings,
+ variablesBar,
+ }) => {
+ const id = await dashboards.seedAndOpen(variablesBarDashboard());
+ const name = 'tb_added';
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.add().click();
+ await settings.form.name().fill(name);
+ await settings.form.type('textbox').click();
+ await expect(settings.form.save()).toBeEnabled();
+ await settings.form.save().click();
+ await expect(settings.variables.row(name)).toBeVisible();
+ await settings.close();
+ // The save is optimistic, so the row alone does not prove the PATCH.
+ await expect.poll(savedNames(dashboards, id)).toContain(name);
+
+ await variablesBar.expand();
+ await expect(variablesBar.label(name)).toBeVisible();
+ await variablesBar.type(name, 'test-value');
+ await expect(variablesBar.textbox(name)).toHaveValue('test-value');
+ });
+
+ test('TC-06 an added custom variable joins the list and the bar', async ({
+ dashboards,
+ settings,
+ variablesBar,
+ }) => {
+ const id = await dashboards.seedAndOpen(variablesBarDashboard());
+ const name = 'cu_added';
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.add().click();
+ await settings.form.name().fill(name);
+ await settings.form.type('custom').click();
+ await settings.form.customValues().fill('east,west');
+ await settings.form.save().click();
+ await expect(settings.variables.row(name)).toBeVisible();
+ await settings.close();
+ await expect.poll(savedNames(dashboards, id)).toContain(name);
+
+ await variablesBar.expand();
+ await expect(variablesBar.select(name)).toContainText('east');
+ });
+
+ test('TC-07 the Query type renders the query editor', async ({
+ dashboards,
+ settings,
+ }) => {
+ await dashboards.seedAndOpen(variablesBarDashboard());
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.add().click();
+ await settings.form.name().fill('query_added');
+ await settings.form.type('query').click();
+
+ await expect(settings.form.queryEditor()).toBeVisible();
+ await settings.form.discard().click();
+ await expect(settings.variables.row('query_added')).toHaveCount(0);
+ });
+
+ test('TC-08 Save Variable stays disabled without a name', async ({
+ dashboards,
+ settings,
+ }) => {
+ const id = await dashboards.seed(emptyDashboard());
+ await dashboards.openEmpty(id);
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.add().click();
+
+ await expect(settings.form.name()).toHaveValue('');
+ await expect(settings.form.save()).toBeDisabled();
+ });
+
+ test('TC-09 the Publish tab offers to publish a private dashboard', async ({
+ dashboards,
+ settings,
+ }) => {
+ await dashboards.seedAndOpen(variablesBarDashboard());
+
+ await settings.open();
+ await settings.openTab('Publish');
+
+ await expect(
+ settings.publish.text('This dashboard is private'),
+ ).toBeVisible();
+ await expect(settings.publish.timeRange()).toBeVisible();
+ await expect(
+ settings.publish.text(
+ "Dashboard variables aren't supported on public links.",
+ ),
+ ).toBeVisible();
+ await expect(settings.publish.publish()).toBeVisible();
+ });
+
+ test('TC-10 renaming a variable renames it in the bar', async ({
+ dashboards,
+ settings,
+ variablesBar,
+ }) => {
+ const id = await dashboards.seedAndOpen(variablesBarDashboard());
+ const renamed = `${V.textEnv}_renamed`;
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.edit(V.textEnv);
+ await expect(settings.form.name()).toHaveValue(V.textEnv);
+ await settings.form.name().fill(renamed);
+ await settings.form.save().click();
+ await expect(settings.variables.row(renamed)).toBeVisible();
+ await settings.close();
+
+ await expect(variablesBar.label(renamed)).toBeVisible();
+ await expect(variablesBar.label(V.textEnv)).toHaveCount(0);
+ await expect.poll(savedNames(dashboards, id)).toContain(renamed);
+ });
+
+ test('TC-11 switching a custom variable to Query swaps the form', async ({
+ dashboards,
+ settings,
+ }) => {
+ await dashboards.seedAndOpen(variablesBarDashboard());
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.edit(V.single);
+ await expect(settings.form.customValues()).toBeVisible();
+ await settings.form.type('query').click();
+
+ await expect(settings.form.queryEditor()).toBeVisible();
+ await expect(settings.form.customValues()).toHaveCount(0);
+ await settings.form.discard().click();
+ });
+
+ test('TC-12 a textbox default saved in Configure survives a reload', async ({
+ dashboards,
+ settings,
+ }) => {
+ const id = await dashboards.seedAndOpen(variablesBarDashboard());
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.edit(V.textService);
+ await expect(settings.form.textDefault()).toHaveValue(BAR_VALUES.textService);
+ await settings.form.textDefault().fill('new-default');
+ await settings.form.save().click();
+ await expect(settings.variables.row(V.textService)).toBeVisible();
+ await expect
+ .poll(async () => {
+ const saved = (await dashboards.get(id)).spec.variables.find(
+ (v) => v.spec.name === V.textService,
+ );
+ return saved?.kind === 'TextVariable' ? saved.spec.value : undefined;
+ })
+ .toBe('new-default');
+ await settings.close();
+
+ await dashboards.reload();
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.edit(V.textService);
+ await expect(settings.form.textDefault()).toHaveValue('new-default');
+ });
+
+ test('TC-13 a deleted variable leaves the bar, its siblings stay', async ({
+ dashboards,
+ settings,
+ variablesBar,
+ }) => {
+ const id = await dashboards.seedAndOpen(variablesBarDashboard());
+ await expect(variablesBar.label(V.textEnv)).toBeVisible();
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.remove(V.textEnv);
+ await settings.close();
+
+ await expect(variablesBar.label(V.textEnv)).toHaveCount(0);
+ await expect(variablesBar.label(V.textService)).toBeVisible();
+ // The bar drops the label before the PATCH lands.
+ await expect.poll(savedNames(dashboards, id)).not.toContain(V.textEnv);
+ });
+
+ test('TC-14 a duplicate name keeps Save Variable disabled', async ({
+ dashboards,
+ settings,
+ }) => {
+ await dashboards.seedAndOpen(variablesBarDashboard());
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.add().click();
+ await settings.form.name().fill(V.textEnv);
+ await settings.form.type('textbox').click();
+
+ await expect(
+ settings.form.error('Variable name already exists'),
+ ).toBeVisible();
+ await expect(settings.form.save()).toBeDisabled();
+ });
+
+ test('TC-15 discarding an edit persists nothing', async ({
+ dashboards,
+ settings,
+ variablesBar,
+ }) => {
+ const id = await dashboards.seedAndOpen(variablesBarDashboard());
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.edit(V.textEnv);
+ await settings.form.name().fill('SHOULD_NOT_PERSIST');
+ await settings.form.discard().click();
+ await expect(settings.variables.row(V.textEnv)).toBeVisible();
+ await settings.close();
+
+ await expect(variablesBar.label(V.textEnv)).toBeVisible();
+ await expect(variablesBar.label('SHOULD_NOT_PERSIST')).toHaveCount(0);
+ const saved = await dashboards.get(id);
+ expect(saved.spec.variables.map((v) => v.spec.name)).not.toContain(
+ 'SHOULD_NOT_PERSIST',
+ );
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await expect(settings.variables.row(V.textEnv)).toBeVisible();
+ });
+
+ test('TC-16 dragging a variable reorders the list, the bar and the spec', async ({
+ dashboards,
+ settings,
+ variablesBar,
+ }) => {
+ const id = await dashboards.seedAndOpen(variablesBarDashboard());
+ const before = await savedNames(dashboards, id)();
+ const [first, second] = before;
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.reorder(second, first);
+
+ const after = [second, first, ...before.slice(2)];
+ await expect.poll(savedNames(dashboards, id)).toEqual(after);
+ await settings.close();
+ expect(await variablesBar.names()).toEqual(after.map((name) => `$${name}`));
+ });
+
+ test('TC-17 a dynamic variable created in Configure lists the field values', async ({
+ dashboards,
+ settings,
+ variablesBar,
+ }) => {
+ // Unique per test: seeded rows outlive it.
+ const label = `e2e_created_${Date.now()}_${process.pid}`;
+ await variablesBar.seedMetricLabel(label, ['ns-one', 'ns-two']);
+ const id = await dashboards.seed(emptyDashboard());
+ await dashboards.openEmpty(id);
+ const name = 'd_created';
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.add().click();
+ await settings.form.name().fill(name);
+ await settings.form.type('dynamic').click();
+ await settings.form.dynamicField(label);
+ await settings.form.save().click();
+ await expect(settings.variables.row(name)).toBeVisible();
+ await settings.close();
+
+ await expect
+ .poll(async () => {
+ const saved = (await dashboards.get(id)).spec.variables.find(
+ (variable) => variable.spec.name === name,
+ );
+ return saved?.kind === 'ListVariable' ? saved.spec.plugin : undefined;
+ })
+ .toMatchObject({ kind: 'signoz/DynamicVariable', spec: { name: label } });
+ await variablesBar.open(name);
+ await expect(variablesBar.option('ns-one')).toBeVisible();
+ await expect(variablesBar.option('ns-two')).toBeVisible();
+ });
+
+ test.fixme('TC-18 the bar picks up a changed textbox default', async ({
+ dashboards,
+ settings,
+ variablesBar,
+ }) => {
+ // Bug: the bar's selection, seeded from the old default on first open, is
+ // persisted locally and outranks the new default on every later visit.
+ await dashboards.seedAndOpen(variablesBarDashboard());
+
+ await settings.open();
+ await settings.openTab('Variables');
+ await settings.variables.edit(V.textService);
+ await settings.form.textDefault().fill('new-default');
+ await settings.form.save().click();
+ await settings.close();
+ await dashboards.reload();
+
+ await expect(variablesBar.textbox(V.textService)).toHaveValue('new-default');
+ });
+});
diff --git a/tests/e2e/tests/dashboards/page/time-range.spec.ts b/tests/e2e/tests/dashboards/page/time-range.spec.ts
new file mode 100644
index 0000000000..2e151e9a62
--- /dev/null
+++ b/tests/e2e/tests/dashboards/page/time-range.spec.ts
@@ -0,0 +1,103 @@
+import {
+ expect,
+ SINGLE_PANEL_ID,
+ singlePanelDashboard,
+ test,
+} from '../../../drivers/dashboard-settings';
+
+// Scope: the dashboard toolbar's time picker, refresh and auto-refresh.
+
+const HOUR_MS = 60 * 60 * 1000;
+
+test.describe('Dashboards — time range', () => {
+ test.beforeEach(async ({ dashboards }) => {
+ await dashboards.seedAndOpen(singlePanelDashboard());
+ });
+
+ test('TC-01 a preset updates the label, the URL and refetches', async ({
+ timePicker,
+ queryRange,
+ authedPage: page,
+ }) => {
+ const windows = queryRange.recordWindows();
+ await timePicker.selectPreset('1h');
+
+ await expect(timePicker.input()).toHaveAccessibleName('Last 1 hour');
+ await expect(page).toHaveURL(/relativeTime=1h/);
+ await expect
+ .poll(() => windows.some((w) => w.end - w.start === HOUR_MS))
+ .toBe(true);
+ });
+
+ test('TC-02 a custom date range switches the URL to absolute timestamps', async ({
+ timePicker,
+ queryRange,
+ authedPage: page,
+ }) => {
+ const windows = queryRange.recordWindows();
+ await timePicker.selectPreviousMonthRange(14, 16);
+
+ await expect(timePicker.input()).toHaveValue(
+ /^14\/\d{2}\/\d{4} 00:00:00 - 16\/\d{2}\/\d{4} 23:59:59$/,
+ );
+ await expect(page).toHaveURL(/startTime=\d+/);
+ await expect(page).toHaveURL(/endTime=\d+/);
+ await expect(page).not.toHaveURL(/relativeTime=/);
+
+ const matchesUrl = (): boolean => {
+ const url = new URL(page.url());
+ const start = Number(url.searchParams.get('startTime'));
+ const end = Number(url.searchParams.get('endTime'));
+ return windows.some((w) => w.start === start && w.end === end);
+ };
+ await expect.poll(matchesUrl).toBe(true);
+ });
+
+ test('TC-03 changing the timezone updates the offset badge', async ({
+ timePicker,
+ }) => {
+ await timePicker.selectTimezone('Tokyo', 'Asia/Tokyo');
+
+ await expect(timePicker.timezoneBadge()).toHaveText('UTC + 9:00');
+ });
+
+ test('TC-04 auto-refresh refetches the panels on its interval, until turned off', async ({
+ timePicker,
+ panels,
+ queryRange,
+ }) => {
+ const target = panels.panel(SINGLE_PANEL_ID);
+ await expect(target.root()).toHaveAttribute('data-panel-visible', 'true');
+ await expect(target.loading()).toBeHidden();
+
+ await timePicker.autoRefresh.open();
+ const checkbox = timePicker.autoRefresh.checkbox();
+ await expect(checkbox).not.toBeChecked();
+ await checkbox.click();
+ await timePicker.autoRefresh.interval('5 seconds').click();
+ await expect(timePicker.autoRefresh.selected()).toHaveText('5 seconds');
+
+ const windows = queryRange.recordWindows();
+ await expect
+ .poll(() => windows.length, { timeout: 15_000 })
+ .toBeGreaterThanOrEqual(2);
+
+ await checkbox.click();
+ await expect(checkbox).not.toBeChecked();
+ });
+
+ test('TC-05 manual refresh refetches the panels', async ({
+ timePicker,
+ panels,
+ queryRange,
+ }) => {
+ const target = panels.panel(SINGLE_PANEL_ID);
+ await expect(target.root()).toHaveAttribute('data-panel-visible', 'true');
+ await expect(target.loading()).toBeHidden();
+
+ const refetch = queryRange.nextRequest();
+ await timePicker.refresh().click();
+
+ await refetch;
+ });
+});
diff --git a/tests/e2e/tests/dashboards/page/variables.spec.ts b/tests/e2e/tests/dashboards/page/variables.spec.ts
new file mode 100644
index 0000000000..006aa87be6
--- /dev/null
+++ b/tests/e2e/tests/dashboards/page/variables.spec.ts
@@ -0,0 +1,332 @@
+import {
+ BAR_VALUES,
+ BAR_VARIABLES as V,
+ EMPTY_VARIABLE_QUERY,
+ GOLDEN,
+ PanelKind,
+ textVariable,
+ VARIABLE_NAMES,
+ VARIABLE_PANEL_ID,
+ variablesDashboard,
+ expect,
+ QUERY_CHILD_SUFFIX,
+ test,
+ variablesBarDashboard,
+} from '../../../drivers/dashboard-settings';
+
+// Scope: the runtime variables bar. Selections live in the dashboard's local
+// store, not the URL: `?variables=` is read once from a share link and dropped,
+// and the share dialog's "Include variables" is what serializes them again.
+
+const ALL = '__ALL__';
+const ORDER = Object.values(V);
+
+test.describe('Dashboards — variables bar', () => {
+ test('TC-01 the bar renders a control for every variable type', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ await dashboards.seedAndOpen(variablesBarDashboard());
+ await variablesBar.expand();
+
+ for (const name of ORDER) {
+ await expect(variablesBar.label(name)).toBeVisible();
+ }
+ await expect(variablesBar.textbox(V.textEnv)).toHaveValue(BAR_VALUES.textEnv);
+ await expect(variablesBar.textbox(V.textService)).toHaveValue(
+ BAR_VALUES.textService,
+ );
+ for (const name of [V.single, V.all, V.multi, V.queryParent, V.dynamic]) {
+ await expect(variablesBar.select(name)).toBeVisible();
+ }
+ });
+
+ test('TC-02 picking a single value selects it and survives a reload', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ await dashboards.seedAndOpen(variablesBarDashboard());
+ await variablesBar.expand();
+
+ await variablesBar.pick(V.single, 'mq-kafka');
+ await expect(variablesBar.select(V.single)).toContainText('mq-kafka');
+
+ await variablesBar.open(V.single);
+ await expect(variablesBar.option('mq-kafka')).toHaveAttribute(
+ 'aria-selected',
+ 'true',
+ );
+
+ await dashboards.reload();
+ await expect(variablesBar.select(V.single)).toContainText('mq-kafka');
+ });
+
+ test('TC-03 a multi-select renders chips and shares its values as an array', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ const id = await dashboards.seed(variablesBarDashboard());
+ await variablesBar.openWith(id, { [V.multi]: ['adservice', 'frontend'] });
+ await variablesBar.expand();
+
+ await expect(variablesBar.chip(V.multi, 'adservice')).toBeVisible();
+ await variablesBar.open(V.multi);
+ await expect(variablesBar.option('adservice')).toHaveAttribute(
+ 'aria-selected',
+ 'true',
+ );
+ await expect(variablesBar.option('frontend')).toHaveAttribute(
+ 'aria-selected',
+ 'true',
+ );
+ await variablesBar.close(V.multi);
+
+ expect((await variablesBar.shared())[V.multi]).toEqual([
+ 'adservice',
+ 'frontend',
+ ]);
+ });
+
+ test('TC-04 removing a chip drops that value once the dropdown closes', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ const id = await dashboards.seed(variablesBarDashboard());
+ await variablesBar.openWith(id, { [V.multi]: ['adservice', 'frontend'] });
+ await variablesBar.expand();
+
+ await variablesBar.chip(V.multi, 'adservice').click();
+ await variablesBar.close(V.multi);
+
+ await expect(variablesBar.chip(V.multi, 'adservice')).toHaveCount(0);
+ await expect(variablesBar.chip(V.multi, 'frontend')).toBeVisible();
+ expect((await variablesBar.shared())[V.multi]).toEqual(['frontend']);
+ });
+
+ test('TC-05 the ALL option selects every value', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ const id = await dashboards.seed(variablesBarDashboard());
+ await variablesBar.openWith(id, { [V.all]: ['otel-demo'] });
+ await variablesBar.expand();
+ await expect(variablesBar.variable(V.all)).toContainText('otel-demo');
+
+ await variablesBar.open(V.all);
+ await variablesBar.option('ALL').click();
+ for (const value of ['ALL', ...BAR_VALUES.envs]) {
+ await expect(variablesBar.option(value)).toHaveAttribute(
+ 'aria-selected',
+ 'true',
+ );
+ }
+ await variablesBar.close(V.all);
+
+ await expect(variablesBar.variable(V.all)).toContainText('ALL');
+ expect((await variablesBar.shared())[V.all]).toBe(ALL);
+ });
+
+ test('TC-06 a textbox commits its value on Enter', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ await dashboards.seedAndOpen(variablesBarDashboard());
+
+ await variablesBar.type(V.textEnv, 'production');
+
+ // Enter commits by blurring, so the field must lose focus without a click.
+ await expect(variablesBar.textbox(V.textEnv)).not.toBeFocused();
+ await expect(variablesBar.textbox(V.textEnv)).toHaveValue('production');
+ expect((await variablesBar.shared())[V.textEnv]).toBe('production');
+ });
+
+ test('TC-07 a child query variable refetches after its parent changes', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ await dashboards.seedAndOpen(variablesBarDashboard());
+ await variablesBar.expand();
+ const [first, second] = BAR_VALUES.queryEnvs;
+ await expect(variablesBar.variable(V.queryChild)).toContainText(
+ `${first}${QUERY_CHILD_SUFFIX}`,
+ );
+
+ await variablesBar.pick(V.queryParent, second);
+
+ await expect(variablesBar.variable(V.queryChild)).toContainText(
+ `${second}${QUERY_CHILD_SUFFIX}`,
+ );
+ await variablesBar.open(V.queryChild);
+ await expect(variablesBar.listbox().getByRole('option')).toHaveCount(1);
+ await expect(
+ variablesBar.option(`${second}${QUERY_CHILD_SUFFIX}`),
+ ).toBeVisible();
+ });
+
+ test('TC-08 a shared link seeds the selection, which outlives the reload', async ({
+ dashboards,
+ variablesBar,
+ authedPage: page,
+ }) => {
+ const id = await dashboards.seed(variablesBarDashboard());
+ await variablesBar.openWith(id, { [V.all]: ['mq-kafka'] });
+ await variablesBar.expand();
+
+ await expect(variablesBar.variable(V.all)).toContainText('mq-kafka');
+ await expect(page).not.toHaveURL(/variables=/);
+
+ await dashboards.reload();
+ await expect(variablesBar.variable(V.all)).toContainText('mq-kafka');
+ });
+
+ test('TC-09 ALL to one value and back to ALL', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ await dashboards.seedAndOpen(variablesBarDashboard());
+ await variablesBar.expand();
+ await expect(variablesBar.variable(V.all)).toContainText('ALL');
+
+ await variablesBar.open(V.all);
+ await variablesBar.option('ALL').click();
+ await variablesBar.option('mq-kafka').click();
+ await variablesBar.close(V.all);
+ await expect(variablesBar.variable(V.all)).toContainText('mq-kafka');
+
+ await variablesBar.toggle(V.all, ['ALL']);
+ await expect(variablesBar.variable(V.all)).toContainText('ALL');
+ expect((await variablesBar.shared())[V.all]).toBe(ALL);
+ });
+
+ test('TC-10 changes to two variables are both kept', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ await dashboards.seedAndOpen(variablesBarDashboard());
+ await variablesBar.expand();
+
+ await variablesBar.pick(V.single, 'production');
+ await variablesBar.toggle(V.multi, ['checkout']);
+
+ const shared = await variablesBar.shared();
+ expect(shared[V.single]).toBe('production');
+ expect(shared[V.multi]).toEqual(['adservice', 'checkout']);
+ });
+
+ test('TC-11 leaving the dashboard and coming back keeps the selection', async ({
+ dashboards,
+ variablesBar,
+ panels,
+ authedPage: page,
+ }) => {
+ const id = await dashboards.seedAndOpen(variablesBarDashboard());
+ await variablesBar.expand();
+ await variablesBar.pick(V.single, 'mq-kafka');
+
+ await dashboards.visit('/dashboard');
+ await expect(page).toHaveURL(/\/dashboard(\?|$)/);
+ await panels.back();
+
+ await expect(page).toHaveURL(new RegExp(`/dashboard/${id}`));
+ await expect(variablesBar.select(V.single)).toContainText('mq-kafka');
+ });
+
+ test('TC-12 a query variable with no rows offers no options', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ const fetched = variablesBar.optionsFetched(EMPTY_VARIABLE_QUERY);
+ await dashboards.seedAndOpen(variablesBarDashboard());
+ await fetched;
+ await variablesBar.expand();
+
+ await variablesBar.open(V.queryEmpty);
+
+ await expect(variablesBar.listbox().getByRole('option')).toHaveCount(0);
+ await expect(variablesBar.select(V.queryEmpty)).toContainText('Select value');
+ });
+
+ test('TC-13 a dynamic variable resolves values from seeded telemetry', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ // Unique per test: seeded rows outlive it, and the list is virtualized.
+ const label = `e2e_namespace_${Date.now()}_${process.pid}`;
+ const namespaces = ['ns-alpha', 'ns-beta'];
+ await variablesBar.seedMetricLabel(label, namespaces);
+ await dashboards.seedAndOpen(
+ variablesBarDashboard({ dynamicAttribute: label }),
+ );
+ await variablesBar.expand();
+
+ await variablesBar.open(V.dynamic);
+
+ for (const namespace of namespaces) {
+ await expect(variablesBar.option(namespace)).toBeVisible();
+ }
+ });
+
+ test('TC-14 the bar follows the spec order', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ await dashboards.seedAndOpen(variablesBarDashboard());
+
+ expect(await variablesBar.names()).toEqual(ORDER.map((name) => `$${name}`));
+ });
+
+ test('TC-15 picking a value refetches the panel that uses it', async ({
+ dashboards,
+ panels,
+ queryRange,
+ variablesBar,
+ }) => {
+ await dashboards.seedAndOpen(variablesDashboard());
+ const target = panels.panel(VARIABLE_PANEL_ID);
+ await expect(
+ target.renderer(PanelKind.TimeSeries).or(target.noData()).first(),
+ ).toBeVisible();
+ const picked = GOLDEN.services[1];
+
+ const refetch = queryRange.nextRequest();
+ await variablesBar.pick(VARIABLE_NAMES.custom, picked);
+
+ const body = (await refetch).postDataJSON() as {
+ variables?: Record<string, { value?: unknown }>;
+ };
+ expect(body.variables?.[VARIABLE_NAMES.custom]?.value).toBe(picked);
+ });
+
+ test('TC-16 a variable description shows in its info tooltip', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ const documented = textVariable('tb_documented', 'x');
+ documented.spec.display.description = 'Deployment environment';
+ const fixture = variablesBarDashboard();
+ fixture.spec.variables.push(documented);
+ await dashboards.seedAndOpen(fixture);
+ await variablesBar.expand();
+
+ const tooltip = await variablesBar.info('tb_documented');
+
+ await expect(tooltip).toContainText('Deployment environment');
+ });
+
+ test.fixme('TC-17 a first visit through a shared link applies its values', async ({
+ dashboards,
+ variablesBar,
+ }) => {
+ // Bug: the selectors' first auto-select batch (computed before the seed
+ // commits) is flushed over the seeded link values, so they are lost.
+ const id = await dashboards.seed(variablesBarDashboard());
+ await variablesBar.firstVisitWith(id, {
+ [V.multi]: ['adservice', 'frontend'],
+ });
+
+ expect((await variablesBar.shared())[V.multi]).toEqual([
+ 'adservice',
+ 'frontend',
+ ]);
+ });
+});
diff --git a/tests/e2e/tests/dashboards/page/viewing.spec.ts b/tests/e2e/tests/dashboards/page/viewing.spec.ts
new file mode 100644
index 0000000000..fb2e25672a
--- /dev/null
+++ b/tests/e2e/tests/dashboards/page/viewing.spec.ts
@@ -0,0 +1,112 @@
+import {
+ COMPACT_PANELS,
+ compactDashboard,
+ expect,
+ PanelKind,
+ test,
+} from '../../../drivers/dashboard-page';
+
+test.describe('Dashboards — viewing', () => {
+ test('TC-01 page chrome renders the breadcrumb, title and toolbar', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ const fixture = compactDashboard();
+ const name = fixture.spec.display.name;
+ await dashboards.seedAndOpen(fixture);
+
+ await expect(dashboardPage.breadcrumbHome()).toBeVisible();
+ await expect(dashboardPage.breadcrumb()).toContainText(name);
+ await expect(dashboardPage.title()).toHaveText(name);
+ await expect.poll(() => dashboardPage.documentTitle()).toBe(name);
+
+ const { toolbar } = dashboardPage;
+ for (const control of [
+ toolbar.timePicker(),
+ toolbar.refresh(),
+ toolbar.autoRefresh(),
+ toolbar.actions(),
+ toolbar.configure(),
+ toolbar.json(),
+ toolbar.newPanel(),
+ toolbar.feedback(),
+ toolbar.share(),
+ ]) {
+ await expect(control).toBeVisible();
+ }
+ });
+
+ test('TC-02 the breadcrumb returns to the dashboards list', async ({
+ dashboards,
+ dashboardPage,
+ authedPage: page,
+ }) => {
+ await dashboards.seedAndOpen(compactDashboard());
+
+ await dashboardPage.breadcrumbHome().click();
+
+ await expect(page).toHaveURL(/\/dashboard(\?|$)/);
+ await expect(dashboardPage.listPage()).toBeVisible();
+ });
+
+ test('TC-03 the tags bar shows two tags and folds the rest', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ await dashboards.seedAndOpen({
+ ...compactDashboard(),
+ tags: [
+ { key: 'team', value: 'apm' },
+ { key: 'latency', value: 'latency' },
+ { key: 'tier', value: 'gold' },
+ ],
+ });
+
+ // A tag whose key equals its value renders as the bare key.
+ await expect(dashboardPage.tags()).toContainText('team:apm');
+ await expect(dashboardPage.tags()).toContainText('latency');
+ await expect(dashboardPage.tags()).not.toContainText('tier:gold');
+ await expect(dashboardPage.tagsOverflow()).toHaveText('+1');
+ });
+
+ test('TC-04 section headers render', async ({ dashboards, dashboardPage }) => {
+ await dashboards.seedAndOpen(compactDashboard());
+
+ await expect(dashboardPage.sectionTitles()).toHaveText(['Charts', 'Tabular']);
+ });
+
+ test('TC-05 panels render inside their sections', async ({
+ dashboards,
+ dashboardPage,
+ }) => {
+ await dashboards.seedAndOpen(compactDashboard());
+
+ await expect(dashboardPage.section('Charts').panels()).toHaveCount(1);
+ await expect(dashboardPage.section('Tabular').panels()).toHaveCount(2);
+ await expect(
+ dashboardPage.section('Charts').root().getByText('Calls by service'),
+ ).toBeVisible();
+ });
+
+ test('TC-06 the initial load raises no page error', async ({
+ dashboards,
+ dashboardPage,
+ panels,
+ }) => {
+ const collected = dashboardPage.collectPageErrors();
+
+ await dashboards.seedAndOpen(compactDashboard());
+ // Settled, not just titled: the errors only count once the data is in.
+ for (const [id, kind] of [
+ [COMPACT_PANELS.timeseries, PanelKind.TimeSeries],
+ [COMPACT_PANELS.table, PanelKind.Table],
+ ] as const) {
+ const target = panels.panel(id);
+ await expect(
+ target.renderer(kind).or(target.noData()).first(),
+ ).toBeVisible();
+ }
+
+ expect(collected.errors).toEqual([]);
+ });
+});