Files
coolify/tests/Feature/ProjectAndEnvironmentSettingsButtonTest.php
T
Andras Bacsai fdd69977a4 feat(canvas): show empty environments as placeholder cards
Environments without resources now appear as placeholder cards on the
project, team projects and server canvases. They sit in the zone that
holds most of their project's cards, or in a new "Empty environments"
zone when there is none. A new EmptyCard component renders them.

- Project canvas: admins can move groups and cards, and the moves are
  saved on their environment canvas. Environments are ordered by id.
- Server canvas: admins can move single cards as well as groups.
- Shared variable canvas: built-in COOLIFY_SERVER_UUID/NAME variables
  and their links are hidden on server scope.
- Main nav: resource menus register through registerMainNavContext()
  with depth levels (#main-nav-context-{depth}). Back goes one level
  lower, and Back at depth 0 returns to the main menu.
- The deploy canvas state, styles and controls are simplified, and the
  related sidebar, navbar and dashboard views are updated.

Tests are added or updated for the canvases and the main nav resource
menus.
2026-10-15 08:46:44 +02:00

73 lines
2.3 KiB
PHP

<?php
use App\Livewire\Project\Show as ProjectShow;
use App\Models\InstanceSettings;
use App\Models\Project;
use App\Models\Team;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use Livewire\Livewire;
uses(RefreshDatabase::class);
beforeEach(function () {
Queue::fake();
InstanceSettings::unguarded(fn () => InstanceSettings::query()->create(['id' => 0]));
$this->user = User::factory()->create();
$this->team = Team::factory()->create();
$this->user->teams()->attach($this->team, ['role' => 'owner']);
$this->actingAs($this->user);
session(['currentTeam' => $this->team]);
$this->project = Project::factory()->create([
'team_id' => $this->team->id,
'name' => 'Test Project',
]);
$this->environment = $this->project->environments()->firstOrFail();
});
test('project show page header links to project settings', function () {
$editUrl = route('project.edit', ['project_uuid' => $this->project->uuid]);
Livewire::test(ProjectShow::class, ['project_uuid' => $this->project->uuid])
->assertSee('Settings')
->assertSee('Project settings', false)
->assertSeeHtml($editUrl);
});
test('environment resources page header links to environment settings', function () {
$editUrl = route('project.environment.edit', [
'project_uuid' => $this->project->uuid,
'environment_uuid' => $this->environment->uuid,
]);
$this->get(route('project.resource.index', [
'project_uuid' => $this->project->uuid,
'environment_uuid' => $this->environment->uuid,
]))
->assertSuccessful()
->assertSee('Settings')
->assertSee('Environment settings', false)
->assertSee($editUrl, false);
});
test('empty environment resources page header links to the canvas', function () {
$canvasUrl = route('project.environment.canvas', [
'project_uuid' => $this->project->uuid,
'environment_uuid' => $this->environment->uuid,
]);
$this->get(route('project.resource.index', [
'project_uuid' => $this->project->uuid,
'environment_uuid' => $this->environment->uuid,
]))
->assertSuccessful()
->assertSee('No resources yet')
->assertSee($canvasUrl, false);
});