mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 10:42:23 +00:00
A locked variable used by Docker Compose could not be changed, unlocked, or deleted, so a lock by mistake had no fix in the UI. A locked value can now be replaced without showing it. The lock is permanent in the UI, the API, and MCP, and Lock asks for confirmation. Closes #6803 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
3.2 KiB
PHP
77 lines
3.2 KiB
PHP
<?php
|
|
|
|
use App\Livewire\Project\Shared\EnvironmentVariable\Add;
|
|
use App\Livewire\Project\Shared\EnvironmentVariable\Show;
|
|
use App\Models\Application;
|
|
use App\Models\Environment;
|
|
use App\Models\EnvironmentVariable;
|
|
use App\Models\InstanceSettings;
|
|
use App\Models\Project;
|
|
use App\Models\SharedEnvironmentVariable;
|
|
use App\Models\Team;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
InstanceSettings::forceCreate(['id' => 0]);
|
|
|
|
$this->resourceTeam = Team::factory()->create();
|
|
$this->sessionTeam = Team::factory()->create();
|
|
$this->user = User::factory()->create();
|
|
$this->user->teams()->attach($this->resourceTeam, ['role' => 'member']);
|
|
$this->user->teams()->attach($this->sessionTeam, ['role' => 'owner']);
|
|
|
|
$this->project = Project::factory()->create(['team_id' => $this->resourceTeam->id]);
|
|
$this->environment = Environment::factory()->create(['project_id' => $this->project->id]);
|
|
$this->application = Application::factory()->create(['environment_id' => $this->environment->id]);
|
|
|
|
SharedEnvironmentVariable::create(['key' => 'RESOURCE_TEAM_VAR', 'value' => 'a', 'type' => 'team', 'team_id' => $this->resourceTeam->id]);
|
|
SharedEnvironmentVariable::create(['key' => 'SESSION_TEAM_VAR', 'value' => 'b', 'type' => 'team', 'team_id' => $this->sessionTeam->id]);
|
|
SharedEnvironmentVariable::create(['key' => 'RESOURCE_PROJECT_VAR', 'value' => 'c', 'type' => 'project', 'team_id' => $this->resourceTeam->id, 'project_id' => $this->project->id]);
|
|
|
|
$this->parameters = [
|
|
'project_uuid' => $this->project->uuid,
|
|
'environment_uuid' => $this->environment->uuid,
|
|
'application_uuid' => $this->application->uuid,
|
|
];
|
|
|
|
$this->actingAs($this->user);
|
|
session(['currentTeam' => $this->sessionTeam]);
|
|
});
|
|
|
|
test('add suggests shared variables of the resource team when the session team differs', function () {
|
|
$component = Livewire::test(Add::class, ['resource' => $this->application]);
|
|
$component->instance()->parameters = $this->parameters;
|
|
|
|
$suggestions = $component->instance()->availableSharedVariables();
|
|
|
|
expect($suggestions['team'])->toBe(['RESOURCE_TEAM_VAR'])
|
|
->and($suggestions['project'])->toBe(['RESOURCE_PROJECT_VAR']);
|
|
});
|
|
|
|
test('show suggests shared variables of the resource team when the session team differs', function () {
|
|
$env = EnvironmentVariable::create([
|
|
'key' => 'APP_VAR',
|
|
'value' => 'x',
|
|
'resourceable_type' => Application::class,
|
|
'resourceable_id' => $this->application->id,
|
|
]);
|
|
|
|
$component = Livewire::test(Show::class, ['env' => $env, 'type' => 'application']);
|
|
$component->instance()->parameters = $this->parameters;
|
|
|
|
$suggestions = $component->instance()->availableSharedVariables();
|
|
|
|
expect($suggestions['team'])->toBe(['RESOURCE_TEAM_VAR'])
|
|
->and($suggestions['project'])->toBe(['RESOURCE_PROJECT_VAR']);
|
|
});
|
|
|
|
test('add without a resource keeps suggesting the session team variables', function () {
|
|
$component = Livewire::test(Add::class, ['shared' => true]);
|
|
|
|
expect($component->instance()->availableSharedVariables()['team'])->toBe(['SESSION_TEAM_VAR']);
|
|
});
|