-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
24,791 additions
and
34,119 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { dirname } from 'path'; | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* 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', | ||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'auth', | ||
testDir: pluginE2eAuth, | ||
testMatch: [/.*\.js/], | ||
}, | ||
{ | ||
name: 'run-tests', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
storageState: 'playwright/.auth/admin.json', | ||
}, | ||
dependencies: ['auth'], | ||
}, | ||
// { | ||
// name: 'createAdminUserAndAuthenticate', | ||
// testDir: pluginE2eAuth, | ||
// testMatch: [/.*\.js/], | ||
// }, | ||
// { | ||
// name: 'run-tests-for-admin', | ||
// testDir: './tests', | ||
// use: { | ||
// ...devices['Desktop Chrome'], | ||
// // @grafana/plugin-e2e writes the auth state to this file, | ||
// // the path should not be modified | ||
// storageState: 'playwright/.auth/admin.json', | ||
// }, | ||
// dependencies: ['createAdminUserAndAuthenticate'], | ||
// }, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { test, expect } from './fixtures'; | ||
import { ROUTES } from '../src/constants'; | ||
|
||
test.describe('navigating app', () => { | ||
test('Page patents should be visible for admin', async ({ gotoPage, page }) => { | ||
// wait for page to successfully render | ||
await gotoPage('/hello'); | ||
await expect(page).toHaveURL(/.*patents/); | ||
await expect(page.getByText('Welcome')).toBeVisible(); | ||
}); | ||
test('Page research docs should be visible for admin', async ({ gotoPage, page }) => { | ||
// wait for page to successfully render | ||
await gotoPage(`/${ROUTES.ResearchDocs}`); | ||
await expect(page).toHaveURL(/.*research/); | ||
await expect(page.getByText('Welcome')).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { AppConfigPage, AppPage, test as base } from '@grafana/plugin-e2e'; | ||
import pluginJson from '../src/plugin.json'; | ||
|
||
type AppTestFixture = { | ||
appConfigPage: AppConfigPage; | ||
gotoPage: (path?: string) => Promise<AppPage>; | ||
}; | ||
|
||
export const test = base.extend<AppTestFixture>({ | ||
appConfigPage: async ({ gotoAppConfigPage }, use) => { | ||
const configPage = await gotoAppConfigPage({ | ||
pluginId: pluginJson.id, | ||
}); | ||
await use(configPage); | ||
}, | ||
gotoPage: async ({ gotoAppPage }, use) => { | ||
await use((path) => | ||
gotoAppPage({ | ||
path, | ||
pluginId: pluginJson.id, | ||
}) | ||
); | ||
}, | ||
}); | ||
|
||
export { expect } from '@grafana/plugin-e2e'; |
Oops, something went wrong.