playwright-ai-reporter 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1183 -0
- package/dist/colors.d.ts +54 -0
- package/dist/colors.js +57 -0
- package/dist/examples/ReporterWorkflow.d.ts +54 -0
- package/dist/examples/ReporterWorkflow.js +307 -0
- package/dist/providers/ProviderRegistry.d.ts +79 -0
- package/dist/providers/ProviderRegistry.js +195 -0
- package/dist/providers/ai/AIProviderFactory.d.ts +33 -0
- package/dist/providers/ai/AIProviderFactory.js +82 -0
- package/dist/providers/ai/AnthropicProvider.d.ts +15 -0
- package/dist/providers/ai/AnthropicProvider.js +128 -0
- package/dist/providers/ai/AzureOpenAIProvider.d.ts +20 -0
- package/dist/providers/ai/AzureOpenAIProvider.js +158 -0
- package/dist/providers/ai/GoogleAIProvider.d.ts +17 -0
- package/dist/providers/ai/GoogleAIProvider.js +154 -0
- package/dist/providers/ai/MistralProvider.d.ts +16 -0
- package/dist/providers/ai/MistralProvider.js +137 -0
- package/dist/providers/ai/OpenAIProvider.d.ts +16 -0
- package/dist/providers/ai/OpenAIProvider.js +141 -0
- package/dist/providers/bugTrackers/AzureDevOpsBugTracker.d.ts +32 -0
- package/dist/providers/bugTrackers/AzureDevOpsBugTracker.js +295 -0
- package/dist/providers/bugTrackers/GitHubBugTracker.d.ts +28 -0
- package/dist/providers/bugTrackers/GitHubBugTracker.js +241 -0
- package/dist/providers/bugTrackers/JiraBugTracker.d.ts +29 -0
- package/dist/providers/bugTrackers/JiraBugTracker.js +279 -0
- package/dist/providers/databases/MySQLProvider.d.ts +32 -0
- package/dist/providers/databases/MySQLProvider.js +274 -0
- package/dist/providers/databases/SQLiteProvider.d.ts +28 -0
- package/dist/providers/databases/SQLiteProvider.js +272 -0
- package/dist/providers/factories/BugTrackerFactory.d.ts +20 -0
- package/dist/providers/factories/BugTrackerFactory.js +50 -0
- package/dist/providers/factories/DatabaseFactory.d.ts +28 -0
- package/dist/providers/factories/DatabaseFactory.js +71 -0
- package/dist/providers/factories/NotificationFactory.d.ts +24 -0
- package/dist/providers/factories/NotificationFactory.js +64 -0
- package/dist/providers/factories/PRProviderFactory.d.ts +20 -0
- package/dist/providers/factories/PRProviderFactory.js +45 -0
- package/dist/providers/index.d.ts +28 -0
- package/dist/providers/index.js +55 -0
- package/dist/providers/interfaces/IAIProvider.d.ts +59 -0
- package/dist/providers/interfaces/IAIProvider.js +5 -0
- package/dist/providers/interfaces/IBugTrackerProvider.d.ts +70 -0
- package/dist/providers/interfaces/IBugTrackerProvider.js +20 -0
- package/dist/providers/interfaces/IDatabaseProvider.d.ts +90 -0
- package/dist/providers/interfaces/IDatabaseProvider.js +5 -0
- package/dist/providers/interfaces/INotificationProvider.d.ts +59 -0
- package/dist/providers/interfaces/INotificationProvider.js +13 -0
- package/dist/providers/interfaces/IPRProvider.d.ts +82 -0
- package/dist/providers/interfaces/IPRProvider.js +5 -0
- package/dist/providers/notifications/EmailNotificationProvider.d.ts +29 -0
- package/dist/providers/notifications/EmailNotificationProvider.js +290 -0
- package/dist/providers/pr/AzureDevOpsPRProvider.d.ts +30 -0
- package/dist/providers/pr/AzureDevOpsPRProvider.js +263 -0
- package/dist/providers/pr/GitHubPRProvider.d.ts +29 -0
- package/dist/providers/pr/GitHubPRProvider.js +320 -0
- package/dist/reporter.d.ts +138 -0
- package/dist/reporter.js +787 -0
- package/dist/types/index.d.ts +168 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/buildInfoUtils.d.ts +26 -0
- package/dist/utils/buildInfoUtils.js +125 -0
- package/dist/utils/configValidator.d.ts +67 -0
- package/dist/utils/configValidator.js +454 -0
- package/dist/utils/fileHandlerUtils.d.ts +42 -0
- package/dist/utils/fileHandlerUtils.js +136 -0
- package/dist/utils/genaiUtils.d.ts +38 -0
- package/dist/utils/genaiUtils.js +178 -0
- package/dist/utils/historyUtils.d.ts +49 -0
- package/dist/utils/historyUtils.js +118 -0
- package/dist/utils/utils.d.ts +104 -0
- package/dist/utils/utils.js +371 -0
- package/docs/API.md +591 -0
- package/docs/ENV_CONFIG_GUIDE.md +444 -0
- package/docs/IMPLEMENTATION_SUMMARY.md +285 -0
- package/docs/PROVIDERS.md +261 -0
- package/docs/QUICKSTART.md +350 -0
- package/docs/README.md +253 -0
- package/docs/TROUBLESHOOTING.md +577 -0
- package/docs/design.md +384 -0
- package/docs/logo.png +0 -0
- package/examples/README.md +326 -0
- package/examples/VALIDATION.md +68 -0
- package/examples/env-configs/.env.anthropic-minimal +40 -0
- package/examples/env-configs/.env.azure-stack +71 -0
- package/examples/env-configs/.env.example +32 -0
- package/examples/env-configs/.env.github-stack +57 -0
- package/examples/env-configs/.env.google-mysql +61 -0
- package/examples/env-configs/.env.ms-auth-examples +56 -0
- package/examples/env-configs/.env.openai-jira +64 -0
- package/examples/package.json +22 -0
- package/package.json +70 -0
- package/playwright-ai-reporter-0.0.4.tgz +0 -0
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
# Environment Configuration Guide
|
|
2
|
+
|
|
3
|
+
This guide explains the pre-configured environment files available in `examples/env-configs/`. Choose the configuration that best matches your infrastructure and copy it to `.env` in the project root.
|
|
4
|
+
|
|
5
|
+
## Available Configurations
|
|
6
|
+
|
|
7
|
+
### 1. `.env.github-stack` (Recommended for GitHub Users)
|
|
8
|
+
|
|
9
|
+
**Stack**: GitHub + Mistral AI + Email + SQLite
|
|
10
|
+
|
|
11
|
+
**Best for**:
|
|
12
|
+
|
|
13
|
+
- Open source projects hosted on GitHub
|
|
14
|
+
- Teams already using GitHub Issues and Pull Requests
|
|
15
|
+
- Quick local setup with minimal infrastructure
|
|
16
|
+
|
|
17
|
+
**Setup**:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
cp examples/env-configs/.env.github-stack .env
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**What you need**:
|
|
24
|
+
|
|
25
|
+
- GitHub Personal Access Token (with `repo` scope)
|
|
26
|
+
- Mistral AI API key
|
|
27
|
+
- Gmail account with App Password (for notifications)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
### 2. `.env.azure-stack` (Recommended for Azure Users)
|
|
32
|
+
|
|
33
|
+
**Stack**: Azure DevOps + Azure OpenAI + Email + MySQL
|
|
34
|
+
|
|
35
|
+
**Best for**:
|
|
36
|
+
|
|
37
|
+
- Enterprise projects on Azure DevOps
|
|
38
|
+
- Teams using Azure cloud infrastructure
|
|
39
|
+
- Production environments with managed identity
|
|
40
|
+
|
|
41
|
+
**Setup**:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
cp examples/env-configs/.env.azure-stack .env
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**What you need**:
|
|
48
|
+
|
|
49
|
+
- Azure DevOps Personal Access Token (with Work Items, Code scope)
|
|
50
|
+
- Azure OpenAI deployment (or use Managed Identity)
|
|
51
|
+
- Azure MySQL or any MySQL server
|
|
52
|
+
- Office 365 email account
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### 3. `.env.openai-jira` (Hybrid Configuration)
|
|
57
|
+
|
|
58
|
+
**Stack**: Jira + GitHub + OpenAI + Email + SQLite
|
|
59
|
+
|
|
60
|
+
**Best for**:
|
|
61
|
+
|
|
62
|
+
- Teams using Jira for issue tracking
|
|
63
|
+
- Code hosted on GitHub
|
|
64
|
+
- Hybrid tool environments
|
|
65
|
+
|
|
66
|
+
**Setup**:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cp examples/env-configs/.env.openai-jira .env
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**What you need**:
|
|
73
|
+
|
|
74
|
+
- Jira Cloud account with API token
|
|
75
|
+
- GitHub Personal Access Token (for PRs)
|
|
76
|
+
- OpenAI API key
|
|
77
|
+
- SendGrid or SMTP email service
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### 4. `.env.anthropic-minimal` (Minimal Configuration)
|
|
82
|
+
|
|
83
|
+
**Stack**: Anthropic Claude + SQLite only
|
|
84
|
+
|
|
85
|
+
**Best for**:
|
|
86
|
+
|
|
87
|
+
- Local development and testing
|
|
88
|
+
- Evaluating AI analysis capabilities
|
|
89
|
+
- No external integrations needed
|
|
90
|
+
|
|
91
|
+
**Setup**:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
cp examples/env-configs/.env.anthropic-minimal .env
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**What you need**:
|
|
98
|
+
|
|
99
|
+
- Anthropic API key (Claude)
|
|
100
|
+
- Nothing else - fully local!
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### 5. `.env.google-mysql` (Google Cloud Configuration)
|
|
105
|
+
|
|
106
|
+
**Stack**: GitHub + Google Gemini + Email + MySQL
|
|
107
|
+
|
|
108
|
+
**Best for**:
|
|
109
|
+
|
|
110
|
+
- Projects using Google Cloud Platform
|
|
111
|
+
- Teams wanting to try Google's Gemini AI
|
|
112
|
+
- Cloud-based database storage
|
|
113
|
+
|
|
114
|
+
**Setup**:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
cp examples/env-configs/.env.google-mysql .env
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**What you need**:
|
|
121
|
+
|
|
122
|
+
- Google AI API key (Gemini)
|
|
123
|
+
- GitHub Personal Access Token
|
|
124
|
+
- Google Cloud SQL MySQL or any MySQL server
|
|
125
|
+
- Gmail account with App Password
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Configuration Steps
|
|
130
|
+
|
|
131
|
+
### Step 1: Choose Your Stack
|
|
132
|
+
|
|
133
|
+
Select the configuration that matches your infrastructure and copy it to `.env`:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Example: Using GitHub stack
|
|
137
|
+
cp examples/env-configs/.env.github-stack .env
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Step 2: Update Credentials
|
|
141
|
+
|
|
142
|
+
Edit the `.env` file and replace all placeholder values:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Windows
|
|
146
|
+
notepad .env
|
|
147
|
+
|
|
148
|
+
# macOS/Linux
|
|
149
|
+
nano .env
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Step 3: Verify Configuration
|
|
153
|
+
|
|
154
|
+
Test your configuration:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npm run validate-config
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Step 4: Run Tests
|
|
161
|
+
|
|
162
|
+
Your reporter will automatically use the provider configuration:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
npx playwright test
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Provider-Specific Setup Instructions
|
|
171
|
+
|
|
172
|
+
### GitHub Configuration
|
|
173
|
+
|
|
174
|
+
1. Create a Personal Access Token:
|
|
175
|
+
|
|
176
|
+
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
|
|
177
|
+
- Generate new token with `repo` scope
|
|
178
|
+
- Copy token to `GITHUB_TOKEN`
|
|
179
|
+
|
|
180
|
+
2. Set repository details:
|
|
181
|
+
```env
|
|
182
|
+
GITHUB_OWNER=your-username-or-org
|
|
183
|
+
GITHUB_REPO=your-repository-name
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Azure DevOps Configuration
|
|
187
|
+
|
|
188
|
+
1. Create a Personal Access Token:
|
|
189
|
+
|
|
190
|
+
- Go to User Settings → Personal access tokens
|
|
191
|
+
- Create token with `Work Items (Read, write)` and `Code (Read, write)` scopes
|
|
192
|
+
- Copy token to `AZURE_DEVOPS_PAT`
|
|
193
|
+
|
|
194
|
+
2. Set organization and project:
|
|
195
|
+
```env
|
|
196
|
+
AZURE_DEVOPS_ORG_URL=https://dev.azure.com/your-org
|
|
197
|
+
AZURE_DEVOPS_PROJECT=YourProject
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Jira Configuration
|
|
201
|
+
|
|
202
|
+
1. Create an API token:
|
|
203
|
+
|
|
204
|
+
- Go to https://id.atlassian.com/manage/api-tokens
|
|
205
|
+
- Create API token
|
|
206
|
+
- Copy token to `JIRA_API_TOKEN`
|
|
207
|
+
|
|
208
|
+
2. Set your Jira details:
|
|
209
|
+
```env
|
|
210
|
+
JIRA_HOST=https://your-company.atlassian.net
|
|
211
|
+
JIRA_EMAIL=your-email@company.com
|
|
212
|
+
JIRA_PROJECT_KEY=QA
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### AI Provider Setup
|
|
216
|
+
|
|
217
|
+
#### Mistral AI
|
|
218
|
+
|
|
219
|
+
1. Get API key from https://console.mistral.ai/
|
|
220
|
+
2. Set in `.env`:
|
|
221
|
+
```env
|
|
222
|
+
MISTRAL_API_KEY=your-key-here
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### Azure OpenAI
|
|
226
|
+
|
|
227
|
+
1. Create Azure OpenAI resource
|
|
228
|
+
2. Deploy a model (e.g., gpt-4)
|
|
229
|
+
3. Set configuration:
|
|
230
|
+
```env
|
|
231
|
+
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
|
|
232
|
+
AZURE_OPENAI_DEPLOYMENT=gpt-4
|
|
233
|
+
AZURE_OPENAI_API_KEY=your-key-here
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
#### OpenAI
|
|
237
|
+
|
|
238
|
+
1. Get API key from https://platform.openai.com/api-keys
|
|
239
|
+
2. Set in `.env`:
|
|
240
|
+
```env
|
|
241
|
+
OPENAI_API_KEY=sk-your-key-here
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
#### Anthropic (Claude)
|
|
245
|
+
|
|
246
|
+
1. Get API key from https://console.anthropic.com/
|
|
247
|
+
2. Set in `.env`:
|
|
248
|
+
```env
|
|
249
|
+
ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### Google AI (Gemini)
|
|
253
|
+
|
|
254
|
+
1. Get API key from https://makersuite.google.com/app/apikey
|
|
255
|
+
2. Set in `.env`:
|
|
256
|
+
```env
|
|
257
|
+
GOOGLE_AI_API_KEY=your-key-here
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Email Configuration
|
|
261
|
+
|
|
262
|
+
#### Gmail
|
|
263
|
+
|
|
264
|
+
1. Enable 2-factor authentication
|
|
265
|
+
2. Create App Password: https://myaccount.google.com/apppasswords
|
|
266
|
+
3. Set configuration:
|
|
267
|
+
```env
|
|
268
|
+
EMAIL_HOST=smtp.gmail.com
|
|
269
|
+
EMAIL_PORT=587
|
|
270
|
+
EMAIL_USER=your-email@gmail.com
|
|
271
|
+
EMAIL_PASSWORD=your-16-char-app-password
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
#### Office 365
|
|
275
|
+
|
|
276
|
+
```env
|
|
277
|
+
EMAIL_HOST=smtp.office365.com
|
|
278
|
+
EMAIL_PORT=587
|
|
279
|
+
EMAIL_USER=your-email@company.com
|
|
280
|
+
EMAIL_PASSWORD=your-password
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
#### SendGrid
|
|
284
|
+
|
|
285
|
+
```env
|
|
286
|
+
EMAIL_HOST=smtp.sendgrid.net
|
|
287
|
+
EMAIL_PORT=587
|
|
288
|
+
EMAIL_USER=apikey
|
|
289
|
+
EMAIL_PASSWORD=your-sendgrid-api-key
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Database Configuration
|
|
293
|
+
|
|
294
|
+
#### SQLite (Local - No Setup Required)
|
|
295
|
+
|
|
296
|
+
```env
|
|
297
|
+
DATABASE_PROVIDER=sqlite
|
|
298
|
+
SQLITE_DATABASE_PATH=./data/test-results.db
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
#### MySQL
|
|
302
|
+
|
|
303
|
+
```env
|
|
304
|
+
DATABASE_PROVIDER=mysql
|
|
305
|
+
MYSQL_HOST=your-server.com
|
|
306
|
+
MYSQL_PORT=3306
|
|
307
|
+
MYSQL_USER=username
|
|
308
|
+
MYSQL_PASSWORD=password
|
|
309
|
+
MYSQL_DATABASE=test_results
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Feature Flags
|
|
315
|
+
|
|
316
|
+
Control which features are enabled:
|
|
317
|
+
|
|
318
|
+
```env
|
|
319
|
+
# Enable/disable bug creation
|
|
320
|
+
ENABLE_BUG_CREATION=true
|
|
321
|
+
|
|
322
|
+
# Enable/disable auto-fix PR generation
|
|
323
|
+
ENABLE_PR_CREATION=true
|
|
324
|
+
|
|
325
|
+
# Enable/disable database logging
|
|
326
|
+
ENABLE_DATABASE_LOGGING=true
|
|
327
|
+
|
|
328
|
+
# Enable/disable email notifications
|
|
329
|
+
ENABLE_NOTIFICATIONS=true
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Environment Metadata
|
|
335
|
+
|
|
336
|
+
Add context to your test runs:
|
|
337
|
+
|
|
338
|
+
```env
|
|
339
|
+
# Environment name (local, dev, staging, production)
|
|
340
|
+
TEST_ENVIRONMENT=staging
|
|
341
|
+
|
|
342
|
+
# Git branch name
|
|
343
|
+
BRANCH_NAME=main
|
|
344
|
+
|
|
345
|
+
# Git commit hash (auto-populated by CI/CD)
|
|
346
|
+
COMMIT_HASH=abc123def456
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## Security Best Practices
|
|
352
|
+
|
|
353
|
+
1. **Never commit `.env` to version control**
|
|
354
|
+
|
|
355
|
+
- `.env` is in `.gitignore` by default
|
|
356
|
+
- Only commit `.env.example` or `.env.*-stack` templates
|
|
357
|
+
|
|
358
|
+
2. **Use environment-specific files**
|
|
359
|
+
|
|
360
|
+
- Use different `.env` files for local vs CI/CD
|
|
361
|
+
- Keep production credentials separate
|
|
362
|
+
|
|
363
|
+
3. **Rotate credentials regularly**
|
|
364
|
+
|
|
365
|
+
- Update API keys and tokens periodically
|
|
366
|
+
- Revoke unused tokens
|
|
367
|
+
|
|
368
|
+
4. **Use managed identities in production**
|
|
369
|
+
- For Azure: Enable `AZURE_USE_MANAGED_IDENTITY=true`
|
|
370
|
+
- Avoid hardcoding credentials in production
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Troubleshooting
|
|
375
|
+
|
|
376
|
+
### Configuration Validation Errors
|
|
377
|
+
|
|
378
|
+
Run the validation script to check your configuration:
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
npm run validate-config
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Provider Connection Issues
|
|
385
|
+
|
|
386
|
+
Test individual providers:
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
# Test AI provider
|
|
390
|
+
node -e "require('./dist/src/providers/ProviderRegistry').ProviderRegistry.getAIProvider().then(p => p.testConnection())"
|
|
391
|
+
|
|
392
|
+
# Test bug tracker
|
|
393
|
+
node -e "require('./dist/src/providers/ProviderRegistry').ProviderRegistry.getBugTrackerProvider().then(p => console.log('Connected'))"
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Common Issues
|
|
397
|
+
|
|
398
|
+
1. **GitHub token permissions**: Ensure token has `repo` scope
|
|
399
|
+
2. **Azure DevOps PAT**: Needs `Work Items` and `Code` scopes
|
|
400
|
+
3. **Email authentication**: Use App Passwords for Gmail, not regular password
|
|
401
|
+
4. **Database connection**: Ensure database exists and credentials are correct
|
|
402
|
+
|
|
403
|
+
---
|
|
404
|
+
|
|
405
|
+
## Examples
|
|
406
|
+
|
|
407
|
+
### Full GitHub Stack Setup
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
# 1. Copy template
|
|
411
|
+
cp examples/env-configs/.env.github-stack .env
|
|
412
|
+
|
|
413
|
+
# 2. Edit .env and set:
|
|
414
|
+
# - GITHUB_TOKEN=ghp_xxx
|
|
415
|
+
# - GITHUB_OWNER=myorg
|
|
416
|
+
# - GITHUB_REPO=myrepo
|
|
417
|
+
# - MISTRAL_API_KEY=xxx
|
|
418
|
+
# - EMAIL_USER=me@gmail.com
|
|
419
|
+
# - EMAIL_PASSWORD=my-app-password
|
|
420
|
+
|
|
421
|
+
# 3. Run tests
|
|
422
|
+
npx playwright test
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### Minimal Local Testing
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
# 1. Copy minimal template
|
|
429
|
+
cp examples/env-configs/.env.anthropic-minimal .env
|
|
430
|
+
|
|
431
|
+
# 2. Edit .env and set only:
|
|
432
|
+
# - ANTHROPIC_API_KEY=sk-ant-xxx
|
|
433
|
+
|
|
434
|
+
# 3. Run tests
|
|
435
|
+
npx playwright test
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
## Need Help?
|
|
441
|
+
|
|
442
|
+
- 📖 See [PROVIDERS.md](./PROVIDERS.md) for provider documentation
|
|
443
|
+
- 🚀 See [QUICKSTART.md](./QUICKSTART.md) for quick setup guide
|
|
444
|
+
- 📋 See [README.md](./README.md) for full documentation
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# Provider Framework Implementation Summary
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Playwright AI Test Reporter has been successfully refactored into a comprehensive provider-based architecture. This allows seamless integration with multiple service providers for AI, bug tracking, databases, notifications, and pull requests.
|
|
6
|
+
|
|
7
|
+
## What Was Implemented
|
|
8
|
+
|
|
9
|
+
### 1. Provider Interfaces
|
|
10
|
+
|
|
11
|
+
Created standardized interfaces for each provider type:
|
|
12
|
+
|
|
13
|
+
- **IAIProvider** - AI service providers (Azure OpenAI, OpenAI, Anthropic, Google AI, Mistral)
|
|
14
|
+
- **IBugTrackerProvider** - Bug tracking systems (Azure DevOps, GitHub, Jira)
|
|
15
|
+
- **IDatabaseProvider** - Database systems (SQLite, MySQL, PostgreSQL)
|
|
16
|
+
- **INotificationProvider** - Notification services (Email, Slack, Teams)
|
|
17
|
+
- **IPRProvider** - Pull request systems (GitHub, Azure DevOps)
|
|
18
|
+
|
|
19
|
+
### 2. AI Provider Implementations
|
|
20
|
+
|
|
21
|
+
Implemented five AI providers with unified interface:
|
|
22
|
+
|
|
23
|
+
- **AzureOpenAIProvider** - Uses Azure managed identity, supports enterprise scenarios
|
|
24
|
+
- **OpenAIProvider** - Direct OpenAI API integration
|
|
25
|
+
- **AnthropicProvider** - Claude models (Sonnet, Opus, Haiku)
|
|
26
|
+
- **GoogleAIProvider** - Gemini models
|
|
27
|
+
- **MistralProvider** - Mistral AI models
|
|
28
|
+
|
|
29
|
+
All providers support:
|
|
30
|
+
|
|
31
|
+
- Chat completions with message history
|
|
32
|
+
- Configurable parameters (temperature, max tokens, etc.)
|
|
33
|
+
- Connection testing
|
|
34
|
+
- Usage tracking
|
|
35
|
+
- JSON response format
|
|
36
|
+
|
|
37
|
+
### 3. Factory Pattern
|
|
38
|
+
|
|
39
|
+
Created factories for each provider type:
|
|
40
|
+
|
|
41
|
+
- **AIProviderFactory** - Creates AI providers
|
|
42
|
+
- **BugTrackerFactory** - Creates bug tracker providers
|
|
43
|
+
- **DatabaseFactory** - Creates database providers
|
|
44
|
+
- **NotificationFactory** - Creates notification providers
|
|
45
|
+
- **PRProviderFactory** - Creates PR providers
|
|
46
|
+
|
|
47
|
+
Each factory supports:
|
|
48
|
+
|
|
49
|
+
- Type-based creation
|
|
50
|
+
- Environment variable configuration
|
|
51
|
+
- Validation and error handling
|
|
52
|
+
|
|
53
|
+
### 4. Provider Registry
|
|
54
|
+
|
|
55
|
+
Implemented a centralized `ProviderRegistry` that:
|
|
56
|
+
|
|
57
|
+
- Manages all provider instances
|
|
58
|
+
- Lazy initialization (providers created only when needed)
|
|
59
|
+
- Singleton pattern for each provider type
|
|
60
|
+
- Configuration via environment variables or programmatic setup
|
|
61
|
+
- Cleanup and connection management
|
|
62
|
+
|
|
63
|
+
### 5. Updated genaiUtils
|
|
64
|
+
|
|
65
|
+
Refactored `genaiUtils.ts` to:
|
|
66
|
+
|
|
67
|
+
- Use the provider registry instead of hardcoded Mistral API
|
|
68
|
+
- Support all AI providers through unified interface
|
|
69
|
+
- Better error handling and logging
|
|
70
|
+
- Provider-agnostic implementation
|
|
71
|
+
|
|
72
|
+
### 6. Configuration System
|
|
73
|
+
|
|
74
|
+
Created comprehensive configuration:
|
|
75
|
+
|
|
76
|
+
- **`.env.example`** - Template with all provider configurations
|
|
77
|
+
- **Environment variable support** - All providers configurable via env vars
|
|
78
|
+
- **Programmatic configuration** - Can override with code
|
|
79
|
+
- **Feature flags** - Enable/disable features (bug creation, notifications, etc.)
|
|
80
|
+
|
|
81
|
+
## Architecture Benefits
|
|
82
|
+
|
|
83
|
+
### 1. Flexibility
|
|
84
|
+
|
|
85
|
+
- Switch AI providers without code changes
|
|
86
|
+
- Support multiple bug trackers, databases, notification systems
|
|
87
|
+
- Easy to add new providers
|
|
88
|
+
|
|
89
|
+
### 2. Maintainability
|
|
90
|
+
|
|
91
|
+
- Clear separation of concerns
|
|
92
|
+
- Each provider is independent
|
|
93
|
+
- Standardized interfaces
|
|
94
|
+
|
|
95
|
+
### 3. Testability
|
|
96
|
+
|
|
97
|
+
- Mock providers easily for testing
|
|
98
|
+
- Test each provider independently
|
|
99
|
+
- Provider registry can be reset for tests
|
|
100
|
+
|
|
101
|
+
### 4. Scalability
|
|
102
|
+
|
|
103
|
+
- Add new providers without modifying existing code
|
|
104
|
+
- Support multiple instances of same provider type
|
|
105
|
+
- Lazy loading reduces startup time
|
|
106
|
+
|
|
107
|
+
## Usage Examples
|
|
108
|
+
|
|
109
|
+
### Basic Usage (Environment Variables)
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# .env file
|
|
113
|
+
AI_PROVIDER=azure-openai
|
|
114
|
+
BUG_TRACKER_PROVIDER=github
|
|
115
|
+
DATABASE_PROVIDER=sqlite
|
|
116
|
+
NOTIFICATION_PROVIDER=email
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
// In reporter
|
|
121
|
+
import {ProviderRegistry} from './providers/ProviderRegistry';
|
|
122
|
+
|
|
123
|
+
// Initialize (loads from environment)
|
|
124
|
+
await ProviderRegistry.initialize();
|
|
125
|
+
|
|
126
|
+
// Use providers
|
|
127
|
+
const aiProvider = await ProviderRegistry.getAIProvider();
|
|
128
|
+
const bugTracker = await ProviderRegistry.getBugTrackerProvider();
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Programmatic Configuration
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import {ProviderRegistry} from './providers/ProviderRegistry';
|
|
135
|
+
|
|
136
|
+
await ProviderRegistry.initialize({
|
|
137
|
+
ai: {type: 'openai'},
|
|
138
|
+
bugTracker: {type: 'github'},
|
|
139
|
+
database: {type: 'mysql'},
|
|
140
|
+
notification: {type: 'email'},
|
|
141
|
+
pr: {type: 'github'},
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Direct Factory Usage
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import {AIProviderFactory} from './providers/ai/AIProviderFactory';
|
|
149
|
+
|
|
150
|
+
const provider = await AIProviderFactory.createProvider('anthropic');
|
|
151
|
+
const response = await provider.generateText('Hello');
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## File Structure
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
src/
|
|
158
|
+
├── providers/
|
|
159
|
+
│ ├── interfaces/ # Provider interfaces
|
|
160
|
+
│ │ ├── IAIProvider.ts
|
|
161
|
+
│ │ ├── IBugTrackerProvider.ts
|
|
162
|
+
│ │ ├── IDatabaseProvider.ts
|
|
163
|
+
│ │ ├── INotificationProvider.ts
|
|
164
|
+
│ │ └── IPRProvider.ts
|
|
165
|
+
│ ├── ai/ # AI implementations
|
|
166
|
+
│ │ ├── AzureOpenAIProvider.ts
|
|
167
|
+
│ │ ├── OpenAIProvider.ts
|
|
168
|
+
│ │ ├── AnthropicProvider.ts
|
|
169
|
+
│ │ ├── GoogleAIProvider.ts
|
|
170
|
+
│ │ ├── MistralProvider.ts
|
|
171
|
+
│ │ └── AIProviderFactory.ts
|
|
172
|
+
│ ├── bugTrackers/ # Bug tracker implementations
|
|
173
|
+
│ ├── databases/ # Database implementations
|
|
174
|
+
│ ├── notifications/ # Notification implementations
|
|
175
|
+
│ ├── pr/ # PR provider implementations
|
|
176
|
+
│ ├── factories/ # Factory classes
|
|
177
|
+
│ │ ├── BugTrackerFactory.ts
|
|
178
|
+
│ │ ├── DatabaseFactory.ts
|
|
179
|
+
│ │ ├── NotificationFactory.ts
|
|
180
|
+
│ │ └── PRProviderFactory.ts
|
|
181
|
+
│ ├── ProviderRegistry.ts # Central registry
|
|
182
|
+
│ └── index.ts # Exports
|
|
183
|
+
├── utils/
|
|
184
|
+
│ └── genaiUtils.ts # Updated to use provider registry
|
|
185
|
+
└── examples/
|
|
186
|
+
└── ReporterWorkflow.ts # Complete workflow example
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Next Steps
|
|
190
|
+
|
|
191
|
+
### 1. Integration with Reporter
|
|
192
|
+
|
|
193
|
+
Update the main reporter (`src/reporter.ts`) to:
|
|
194
|
+
|
|
195
|
+
- Initialize providers at start
|
|
196
|
+
- Use workflow for test failures
|
|
197
|
+
- Save results to database
|
|
198
|
+
- Send notifications
|
|
199
|
+
- Create bugs and PRs as configured
|
|
200
|
+
|
|
201
|
+
### 2. Additional Providers
|
|
202
|
+
|
|
203
|
+
Implement remaining providers:
|
|
204
|
+
|
|
205
|
+
- Slack notification provider
|
|
206
|
+
- Microsoft Teams notification provider
|
|
207
|
+
- PostgreSQL database provider
|
|
208
|
+
- Additional bug trackers (Linear, Asana, etc.)
|
|
209
|
+
|
|
210
|
+
### 3. Enhanced Features
|
|
211
|
+
|
|
212
|
+
- **Retry logic** - Automatic retries for failed API calls
|
|
213
|
+
- **Rate limiting** - Respect API rate limits
|
|
214
|
+
- **Caching** - Cache AI responses to reduce costs
|
|
215
|
+
- **Metrics** - Track provider usage and costs
|
|
216
|
+
- **Provider health checks** - Monitor provider availability
|
|
217
|
+
|
|
218
|
+
### 4. Documentation
|
|
219
|
+
|
|
220
|
+
- API documentation for each provider
|
|
221
|
+
- Configuration guides
|
|
222
|
+
- Migration guide from old implementation
|
|
223
|
+
- Best practices document
|
|
224
|
+
|
|
225
|
+
### 5. Testing
|
|
226
|
+
|
|
227
|
+
- Unit tests for each provider
|
|
228
|
+
- Integration tests for workflows
|
|
229
|
+
- Mock providers for testing
|
|
230
|
+
- Performance benchmarks
|
|
231
|
+
|
|
232
|
+
## Environment Variables
|
|
233
|
+
|
|
234
|
+
See `.env.example` for complete list. Key variables:
|
|
235
|
+
|
|
236
|
+
```env
|
|
237
|
+
# Provider Selection
|
|
238
|
+
AI_PROVIDER=azure-openai
|
|
239
|
+
BUG_TRACKER_PROVIDER=github
|
|
240
|
+
DATABASE_PROVIDER=sqlite
|
|
241
|
+
NOTIFICATION_PROVIDER=email
|
|
242
|
+
PR_PROVIDER=github
|
|
243
|
+
|
|
244
|
+
# Feature Flags
|
|
245
|
+
ENABLE_BUG_CREATION=true
|
|
246
|
+
ENABLE_DATABASE_LOGGING=true
|
|
247
|
+
ENABLE_NOTIFICATIONS=true
|
|
248
|
+
ENABLE_AUTO_HEALING=true
|
|
249
|
+
ENABLE_PR_CREATION=false
|
|
250
|
+
|
|
251
|
+
# Provider-specific configs
|
|
252
|
+
AZURE_OPENAI_ENDPOINT=https://...
|
|
253
|
+
GITHUB_TOKEN=ghp_...
|
|
254
|
+
SQLITE_DB_PATH=./test-results.db
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Dependencies
|
|
258
|
+
|
|
259
|
+
Added to package.json:
|
|
260
|
+
|
|
261
|
+
- `@azure/identity` - Azure authentication for AzureOpenAIProvider
|
|
262
|
+
|
|
263
|
+
All other providers use built-in fetch API (no additional dependencies needed).
|
|
264
|
+
|
|
265
|
+
## Migration Path
|
|
266
|
+
|
|
267
|
+
For existing users:
|
|
268
|
+
|
|
269
|
+
1. **Update environment variables** - Add new provider configuration
|
|
270
|
+
2. **Install dependencies** - Run `npm install`
|
|
271
|
+
3. **Update reporter configuration** - Switch to provider-based config
|
|
272
|
+
4. **Test** - Verify all providers work correctly
|
|
273
|
+
5. **Deploy** - Roll out gradually
|
|
274
|
+
|
|
275
|
+
## Benefits for Production
|
|
276
|
+
|
|
277
|
+
1. **Cost Optimization** - Switch to cheaper AI providers when appropriate
|
|
278
|
+
2. **Resilience** - Fallback to different providers if one fails
|
|
279
|
+
3. **Compliance** - Use different providers for different regions/requirements
|
|
280
|
+
4. **Performance** - Choose fastest provider for your use case
|
|
281
|
+
5. **Vendor Independence** - Not locked into single provider
|
|
282
|
+
|
|
283
|
+
## Conclusion
|
|
284
|
+
|
|
285
|
+
The provider-based architecture is now fully implemented and ready for integration into the main reporter. This provides a solid foundation for a productionized, enterprise-ready test reporter that can adapt to different environments and requirements.
|