From 0c955e885fc30404c7600b85ef26795f079f28d4 Mon Sep 17 00:00:00 2001 From: Paulo Castellano Date: Tue, 19 May 2026 13:19:01 -0300 Subject: [PATCH] test(post): cover all 4 terminal statuses on MCP update + API update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UpdatePost::execute returns Finalized for Published, PartiallyPublished, Failed, and Publishing — the four "terminal" states the PR introduced. The existing tests for UpdatePostTool (MCP) and Api/PostController only exercised the Published path. Convert both to a Pest dataset over all four statuses so a future regression that lets one state slip through the check fails loudly. Same shape already used for PublishPostTool and App/PostController. --- tests/Feature/Api/PostApiTest.php | 11 ++++++++--- tests/Feature/Mcp/PostPublishToolTest.php | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/Feature/Api/PostApiTest.php b/tests/Feature/Api/PostApiTest.php index 25043996..592ed299 100644 --- a/tests/Feature/Api/PostApiTest.php +++ b/tests/Feature/Api/PostApiTest.php @@ -196,11 +196,11 @@ ->assertNotFound(); }); -it('cannot update published post', function () { +it('cannot update post in any terminal state', function (PostStatus $status) { $post = Post::factory()->create([ 'workspace_id' => $this->workspace->id, 'user_id' => $this->user->id, - 'status' => PostStatus::Published, + 'status' => $status, ]); $postPlatform = PostPlatform::factory()->linkedin()->create([ @@ -220,7 +220,12 @@ ], ]) ->assertUnprocessable(); -}); +})->with([ + PostStatus::Published, + PostStatus::PartiallyPublished, + PostStatus::Failed, + PostStatus::Publishing, +]); it('validates post update fields', function () { $post = Post::factory()->create([ diff --git a/tests/Feature/Mcp/PostPublishToolTest.php b/tests/Feature/Mcp/PostPublishToolTest.php index 7b269fdc..91c517a7 100644 --- a/tests/Feature/Mcp/PostPublishToolTest.php +++ b/tests/Feature/Mcp/PostPublishToolTest.php @@ -106,18 +106,23 @@ $response->assertHasErrors(['Post not found.']); }); -test('update post rejects already-published post', function () { +test('update post rejects posts in any terminal state', function (PostStatus $status) { $post = Post::factory()->create([ 'workspace_id' => $this->workspace->id, 'user_id' => $this->user->id, - 'status' => PostStatus::Published, + 'status' => $status, ]); $response = TryPostServer::actingAs($this->user) ->tool(UpdatePostTool::class, ['post_id' => $post->id, 'content' => 'x']); $response->assertHasErrors(['Cannot edit a published post.']); -}); +})->with([ + PostStatus::Published, + PostStatus::PartiallyPublished, + PostStatus::Failed, + PostStatus::Publishing, +]); test('update post rejects a platforms[].id that belongs to another post', function () { $myPost = Post::factory()->create([