fix(environment): keep Compose self-references editable

This commit is contained in:
Andras Bacsai
2026-08-15 10:59:04 +02:00
parent 096a1f5f08
commit ec8a24d178
2 changed files with 72 additions and 1 deletions
@@ -182,6 +182,42 @@ YAML,
->toBe(['API_TOKEN']);
});
it('keeps Compose self-referencing environment variables editable without changing Compose', function () {
$dockerCompose = <<<'YAML'
services:
app:
image: nginx
environment:
API_TOKEN: ${API_TOKEN}
LOG_LEVEL: ${LOG_LEVEL:-info}
FIXED_VALUE: production
YAML;
$service = Service::factory()->create([
'environment_id' => $this->environment->id,
'docker_compose_raw' => $dockerCompose,
]);
foreach (['API_TOKEN', 'LOG_LEVEL'] as $key) {
EnvironmentVariable::create([
'key' => $key,
'resourceable_type' => Service::class,
'resourceable_id' => $service->id,
]);
}
$rows = Livewire::test(All::class, ['resource' => $service])
->call('loadEnvironmentVariables')
->instance()
->environmentVariablePageRows;
expect($rows->where('kind', 'managed')->pluck('environmentVariable.key')->all())
->toBe(['API_TOKEN', 'LOG_LEVEL'])
->and($rows->where('kind', 'hardcoded')->pluck('environmentVariable.key')->all())
->toBe(['FIXED_VALUE'])
->and($service->fresh()->docker_compose_raw)->toBe($dockerCompose);
});
it('shows a Compose-defined value as read-only when a managed variable has the same key', function () {
$service = Service::factory()->create([
'environment_id' => $this->environment->id,