trypost/tests/Unit
Matteo Martini a33ff5d00f
fix: keep post drafts unscheduled by default (#209)
* fix: keep post drafts unscheduled by default

* Align schedule validation and keep drafts unscheduled.

Require scheduled_at only when status is scheduled and the post has no
usable future schedule. Share that rule across web, API, and MCP, keep
create without a date as null, and preserve the legacy date → 09:00 UTC
fallback.

* Polish schedule validation typing and tests.

Type requiresExplicitSchedule status as ?string, reuse a local status
variable in request/tool validation, tighten the web reject assertion,
and collapse overlapping MCP unscheduled-create cases.

* Centralize status helper in post update validation.

Reuse the typed status() helper across FormRequests and the already-parsed
$status in UpdatePostTool so schedule checks stay consistent and less noisy.

* Share scheduled_at update rules across web, API, and MCP.

Centralize schedule validation in PostStatusRules, normalize status parsing
in one place, and align past-schedule coverage across entry points.

* Cover the full unscheduled-draft checklist in Pest.

Add feature coverage for null/past schedule rejection, explicit scheduling,
draft saves, publish-now without a schedule, calendar exclusion, and
09:00 UTC date defaults across web, API, and MCP.

* Remove normalizeStatus helper.

Keep the inline is_string check at the few call sites that read raw
request status before validation — no shared wrapper needed.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Drop is_string status guards from schedule validation.

Accept mixed status in PostStatusRules and rely on strict comparisons
with Rule::requiredIf / Rule::when — malformed input simply does not match.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Paulo Castellano <paulo@castellanos.llc>
2026-08-01 17:39:18 -03:00
..
Actions Allow account owners to delete workspaces (#208) 2026-08-01 13:00:38 -04:00
Ai/Agents Share a ContentLanguageOption type and close the review's test gaps 2026-07-03 19:28:28 -03:00
Automation test(automations): extract inline feed XML into shared fixtures 2026-06-16 11:06:46 -03:00
Broadcasting feat: workspace-scoped broadcast channel and post lifecycle events 2026-05-07 16:02:22 -03:00
DataTransferObjects test(tiktok): cover MediaItem dimensions and platform max-width helpers 2026-06-26 12:31:46 -03:00
Enums Allow account owners to delete workspaces (#208) 2026-08-01 13:00:38 -04:00
Events refactor: prefer string interpolation over concatenation for channel names 2026-05-08 19:22:01 -03:00
Exceptions/Social fix(x): harden chunked media upload handling and coverage 2026-07-24 10:30:34 -03:00
Mail feat: @mentions in comments, AI Action layer + MCP tools, settings tabs 2026-05-01 20:59:03 -03:00
Models chore: remove legacy plan tiers (starter/plus/pro/max) 2026-06-22 15:31:32 -03:00
Policies Allow account owners to delete workspaces (#208) 2026-08-01 13:00:38 -04:00
PostTemplates refactor: reorganize settings UI, migrate post templates to a file-based registry, and remove legacy video generation features 2026-05-03 13:44:13 -03:00
Rules refactor(linkedin): infer post format from media + unify account connection 2026-06-24 21:05:09 -03:00
Services fix(security): make SSRF private-network block configurable and guard the last user-URL fetches 2026-07-17 15:40:15 -03:00
Settings Allow account owners to delete workspaces (#208) 2026-08-01 13:00:38 -04:00
Socialite refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
Support fix: keep post drafts unscheduled by default (#209) 2026-08-01 17:39:18 -03:00
Traits Allow account owners to delete workspaces (#208) 2026-08-01 13:00:38 -04:00
ExampleTest.php refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
HelpersTest.php fix(security): make SSRF private-network block configurable and guard the last user-URL fetches 2026-07-17 15:40:15 -03:00
MediaItemAltTextTest.php Extract alt-text truncation onto MediaItem and close test gaps 2026-07-11 10:34:57 -03:00
MediaPolymorphTest.php fix: persist morph map alias on AI-generated Media rows 2026-05-04 14:14:14 -03:00
MorphMapTest.php Register all models in the morph map + lock it with a test 2026-06-14 16:12:49 -03:00
PlatformAltTextTest.php Harden per-image alt text across publishers, validation, and attach paths 2026-07-16 13:55:33 -03:00
PostHogServiceTest.php chore: remove legacy plan tiers (starter/plus/pro/max) 2026-06-22 15:31:32 -03:00
PostPlatformTest.php fix(facebook): empty-message rejection + state consistency + no re-publish on terminal 2026-05-19 12:47:18 -03:00