-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplaywright.real-webauthn.config.ts
More file actions
153 lines (130 loc) · 4.67 KB
/
playwright.real-webauthn.config.ts
File metadata and controls
153 lines (130 loc) · 4.67 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
/**
* Playwright Configuration for Real WebAuthn Testing
*
* This configuration runs tests in headed mode with Chrome's software
* platform authenticator, enabling testing of real WebAuthn flows
* without CDP virtual authenticator mocking.
*
* Usage:
* npm run test:real-webauthn
* make test-real-webauthn # With Docker services
* make test-real-webauthn-ci # With Xvfb for CI
*/
import { defineConfig, devices } from '@playwright/test';
import * as path from 'path';
// Load environment variables from .env file
import * as dotenv from 'dotenv';
dotenv.config();
// Use same environment variables as main config for consistency with Docker setup
const baseURL = process.env.FRONTEND_URL || 'http://localhost:3000';
const backendURL = process.env.BACKEND_URL || 'http://localhost:8080';
const adminURL = process.env.ADMIN_URL || 'http://localhost:8081';
export default defineConfig({
testDir: './specs/real-webauthn',
// Run tests serially - WebAuthn operations can conflict with each other
fullyParallel: false,
workers: 1,
// 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,
// Reporter configuration
// Set open: 'never' to prevent HTML reporter from opening browser and hanging
reporter: process.env.CI
? [['github'], ['html', { outputFolder: 'playwright-report-real-webauthn', open: 'never' }]]
: [['list'], ['html', { outputFolder: 'playwright-report-real-webauthn', open: 'never' }]],
// Global timeout - real WebAuthn may need more time for UI interactions
timeout: 60000,
use: {
// CRITICAL: Real WebAuthn requires headed mode
headless: false,
// Base URL for all page.goto() calls
baseURL,
// Browser launch options for WebAuthn support
launchOptions: {
args: [
// Enable Chrome's caBLE (Cloud-Assisted BLE) and WebAuthn features
'--enable-features=WebAuthenticationCable,WebAuthenticationMacPlatformAuthenticator',
// Allow insecure localhost for development
'--ignore-certificate-errors',
// Disable various Chrome features that might interfere
'--disable-background-networking',
'--disable-client-side-phishing-detection',
'--disable-default-apps',
'--disable-extensions',
'--disable-hang-monitor',
'--disable-popup-blocking',
'--disable-prompt-on-repost',
'--disable-sync',
'--disable-translate',
// Enable automation features
'--enable-automation',
// Log WebAuthn operations for debugging
'--vmodule=*webauthn*=3',
],
// Slow down for debugging if needed
slowMo: process.env.SLOW_MO ? parseInt(process.env.SLOW_MO) : 0,
},
// Accept self-signed certificates
ignoreHTTPSErrors: true,
// Trace collection for debugging
trace: 'on-first-retry',
// Video recording for debugging test failures
video: 'on-first-retry',
// Screenshot on failure
screenshot: 'only-on-failure',
// Viewport size
viewport: { width: 1280, height: 720 },
// Extra HTTP headers
extraHTTPHeaders: {
'Accept-Language': 'en-US,en;q=0.9',
},
},
// Output directories
outputDir: 'test-results-real-webauthn',
// Projects configuration
projects: [
{
name: 'real-webauthn-chromium',
use: {
...devices['Desktop Chrome'],
// Override device settings for WebAuthn
hasTouch: false, // Platform authenticator, not NFC
},
},
// TODO: Add Firefox and Safari when their WebAuthn automation improves
// {
// name: 'real-webauthn-firefox',
// use: { ...devices['Desktop Firefox'] },
// },
// {
// name: 'real-webauthn-safari',
// use: { ...devices['Desktop Safari'] },
// },
],
// Global setup - can be used to start services
// globalSetup: require.resolve('./global-setup'),
// globalTeardown: require.resolve('./global-teardown'),
// Web server configuration - starts the frontend if needed
webServer: process.env.START_WEBSERVER
? [
{
command: 'cd ../wallet-frontend && npm run dev',
url: baseURL,
reuseExistingServer: !process.env.CI,
timeout: 120000,
},
{
command: 'cd ../go-wallet-backend && go run ./cmd/wallet-backend',
url: `${backendURL}/health`,
reuseExistingServer: !process.env.CI,
timeout: 120000,
},
]
: undefined,
// Expect configuration
expect: {
// Increase timeout for WebAuthn operations which may show UI
timeout: 15000,
},
});