Skip to content

Cut tests that can't fail and make the weak ones catch regressions - #235

Merged
SunkenInTime merged 4 commits into
mainfrom
t3code/audit-redundant-tests
Oct 1, 2026
Merged

SunkenInTime merged 4 commits into
mainfrom
t3code/audit-redundant-tests

Conversation

@SunkenInTime

@SunkenInTime SunkenInTime commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

An audit of every test (630 test/testWidgets calls across 116 files) for ones that can't fail or only repeat a stronger test. Answer: 24 are useless (3.8%), and 19 more guarded real behavior but were built so they couldn't catch a regression. This cuts the first group and rewrites the second. 630 → 607 tests.

The one that mattered

strategy_integrity_test.dart, the .ica round-trip suite that guards the library, never ran the app's importer or exporter. It used _importStrategyFromDecoded and _buildExportPayload, copies of production code kept in the test file, and the copies had already drifted from production (theme palette resolution, the version guard, image loading). A broken real importer still passed.

The tests now go through loadFromFilePath and zipStrategy against a throwaway Hive library:

  • Every fixture in test/fixtures/strategy_integrity/ imports to the current version. The exported .ica itself is then reimported and must re-export the same JSON and the same image attachments (canvas-compatibility-v97.ica carries 7 PNGs).
  • A corrupt file or one missing mapData must throw and leave the library empty.
  • Image and temp folders are routed into the test's temp directory. The Hive group also deletes its temp library now; before this, every run left one in %TEMP% (I found 166).

Mutation checks against the real code, reverted afterwards:

Mutation in strategy_provider.dart Before After
Skip migrateLegacyData in _importStrategyFile passes fails
zipStrategy stops packing image files passes fails

Cut (24)

  • Tautologies: a const compared with its own expression; a "migration version 97" constant nothing reads; a scratch glyph-dump file whose header says "Not meant to be committed" (no assertions, skipped everywhere but one Mac).
  • Redundant: weaker copies of a test on the same code path, e.g. three per-fps timing tests already pinned by the full-duration tests, Split/Summit boundary tests covered by the every-map test, zero-rotation cases of an unconditional -(rotation ?? 0), and two single-fixture round-trips the fixture matrix now covers.

Rewritten (19)

  • Asserts that couldn't fail: the view-cone menu test checked for absent menu items without opening the menu; the ability bar passed while rendering nothing; the inset-shadow "outside" pixels were inside the fill.
  • Circular expectations: expected values computed by the method under test (map artwork offset, folder icon fallback). Drag round-trips compared min size against max size but never against the stored position.
    • Pinning them to the stored position exposed that circle abilities only come back within half a pixel, because screenPositionForWidget snaps circles to whole pixels on purpose. The test now states that tolerance.
  • Setup that never reached the branch in the title: the gzip-damage test stopped at the catalog hash and never reached decodeWorldGzip's footer check; the screenshot failure test fails before coordinates are entered.
  • The update-status provider test can't distinguish Store-only from remote fallback, and only works on Windows. It now has a case that tells them apart, and both are skipped off Windows.

Review

Astra (gpt-6-astra) checked every cut and every rewrite against the code. Two cuts were wrong and are restored in the second commit: the 10/20 MiB video targets set the re-encode threshold, and the zip Paranoia test was the only one round-tripping lineup and deleted Paranoias. Astra also caught the image gap and the temp-folder leak above.

Kept on purpose: the direct version-guard test for current/older versions. Every real-path import test uses a current-version file, so nothing else proves an older .ica gets past the guard.

For Dara

strategy_folder_import_test.dart "manifest zip/directory apply failure does not fall back to legacy import" require the "Manifest Root" folder to still exist after a failed import. That locks a half-finished write in as expected behavior, which goes against "fail loudly without saving". Untouched here; worth deciding whether that's intended.

Verification

  • flutter test (full suite, Windows): 624 passed, 3 skipped (native SVG, needs ICARUS_SVG_NATIVE_LIBRARY) on the first commit. Second-round files: 71 passed.
  • flutter analyze clean on touched files.
  • Only files that were already dart format-clean on main were formatted.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Updated checks for ability and agent placement, position restoration, and strategy import/export behavior.
    • Expanded validation of map geometry, vision boundaries, utility snapshots, and rendering details.
    • Refined checks for update results, screenshot-save failures, and damaged strategy data.
    • Adjusted test expectations to reflect behavior at different display sizes and on supported platforms.

RetriggerConfidence Score: 5/5

No outstanding findings block merging.

Summary

The PR strengthens tests for strategy import/export and widget interactions. The two previously reported test concerns are fixed, and no findings remain outstanding.

Reviews (3) · Last reviewed commit: "Wait for agent icons before tapping thei..."

SunkenInTime and others added 2 commits October 1, 2026 18:10
An audit of all 630 tests found 25 that guard nothing: they assert a
constant equals itself, print a benchmark, or repeat a stronger test on
the same code path. They are removed.

Eighteen more guarded real behavior but could not fail. The largest:
the .ica round-trip tests imported and exported through copies of the
production code kept inside the test file, so a broken importer still
passed. They now go through loadFromFilePath and zipStrategy against a
throwaway Hive library, every fixture round-trips, and corrupt files
must fail without saving. Skipping migration in the real importer now
fails the fixture test; before, it passed.

The rest: assertions too loose to fail, expected values computed by the
code under test, setup that never reached the branch named in the
title, and a Windows-only provider path that could not tell its two
entry points apart.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The video size-target and zip Paranoia tests were not covered elsewhere:
the 10/20 MiB targets set the re-encode threshold, and only the Paranoia
test round-trips lineup and deleted Paranoias. Both are back. The dense
cone query keeps its ray and edge counters without the benchmark loop.

The fixture round-trip now reimports the exported .ica itself and
compares image attachments, so an exporter that drops images fails.
Imports and exports write their images inside the test's temp library,
and the Hive group deletes its temp library instead of leaking one per
run.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 942a69e2-3cf9-4606-a148-59ea962cdbca

📥 Commits

Reviewing files that changed from the base of the PR and between 0d91b0e and f1b1137.

📒 Files selected for processing (2)
  • test/agent_dragable_lineup_state_test.dart
  • test/strategy_integrity_test.dart

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: c6e3cd3d-ac33-4800-ad57-34416aa91ca2

📥 Commits

Reviewing files that changed from the base of the PR and between d8f2a2d and 0d91b0e.

📒 Files selected for processing (30)
  • test/ability_anchor_scaling_test.dart
  • test/ability_bar_lineup_state_test.dart
  • test/ability_visibility_widgets_test.dart
  • test/agent_dragable_lineup_state_test.dart
  • test/authored_vision_boundary_test.dart
  • test/canonical_coordinates_migration_test.dart
  • test/canonical_coordinates_test.dart
  • test/canonical_map_artwork_test.dart
  • test/cursor_glyph_debug_test.dart
  • test/custom_shape_color_test.dart
  • test/deadlock_barrier_switch_sides_test.dart
  • test/folder_icon_registry_test.dart
  • test/navigation_geometry_provider_test.dart
  • test/resizable_square_ability_test.dart
  • test/role_icon_agent_size_test.dart
  • test/screenshot_export_failure_test.dart
  • test/sector_circle_ability_test.dart
  • test/square_icon_counter_rotation_test.dart
  • test/strategy_import_version_guard_test.dart
  • test/strategy_integrity_test.dart
  • test/svg_height_app_integration_test.dart
  • test/svg_height_visibility_test.dart
  • test/text_editing_shortcut_scope_test.dart
  • test/update_checker_test.dart
  • test/video_export_timing_test.dart
  • test/view_cone_agent_drag_feedback_test.dart
  • test/vision_geometry_map_test.dart
  • test/vision_polygon_test.dart
  • test/widgets/inset_shadow_decoration_test.dart
  • test/windows_desktop_update_restart_service_test.dart
💤 Files with no reviewable changes (13)
  • test/square_icon_counter_rotation_test.dart
  • test/svg_height_app_integration_test.dart
  • test/canonical_coordinates_migration_test.dart
  • test/windows_desktop_update_restart_service_test.dart
  • test/resizable_square_ability_test.dart
  • test/text_editing_shortcut_scope_test.dart
  • test/ability_visibility_widgets_test.dart
  • test/authored_vision_boundary_test.dart
  • test/video_export_timing_test.dart
  • test/strategy_import_version_guard_test.dart
  • test/sector_circle_ability_test.dart
  • test/role_icon_agent_size_test.dart
  • test/cursor_glyph_debug_test.dart

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

This PR updates tests across strategy archives, map and placement geometry, widgets, and providers. It adds direct coordinate and geometry assertions, exercises strategy imports and exports through a provider-backed harness, and changes or removes several existing test checks.

Changes

Test suite updates

Layer / File(s) Summary
Placement and map geometry checks
test/ability_anchor_scaling_test.dart, test/canonical_coordinates_migration_test.dart, test/canonical_coordinates_test.dart, test/canonical_map_artwork_test.dart, test/deadlock_barrier_switch_sides_test.dart, test/authored_vision_boundary_test.dart, test/role_icon_agent_size_test.dart, test/vision_geometry_map_test.dart, test/vision_polygon_test.dart, test/svg_height_visibility_test.dart, test/svg_height_app_integration_test.dart
Drag round-trip tests compare restored coordinates with stored positions. Other tests expand reflected-geometry and polygon checks or remove assertions for selected migration, boundary, coordinate, and SVG-provider behavior.
Widget interaction and rendering checks
test/ability_bar_lineup_state_test.dart, test/ability_visibility_widgets_test.dart, test/agent_dragable_lineup_state_test.dart, test/cursor_glyph_debug_test.dart, test/resizable_square_ability_test.dart, test/screenshot_export_failure_test.dart, test/sector_circle_ability_test.dart, test/square_icon_counter_rotation_test.dart, test/text_editing_shortcut_scope_test.dart, test/view_cone_agent_drag_feedback_test.dart, test/widgets/inset_shadow_decoration_test.dart, test/video_export_timing_test.dart
Tests add a draggable-count assertion, simulate a tile tap and context-menu interaction, and check a transparent pixel. Several widget, diagnostic, and video-timing tests are removed; screenshot failure checks retain spinner and icon assertions.
Strategy import and export tests
test/strategy_integrity_test.dart, test/custom_shape_color_test.dart, test/strategy_import_version_guard_test.dart
Strategy integrity tests use a temporary Hive-backed harness to import and export .ica archives through the provider. The tests check round trips, attachments, invalid payloads, and snapshot color restoration. A version-guard test is removed.
Provider, update, and asset tests
test/folder_icon_registry_test.dart, test/navigation_geometry_provider_test.dart, test/update_checker_test.dart, test/windows_desktop_update_restart_service_test.dart
Navigation tests distinguish catalog checksum failures from damaged-gzip errors. Update-provider tests run on Windows and add an unsupported Store result case. Folder icon fallback expectations change, and an executable-path test is removed.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 0d91b

The tests strengthen production archive round trips and behavioral assertions without an established workflow regression. Mergeable subject to normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: removing ineffective tests and strengthening weak regression checks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread test/strategy_integrity_test.dart
Comment thread test/strategy_integrity_test.dart Outdated
The fixture matrix compared the second export with the first, so content
lost on the first import went unnoticed. Every page and every placed
element in each fixture must now come through import by id.

If opening the harness fails partway, it closes Hive, removes its
path_provider mock and deletes its folder before rethrowing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@SunkenInTime

Copy link
Copy Markdown
Owner Author

@greptileai review

greptile-apps[bot]
greptile-apps Bot previously approved these changes Oct 1, 2026
An agent tile takes its size from its icon, so until the image decodes
the tile is 0x0 and a real tap lands on whatever sits underneath. CI hit
that race once the test stopped calling onTap directly. The harness now
precaches both icons before settling.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@greptile-apps
greptile-apps Bot dismissed their stale review October 1, 2026 22:42

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@SunkenInTime
SunkenInTime merged commit a0dcea8 into main Oct 1, 2026
3 checks passed
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