Skip to content

Commit

Permalink
Plugin E2E: Fix some APIs that were broken in older versions of Grafa…
Browse files Browse the repository at this point in the history
…na (#1391)
  • Loading branch information
sunker authored Dec 11, 2024
1 parent 7f3da2d commit c03938e
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 85 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
with:
version-resolver-type: plugin-grafana-dependency
grafana-dependency: '>=8.5.0'
# limit: 0 # Uncomment to test all versions since 8.5.0. Useful when testing compatibility for new APIs.

playwright-tests:
needs: resolve-versions
Expand Down Expand Up @@ -82,7 +83,7 @@ jobs:
GOOGLE_JWT_FILE: ${{ secrets.GOOGLE_JWT_FILE }}

- name: Publish report to GCS
if: ${{ github.repository_owner == 'grafana' && (always() && steps.run-tests.outcome == 'success') || (failure() && steps.run-tests.outcome == 'failure') }}
if: ${{ github.repository_owner == 'grafana' && (failure() && steps.run-tests.outcome == 'failure') }}
uses: grafana/plugin-actions/publish-report@main
with:
grafana-version: ${{ matrix.GRAFANA_IMAGE.VERSION }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ playwright-report/
packages/plugin-e2e/test-results/
packages/plugin-e2e/playwright/.cache/
packages/plugin-e2e/playwright/.auth
playwright/.cache/
playwright/.auth
.nx

# Used in CI to pass built packages to the next job
Expand Down
52 changes: 26 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/plugin-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"dotenv": "^16.3.1"
},
"dependencies": {
"@grafana/e2e-selectors": "^11.5.0-211617",
"@grafana/e2e-selectors": "^11.5.0-212629",
"semver": "^7.5.4",
"uuid": "^11.0.2",
"yaml": "^2.3.4"
Expand Down
7 changes: 5 additions & 2 deletions packages/plugin-e2e/src/models/components/Panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { GrafanaPage } from '../pages/GrafanaPage';
const ERROR_STATUS = 'error';

export class Panel extends GrafanaPage {
constructor(readonly ctx: PluginTestCtx, readonly locator: Locator) {
constructor(
readonly ctx: PluginTestCtx,
readonly locator: Locator
) {
super(ctx);
}

Expand Down Expand Up @@ -66,7 +69,7 @@ export class Panel extends GrafanaPage {
let selector = this.ctx.selectors.components.Panels.Panel.status(ERROR_STATUS);

// the selector (not the selector value) used to identify a panel error changed in 9.4.3
if (semver.lte(this.ctx.grafanaVersion, '9.4.3')) {
if (semver.lt(this.ctx.grafanaVersion, '9.5.0')) {
selector = this.ctx.selectors.components.Panels.Panel.headerCornerInfo(ERROR_STATUS);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-e2e/src/models/pages/DashboardPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class DashboardPage extends GrafanaPage {
await this.getByGrafanaSelector(components.NavToolbar.editDashboard.editButton).click();
}

if (semver.gte(this.ctx.grafanaVersion, '10.0.0')) {
if (semver.gte(this.ctx.grafanaVersion, '9.5.0')) {
await this.getByGrafanaSelector(components.PageToolbar.itemButton(constants.PageToolBar.itemButtonTitle)).click();
await this.getByGrafanaSelector(pages.AddDashboard.itemButton(pages.AddDashboard.itemButtonAddViz)).click();
} else {
Expand Down
4 changes: 1 addition & 3 deletions packages/plugin-e2e/src/models/pages/PanelEditPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,8 @@ export class PanelEditPage extends GrafanaPage {
await this.getByGrafanaSelector(
this.ctx.selectors.components.NavToolbar.editDashboard.backToDashboardButton
).click();
} else if (semver.gte(this.ctx.grafanaVersion, '9.0.0')) {
await this.ctx.page.getByTestId(this.ctx.selectors.components.PanelEditor.applyButton).click();
} else {
await this.ctx.page.getByLabel('panel editor apply').click();
await this.getByGrafanaSelector(this.ctx.selectors.components.PanelEditor.applyButton).click();
}

return new DashboardPage(this.ctx, this.args);
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-e2e/src/selectors/versionedAPIs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const versionedAPIs = {
[MIN_GRAFANA_VERSION]: '/api/ds/query',
},
health: {
'9.5.0': (uid: string, _: string) => `/api/datasources/uid/${uid}/health`,
'9.4.0': (uid: string, _: string) => `/api/datasources/uid/${uid}/health`,
[MIN_GRAFANA_VERSION]: (_: string, id: string) => `/api/datasources/${id}/health`,
},
datasourceByUID: {
Expand Down
25 changes: 0 additions & 25 deletions playwright/.auth/admin.json

This file was deleted.

25 changes: 0 additions & 25 deletions playwright/.auth/grafanaAPICredentials.json

This file was deleted.

0 comments on commit c03938e

Please # to comment.