Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
99 lines (96 loc) · 3.95 KB
/
Copy pathplaywright.config.ts
File metadata and controls
99 lines (96 loc) · 3.95 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
import { defineConfig } from '@playwright/test';
import { SCREEN_SIZES, crawlAccount } from './e2e/crawl/report';
import { storageStatePath } from './e2e/support/accounts';
// The target and the account come from the environment only (see
// e2e/support/env.ts); nothing here names a host or a credential. The base URL
// is the UI root and must end in /ui/, and tests navigate with relative paths
// such as page.goto('deb/repositories') so the prefix is kept.
//
// The remote projects run against a deployment given by PULP_UI_E2E_BASE_URL
// with the accounts listed in the JSON file named by PULP_UI_E2E_ACCOUNTS. They
// sign in once through the API (remote-setup), reuse that session per role, and
// end it again (remote-teardown). They are meant for a person at a terminal, not
// for a hosted workflow: their output holds session data.
// A trace records the headers of every request, and the sign-in requests (the
// setup project, the API login helpers and the application's own sign-in)
// carry the account's Basic credential. Projects that run against a real
// deployment therefore keep no trace; failures are still evidenced by
// screenshots. Only the smoke project, which runs against a throwaway local
// instance, keeps traces.
const untraced = { trace: 'off' } as const;
// The screen crawler (e2e/crawl) visits every route of the application, signed
// in as the account named by PULP_UI_CRAWL_ACCOUNT (admin unless set to
// viewer), and writes its report to PULP_UI_CRAWL_OUT (crawl-report/ unless
// set). One project is one theme at one width; the theme is the browser's
// colour scheme, which the application follows when the user has made no
// choice. Reports show a deployment's data and URLs and are meant to stay on
// the machine that ran the crawl.
function crawlProject(theme: 'light' | 'dark', viewport: 'desktop' | 'phone') {
return {
name: `crawl-${theme}-${viewport}`,
testMatch: 'crawl/**/*.spec.ts',
metadata: { theme, viewport },
use: {
...untraced,
colorScheme: theme,
viewport: SCREEN_SIZES[viewport],
...(viewport === 'phone' ? { isMobile: true, hasTouch: true } : {}),
storageState: storageStatePath(crawlAccount()),
},
dependencies: ['remote-setup'],
};
}
export default defineConfig({
testDir: 'e2e',
// The crawl run is named before the workers start and summarised after every
// project has finished; both do nothing in a run without crawl projects.
globalSetup: './e2e/crawl/global-setup.ts',
globalTeardown: './e2e/crawl/summarize.ts',
// One worker in CI: the tests share one Pulp and sign in as the same account.
workers: process.env['CI'] ? 1 : undefined,
forbidOnly: !!process.env['CI'],
reporter: [['list'], ['html', { open: 'never' }]],
use: {
baseURL: process.env['PULP_UI_E2E_BASE_URL'],
// Failure evidence is kept, successful runs leave nothing behind. The
// projects that sign in to a real deployment turn tracing off (see
// "untraced").
trace: 'retain-on-failure',
screenshot: 'only-on-failure',
viewport: { width: 1920, height: 1080 },
},
projects: [
{
name: 'smoke',
testMatch: 'smoke/**/*.spec.ts',
},
{
name: 'remote-setup',
testMatch: 'remote/auth.setup.ts',
use: untraced,
teardown: 'remote-teardown',
},
{
name: 'remote-teardown',
testMatch: 'remote/auth.teardown.ts',
use: untraced,
},
{
name: 'remote-admin',
testMatch: 'remote/**/*.spec.ts',
testIgnore: '**/*.viewer.spec.ts',
use: { ...untraced, storageState: 'playwright/.auth/admin.json' },
dependencies: ['remote-setup'],
},
{
name: 'remote-viewer',
testMatch: 'remote/**/*.viewer.spec.ts',
use: { ...untraced, storageState: 'playwright/.auth/viewer.json' },
dependencies: ['remote-setup'],
},
crawlProject('light', 'desktop'),
crawlProject('dark', 'desktop'),
crawlProject('light', 'phone'),
crawlProject('dark', 'phone'),
],
});