forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
215 lines (208 loc) · 6.16 KB
/
playwright.config.ts
File metadata and controls
215 lines (208 loc) · 6.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
import { defineConfig, devices, PlaywrightTestConfig, Project } from '@playwright/test';
import path, { dirname } from 'path';
import { PluginOptions } from '@grafana/plugin-e2e';
export const testDirRoot = 'e2e-playwright';
const pluginDirRoot = path.join(testDirRoot, 'plugin-e2e');
export const DEFAULT_URL = 'http://localhost:3001';
export function withAuth(project: Project): Project {
project.dependencies ??= [];
project.use ??= {};
project.dependencies = project.dependencies.concat('authenticate');
project.use = {
...project.use,
storageState: `playwright/.auth/${process.env.GRAFANA_ADMIN_USER || 'admin'}.json`,
};
return project;
}
export const baseConfig: PlaywrightTestConfig<PluginOptions, {}> = {
fullyParallel: true,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
reporter: [
['html'], // pretty
],
expect: {
timeout: 10_000,
},
use: {
...devices['Desktop Chrome'],
baseURL: process.env.GRAFANA_URL ?? DEFAULT_URL,
trace: 'retain-on-failure',
httpCredentials: {
username: 'admin',
password: 'admin',
},
screenshot: 'only-on-failure',
permissions: ['clipboard-read', 'clipboard-write'],
provisioningRootDir: path.join(process.cwd(), process.env.PROV_DIR ?? 'conf/provisioning'),
},
};
export default defineConfig<PluginOptions>({
...baseConfig,
...(!process.env.GRAFANA_URL && {
webServer: {
command: 'yarn e2e:plugin:build && ./e2e-playwright/start-server',
url: DEFAULT_URL,
stdout: 'pipe',
stderr: 'pipe',
},
}),
projects: [
// Login to Grafana with admin user and store the cookie on disk for use in other tests
{
name: 'authenticate',
testDir: `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`,
testMatch: [/.*\.js/],
},
// Login to Grafana with new user with viewer role and store the cookie on disk for use in other tests
{
name: 'createUserAndAuthenticate',
testDir: `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`,
testMatch: [/.*\.js/],
use: {
user: {
user: 'viewer',
password: 'password',
role: 'Viewer',
},
},
},
// Run all tests in parallel using user with admin role
withAuth({
name: 'admin',
testDir: path.join(pluginDirRoot, '/plugin-e2e-api-tests/as-admin-user'),
}),
// Run all tests in parallel using user with viewer role
{
name: 'viewer',
testDir: path.join(pluginDirRoot, '/plugin-e2e-api-tests/as-viewer-user'),
use: {
...devices['Desktop Chrome'],
storageState: 'playwright/.auth/viewer.json',
},
dependencies: ['createUserAndAuthenticate'],
},
withAuth({
name: 'elasticsearch',
testDir: path.join(pluginDirRoot, '/elasticsearch'),
}),
withAuth({
name: 'mysql',
testDir: path.join(pluginDirRoot, '/mysql'),
}),
withAuth({
name: 'mssql',
testDir: path.join(pluginDirRoot, '/mssql'),
}),
withAuth({
name: 'extensions-test-app',
testDir: path.join(testDirRoot, '/test-plugins/grafana-extensionstest-app'),
}),
withAuth({
name: 'grafana-e2etest-datasource',
testDir: path.join(testDirRoot, '/test-plugins/grafana-test-datasource'),
}),
withAuth({
name: 'cloudwatch',
testDir: path.join(pluginDirRoot, '/cloudwatch'),
}),
withAuth({
name: 'azuremonitor',
testDir: path.join(pluginDirRoot, '/azuremonitor'),
}),
withAuth({
name: 'cloudmonitoring',
testDir: path.join(pluginDirRoot, '/cloudmonitoring'),
}),
withAuth({
name: 'graphite',
testDir: path.join(pluginDirRoot, '/graphite'),
}),
withAuth({
name: 'influxdb',
testDir: path.join(pluginDirRoot, '/influxdb'),
}),
withAuth({
name: 'opentsdb',
testDir: path.join(pluginDirRoot, '/opentsdb'),
}),
withAuth({
name: 'jaeger',
testDir: path.join(pluginDirRoot, '/jaeger'),
}),
withAuth({
name: 'grafana-postgresql-datasource',
testDir: path.join(pluginDirRoot, '/grafana-postgresql-datasource'),
}),
withAuth({
name: 'canvas',
testDir: path.join(testDirRoot, '/canvas'),
}),
withAuth({
name: 'zipkin',
testDir: path.join(pluginDirRoot, '/zipkin'),
}),
{
name: 'unauthenticated',
testDir: path.join(testDirRoot, '/unauthenticated'),
},
withAuth({
name: 'various',
testDir: path.join(testDirRoot, '/various-suite'),
}),
withAuth({
name: 'panels',
testDir: path.join(testDirRoot, '/panels-suite'),
}),
withAuth({
name: 'smoke',
testDir: path.join(testDirRoot, '/smoke-tests-suite'),
}),
withAuth({
name: 'dashboards',
testDir: path.join(testDirRoot, '/dashboards-suite'),
}),
withAuth({
name: 'loki',
testDir: path.join(testDirRoot, '/loki'),
}),
withAuth({
name: 'cloud-plugins',
testDir: path.join(testDirRoot, '/cloud-plugins-suite'),
}),
withAuth({
name: 'alerting',
testDir: path.join(testDirRoot, '/alerting-suite'),
}),
withAuth({
name: 'dashboard-new-layouts',
testDir: path.join(testDirRoot, '/dashboard-new-layouts'),
}),
// Setup project for dashboard CUJS tests
withAuth({
name: 'dashboard-cujs-setup',
testDir: path.join(testDirRoot, '/dashboard-cujs'),
testMatch: ['global-setup.spec.ts'],
}),
// Main dashboard CUJS tests
withAuth({
name: 'dashboard-cujs',
testDir: path.join(testDirRoot, '/dashboard-cujs'),
testIgnore: ['global-setup.spec.ts', 'global-teardown.spec.ts'],
dependencies: ['dashboard-cujs-setup'],
}),
// Teardown project for dashboard CUJS tests
withAuth({
name: 'dashboard-cujs-teardown',
testDir: path.join(testDirRoot, '/dashboard-cujs'),
testMatch: ['global-teardown.spec.ts'],
dependencies: ['dashboard-cujs'],
}),
withAuth({
name: 'grafana-e2etest-panel',
testDir: path.join(testDirRoot, '/test-plugins/grafana-test-panel'),
}),
],
});