Implement Keystone environment deployments

This commit is contained in:
2026-05-13 16:11:23 +01:00
parent 65d3142d03
commit aa680b25fd
175 changed files with 10258 additions and 740 deletions

View File

@@ -0,0 +1,54 @@
<?php
use App\Enums\EnvironmentVariableSource;
use App\Models\Application;
use App\Models\Environment;
use App\Models\Organisation;
use App\Models\User;
use Inertia\Testing\AssertableInertia;
it('shows the user environment variable create page', function () {
$user = User::factory()->create();
$organisation = Organisation::factory()->create(['owner_id' => $user->id]);
$application = Application::factory()->for($organisation)->create();
$environment = Environment::factory()->for($application)->create();
$response = $this->actingAs($user)->get(route('environment-variables.create', [
'organisation' => $organisation->id,
'application' => $application->id,
'environment' => $environment->id,
]));
$response->assertOk();
$response->assertInertia(fn (AssertableInertia $page) => $page
->component('environment-variables/Create', false));
});
it('stores editable user-defined environment variables', function () {
$user = User::factory()->create();
$organisation = Organisation::factory()->create(['owner_id' => $user->id]);
$application = Application::factory()->for($organisation)->create();
$environment = Environment::factory()->for($application)->create();
$response = $this->actingAs($user)->post(route('environment-variables.store', [
'organisation' => $organisation->id,
'application' => $application->id,
'environment' => $environment->id,
]), [
'key' => 'APP_DEBUG',
'value' => 'false',
]);
$response->assertRedirect(route('applications.show', [
'organisation' => $organisation->id,
'application' => $application->id,
]));
$variable = $environment->variables()->firstOrFail();
expect($variable->key)->toBe('APP_DEBUG')
->and($variable->value)->toBe('false')
->and($variable->source)->toBe(EnvironmentVariableSource::USER)
->and($variable->overridable)->toBeTrue()
->and($variable->service_slice_id)->toBeNull();
});