From 525217ddad21e6b985fc7f6ad654ca638a394cdc Mon Sep 17 00:00:00 2001 From: Gareth Dawson Date: Tue, 4 Feb 2025 18:04:07 +0700 Subject: [PATCH] Add E2E smoke test (#1962) creates a smoke test for the zabbix data source closes https://github.com/grafana/data-sources/issues/194 --- package.json | 4 ++-- playwright.config.ts | 4 ++-- tests/e2e/smoke.test.ts | 8 +++++++ yarn.lock | 46 ++++++++++++++++++++--------------------- 4 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 tests/e2e/smoke.test.ts diff --git a/package.json b/package.json index 0209003e..c06460f4 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,9 @@ "devDependencies": { "@babel/core": "^7.21.4", "@grafana/eslint-config": "^6.0.0", - "@grafana/plugin-e2e": "^1.14.6", + "@grafana/plugin-e2e": "^1.17.1", "@grafana/tsconfig": "^1.2.0-rc1", - "@playwright/test": "^1.48.0", + "@playwright/test": "^1.50.1", "@swc/core": "^1.3.90", "@swc/helpers": "^0.5.0", "@swc/jest": "^0.2.26", diff --git a/playwright.config.ts b/playwright.config.ts index 3d74e3aa..f914f3ab 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -14,7 +14,7 @@ const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`; * See https://playwright.dev/docs/test-configuration. */ export default defineConfig({ - testDir: './tests', + testDir: './tests/e2e', /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ @@ -28,7 +28,7 @@ export default defineConfig({ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: 'http://localhost:3000', + baseURL: process.env.GRAFANA_URL || `http://localhost:${process.env.PORT || 3000}`, /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', diff --git a/tests/e2e/smoke.test.ts b/tests/e2e/smoke.test.ts new file mode 100644 index 00000000..27b46fdb --- /dev/null +++ b/tests/e2e/smoke.test.ts @@ -0,0 +1,8 @@ +import { test, expect } from '@grafana/plugin-e2e'; + +test('Smoke test: plugin loads', async ({ createDataSourceConfigPage, page }) => { + await createDataSourceConfigPage({ type: 'alexanderzobnin-zabbix-datasource' }); + + await expect(await page.getByText('Type: Zabbix', { exact: true })).toBeVisible(); + await expect(await page.getByRole('heading', { name: 'Connection', exact: true })).toBeVisible(); +}); diff --git a/yarn.lock b/yarn.lock index 082582be..88a473fb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1040,10 +1040,10 @@ tslib "2.6.2" typescript "5.3.3" -"@grafana/e2e-selectors@^11.5.0-216287": - version "11.5.0-216566" - resolved "https://registry.yarnpkg.com/@grafana/e2e-selectors/-/e2e-selectors-11.5.0-216566.tgz#bec2387690e2a9046dcd97e29102fc22f72af11d" - integrity sha512-uhMZxhVOsMjLIRNI7yJRXcfm+F1LXLITdCCkKNh5ATMLe67utpTKWK89Yi9534R0SN38i8w8ReChehetbR0gFA== +"@grafana/e2e-selectors@^11.5.0-221187": + version "11.5.1" + resolved "https://registry.yarnpkg.com/@grafana/e2e-selectors/-/e2e-selectors-11.5.1.tgz#334636ad9e030bf87efaa8dd3dac8b8b5c3b3291" + integrity sha512-pvWax2RBAGarEoXdby5wftX6P+PZluWAF1ylN93OZfwJqvqVNbN1BHmYe2Y83HOKzhne9ML1kTH0KaJMiefaBA== dependencies: "@grafana/tsconfig" "^2.0.0" semver "7.6.3" @@ -1081,12 +1081,12 @@ ua-parser-js "^1.0.32" web-vitals "^3.1.1" -"@grafana/plugin-e2e@^1.14.6": - version "1.14.6" - resolved "https://registry.yarnpkg.com/@grafana/plugin-e2e/-/plugin-e2e-1.14.6.tgz#3ad08b4fd5aadee8dfd9170c7bb6d5e31a67bb53" - integrity sha512-YnARXviUFI+Ez0ygi1CypBHZGY+rNIShI428Mnrj8bn48mr0lCeiI/V2NGsQUz5YJegIfP1JSb05gb/7t8avBQ== +"@grafana/plugin-e2e@^1.17.1": + version "1.17.1" + resolved "https://registry.yarnpkg.com/@grafana/plugin-e2e/-/plugin-e2e-1.17.1.tgz#a6e71044c65e66129fd25f7aa9171726441b4a6d" + integrity sha512-2M2+9vHwvZ+TdfS4w35/BoeaKsIixa+Jxvkq4hhRQy1H6oslShBRpohLIIFvjoHxP5o7dTislDV4pv3ugftmQA== dependencies: - "@grafana/e2e-selectors" "^11.5.0-216287" + "@grafana/e2e-selectors" "^11.5.0-221187" semver "^7.5.4" uuid "^11.0.2" yaml "^2.3.4" @@ -1792,12 +1792,12 @@ picocolors "^1.0.0" tslib "^2.6.0" -"@playwright/test@^1.48.0": - version "1.49.1" - resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.49.1.tgz#55fa360658b3187bfb6371e2f8a64f50ef80c827" - integrity sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g== +"@playwright/test@^1.50.1": + version "1.50.1" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.50.1.tgz#027d00ca77ec79688764eb765cfe9a688807bf0b" + integrity sha512-Jii3aBg+CEDpgnuDxEp/h7BimHcUTDlpEtce89xEumlJ5ef2hqepZ+PWp1DDpYC/VO9fmWVI1IlEaoI5fK9FXQ== dependencies: - playwright "1.49.1" + playwright "1.50.1" "@popperjs/core@2.11.8", "@popperjs/core@^2.11.5": version "2.11.8" @@ -7156,17 +7156,17 @@ pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" -playwright-core@1.49.1: - version "1.49.1" - resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.49.1.tgz#32c62f046e950f586ff9e35ed490a424f2248015" - integrity sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg== +playwright-core@1.50.1: + version "1.50.1" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.50.1.tgz#6a0484f1f1c939168f40f0ab3828c4a1592c4504" + integrity sha512-ra9fsNWayuYumt+NiM069M6OkcRb1FZSK8bgi66AtpFoWkg2+y0bJSNmkFrWhMbEBbVKC/EruAHH3g0zmtwGmQ== -playwright@1.49.1: - version "1.49.1" - resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.49.1.tgz#830266dbca3008022afa7b4783565db9944ded7c" - integrity sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA== +playwright@1.50.1: + version "1.50.1" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.50.1.tgz#2f93216511d65404f676395bfb97b41aa052b180" + integrity sha512-G8rwsOQJ63XG6BbKj2w5rHeavFjy5zynBA9zsJMMtBoe/Uf757oG12NXz6e6OirF7RCrTVAKFXbLmn1RbL7Qaw== dependencies: - playwright-core "1.49.1" + playwright-core "1.50.1" optionalDependencies: fsevents "2.3.2"