Skip to content

Split the monolithic Mac test suite - #144

Merged
HemSoft merged 4 commits into
mainfrom
feature/issue-142-split-mac-test-suite
Aug 5, 2026
Merged

Split the monolithic Mac test suite#144
HemSoft merged 4 commits into
mainfrom
feature/issue-142-split-mac-test-suite

Conversation

@HemSoft

@HemSoft HemSoft commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Closes #142

Summary

  • split the 12,850-line catch-all XCTest file into 12 domain-focused test classes
  • move OAuth/network, credential-store, and refresh doubles into four focused support files
  • explicitly register every new test source in the Xcode target and document the organization change

Verification

  • ./test.sh — passed; 344 tests, 0 failures (plus release/run smoke checks)
  • Debug xcodebuild ... build — passed with project -warnings-as-errors enabled
  • git diff --check — passed
  • xcodebuild analyze — passed
  • baseline/current method-name inventory — 344/344, no deleted or renamed tests
  • baseline/current XCTest assertion-call inventory — identical

Residual risk

  • XCTest suite-qualified identifiers now use the new domain class names; individual test method names and bodies are preserved.

Summary by cubic

Split the 12,850-line monolithic Mac XCTest file into 12 domain-focused test suites with small, shared test support. Test coverage (344 tests) and assertions are preserved.

  • Refactors

    • Replaced CodexBarMacTests.swift with 12 focused test classes (providers, dashboard, usage, config, workflows).
    • Moved and hardened OAuth/network, credential-store, and refresh helpers into dedicated support files (deterministic OAuth values, MockURLProtocol request parsing, sequenced usage providers).
    • Trimmed unused test imports.
    • Registered all new test sources in the Xcode target and updated the CHANGELOG.
    • Normalized file endings across new test files for consistent diffs.
    • Preserved the full test inventory (no deleted or renamed tests; 344/344).
  • Migration

    • XCTest suite-qualified identifiers now use new class names; individual test method names are unchanged.

Written for commit 541a9b8. Summary will update on new commits.

Review in cubic

Note

Split the monolithic Mac XCTest suite into domain-focused test classes

Replaces the single CodexBarMacTests.swift file with multiple domain-scoped test files covering usage refresh, alerts, history, dashboard ordering, and provider-specific behavior (Claude, Codex, Copilot, Gemini, OpenCode, OpenRouter).

  • Adds shared test support files for credentials, OAuth flows, network mocking, and provider stubs to reduce duplication across suites.
  • Updates project.pbxproj to register all new source files in the test target and remove the old monolithic file.
  • The regression inventory is preserved; no production code is changed.

Macroscope summarized 541a9b8.

@cursor

cursor Bot commented Aug 5, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@HemSoft

HemSoft commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

@macroscope-app review

@HemSoft

HemSoft commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Reorganized the Mac XCTest suite into focused, domain-specific test classes.
    • Expanded coverage for provider authentication, usage reporting, credential workflows, dashboards, alerts, history, refresh behavior, persistence, and error handling.
    • Preserved the existing 344-test regression inventory while improving test organization and shared support.
  • Documentation
    • Added a changelog entry describing the XCTest suite improvements.

Walkthrough

This PR splits the Mac XCTest suite into domain-focused test files, adds shared test-support helpers, updates the Xcode test target to compile the new files, and documents the new test layout in the changelog.

Changes

Mac XCTest suite reorganization

Layer / File(s) Summary
Shared test support and target wiring
CodexBarMacTests/CredentialTestSupport.swift, CodexBarMacTests/NetworkTestSupport.swift, CodexBarMacTests/OAuthTestSupport.swift, CodexBarMacTests/RefreshTestSupport.swift, CodexBarMac.xcodeproj/project.pbxproj, CHANGELOG.md
Adds shared helpers for credential, networking, OAuth, and refresh tests. The Xcode project now references and builds the new test files. The changelog records the suite split.
App, credential, and configuration workflows
CodexBarMacTests/AppAndCredentialWorkflowTests.swift, CodexBarMacTests/ConfigurationPersistenceTests.swift
Adds tests for status-bar routing, credential save and removal flows, readiness states, Sparkle settings, configuration recovery, account identity validation, transactional credential replacement, bootstrap import, Gemini account handling, and history visibility persistence.
Provider authentication and usage coverage
CodexBarMacTests/APIKeyAndCursorProviderTests.swift, CodexBarMacTests/ClaudeProviderTests.swift, CodexBarMacTests/CodexProviderTests.swift, CodexBarMacTests/CopilotProviderTests.swift, CodexBarMacTests/GeminiProviderTests.swift, CodexBarMacTests/OpenCodeProviderTests.swift
Adds provider-specific suites for API-key, OAuth, parsing, credential, request, refresh, billing, cache, and fallback behavior across OpenRouter, Moonshot, Cursor, Claude, Codex, Copilot, Gemini, and OpenCode flows.
Refresh, alerts, history, and dashboard behavior
CodexBarMacTests/UsageRefreshTests.swift, CodexBarMacTests/UsageAlertTests.swift, CodexBarMacTests/UsageHistoryTests.swift, CodexBarMacTests/DashboardTests.swift
Adds tests for incomplete refresh handling, OpenCode cache reuse rules, timeout and cancellation behavior, alert persistence and severity logic, usage-history persistence and recovery, series generation, and dashboard ordering modes.

Estimated code review effort: 4 (Complex) | ~75 minutes

Possibly related issues

Possibly related PRs

  • HemSoft/codexbar-mac#143 — This PR relocates and expands the same Codex, Claude, and Copilot OAuth token-exchange coverage into the new split test structure.
  • HemSoft/codexbar-mac#91 — The new ConfigurationPersistenceTests.swift directly covers recovery, rollback, and OpenCode bootstrap-import behavior from that PR.
  • HemSoft/codexbar-mac#79 — The new UsageRefreshTests.swift directly exercises cached-usage preservation and incomplete-refresh behavior from that PR.

Suggested labels: refactor

Poem

I split one burrow into many neat rooms,
where tests now hop in ordered blooms.
With helpers tucked in tidy hay,
the suite can nibble day by day.
🐇 Green checks rustle through the clover.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #142 by organizing tests, extracting support, registering sources, preserving 344 tests, passing checks, and updating the changelog.
Out of Scope Changes check ✅ Passed All changes support the requested test-suite reorganization, including source registration, test support extraction, verification, and changelog documentation.
Title check ✅ Passed The title clearly describes the main change: splitting the monolithic Mac test suite.
Description check ✅ Passed The description directly explains the test-suite split, support-file reorganization, target registration, and verification results.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/issue-142-split-mac-test-suite

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.

@macroscopeapp

macroscopeapp Bot commented Aug 5, 2026

Copy link
Copy Markdown

Manual reviews triggered for commit 541a9b8:

All prior checks · these links stay valid even if you push more commits.

@macroscopeapp

macroscopeapp Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review is in progress. Results will be posted as check runs when complete.

@macroscopeapp

macroscopeapp Bot commented Aug 5, 2026

Copy link
Copy Markdown

Approvability

Verdict: Needs human review

Unable to check for correctness in 541a9b8. Diff is too large for automated approval analysis. A human reviewer should evaluate this PR.

You can customize Macroscope's approvability policy. Learn more.

@coderabbitai coderabbitai Bot added the refactor label Aug 5, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: e44904fb57

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CodexBarMacTests/AppAndCredentialWorkflowTests.swift`:
- Around line 178-189: Add kSecUseDataProtectionKeychain set to true to the
SecItemAdd attributes in the test and to the keychain attributes used by
KeychainService.saveSecret. Preserve the existing ThisDeviceOnly accessibility
setting and ensure both insertion paths explicitly target the Data Protection
keychain.

In `@CodexBarMacTests/CredentialTestSupport.swift`:
- Line 99: Add an explicit empty deinit to TransactionalReplacementSecretStore
and the six other test-double classes at the referenced declarations, matching
the existing deinit declarations in CredentialMutationSecretStore and
FailingCredentialCompensationSecretStore to satisfy required_deinit.
- Around line 232-254: Make SelectiveDeletionSecretStore’s failingAccounts state
thread-safe to justify its `@unchecked` Sendable conformance, following the
NSLock-protected storage pattern used by the other test doubles. Guard both
reads in deleteSecret(account:) and mutations of failingAccounts, or remove
`@unchecked` Sendable if synchronization is not needed.

In `@CodexBarMacTests/OAuthTestSupport.swift`:
- Around line 87-110: Protect presentedAuthorizationURL with a lock-guarded box
shared by the main-actor authorization callback and MockURLProtocol.handler.
Replace direct assignment and read access with the box’s synchronized setter and
getter, preserving the existing XCTUnwrap and request-inspection flow.

In `@CodexBarMacTests/RefreshTestSupport.swift`:
- Around line 70-74: Update waitUntilStarted to use the same bounded polling
pattern as waitUntilCancellationObserved, returning a Boolean that indicates
whether started became true before the limit; preserve yielding between checks
so callers can assert the result with XCTAssertTrue instead of hanging
indefinitely.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 335e8d4a-8442-4b06-b645-1182cb283e59

📥 Commits

Reviewing files that changed from the base of the PR and between bf9ebf0 and e44904f.

📒 Files selected for processing (19)
  • CHANGELOG.md
  • CodexBarMac.xcodeproj/project.pbxproj
  • CodexBarMacTests/APIKeyAndCursorProviderTests.swift
  • CodexBarMacTests/AppAndCredentialWorkflowTests.swift
  • CodexBarMacTests/ClaudeProviderTests.swift
  • CodexBarMacTests/CodexBarMacTests.swift
  • CodexBarMacTests/CodexProviderTests.swift
  • CodexBarMacTests/ConfigurationPersistenceTests.swift
  • CodexBarMacTests/CopilotProviderTests.swift
  • CodexBarMacTests/CredentialTestSupport.swift
  • CodexBarMacTests/DashboardTests.swift
  • CodexBarMacTests/GeminiProviderTests.swift
  • CodexBarMacTests/NetworkTestSupport.swift
  • CodexBarMacTests/OAuthTestSupport.swift
  • CodexBarMacTests/OpenCodeProviderTests.swift
  • CodexBarMacTests/RefreshTestSupport.swift
  • CodexBarMacTests/UsageAlertTests.swift
  • CodexBarMacTests/UsageHistoryTests.swift
  • CodexBarMacTests/UsageRefreshTests.swift

Comment thread CodexBarMacTests/AppAndCredentialWorkflowTests.swift
Comment thread CodexBarMacTests/CredentialTestSupport.swift
Comment thread CodexBarMacTests/CredentialTestSupport.swift
Comment thread CodexBarMacTests/OAuthTestSupport.swift Outdated
Comment thread CodexBarMacTests/RefreshTestSupport.swift Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

Comment thread CodexBarMacTests/AppAndCredentialWorkflowTests.swift
Comment thread CodexBarMacTests/NetworkTestSupport.swift
Comment thread CodexBarMacTests/UsageAlertTests.swift Outdated
Comment thread CodexBarMacTests/CodexProviderTests.swift
Comment thread CodexBarMacTests/AppAndCredentialWorkflowTests.swift
@HemSoft

HemSoft commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@HemSoft

HemSoft commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

@macroscope-app review

@HemSoft

HemSoft commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 76baaa6de0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@HemSoft

HemSoft commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@HemSoft

HemSoft commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

@macroscope-app review

@HemSoft

HemSoft commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@macroscopeapp

macroscopeapp Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review triggered. Results will be posted as check runs when complete.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 541a9b841d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@HemSoft
HemSoft merged commit 0d7f787 into main Aug 5, 2026
5 checks passed
@HemSoft
HemSoft deleted the feature/issue-142-split-mac-test-suite branch August 5, 2026 08:58
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.

Split the monolithic Mac test suite

1 participant