Files
grafana/e2e-playwright/plugin-e2e/plugin-e2e-api-tests/as-admin-user/panelDataAssertion.spec.ts
Paul Marbach 021e0c6da0 Suggestions: improve styling for new version (#114381)
* Suggestions: hashes on suggestions, update logic to select first suggestion

* fix types

* Suggestions: New UI style updates

* update some styles

* getting styles just right

* remove grouping when not on flag

* adjust minimum width for sidebar

* CI cleanups

* updates from ad hoc review

* add loading and error states to suggestions

* remove unused import

* update header ui for panel editor

* restore back button to vizpicker

* fix e2e test

* fix e2e

* add i18n update

* use new util for setVisualization operation

* Apply suggestions from code review

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>

* comments from review

* updates from review

---------

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2025-12-02 11:36:46 -08:00

107 lines
4.5 KiB
TypeScript

import { expect, test } from '@grafana/plugin-e2e';
import { setVisualization } from '../../../panels-suite/vizpicker-utils';
import { formatExpectError } from '../errors';
import { successfulDataQuery } from '../mocks/queries';
const REACT_TABLE_DASHBOARD = { uid: 'U_bZIMRMk' };
test.describe(
'plugin-e2e-api-tests admin',
{
tag: ['@plugins'],
},
() => {
test.describe('panel edit page', () => {
test('table panel data assertions with provisioned dashboard', async ({ gotoPanelEditPage }) => {
const panelEditPage = await gotoPanelEditPage({ dashboard: REACT_TABLE_DASHBOARD, id: '4' });
await expect(
panelEditPage.panel.locator,
formatExpectError('Could not locate panel in panel edit page')
).toBeVisible();
await expect(
panelEditPage.panel.fieldNames,
formatExpectError('Could not locate header elements in table panel')
).toContainText(['Field', 'Max', 'Mean', 'Last']);
});
test('table panel data assertions', async ({ panelEditPage, selectors }) => {
await panelEditPage.mockQueryDataResponse(successfulDataQuery, 200);
await panelEditPage.datasource.set('gdev-testdata');
await setVisualization(panelEditPage, 'Table', selectors);
await panelEditPage.refreshPanel();
await expect(
panelEditPage.panel.locator,
formatExpectError('Could not locate panel in panel edit page')
).toBeVisible();
await expect(
panelEditPage.panel.fieldNames,
formatExpectError('Could not locate header elements in table panel')
).toContainText(['col1', 'col2']);
await expect(
panelEditPage.panel.data,
formatExpectError('Could not locate headers in table panel')
).toContainText(['val1', 'val2', 'val3', 'val4']);
});
test('timeseries panel - table view assertions', async ({ panelEditPage, selectors }) => {
await panelEditPage.mockQueryDataResponse(successfulDataQuery, 200);
await panelEditPage.datasource.set('gdev-testdata');
await setVisualization(panelEditPage, 'Time series', selectors);
await panelEditPage.refreshPanel();
await panelEditPage.toggleTableView();
await expect(
panelEditPage.panel.locator,
formatExpectError('Could not locate panel in panel edit page')
).toBeVisible();
await expect(
panelEditPage.panel.fieldNames,
formatExpectError('Could not locate header elements in table panel')
).toContainText(['col1', 'col2']);
await expect(
panelEditPage.panel.data,
formatExpectError('Could not locate data elements in table panel')
).toContainText(['val1', 'val2', 'val3', 'val4']);
});
});
test.describe('dashboard page', () => {
test('getting panel by title', async ({ gotoDashboardPage }) => {
const dashboardPage = await gotoDashboardPage(REACT_TABLE_DASHBOARD);
await dashboardPage.goto();
const panel = await dashboardPage.getPanelByTitle('Colored background');
await expect(panel.fieldNames).toContainText(['Field', 'Max', 'Mean', 'Last']);
});
test('getting panel by id', async ({ gotoDashboardPage }) => {
const dashboardPage = await gotoDashboardPage(REACT_TABLE_DASHBOARD);
await dashboardPage.goto();
const panel = await dashboardPage.getPanelByTitle('Colored background');
await expect(
panel.fieldNames,
formatExpectError('Could not locate header elements in table panel')
).toContainText(['Field', 'Max', 'Mean', 'Last']);
});
});
test.describe('explore page', () => {
test('table panel', async ({ explorePage }) => {
const url =
'left=%7B"datasource":"grafana","queries":%5B%7B"queryType":"randomWalk","refId":"A","datasource":%7B"type":"datasource","uid":"grafana"%7D%7D%5D,"range":%7B"from":"1547161200000","to":"1576364400000"%7D%7D&orgId=1';
await explorePage.goto({
queryParams: new URLSearchParams(url),
});
await expect(
explorePage.timeSeriesPanel.locator,
formatExpectError('Could not locate time series panel in explore page')
).toBeVisible();
await expect(
explorePage.tablePanel.locator,
formatExpectError('Could not locate table panel in explore page')
).toBeVisible();
await expect(explorePage.tablePanel.fieldNames).toContainText(['time', 'A-series']);
});
});
}
);