feat(api): allow preview deployments on app create

Expose is_preview_deployments_enabled in the application create API
schema and validation, and skip deployment configuration column casts on
sqlite migrations.
This commit is contained in:
Andras Bacsai committed 2026-07-07 12:36:35 +02:00
1 parent 77086e28af
commit cf12e1d7ef
5 files changed
+96 -1

No files matched your search

@@ -1,7 +1,7 @@
<?php
use App\Models\Application;
use App\Models\Environment;
use App\Models\InstanceSettings;
use App\Models\Project;
use App\Models\Server;
use App\Models\StandaloneDocker;
@@ -13,6 +13,10 @@ use Visus\Cuid2\Cuid2;
uses(RefreshDatabase::class);
beforeEach(function () {
config(['app.maintenance.driver' => 'file']);
InstanceSettings::unguarded(fn () => InstanceSettings::firstOrCreate(['id' => 0]));
$this->team = Team::factory()->create();
$this->user = User::factory()->create();
$this->team->members()->attach($this->user->id, ['role' => 'owner']);
@@ -106,3 +110,42 @@ describe('PATCH /api/v1/applications/{uuid} is_preview_deployments_enabled', fun
$response->assertStatus(422);
});
});
describe('POST /api/v1/applications/public is_preview_deployments_enabled', function () {
test('can enable preview deployments on create', function () {
$response = $this->withHeaders(previewDeploymentsAuthHeaders($this->bearerToken))
->postJson('/api/v1/applications/public', [
'project_uuid' => $this->project->uuid,
'environment_uuid' => $this->environment->uuid,
'server_uuid' => $this->server->uuid,
'git_repository' => 'https://gitlab.com/coolify/test-preview-app',
'git_branch' => 'main',
'build_pack' => 'nixpacks',
'ports_exposes' => '3000',
'is_preview_deployments_enabled' => true,
'autogenerate_domain' => false,
]);
$response->assertCreated();
$application = Application::where('uuid', $response->json('uuid'))->firstOrFail();
expect($application->settings->is_preview_deployments_enabled)->toBeTrue();
});
test('rejects non-boolean value on create', function () {
$response = $this->withHeaders(previewDeploymentsAuthHeaders($this->bearerToken))
->postJson('/api/v1/applications/public', [
'project_uuid' => $this->project->uuid,
'environment_uuid' => $this->environment->uuid,
'server_uuid' => $this->server->uuid,
'git_repository' => 'https://gitlab.com/coolify/test-preview-app',
'git_branch' => 'main',
'build_pack' => 'nixpacks',
'ports_exposes' => '3000',
'is_preview_deployments_enabled' => 'yes',
'autogenerate_domain' => false,
]);
$response->assertUnprocessable();
});
});