mirror of https://github.com/grafana/grafana.git
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:
parent
672e6d08bf
commit
a009da2087
|
@ -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();
|
|
||||||
}
|
|
||||||
);
|
|
|
@ -4,7 +4,7 @@ import { GrafanaBootConfig } from '@grafana/runtime';
|
||||||
test.describe(
|
test.describe(
|
||||||
'Panels smokescreen',
|
'Panels smokescreen',
|
||||||
{
|
{
|
||||||
tag: ['@smoke'],
|
tag: ['@acceptance'],
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
test('Tests each panel type in the panel edit view to ensure no crash', async ({
|
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
|
// this test can absolutely take longer than the default 30s timeout
|
||||||
test.setTimeout(60000);
|
test.setTimeout(60000);
|
||||||
|
|
||||||
// Create new dashboard
|
// Create new dashboard
|
||||||
const dashboardPage = await gotoDashboardPage({});
|
const dashboardPage = await gotoDashboardPage({});
|
||||||
|
|
||||||
|
@ -30,19 +31,20 @@ test.describe(
|
||||||
|
|
||||||
// Loop through every panel type and ensure no crash
|
// Loop through every panel type and ensure no crash
|
||||||
for (const [_, panel] of Object.entries(panelTypes)) {
|
for (const [_, panel] of Object.entries(panelTypes)) {
|
||||||
// Skip hidden and deprecated panels
|
if (panel.hideFromList || panel.state === 'deprecated') {
|
||||||
if (!panel.hideFromList && panel.state !== 'deprecated') {
|
continue; // Skip hidden and deprecated panels
|
||||||
// Open visualization picker
|
|
||||||
const vizPicker = dashboardPage.getByGrafanaSelector(selectors.components.PanelEditor.toggleVizPicker);
|
|
||||||
await vizPicker.click();
|
|
||||||
await dashboardPage.getByGrafanaSelector(selectors.components.PluginVisualization.item(panel.name)).click();
|
|
||||||
|
|
||||||
// Verify panel type is selected
|
|
||||||
await expect(vizPicker).toHaveText(panel.name);
|
|
||||||
|
|
||||||
// Ensure no unexpected error occurred
|
|
||||||
await expect(page.getByText('An unexpected error happened')).toBeHidden();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
|
||||||
|
// Verify panel type is selected
|
||||||
|
await expect(vizPicker).toHaveText(panel.name);
|
||||||
|
|
||||||
|
// Ensure no unexpected error occurred
|
||||||
|
await expect(page.getByText('An unexpected error happened')).toBeHidden();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@ import { test, expect } from '@grafana/plugin-e2e';
|
||||||
test.describe(
|
test.describe(
|
||||||
'Smoke tests',
|
'Smoke tests',
|
||||||
{
|
{
|
||||||
tag: ['@smoke'],
|
tag: ['@acceptance'],
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
test('Login, create test data source, create dashboard and panel scenario', async ({
|
test('Login, create test data source, create dashboard and panel scenario', async ({
|
|
@ -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();
|
||||||
|
}
|
||||||
|
);
|
|
@ -23,6 +23,7 @@
|
||||||
"e2e:enterprise:debug": "./e2e/start-and-run-suite enterprise debug",
|
"e2e:enterprise:debug": "./e2e/start-and-run-suite enterprise debug",
|
||||||
"e2e:playwright": "yarn playwright test",
|
"e2e:playwright": "yarn playwright test",
|
||||||
"e2e:playwright:storybook": "yarn playwright test -c playwright.storybook.config.ts",
|
"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:storybook": "PORT=9001 ./e2e/run-suite storybook true",
|
||||||
"e2e:plugin:build": "nx run-many -t build --projects='@test-plugins/*'",
|
"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",
|
"e2e:plugin:build:dev": "nx run-many -t dev --projects='@test-plugins/*' --maxParallel=100",
|
||||||
|
|
|
@ -205,8 +205,8 @@ export default defineConfig<PluginOptions>({
|
||||||
dependencies: ['authenticate'],
|
dependencies: ['authenticate'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'scenarios',
|
name: 'unauthenticated',
|
||||||
testDir: path.join(testDirRoot, '/scenarios'),
|
testDir: path.join(testDirRoot, '/unauthenticated'),
|
||||||
use: {
|
use: {
|
||||||
...devices['Desktop Chrome'],
|
...devices['Desktop Chrome'],
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue