Skip to content

test(cli): make snapshot tests robust against live Wikipedia churn - #589

Merged
martin-majlis merged 1 commit into
masterfrom
2026-05-26-fix-test
May 26, 2026
Merged

martin-majlis merged 1 commit into
masterfrom
2026-05-26-fix-test

Conversation

@martin-majlis

Copy link
Copy Markdown
Owner

Summary

  • Expand NONDETERMINISTIC_TESTS: backlinks_en/json, categories_en/json, links_en/json, langlinks_fr, images_en, images_en_imageinfo, images_en_limit, geosearch_max_dim, and search_en_json were treated as strict exact-match fixtures but their content changes between consecutive Wikipedia API calls. They now use the weak check (non-empty / valid JSON / line count within ±50%).
  • Small mismatches no longer exit 1: A <5% word-count difference already printed a yellow SMALL MISMATCH warning; it is now truly a warning-only so a single added sentence in a large article does not fail CI.
  • Fix section_en test: Updated from 'Etymology' to 'Crust' (the Etymology section was removed from the Earth article).
  • Update fixtures: Re-recorded snapshots from the current live Wikipedia state.

Problem

make run-test-cli-record followed immediately by make run-test-cli-verify would still fail because verify re-calls the live Wikipedia API and gets slightly different data — Wikipedia content (backlinks, category membership, image lists, search result metadata) changes continuously.

Test plan

  • make run-tests-cli-unit — 64 tests pass
  • All pre-commit hooks pass (shellcheck, prettier, ruff, ty, etc.)
  • make run-test-cli-record && make run-test-cli-verify — should now pass (or show only yellow warnings, no exit 1)

🤖 Generated with Claude Code

Two changes to tests/cli/test_cli.sh:

1. Expand NONDETERMINISTIC_TESTS — backlinks, categories, links,
   langlinks, images (non-JSON variants), geosearch_max_dim, and
   search_en_json were treated as strict exact-match fixtures but their
   content changes between consecutive API calls.  They now use the
   weak check (non-empty / valid JSON / line count within ±50 %).

2. Small mismatches no longer exit 1 — a <5 % word-count difference
   already printed a yellow SMALL MISMATCH warning; now it is truly
   a warning only, so a single added sentence in a large article does
   not fail CI.

Also update the fixtures recorded by the most recent run of
make run-test-cli-record and fix the section_en test to use the
'Crust' section (Etymology was removed from the Earth article).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented May 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.04%. Comparing base (9aaf913) to head (f1b6a77).
⚠️ Report is 50 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #589   +/-   ##
=======================================
  Coverage   94.04%   94.04%           
=======================================
  Files          76       76           
  Lines        3373     3373           
=======================================
  Hits         3172     3172           
  Misses        201      201           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@martin-majlis
martin-majlis merged commit d8fa0fe into master May 26, 2026
43 checks passed
@martin-majlis
martin-majlis deleted the 2026-05-26-fix-test branch May 26, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant