Skip to content

Deduplicate test fixtures and prune subsumed tests - #1163

Merged
robinebers merged 1 commit into
mainfrom
claude/audit-test-suites-759d8e
Aug 25, 2026
Merged

Deduplicate test fixtures and prune subsumed tests#1163
robinebers merged 1 commit into
mainfrom
claude/audit-test-suites-759d8e

Conversation

@robinebers

@robinebers robinebers commented Aug 25, 2026

Copy link
Copy Markdown
Owner

TL;DR — Second test-simplification pass after #1143, focused on the suites that pass didn't touch: consolidates duplicated test fixtures, parameterizes near-identical test clusters, and removes tests whose behavior is already verified elsewhere. Net −360 lines (724 deleted, 364 added) with the full suite still green.

What was happening

  • Four test files each carried their own private copy of the Cursor JWT builder and an identical key/value SQLite fake; the OpenCode scanner and provider suites duplicated their SQLite stub and row builder; BlockingParser existed twice (integer and Claude-entry variants); and TogglingProviderRuntime / a private SequenceProviderRuntime were the same idea implemented twice.
  • Several suites repeated ~25-line provider constructions per test (ClaudeDesktopAuthStore, Antigravity error-category tests).
  • A handful of tests were near-identical clones (four Grok Bot optional-endpoint tests, Grok credits absent/non-numeric field pairs, Devin credentials-TOML pair), byte-identical duplicates (a ReorderGeometry test that only renamed a string ID), or restated the implementation in the test loop (two ShareCard condensed-row tests recomputed the production rule instead of asserting expected output).
  • A few single tests were fully subsumed by stronger tests elsewhere (PanelHeightCoordinator, AntigravityLayout pins, ZAI empty-limits, GrokCreditsConfig monthly period, MenuBarContent compaction, LocalUsageAPI limits-404, OpenCode zen-only scan, ShellEnvironmentSnapshot roundtrip, ClaudeDesktopAuthStore revoked-CLI fallback pair).

What this changes

  • Adds shared makeCursorJWT and KeyValueSQLite to TestSupport.swift; the four Cursor suites now use them.
  • Shares the OpenCode SQLite stub (OpenCodeFakeSQLite) and openCodeRow builder between the scanner and provider suites.
  • Replaces TogglingProviderRuntime with one shared SequenceProviderRuntime (different snapshot per refresh, call-counting); makes BlockingParser generic over the item type.
  • Extracts makeProvider/makeAuthStore helpers in ClaudeDesktopAuthStoreTests and a makeCloudCodeProvider helper in AntigravityProviderTests, collapsing repeated construction boilerplate.
  • Parameterizes the four Grok Bot optional-endpoint tests into one table-driven test (all four cases kept), and merges the Grok credits, Devin TOML, and OpenCode hasLocalCredentials pairs.
  • Removes duplicated or subsumed tests listed above, each verified as covered elsewhere before deletion; the ShareCard pair is replaced by one fixed-expectation test on a hand-built fixture, and MenuBarContent's unique $130 rounding case moved into MetricFormatterTests where the rule lives.

Heads-up

  • Deliberately untouched: LayoutStoreTests and the large Claude/Codex/Copilot suites (every test pins a distinct behavior or documented regression), LogRedactionTests' verbatim Rust-parity cases, all boundary/clamp tests, and every concurrency/ownership/account-isolation test.
  • No production code changed — all 25 modified files are under Tests/.

Tests

  • swift build --build-tests — clean (only pre-existing warnings).
  • swift test — 1,173 tests passed, 0 failures, 3 skipped (pre-existing env-gated live/parity tests), plus the CLI and swift-testing bundles. Baseline run before the changes was also green.

🤖 Generated with Claude Code


Note

Low Risk
Only test code under Tests/OpenUsageTests is modified; behavior is unchanged and risk is limited to possible loss of unique test coverage, which the PR explicitly addresses by consolidating rather than deleting scenarios.

Overview
This PR is a test-only cleanup (~−360 lines): no production code changes.

Shared fixturesmakeCursorJWT, KeyValueSQLite, SequenceProviderRuntime (replacing TogglingProviderRuntime), and a generic BlockingParser land in TestSupport.swift / JSONLScannerTestSupport.swift. Cursor suites drop four duplicate JWT/SQLite copies; OpenCode shares openCodeRow and OpenCodeFakeSQLite between scanner and provider tests.

Less boilerplatemakeCloudCodeProvider in Antigravity provider tests and makeAuthStore / makeProvider / cliCredentials in Claude desktop auth tests replace repeated ~25-line setups.

Consolidated cases — Four Grok Bot optional-endpoint tests become one table-driven test; Grok credits absent-field tests, Devin HTTPS-vs-HTTP TOML tests, and OpenCode hasLocalCredentials positive/empty paths are merged. ShareCard condensing is asserted on a fixed hand-built fixture instead of re-implementing the production rule in the test.

Removed redundancy — Tests dropped where coverage already exists (e.g. Antigravity pins exact-set, MenuBar compaction → MetricFormatterTests for $130 tray rounding, duplicate Claude revoked-CLI fallback, LocalUsageAPI limits 404, and others noted in the PR description).

The full suite remains green (1,173 tests).

Reviewed by Cursor Bugbot for commit d0771a3. Bugbot is set up for automated code reviews on this repo. Configure here.

Second simplification pass after #1143, covering the suites that pass
did not touch: consolidates duplicated fixtures (Cursor JWT/SQLite
fakes, OpenCode stub, BlockingParser, sequence runtimes), parameterizes
near-identical test clusters, and removes tests whose behavior is
verified elsewhere or that restated the implementation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the tests label Aug 25, 2026
@robinebers
robinebers merged commit a7f603e into main Aug 25, 2026
3 checks passed
@robinebers
robinebers deleted the claude/audit-test-suites-759d8e branch August 25, 2026 04:25
liaomingxin added a commit to liaomingxin/openusage that referenced this pull request Aug 26, 2026
Brings in the 8 upstream commits behind v0.7.10-beta.3: multi-account Claude
(robinebers#1164), sub-1% session countdown (robinebers#1167, WidgetData.isSessionWindow →
sessionStartSignal), Codex Session on by default (robinebers#1165), GLM 5.3 pricing
(robinebers#1171), test-fixture dedup (robinebers#1163), plus docs/policy chores.

Conflicts and how they were resolved (both sides kept everywhere):

- Sources/OpenUsage/Services/ProviderAccountAssembly.swift — kept both the
  fork's Codex extra cards (CodexExtraCard, extraCodexCards, the
  ~/.cli-proxy-api discovery, mergedObservations/mergedSources) and upstream's
  Claude Desktop organization discovery (ClaudeAccountCard, claudeCards,
  allowsUnattributedPiUsage, the bare "claude" identity key rewritten to the
  org record id). Restructured the core make() so it appends the extra-Codex
  observations, then runs the Claude desktop-org discovery, then reconciles
  exactly once per pass through mergedObservations, then builds BOTH card
  lists — upstream's two early returns are now conditions on the discovery
  block, so a skipped/legacy Claude path still emits the Codex extra cards.
  Kept the fork's cold-login-shell guard (!families.isEmpty ||
  !extraCodex.isEmpty) and the extra-Codex read in
  make(defaults:waitsForLoginShell:). init takes both extraCodexCards and
  claudeCards with defaults so upstream and fork tests both compile. 361 LOC,
  no split needed.

- Sources/OpenUsage/Providers/ProviderCatalog.swift — one
  make(defaults:extraCodexCards:claudeCards:claudeIdentityKeys:): upstream's
  Claude card list first, then CodexProvider() followed by the fork's extra
  Codex cards, then Cursor and the alphabetical tail with Kimi after Grok.
  Comment updated to mention both.

- Sources/OpenUsage/App/AppContainer.swift — call site passes all three
  arguments (extraCodexCards, claudeCards, claudeIdentityKeys).

- Sources/OpenUsage/Services/UsageReader.swift — same three arguments; kept
  upstream's placement of ProviderEnablementStore(defaults:) after the
  registry is built.

- docs/menu-bar.md — default-star sentence lists both upstream's Codex
  Session/Weekly and the fork's Kimi Session/Weekly.

Sanity-checked DefaultLayout.swift (auto-merged): kimi rows still in
metricIDs/pinnedMetricIDs/expandedMetricIDs, codex.session now in metricIDs
and pinnedMetricIDs.

Verified: swift build and swift build --build-tests both succeed;
ProviderAccountAssembly / CodexMultiAccount / ClaudeDesktopAuthStore /
CodexExtraCardCatalog tests pass (24/24).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant