trypost/tests/Feature
Paulo Castellano 5f7768ca3a fix: apply code review — enforce quota server-side, project conventions
Critical fixes:
- Quota enforcement regressed when the regex flow was replaced with
  tools. The LLM was trusted to respect [Session state] quota hints,
  which is vulnerable to prompt injection / hallucination. Each tool
  now checks Pennant feature limits at the top of handle() and returns
  a short quota-exhausted string instead of calling the provider.
  Audio shares the video quota (there is no AiAudioLimit by design).
- N+1 on aiMessages: combined the two separate ->get() scans that
  produced imagesInThread and videosInThread into a single query.
- postPlatforms lazy load: controller now loadMissing('postPlatforms')
  before constructing SocialMediaAssistant, which accesses the relation
  in activePlatformRules().

Project conventions:
- \RuntimeException and \Throwable are now imported at the top of the
  controller instead of inlined per CLAUDE.md.
- Tool handle() methods use data_get($request, 'prompt') instead of
  direct array access, matching the data_get convention for service
  classes.
- enrichContent() pluralizes attachment types via Str::plural so
  '2 images' reads naturally instead of '2 image'.

Tests:
- Added Storage::fake('public') in tool tests so runs don't pollute
  the local disk with fake-generated files.
- Restored quota enforcement coverage (deleted when the flow changed)
  as three new tests — one per tool — that fill the monthly bucket
  and assert the tool refuses and nothing is generated.
- Removed inline \App\ references in tests in favor of imports.
2026-04-16 10:22:55 -03:00
..
Ai fix: apply code review — enforce quota server-side, project conventions 2026-04-16 10:22:55 -03:00
Api feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
Auth chore: tracking, gtm and more 2026-03-30 21:32:43 -03:00
Commands feat: publishing hardening — content sanitization, validation, scopes, stuck recovery 2026-04-01 11:25:25 -03:00
Controllers feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
Jobs feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
Listeners feat: redesign billing, onboarding, sidebar, and settings architecture 2026-04-15 00:33:38 -03:00
Mcp feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
Middleware feat: redesign billing, onboarding, sidebar, and settings architecture 2026-04-15 00:33:38 -03:00
Services/Social fix: overhaul social publishing — validation, uploads, token refresh 2026-03-31 19:25:19 -03:00
Settings feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
Social feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
AcceptInviteControllerTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
AccountControllerTest.php fix: self-host billing bypass, Facebook API metrics migration, X token refresh, and duplicate social accounts 2026-04-15 09:46:18 -03:00
AiUsageLogTest.php fix: update monthlyCount() callers to pass UsageType enum 2026-04-16 09:29:37 -03:00
ApiKeyControllerTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
AssetControllerTest.php feat: integrate Giphy support and add trending endpoints for media assets 2026-04-15 11:02:10 -03:00
BillingControllerTest.php fix: self-host billing bypass, Facebook API metrics migration, X token refresh, and duplicate social accounts 2026-04-15 09:46:18 -03:00
CreateUserActionTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
ExampleTest.php refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
GoogleAuthToggleTest.php fix: keep Google OAuth routes always registered and add tests 2026-04-14 14:28:17 -03:00
InstagramFacebookIntegrationTest.php feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
LimitEnforcementTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
MediaControllerTest.php feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
NotificationControllerTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
OnboardingControllerTest.php feat: redesign billing, onboarding, sidebar, and settings architecture 2026-04-15 00:33:38 -03:00
PlanSeederTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
PlanTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
PostAssistantTest.php refactor: migrate PostAssistantController to SDK Agent + tools 2026-04-16 09:59:10 -03:00
PostCommentControllerTest.php test: add PostCommentController feature tests 2026-04-15 20:18:21 -03:00
PostControllerTest.php feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
PostSearchTest.php feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
SendPostHogEventTest.php chore: posthog, ui, features and more 2026-03-30 21:18:07 -03:00
SignupSuccessControllerTest.php refactor: code review fixes — policies, enums, data_get, tests 2026-03-31 00:40:18 -03:00
SocialAccountToggleTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
SocialControllerTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
SocialLoginControllerTest.php chore: tracking, gtm and more 2026-03-30 21:32:43 -03:00
StripeEventListenerTest.php feat: redesign billing, onboarding, sidebar, and settings architecture 2026-04-15 00:33:38 -03:00
UsageControllerTest.php fix: self-host billing bypass, Facebook API metrics migration, X token refresh, and duplicate social accounts 2026-04-15 09:46:18 -03:00
VerifyWorkspaceConnectionsTest.php fix: VerifyWorkspaceConnections uses TokenExpired/Disconnected escalation, eager load workspace 2026-04-01 11:52:03 -03:00
WorkspaceBillingTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
WorkspaceControllerTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
WorkspaceHashtagControllerTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
WorkspaceInviteControllerTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
WorkspaceLabelControllerTest.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
YouTubeAnalyticsTest.php refactor: optimize json parsing and add missing test coverage 2026-04-14 13:36:22 -03:00