@@ -217,33 +217,49 @@ jobs:
217217 name : playwright-artifacts
218218 path : playwright-artifacts
219219
220- - name : Count new tests
221- id : count_tests
220+ - name : Analyze test changes
221+ id : analyze_tests
222222 run : |
223223 git fetch origin main:main
224224 new_tests=0
225+ test_details=""
225226
226227 # Get list of changed test files
227228 for file in $(git diff --name-only main...HEAD | grep -E '^tests/suites/.*\.(spec|test)\.(ts|tsx|js|jsx)$'); do
228- # Count tests in current version
229+ echo "Analyzing file: $file"
230+
231+ # Get test names from current version
229232 if git show HEAD:"$file" > /dev/null 2>&1; then
230- current_tests=$(git show HEAD:"$file" | grep -E "test\([\'\"]" | wc -l )
233+ current_tests=$(git show HEAD:"$file" | grep -E "test\([\'\"]" | sed -E "s/.*test\(['\"]([^'\"]+)['\"].*/\1/" )
231234 else
232- current_tests=0
235+ current_tests=""
233236 fi
234237
235- # Count tests in main version
238+ # Get test names from main version
236239 if git show main:"$file" > /dev/null 2>&1; then
237- base_tests=$(git show main:"$file" | grep -E "test\([\'\"]" | wc -l )
240+ base_tests=$(git show main:"$file" | grep -E "test\([\'\"]" | sed -E "s/.*test\(['\"]([^'\"]+)['\"].*/\1/" )
238241 else
239- base_tests=0
242+ base_tests=""
240243 fi
241244
242- # Add difference to total
243- ((new_tests += current_tests - base_tests))
245+ # Compare and find new tests
246+ while IFS= read -r test_name; do
247+ if [ ! -z "$test_name" ] && ! echo "$base_tests" | grep -Fxq "$test_name"; then
248+ ((new_tests++))
249+ test_details+="- ✨ Added test: \`$test_name\` in \`$file\`\\n"
250+ fi
251+ done <<< "$current_tests"
244252 done
245253
254+ # Escape the test details for GitHub Actions
255+ test_details="${test_details//'%'/'%25'}"
256+ test_details="${test_details//$'\n'/'%0A'}"
257+ test_details="${test_details//$'\r'/'%0D'}"
258+
246259 echo "new_tests=$new_tests" >> $GITHUB_OUTPUT
260+ echo "test_details<<EOF" >> $GITHUB_OUTPUT
261+ echo "$test_details" >> $GITHUB_OUTPUT
262+ echo "EOF" >> $GITHUB_OUTPUT
247263
248264 - name : Update PR description
249265 uses : actions/github-script@v6
@@ -289,7 +305,8 @@ jobs:
289305 parseFloat(percent) > 0 ? '🔺' :
290306 parseFloat(percent) < 0 ? '🔽' : '✅';
291307
292- const newTests = parseInt('${{ steps.count_tests.outputs.new_tests }}');
308+ const newTests = parseInt('${{ steps.analyze_tests.outputs.new_tests }}');
309+ const testDetails = '${{ steps.analyze_tests.outputs.test_details }}'.replace(/%0A/g, '\n');
293310 const testsStatus = newTests > 0 ? '✨' : '➖';
294311
295312 const ciSection = `## CI Results
@@ -301,6 +318,9 @@ jobs:
301318 |:-----:|:------:|:------:|:-----:|:-------:|:---------:|
302319 | ${testResults.total} | ${testResults.passed} | ${testResults.failed} | ${testResults.flaky} | ${testResults.skipped} | ${testsStatus} ${newTests} |
303320
321+ ${newTests > 0 ? `<details>
322+ <summary>✨ New Tests Added</summary>\n\n${testDetails}</details>\n` : ''}
323+
304324 ### Bundle Size: ${bundleStatus}
305325 Current: ${formatSize(currentSize)} | Main: ${formatSize(mainSize)}
306326 Diff: ${diff > 0 ? '+' : ''}${formatSize(Math.abs(diff))} (${percent === 'N/A' ? 'N/A' : `${percent}%`})
0 commit comments