test: cover LogHabit reactivation pay gate through handler (ORB-255) - #474
Conversation
|
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. |
There was a problem hiding this comment.
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-testwithout changing any source or test file. - Existing coverage remains helper-level.
PayGateServiceTestsinvokesHabitReactivationAllowancedirectly, whileLogHabitCommandHandlerTestsstill 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.GPT Sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes I reviewed the handler regression coverage added since the prior Pullfrog review.
- Injected the pay gate. Added
IPayGateServiceto the existingLogHabitCommandHandlerTestsfixture so the handler path can be exercised directly. - Covered reactivation rejection. Added a completed one-time task case that verifies the exact
PAY_GATEresult, one-habit allowance request, preserved domain state, and no persistence attempt.
GPT Sol | 𝕏
|




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