playwright-smart-test 1.0.8 โ 1.0.9
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/README.md
CHANGED
|
@@ -189,83 +189,103 @@ Generate a starter configuration with `npx playwright-smart-test init` or create
|
|
|
189
189
|
|
|
190
190
|
## ๐ GitHub Actions CI/CD Integration
|
|
191
191
|
|
|
192
|
-
Add this step to your Pull Request workflow (`.github/workflows/regression.yml`):
|
|
192
|
+
Add this step to your Pull Request workflow (`.github/workflows/smart-regression.yml`):
|
|
193
193
|
|
|
194
194
|
```yaml
|
|
195
195
|
name: Playwright Smart Regression
|
|
196
196
|
|
|
197
197
|
on:
|
|
198
198
|
pull_request:
|
|
199
|
-
|
|
199
|
+
types: [opened, synchronize, reopened]
|
|
200
|
+
push:
|
|
201
|
+
branches: [main]
|
|
200
202
|
|
|
201
203
|
jobs:
|
|
202
|
-
|
|
204
|
+
smart-regression:
|
|
203
205
|
runs-on: ubuntu-latest
|
|
206
|
+
permissions:
|
|
207
|
+
contents: read
|
|
208
|
+
issues: write # Required for posting/updating PR comments
|
|
209
|
+
pull-requests: write # Required for PR comment metadata
|
|
210
|
+
|
|
204
211
|
steps:
|
|
205
|
-
- name: Checkout
|
|
212
|
+
- name: Checkout code
|
|
206
213
|
uses: actions/checkout@v4
|
|
207
214
|
with:
|
|
208
|
-
|
|
215
|
+
ref: ${{ github.event.pull_request.head.ref || github.ref }}
|
|
216
|
+
fetch-depth: 0 # Full history needed for git diff
|
|
217
|
+
|
|
218
|
+
- name: Fetch target base branch
|
|
219
|
+
if: github.event_name == 'pull_request'
|
|
220
|
+
run: |
|
|
221
|
+
git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
|
|
209
222
|
|
|
210
223
|
- name: Setup Node.js
|
|
211
224
|
uses: actions/setup-node@v4
|
|
212
225
|
with:
|
|
213
|
-
node-version:
|
|
226
|
+
node-version: 22
|
|
214
227
|
cache: 'npm'
|
|
215
228
|
|
|
216
|
-
- name: Install
|
|
229
|
+
- name: Install dependencies
|
|
217
230
|
run: npm ci
|
|
218
231
|
|
|
219
|
-
- name: Install Playwright
|
|
220
|
-
run: npx playwright install --with-deps
|
|
232
|
+
- name: Install Playwright Chromium
|
|
233
|
+
run: npx playwright install --with-deps chromium
|
|
221
234
|
|
|
222
|
-
- name: Run Smart Regression
|
|
223
|
-
id: smart-regression
|
|
235
|
+
- name: Run AI Smart Regression Selection & Targeted E2E Tests
|
|
224
236
|
env:
|
|
225
237
|
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
|
238
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
226
239
|
run: |
|
|
227
|
-
npx playwright-smart-test
|
|
228
|
-
npx playwright-smart-test run --base "origin/${{ github.base_ref }}"
|
|
229
|
-
|
|
230
|
-
- name: Post PR Comment
|
|
231
|
-
if: always()
|
|
232
|
-
uses: thollander/actions-comment-pull-request@v2
|
|
233
|
-
with:
|
|
234
|
-
filePath: pr-report.md
|
|
235
|
-
comment_tag: smart-regression-report
|
|
240
|
+
npx playwright-smart-test run --comment --base "${{ github.event_name == 'pull_request' && format('origin/{0}', github.base_ref) || 'HEAD~1' }}"
|
|
236
241
|
```
|
|
237
242
|
|
|
238
243
|
---
|
|
239
244
|
|
|
240
245
|
## ๐ Sample PR Impact Report
|
|
241
246
|
|
|
242
|
-
When running `playwright-smart-test comment` or
|
|
247
|
+
When running `playwright-smart-test run --comment` or `playwright-smart-test comment`, the agent automatically posts an interactive analysis report directly to the GitHub Pull Request and GitHub Actions Step Summary:
|
|
243
248
|
|
|
244
249
|
```markdown
|
|
245
250
|
## ๐ค Playwright Smart Regression Selection Report
|
|
246
251
|
|
|
247
|
-
|
|
252
|
+
### ๐ Impact & Risk Assessment
|
|
248
253
|
|
|
249
|
-
|
|
|
254
|
+
| Metric | Assessment |
|
|
250
255
|
| :--- | :--- |
|
|
256
|
+
| **Overall Risk** | ๐ **HIGH** |
|
|
257
|
+
| **Analysis Confidence** | ๐ข **HIGH** |
|
|
251
258
|
| **Changed Components** | `checkout`, `payment` |
|
|
252
259
|
| **Potentially Impacted Areas** | `cart`, `order-summary` |
|
|
253
260
|
|
|
254
261
|
### ๐ง AI Semantic Rationale
|
|
262
|
+
|
|
255
263
|
- **Direct Impact:** Modified voucher code calculation logic in CheckoutPage.
|
|
256
264
|
- **Ripple Effects:** Discount changes propagate into final payment charge payload.
|
|
257
265
|
|
|
266
|
+
<details>
|
|
267
|
+
<summary><b>๐ Modified Files Analyzed (3)</b></summary>
|
|
268
|
+
|
|
269
|
+
| File | Status | Diff Lines |
|
|
270
|
+
| :--- | :---: | :---: |
|
|
271
|
+
| `src/components/Checkout.tsx` | ๐ก Modified | +24 / -8 |
|
|
272
|
+
| `src/components/Payment.tsx` | ๐ก Modified | +12 / -3 |
|
|
273
|
+
| `src/types.ts` | ๐ก Modified | +2 / -0 |
|
|
274
|
+
|
|
275
|
+
</details>
|
|
276
|
+
|
|
258
277
|
### ๐งช Selected Regression Tests (3)
|
|
259
278
|
|
|
260
279
|
| Spec File | Selection Type | Rationale |
|
|
261
280
|
| :--- | :---: | :--- |
|
|
262
|
-
| `tests/checkout.spec.ts` | ๐ข Direct | Directly touches changed component 'checkout'. |
|
|
263
|
-
| `tests/payment.spec.ts` | ๐ก Ripple | Indirectly impacted by ripple effects on domain 'payment'. |
|
|
264
|
-
| `tests/cart.spec.ts` | ๐ก Ripple | Indirectly impacted by ripple effects on domain 'cart'. |
|
|
281
|
+
| `playwright/e2e/tests/checkout.spec.ts` | ๐ข Direct | Directly touches changed component 'checkout'. |
|
|
282
|
+
| `playwright/e2e/tests/payment.spec.ts` | ๐ก Ripple | Indirectly impacted by ripple effects on domain 'payment'. |
|
|
283
|
+
| `playwright/e2e/tests/cart.spec.ts` | ๐ก Ripple | Indirectly impacted by ripple effects on domain 'cart'. |
|
|
265
284
|
|
|
266
285
|
### โก Playwright Execution Command
|
|
286
|
+
|
|
267
287
|
```bash
|
|
268
|
-
npx playwright test "tests/checkout.spec.ts" "tests/payment.spec.ts" "tests/cart.spec.ts"
|
|
288
|
+
npx playwright test "playwright/e2e/tests/checkout.spec.ts" "playwright/e2e/tests/payment.spec.ts" "playwright/e2e/tests/cart.spec.ts"
|
|
269
289
|
```
|
|
270
290
|
```
|
|
271
291
|
|
package/dist/cli/index.js
CHANGED
|
@@ -15,7 +15,7 @@ const program = new Command();
|
|
|
15
15
|
program
|
|
16
16
|
.name('playwright-smart-test')
|
|
17
17
|
.description('AI-Powered Smart Regression Test Selection Agent for Playwright')
|
|
18
|
-
.version('1.0.
|
|
18
|
+
.version('1.0.9');
|
|
19
19
|
async function executeAnalysis(options) {
|
|
20
20
|
const cwd = options.cwd ? path.resolve(options.cwd) : process.cwd();
|
|
21
21
|
const config = loadConfig(cwd, options.config);
|
|
@@ -64,11 +64,14 @@ export class GitDiffAnalyzer {
|
|
|
64
64
|
await this.runGit(['rev-parse', '--verify', safeBase]);
|
|
65
65
|
}
|
|
66
66
|
catch {
|
|
67
|
-
const remoteRef = this.parseRemoteRef(safeBase);
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const remoteRef = this.parseRemoteRef(safeBase) ?? { remote: 'origin', branch: safeBase };
|
|
68
|
+
const { remote, branch } = remoteRef;
|
|
69
|
+
try {
|
|
70
|
+
await this.runGit(['fetch', '--depth=100', remote, `+refs/heads/${branch}:refs/remotes/${remote}/${branch}`]);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
70
73
|
try {
|
|
71
|
-
await this.runGit(['fetch', '--depth=100', remote,
|
|
74
|
+
await this.runGit(['fetch', '--depth=100', remote, `+${branch}:refs/remotes/${remote}/${branch}`]);
|
|
72
75
|
}
|
|
73
76
|
catch {
|
|
74
77
|
// Ignore fetch failure and proceed with available refs.
|
|
@@ -93,13 +96,15 @@ export class GitDiffAnalyzer {
|
|
|
93
96
|
try {
|
|
94
97
|
numstatOutput = await this.runGit(['diff', '--numstat', ...diffRangeArgs]);
|
|
95
98
|
}
|
|
96
|
-
catch {
|
|
99
|
+
catch (diffErr) {
|
|
97
100
|
const fallbackArgs = safeBase ? [safeBase] : ['HEAD'];
|
|
98
101
|
try {
|
|
99
102
|
numstatOutput = await this.runGit(['diff', '--numstat', ...fallbackArgs]);
|
|
100
103
|
diffRangeArgs = fallbackArgs;
|
|
101
104
|
}
|
|
102
|
-
catch {
|
|
105
|
+
catch (fallbackErr) {
|
|
106
|
+
const diffMessage = diffErr instanceof Error ? diffErr.message : String(diffErr);
|
|
107
|
+
console.warn(`[playwright-smart-test] Warning: git diff failed for [${diffRangeArgs.join(' ')}] and fallback [${fallbackArgs.join(' ')}]: ${diffMessage}`);
|
|
103
108
|
numstatOutput = '';
|
|
104
109
|
}
|
|
105
110
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export class GitHubReporter {
|
|
2
2
|
static generateMarkdown(result) {
|
|
3
3
|
const riskBadge = this.getRiskBadge(result.aiAnalysis.riskScore);
|
|
4
|
+
const confidenceBadge = this.getConfidenceBadge(result.aiAnalysis.confidenceScore);
|
|
4
5
|
const changedBadges = result.changedComponents.length > 0
|
|
5
6
|
? result.changedComponents.map((c) => `\`${c}\``).join(', ')
|
|
6
7
|
: '_None identified_';
|
|
@@ -8,7 +9,6 @@ export class GitHubReporter {
|
|
|
8
9
|
? result.impactedComponents.map((c) => `\`${c}\``).join(', ')
|
|
9
10
|
: '_None_';
|
|
10
11
|
let markdown = `## ๐ค Playwright Smart Regression Selection Report\n\n`;
|
|
11
|
-
markdown += `**Risk Level:** ${riskBadge}\n\n`;
|
|
12
12
|
if (result.isFullRegression) {
|
|
13
13
|
markdown += `> [!WARNING]\n`;
|
|
14
14
|
markdown += `> **Full Regression Suite Triggered**: ${result.fullRegressionReason || 'Critical configuration or high impact threshold reached.'}\n\n`;
|
|
@@ -17,16 +17,35 @@ export class GitHubReporter {
|
|
|
17
17
|
markdown += `> [!NOTE]\n`;
|
|
18
18
|
markdown += `> **Smoke Safety Net Activated**: ${result.smokeFallbackReason}\n\n`;
|
|
19
19
|
}
|
|
20
|
-
markdown +=
|
|
20
|
+
markdown += `### ๐ Impact & Risk Assessment\n\n`;
|
|
21
|
+
markdown += `| Metric | Assessment |\n`;
|
|
21
22
|
markdown += `| :--- | :--- |\n`;
|
|
23
|
+
markdown += `| **Overall Risk** | ${riskBadge} |\n`;
|
|
24
|
+
markdown += `| **Analysis Confidence** | ${confidenceBadge} |\n`;
|
|
22
25
|
markdown += `| **Changed Components** | ${changedBadges} |\n`;
|
|
23
26
|
markdown += `| **Potentially Impacted Areas** | ${impactedBadges} |\n\n`;
|
|
24
|
-
markdown += `### ๐ง AI Semantic Rationale\n`;
|
|
27
|
+
markdown += `### ๐ง AI Semantic Rationale\n\n`;
|
|
25
28
|
markdown += `- **Direct Impact:** ${result.aiAnalysis.directReason}\n`;
|
|
26
29
|
if (result.aiAnalysis.rippleEffectReason) {
|
|
27
30
|
markdown += `- **Ripple Effects:** ${result.aiAnalysis.rippleEffectReason}\n`;
|
|
28
31
|
}
|
|
29
32
|
markdown += `\n`;
|
|
33
|
+
if (result.changedFiles && result.changedFiles.length > 0) {
|
|
34
|
+
markdown += `<details>\n<summary><b>๐ Modified Files Analyzed (${result.changedFiles.length})</b></summary>\n\n`;
|
|
35
|
+
markdown += `| File | Status | Diff Lines |\n`;
|
|
36
|
+
markdown += `| :--- | :---: | :---: |\n`;
|
|
37
|
+
for (const file of result.changedFiles) {
|
|
38
|
+
const statusBadge = file.status === 'added'
|
|
39
|
+
? '๐ข Added'
|
|
40
|
+
: file.status === 'deleted'
|
|
41
|
+
? '๐ด Deleted'
|
|
42
|
+
: file.status === 'renamed'
|
|
43
|
+
? '๐ต Renamed'
|
|
44
|
+
: '๐ก Modified';
|
|
45
|
+
markdown += `| \`${file.path}\` | ${statusBadge} | +${file.additions} / -${file.deletions} |\n`;
|
|
46
|
+
}
|
|
47
|
+
markdown += `\n</details>\n\n`;
|
|
48
|
+
}
|
|
30
49
|
markdown += `### ๐งช Selected Regression Tests (${result.selectedSpecs.length})\n\n`;
|
|
31
50
|
if (result.selectedSpecs.length === 0) {
|
|
32
51
|
markdown += `_No tests selected. Changes do not impact any existing test suites._\n\n`;
|
|
@@ -51,7 +70,7 @@ export class GitHubReporter {
|
|
|
51
70
|
}
|
|
52
71
|
markdown += `\n`;
|
|
53
72
|
}
|
|
54
|
-
markdown += `### โก Playwright Execution Command\n`;
|
|
73
|
+
markdown += `### โก Playwright Execution Command\n\n`;
|
|
55
74
|
if (result.selectedSpecs.length === 0 && !result.isFullRegression) {
|
|
56
75
|
markdown += `_No tests executed (0 impacted tests identified)._\n\n`;
|
|
57
76
|
}
|
|
@@ -74,4 +93,15 @@ export class GitHubReporter {
|
|
|
74
93
|
return '๐ข **LOW**';
|
|
75
94
|
}
|
|
76
95
|
}
|
|
96
|
+
static getConfidenceBadge(confidence) {
|
|
97
|
+
switch (confidence) {
|
|
98
|
+
case 'HIGH':
|
|
99
|
+
return '๐ข **HIGH**';
|
|
100
|
+
case 'LOW':
|
|
101
|
+
return '๐ด **LOW**';
|
|
102
|
+
case 'MEDIUM':
|
|
103
|
+
default:
|
|
104
|
+
return '๐ก **MEDIUM**';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
77
107
|
}
|