Skip to content

test: cover LogHabit reactivation pay gate through handler (ORB-255) - #474

Merged
thomasluizon merged 2 commits into
mainfrom
feature/orb-255-loghabit-reactivation-test
Aug 13, 2026
Merged

test: cover LogHabit reactivation pay gate through handler (ORB-255)#474
thomasluizon merged 2 commits into
mainfrom
feature/orb-255-loghabit-reactivation-test

Conversation

@thomasluizon

@thomasluizon thomasluizon commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Ticket

Closes ORB-255.

Summary

Add a LogHabitCommandHandler regression test for the completed one-time task reactivation path. The test supplies a pay gate failure, confirms the handler requests one habit allowance, and verifies the task remains completed with the original active log and no save attempt.

Scope choice

I treated no mutation as both domain-state preservation and persistence preservation: the completion flag remains true, the same log instance remains attached and not deleted, and SaveChangesAsync is not called. I kept the change in the existing handler test fixture because the production gate already exists and the reported gap is caller-visible coverage.

Verification

  • Focused LogHabitCommandHandler regression: 1 passed
  • dotnet build Orbit.slnx: 0 errors
  • dotnet test --no-build: 5,730 passed, 0 failed

@thomasluizon

Copy link
Copy Markdown
Owner Author

Approach: add one focused case to tests/Orbit.Application.Tests/Habits/Commands/LogHabitCommandHandlerTests.cs. The test will arrange a completed one-time task, make IPayGateService return PAY_GATE for the reactivation check, execute LogHabitCommandHandler, and assert rejection plus unchanged habit and log state. This belongs at the handler boundary because the existing PayGateServiceTests exercise only the helper and would remain green if the handler stopped calling it. I will not change production code or add another helper-level test because neither would close the caller-visible coverage gap.

@pullfrog pullfrog 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.

Important

This PR currently contains no test change, so it does not provide the promised handler regression coverage and should not close ORB-255 as-is.

Reviewed changes I reviewed the complete zero-file diff and traced the stated scenario through LogHabitCommandHandler and the existing pay-gate tests.

  • Branch initialization only. The sole commit initializes feature/orb-255-loghabit-reactivation-test without changing any source or test file.
  • Existing coverage remains helper-level. PayGateServiceTests invokes HabitReactivationAllowance directly, while LogHabitCommandHandlerTests still has no completed one-time reactivation pay-gate case.

⚠️ Handler regression coverage is still absent

The branch changes zero files, so the handler-level regression described in the PR title, body, and approach comment has not been added. The existing helper-level test bypasses LogHabitCommandHandler and would remain green if the handler stopped invoking HabitReactivationAllowance, leaving the caller-visible pay-gate behavior unprotected.

Technical details
# Add the promised handler-level reactivation pay-gate test

## Affected sites
- `tests/Orbit.Application.Tests/Commands/Habits/LogHabitCommandHandlerTests.cs:40`: the fixture constructs `LogHabitServices` without an `IPayGateService` and contains no completed one-time reactivation rejection case.
- `tests/Orbit.Application.Tests/Common/PayGateServiceTests.cs:151`: this test exercises `HabitReactivationAllowance.ExecuteAsync` directly, so it does not verify that `LogHabitCommandHandler.Handle` reaches the gate.

## Required outcome
- Add a `LogHabitCommandHandler` test that arranges a completed one-time task, supplies an `IPayGateService` whose `CanCreateHabits` returns an exact `PAY_GATE` failure, invokes `Handle`, and verifies the failure is propagated without deleting the log, clearing completion, or saving changes.

Pullfrog  | Fix it ➔View workflow run | Using GPT Sol𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes I reviewed the handler regression coverage added since the prior Pullfrog review.

  • Injected the pay gate. Added IPayGateService to the existing LogHabitCommandHandlerTests fixture so the handler path can be exercised directly.
  • Covered reactivation rejection. Added a completed one-time task case that verifies the exact PAY_GATE result, one-habit allowance request, preserved domain state, and no persistence attempt.

Pullfrog  | View workflow run | Using GPT Sol𝕏

@sonarqubecloud

Copy link
Copy Markdown

@thomasluizon
thomasluizon merged commit f9534dd into main Aug 13, 2026
26 checks passed
@thomasluizon
thomasluizon deleted the feature/orb-255-loghabit-reactivation-test branch August 13, 2026 21:27
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