Skip to content

E2E: Use grafana selectors instead of getByText #380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions e2e/query-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test.describe('Prometheus query editor', () => {
step
type
exemplars
`, async ({ readProvisionedDataSource, explorePage, page }) => {
`, async ({ readProvisionedDataSource, explorePage, grafanaVersion, page }) => {
const ds = await readProvisionedDataSource<DataSourcePluginOptionsEditorProps<PromOptions>>({
fileName: 'datasources.yml',
});
Expand Down Expand Up @@ -55,17 +55,26 @@ test.describe('Prometheus query editor', () => {
explorePage.getByGrafanaSelector(selectors.components.DataSource.Prometheus.queryEditor.format)
).toBeVisible();

// TODO: use selectors when <EditorSwitch/> is fixed to pass data-testid
await expect(page.getByText('Min step')).toBeVisible();

// type
await expect(
explorePage.getByGrafanaSelector(selectors.components.DataSource.Prometheus.queryEditor.type)
).toBeVisible();

// exemplars
// TODO: use selectors when <EditorSwitch/> is fixed to pass data-testid
await expect(page.getByText('Exemplars')).toBeVisible();
if (semver.gte(grafanaVersion, '12.1.0')) {
// min step
await expect(
explorePage.getByGrafanaSelector(selectors.components.DataSource.Prometheus.queryEditor.step)
).toBeVisible();
// exemplars
await expect(
explorePage.getByGrafanaSelector(selectors.components.DataSource.Prometheus.queryEditor.exemplars)
).toBeVisible();
} else {
// min step
await expect(page.getByText('Min step')).toBeVisible();
// exemplars
await expect(page.getByText('Exemplars')).toBeVisible();
}
});

test.describe('Code editor', () => {
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@eslint/compat": "^1.2.9",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.27.0",
"@grafana/e2e-selectors": "12.0.1",
"@grafana/e2e-selectors": "12.1.0-250688",
"@grafana/eslint-config": "^8.0.0",
"@grafana/plugin-e2e": "^2.0.2",
"@grafana/tsconfig": "^2.0.0",
Expand Down Expand Up @@ -90,12 +90,12 @@
"dependencies": {
"@emotion/css": "11.13.5",
"@grafana/aws-sdk": "^0.7.0",
"@grafana/data": "12.1.0-245310",
"@grafana/data": "12.1.0-250688",
"@grafana/plugin-ui": "^0.10.6",
"@grafana/prometheus": "12.1.0-245310",
"@grafana/runtime": "12.1.0-245310",
"@grafana/schema": "12.1.0-245310",
"@grafana/ui": "12.1.0-245310",
"@grafana/prometheus": "12.1.0-250688",
"@grafana/runtime": "12.1.0-250688",
"@grafana/schema": "12.1.0-250688",
"@grafana/ui": "12.1.0-250688",
"lodash": "4.17.21",
"react": "18.3.1",
"react-dom": "18.3.1",
Expand Down
Loading