feat: expose cms_type/WordPress credentials and published_url in API responses
This commit is contained in:
@@ -18,6 +18,7 @@ class PostResource extends JsonResource
|
|||||||
'body' => $this->body,
|
'body' => $this->body,
|
||||||
'status' => $this->status,
|
'status' => $this->status,
|
||||||
'scheduled_at' => $this->scheduled_at,
|
'scheduled_at' => $this->scheduled_at,
|
||||||
|
'published_url' => $this->published_url,
|
||||||
'created_at' => $this->created_at,
|
'created_at' => $this->created_at,
|
||||||
'updated_at' => $this->updated_at,
|
'updated_at' => $this->updated_at,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -14,8 +14,11 @@ class SiteResource extends JsonResource
|
|||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'url' => $this->url,
|
'url' => $this->url,
|
||||||
'description' => $this->description,
|
'description' => $this->description,
|
||||||
|
'cms_type' => $this->cms_type,
|
||||||
|
'wp_username' => $this->wp_username,
|
||||||
|
'wp_app_password' => $this->wp_app_password,
|
||||||
'created_at' => $this->created_at,
|
'created_at' => $this->created_at,
|
||||||
'updated_at' => $this->updated_at,
|
'updated_at' => $this->updated_at,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,3 +134,11 @@ test('it deletes a post', function () {
|
|||||||
$response->assertNoContent();
|
$response->assertNoContent();
|
||||||
expect(Post::find($post->id))->toBeNull();
|
expect(Post::find($post->id))->toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('it includes published_url in the post response', function () {
|
||||||
|
$post = Post::factory()->create(['published_url' => 'https://example.com/my-post']);
|
||||||
|
|
||||||
|
$response = $this->getJson("/api/posts/{$post->id}");
|
||||||
|
|
||||||
|
$response->assertOk()->assertJsonPath('data.published_url', 'https://example.com/my-post');
|
||||||
|
});
|
||||||
|
|||||||
@@ -32,3 +32,17 @@ test('it shows a single site', function () {
|
|||||||
test('it returns 404 for a missing site', function () {
|
test('it returns 404 for a missing site', function () {
|
||||||
$this->getJson('/api/sites/999')->assertNotFound();
|
$this->getJson('/api/sites/999')->assertNotFound();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('it includes WordPress fields in the site response', function () {
|
||||||
|
$site = Site::factory()->wordpress()->create([
|
||||||
|
'wp_username' => 'admin',
|
||||||
|
'wp_app_password' => 'abcd 1234 efgh 5678',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = $this->getJson("/api/sites/{$site->id}");
|
||||||
|
|
||||||
|
$response->assertOk()
|
||||||
|
->assertJsonPath('data.cms_type', 'wordpress')
|
||||||
|
->assertJsonPath('data.wp_username', 'admin')
|
||||||
|
->assertJsonPath('data.wp_app_password', 'abcd 1234 efgh 5678');
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user