For custom sites we'll post to via their own API — there's no wired-in publisher for these, so this is where the site owner documents how to actually post there (auth, endpoints, payload shape). Shown in the UI for non-WordPress sites, exposed via the JSON API, and pointed to from AI_API.md's "any other network/CMS" fallback section so an agent checks it before improvising. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
<?php
|
|
|
|
use App\Models\Site;
|
|
|
|
test('it lists all sites', function () {
|
|
Site::factory()->count(3)->create();
|
|
|
|
$response = $this->getJson('/api/sites');
|
|
|
|
$response->assertOk()->assertJsonCount(3, 'data');
|
|
});
|
|
|
|
test('it filters sites by partial name match', function () {
|
|
Site::factory()->create(['name' => 'My Awesome Blog']);
|
|
Site::factory()->create(['name' => 'Other Site']);
|
|
|
|
$response = $this->getJson('/api/sites?name=Awesome');
|
|
|
|
$response->assertOk()
|
|
->assertJsonCount(1, 'data')
|
|
->assertJsonPath('data.0.name', 'My Awesome Blog');
|
|
});
|
|
|
|
test('it shows a single site', function () {
|
|
$site = Site::factory()->create(['name' => 'Solo Site']);
|
|
|
|
$response = $this->getJson("/api/sites/{$site->id}");
|
|
|
|
$response->assertOk()->assertJsonPath('data.name', 'Solo Site');
|
|
});
|
|
|
|
test('it returns 404 for a missing site', function () {
|
|
$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');
|
|
});
|
|
|
|
test('it includes api_instructions in the site response', function () {
|
|
$site = Site::factory()->create([
|
|
'cms_type' => 'custom',
|
|
'api_instructions' => 'POST to /api/publish with a bearer token from .env',
|
|
]);
|
|
|
|
$response = $this->getJson("/api/sites/{$site->id}");
|
|
|
|
$response->assertOk()
|
|
->assertJsonPath('data.api_instructions', 'POST to /api/publish with a bearer token from .env');
|
|
});
|