test(post): cover all 4 terminal statuses on MCP update + API update

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.
This commit is contained in:
Paulo Castellano 2026-05-19 13:19:01 -03:00
parent d8f836a569
commit 0c955e885f
2 changed files with 16 additions and 6 deletions

View file

@ -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([

View file

@ -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([