Add free-text api_instructions field to Sites

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>
This commit is contained in:
m105
2026-07-22 14:03:43 +03:00
co-authored by Claude Sonnet 5
parent 4b3af4cc89
commit b3b250aaca
9 changed files with 110 additions and 5 deletions
+12
View File
@@ -46,3 +46,15 @@ test('it includes WordPress fields in the site response', function () {
->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');
});
+21
View File
@@ -121,3 +121,24 @@ test('switching a WordPress site to a non-WordPress cms_type clears its credenti
->wp_username->toBeNull()
->wp_app_password->toBeNull();
});
test('a custom site can be created with api_instructions', function () {
Livewire::test(Index::class)
->set('name', 'Custom Site')
->set('url', 'https://custom.example.com')
->set('cmsType', 'custom')
->set('apiInstructions', 'POST to /api/publish with a bearer token from .env')
->call('save');
$site = Site::where('name', 'Custom Site')->first();
expect($site->api_instructions)->toBe('POST to /api/publish with a bearer token from .env');
});
test('editing a site loads its api_instructions', function () {
$site = Site::factory()->create(['cms_type' => 'custom', 'api_instructions' => 'Use the /publish endpoint']);
Livewire::test(Index::class)
->call('edit', $site->id)
->assertSet('apiInstructions', 'Use the /publish endpoint');
});
+17
View File
@@ -50,3 +50,20 @@ test('a site can be created as WordPress with credentials', function () {
->wp_username->toBe('admin')
->wp_app_password->toBe('abcd 1234 efgh 5678');
});
test('a custom site can store free-text api_instructions', function () {
$site = Site::create([
'name' => 'Custom Site',
'url' => 'https://custom.example.com',
'cms_type' => 'custom',
'api_instructions' => 'POST to /api/publish with a bearer token from .env',
]);
expect($site->fresh()->api_instructions)->toBe('POST to /api/publish with a bearer token from .env');
});
test('api_instructions defaults to null', function () {
$site = Site::create(['name' => 'My Blog', 'url' => 'https://example.com']);
expect($site->fresh()->api_instructions)->toBeNull();
});