add e2e to exercise the case

This commit is contained in:
Paul Marbach
2026-01-13 11:15:51 -05:00
parent 7b2acac9cb
commit dbb3a3a9f8
@@ -3,7 +3,7 @@ import { test, expect } from '@grafana/plugin-e2e';
test.use({
featureToggles: {
newVizSuggestions: true,
externalVizSuggestions: false,
externalVizSuggestions: true,
},
viewport: {
width: 800,
@@ -174,5 +174,40 @@ test.describe(
'time series to be rendered inside the panel'
).toBeVisible();
});
test('should not apply suggestion if you navigate back to the dashboard for a new panel', async ({
page,
selectors,
gotoDashboardPage,
}) => {
// New dashboard
const dashboardPage = await gotoDashboardPage({});
// Press the empty-state Create new panel button
await dashboardPage
.getByGrafanaSelector(selectors.pages.AddDashboard.itemButton('Create new panel button'))
.click();
await expect(dashboardPage.getByGrafanaSelector(selectors.components.PanelEditor.General.content)).toBeVisible();
// Verify we see suggestions on load (after closing the data source picker)
await page.getByRole('button', { name: 'Close', exact: true }).click({ force: true });
await expect(
dashboardPage.getByGrafanaSelector(selectors.components.VisualizationPreview.card('Line chart')),
'line chart suggestion to be rendered'
).toBeVisible();
// Select a visualization
await dashboardPage.getByGrafanaSelector(selectors.components.VisualizationPreview.card('Table')).click();
await expect(page.getByRole('grid').getByRole('row').first(), 'table row to be rendered').toBeVisible();
// Verify that navigating back to the dashboard cancels the suggestion and restores the line chart.
await dashboardPage
.getByGrafanaSelector(selectors.components.NavToolbar.editDashboard.backToDashboardButton)
.click();
await expect(
page.locator('[data-viz-panel-key="panel-1"]').locator('.uplot'),
'time series to be rendered inside the panel'
).toBeVisible();
});
}
);