Playwright: Acceptance tests (#108770)

* create a set of acceptance tests to run with bench

* move tests back, fix login tests to work with supplied credentials:

* rename files again

* rename skip message
This commit is contained in:
Josh Hunt 2025-07-28 17:32:18 +01:00 committed by GitHub
parent 672e6d08bf
commit a009da2087
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 59 additions and 35 deletions

View File

@ -1,19 +0,0 @@
import { test, expect } from '@grafana/plugin-e2e';
test(
'Scenario test: Can login successfully',
{
tag: ['@scenarios'],
},
async ({ selectors, page }) => {
await page.goto(selectors.pages.Login.url);
await page.getByTestId(selectors.pages.Login.username).fill('admin');
await page.getByTestId(selectors.pages.Login.password).fill('admin');
await page.getByTestId(selectors.pages.Login.submit).click();
await page.getByTestId(selectors.pages.Login.skip).click();
await expect(page.getByTestId(selectors.components.NavToolbar.commandPaletteTrigger)).toBeVisible();
}
);

View File

@ -4,7 +4,7 @@ import { GrafanaBootConfig } from '@grafana/runtime';
test.describe(
'Panels smokescreen',
{
tag: ['@smoke'],
tag: ['@acceptance'],
},
() => {
test('Tests each panel type in the panel edit view to ensure no crash', async ({
@ -14,6 +14,7 @@ test.describe(
}) => {
// this test can absolutely take longer than the default 30s timeout
test.setTimeout(60000);
// Create new dashboard
const dashboardPage = await gotoDashboardPage({});
@ -30,9 +31,11 @@ test.describe(
// Loop through every panel type and ensure no crash
for (const [_, panel] of Object.entries(panelTypes)) {
// Skip hidden and deprecated panels
if (!panel.hideFromList && panel.state !== 'deprecated') {
// Open visualization picker
if (panel.hideFromList || panel.state === 'deprecated') {
continue; // Skip hidden and deprecated panels
}
// Select the panel type in the viz picker
const vizPicker = dashboardPage.getByGrafanaSelector(selectors.components.PanelEditor.toggleVizPicker);
await vizPicker.click();
await dashboardPage.getByGrafanaSelector(selectors.components.PluginVisualization.item(panel.name)).click();
@ -43,7 +46,6 @@ test.describe(
// Ensure no unexpected error occurred
await expect(page.getByText('An unexpected error happened')).toBeHidden();
}
}
});
}
);

View File

@ -5,7 +5,7 @@ import { test, expect } from '@grafana/plugin-e2e';
test.describe(
'Smoke tests',
{
tag: ['@smoke'],
tag: ['@acceptance'],
},
() => {
test('Login, create test data source, create dashboard and panel scenario', async ({

View File

@ -0,0 +1,40 @@
import { test, expect } from '@grafana/plugin-e2e';
test(
'Can login successfully',
{
tag: ['@acceptance'],
},
async ({ selectors, page, grafanaAPICredentials }) => {
test.skip(grafanaAPICredentials.password === 'admin', 'Does not run with default password');
await page.goto(selectors.pages.Login.url);
await page.getByTestId(selectors.pages.Login.username).fill(grafanaAPICredentials.user);
await page.getByTestId(selectors.pages.Login.password).fill(grafanaAPICredentials.password);
await page.getByTestId(selectors.pages.Login.submit).click();
await expect(page.getByTestId(selectors.components.NavToolbar.commandPaletteTrigger)).toBeVisible();
}
);
test(
'Can login successfully and skip password change',
{
tag: ['@acceptance'],
},
async ({ selectors, page, grafanaAPICredentials }) => {
test.skip(grafanaAPICredentials.password !== 'admin', 'Only runs with the default password');
await page.goto(selectors.pages.Login.url);
await page.getByTestId(selectors.pages.Login.username).fill(grafanaAPICredentials.user);
await page.getByTestId(selectors.pages.Login.password).fill(grafanaAPICredentials.password);
await page.getByTestId(selectors.pages.Login.submit).click();
await page.getByTestId(selectors.pages.Login.skip).click();
await expect(page.getByTestId(selectors.components.NavToolbar.commandPaletteTrigger)).toBeVisible();
}
);

View File

@ -23,6 +23,7 @@
"e2e:enterprise:debug": "./e2e/start-and-run-suite enterprise debug",
"e2e:playwright": "yarn playwright test",
"e2e:playwright:storybook": "yarn playwright test -c playwright.storybook.config.ts",
"e2e:acceptance": "yarn playwright test --grep @acceptance",
"e2e:storybook": "PORT=9001 ./e2e/run-suite storybook true",
"e2e:plugin:build": "nx run-many -t build --projects='@test-plugins/*'",
"e2e:plugin:build:dev": "nx run-many -t dev --projects='@test-plugins/*' --maxParallel=100",

View File

@ -205,8 +205,8 @@ export default defineConfig<PluginOptions>({
dependencies: ['authenticate'],
},
{
name: 'scenarios',
testDir: path.join(testDirRoot, '/scenarios'),
name: 'unauthenticated',
testDir: path.join(testDirRoot, '/unauthenticated'),
use: {
...devices['Desktop Chrome'],
},