@@ -231,6 +231,7 @@ jobs:
231231 added_tests=()
232232 deleted_tests=()
233233 skipped_tests=()
234+ existing_tests=()
234235
235236 # Function to extract test names from a file
236237 extract_test_names() {
@@ -241,10 +242,19 @@ jobs:
241242 fi
242243 }
243244
244- # Get skipped tests first from test results
245- if [ -f "playwright-artifacts/ test-results.json" ]; then
245+ # First, get all existing tests in current branch
246+ for file in $(git ls-files | grep -E '^tests/suites/.*\.(spec| test)\.(ts|tsx|js|jsx)$'); do
246247 while IFS= read -r test; do
247248 if [[ -n "$test" ]]; then
249+ existing_tests+=("$test")
250+ fi
251+ done < <(extract_test_names "$file" HEAD)
252+ done
253+
254+ # Get skipped tests from test results, but only if they exist in current branch
255+ if [ -f "playwright-artifacts/test-results.json" ]; then
256+ while IFS= read -r test; do
257+ if [[ -n "$test" ]] && printf '%s\n' "${existing_tests[@]}" | grep -Fxq "$test"; then
248258 skipped_tests+=("$test")
249259 fi
250260 done < <(jq -r '.suites[].specs[] | select(.ok == false and .skipped == true) | .title' playwright-artifacts/test-results.json)
@@ -256,7 +266,7 @@ jobs:
256266 current_tests=$(extract_test_names "$file" HEAD)
257267 base_tests=$(extract_test_names "$file" main)
258268
259- # Compare tests
269+ # Find added tests (in current but not in base)
260270 while IFS= read -r test; do
261271 if [[ -n "$test" ]]; then
262272 if ! echo "$base_tests" | grep -Fxq "$test"; then
@@ -265,11 +275,14 @@ jobs:
265275 fi
266276 done <<< "$current_tests"
267277
278+ # Find deleted tests (in base but not in current)
268279 while IFS= read -r test; do
269280 if [[ -n "$test" ]]; then
270- # Only mark as deleted if it's not in current tests AND not in skipped tests
271- if ! echo "$current_tests" | grep -Fxq "$test" && ! printf '%s\n' "${skipped_tests[@]}" | grep -Fxq "$test"; then
272- deleted_tests+=("$test")
281+ if ! echo "$current_tests" | grep -Fxq "$test"; then
282+ # Only count as deleted if it's not marked as skipped
283+ if ! printf '%s\n' "${skipped_tests[@]}" | grep -Fxq "$test"; then
284+ deleted_tests+=("$test")
285+ fi
273286 fi
274287 fi
275288 done <<< "$base_tests"
0 commit comments