whisper-money/tests/Feature/Console
Víctor Falcón 8382a56e98
feat(ai): add command to delete a user's AI consent by email (#729)
## What

Adds an Artisan command to delete a specific user's AI consent by email:

```bash
php artisan ai:delete-consent user@example.com
```

It looks up the user by email and **hard-deletes** all their AI consent
records — as if they had never granted it (no `revoked_at` trail left
behind). Since `AiCategorizationGate` requires `hasActiveAiConsent()`,
AI stops being used for that account immediately (queued categorization
jobs re-check the gate at execution time and early-return).

The command is idempotent: it reports "nothing to do" when there's no
consent on record and fails cleanly when the email doesn't exist.

## Why

Two goals:

1. **Stop using AI for a given user** on request, with no lingering
consent record.
2. **Let users who enabled AI by mistake fall back to a free plan.**
Non-Pro users with active AI consent are pushed toward the paid plan by
`EnsureUserIsSubscribed`. Deleting consent moves them back into the
free-plan-eligible bucket. This billing-gating change is **intended**,
not a side effect.

## Notes / scope decisions

- **Hard delete, not revoke.** Removes every consent row for the user
(all scopes/versions) so there's no trace they ever consented.
- **Prompt flag untouched.** `ai_consent_prompt_dismissed_at` is left
as-is, so the in-app consent banner does not re-appear to nudge them
back on.
- **Live users only.** Deleted (soft-deleted) accounts are out of scope
— they can't use the app, so their consent is moot.
- **No subscription changes.** The command only touches AI consent; it
doesn't cancel Stripe subscriptions (`user:delete` already handles that
separately).

## Tests

New Pest feature test covering all three paths (delete all consent
records incl. a revoked one / no consent on record / user not found).
Green locally.
2026-07-23 08:35:28 +00:00
..
AgentDatabaseCommandTest.php feat(console): add agent:db command for querying local and prod DB (#522) 2026-06-12 18:35:14 +02:00
CheckBankLogosCommandTest.php Add weekly bank logo audit command (#211) 2026-03-06 11:05:13 +00:00
DeleteAiConsentCommandTest.php feat(ai): add command to delete a user's AI consent by email (#729) 2026-07-23 08:35:28 +00:00
DeleteEncryptedDataAccountsCommandTest.php fix(encryption): never email or delete users who are still being billed (#656) 2026-07-07 16:04:27 +00:00
DeleteManualAccountDataCommandTest.php feat(commands): delete transactions and balances of a user's non-connected accounts (#728) 2026-07-23 08:26:11 +00:00
FeatureEnableCommandTest.php refactor(ai): remove AiConsentSettings feature flag (#619) 2026-07-01 09:47:55 +02:00
NotifyEncryptedDataRemovalCommandTest.php feat(encryption): report count of users still holding encrypted data (#687) 2026-07-17 09:29:33 +00:00
ResetDemoAccountCommandTest.php fix: skip demo reset when demo account is disabled (#626) 2026-07-03 07:27:43 +00:00
ResetUserCategoriesCommandTest.php fix(categories): expose cashflow setting on create (#448) 2026-05-29 11:05:04 +02:00
SendPaywallFollowUpEmailsCommandTest.php feat(drip): email users stuck on the paywall a day after onboarding (#562) 2026-06-19 14:11:12 +00:00
SendSubscriptionCancelledEmailCommandTest.php Add subscription cancellation email with manual trigger command (#47) 2025-12-30 20:32:44 +01:00
SendUpdateEmailCommandTest.php Support soft-deleted users with reusable emails (#316) 2026-04-22 11:41:41 +01:00
SetBankLogoCommandTest.php fix(banks:set-logo): add JPEG support test coverage and prompt for missing arguments (#214) 2026-03-07 16:33:54 +00:00
SetupMainUserCommandTest.php Command: Setup Main User 2025-11-15 22:16:41 +01:00