Files
grafana/e2e-playwright/dashboards-suite/templating-dashboard-links-and-variables.spec.ts
Ashley Harrison 6408e3acaa E2E: Remove cypress dashboards-suite (#109038)
* add equivalent dashboard-time-zone test

* remove cypress dashboards-suite

* modify tests to work with schema-v2 + update workflow to run playwright instead

* fix package.json

* update CODEOWNERS

* fix start-server to include ARCH
2025-08-05 10:09:49 +01:00

71 lines
2.3 KiB
TypeScript

import { test, expect } from '@grafana/plugin-e2e';
const DASHBOARD_UID = 'yBCC3aKGk';
test.use({
featureToggles: {
kubernetesDashboards: process.env.KUBERNETES_DASHBOARDS === 'true',
},
});
test.describe(
'Templating dashboard links and variables',
{
tag: ['@dashboards'],
},
() => {
test('Tests dashboard links and variables in links', async ({ page, gotoDashboardPage, selectors }) => {
const dashboardPage = await gotoDashboardPage({ uid: DASHBOARD_UID });
const verifyLinks = async (variableValue: string) => {
const dashboardLinks = dashboardPage.getByGrafanaSelector(selectors.components.DashboardLinks.link);
let linkCount = 0;
await expect
.poll(async () => {
linkCount = await dashboardLinks.count();
return linkCount;
})
.toBeGreaterThan(13);
for (let i = 0; i < linkCount; i++) {
const href = await dashboardLinks.nth(i).getAttribute('href');
expect(href).toContain(variableValue);
}
};
// Click on dashboard links dropdown
const dashboardLinksDropdown = dashboardPage.getByGrafanaSelector(selectors.components.DashboardLinks.dropDown);
await expect(dashboardLinksDropdown).toBeVisible();
await dashboardLinksDropdown.click();
// Verify links contain default variable value
await verifyLinks('var-custom=$__all');
// Close dropdown
await page.locator('body').click({ position: { x: 0, y: 0 } });
// Change variable value from $__all to p2
const customVariable = dashboardPage
.getByGrafanaSelector(selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('$__all'))
.locator('input');
await expect(customVariable).toBeVisible();
await customVariable.click();
await dashboardPage
.getByGrafanaSelector(selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('p2'))
.click();
// Close dropdown
await page.locator('body').click({ position: { x: 0, y: 0 } });
// Open dashboard links dropdown again
await expect(dashboardLinksDropdown).toBeVisible();
await dashboardLinksDropdown.click();
// Verify all links now contain the p2 value
await verifyLinks('p2');
});
}
);