mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 15:39:59 +00:00
- Delete Blade components, component classes, Livewire components and views that nothing uses after the redesign. - Delete tests that only compare Blade/CSS source text; keep the source checks for authorization gates, stable wire:key values and escaping. - Update stale tests to the current UI and behaviour. - Update DESIGN.md to the current navigation and layout. - Add a lesson: test behaviour, not source markup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
2.1 KiB
PHP
57 lines
2.1 KiB
PHP
<?php
|
|
|
|
use App\Livewire\Project\Shared\EnvironmentVariable\Add;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
it('has availableSharedVariables computed property', function () {
|
|
$component = new Add;
|
|
|
|
// Check that the method exists
|
|
expect(method_exists($component, 'availableSharedVariables'))->toBeTrue();
|
|
});
|
|
|
|
it('component has required properties for environment variable autocomplete', function () {
|
|
$component = new Add;
|
|
|
|
expect($component)->toHaveProperty('key')
|
|
->and($component)->toHaveProperty('value')
|
|
->and($component)->toHaveProperty('is_multiline')
|
|
->and($component)->toHaveProperty('is_literal')
|
|
->and($component)->toHaveProperty('is_runtime')
|
|
->and($component)->toHaveProperty('is_buildtime')
|
|
->and($component)->toHaveProperty('parameters');
|
|
});
|
|
|
|
it('returns empty arrays when currentTeam returns null', function () {
|
|
// Mock Auth facade to return null for user
|
|
Auth::shouldReceive('user')
|
|
->andReturn(null);
|
|
|
|
$component = new Add;
|
|
$component->parameters = [];
|
|
|
|
$result = $component->availableSharedVariables();
|
|
|
|
expect($result)->toBe([
|
|
'team' => [],
|
|
'project' => [],
|
|
'environment' => [],
|
|
'server' => [],
|
|
]);
|
|
});
|
|
|
|
it('availableSharedVariables method wraps authorization checks in try-catch blocks', function () {
|
|
// Read the source code to verify the authorization pattern
|
|
$reflectionMethod = new ReflectionMethod(Add::class, 'availableSharedVariables');
|
|
$source = file_get_contents($reflectionMethod->getFileName());
|
|
|
|
// Verify that the method contains authorization checks
|
|
expect($source)->toContain('$this->authorize(\'view\', $team)')
|
|
->and($source)->toContain('$this->authorize(\'view\', $project)')
|
|
->and($source)->toContain('$this->authorize(\'view\', $environment)')
|
|
->and($source)->toContain('$this->authorize(\'view\', $server)')
|
|
// Verify authorization checks are wrapped in try-catch blocks
|
|
->and($source)->toContain('use Illuminate\Auth\Access\AuthorizationException;')
|
|
->and($source)->toContain('} catch (AuthorizationException $e) {');
|
|
});
|