mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-16 16:15:36 +00:00
Merge remote-tracking branch 'origin/next' into api-sensitive-data-scrubber
This commit is contained in:
commit
2fcc42b0a9
16 files changed
+1071
-142
No files matched your search
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
it('shows an empty state when there are no projects', function () {
|
||||
$this->view('livewire.project.index', [
|
||||
'projects' => collect(),
|
||||
])
|
||||
->assertSee('No projects found.')
|
||||
->assertSee('onboarding');
|
||||
});
|
||||
|
||||
it('does not show the empty state when projects exist', function () {
|
||||
$project = new class
|
||||
{
|
||||
public string $name = 'Test Project';
|
||||
|
||||
public string $description = 'A project description';
|
||||
|
||||
public string $uuid = 'test-project-uuid';
|
||||
|
||||
public $environments;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->environments = collect();
|
||||
}
|
||||
|
||||
public function navigateTo(): string
|
||||
{
|
||||
return '#';
|
||||
}
|
||||
};
|
||||
|
||||
$this->view('livewire.project.index', [
|
||||
'projects' => collect([$project]),
|
||||
])
|
||||
->assertSee('Test Project')
|
||||
->assertDontSee('No projects found.');
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use App\Console\Commands\Generate\Services;
|
||||
use Illuminate\Console\OutputStyle;
|
||||
use Illuminate\Support\Facades\Process;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
|
||||
it('adds the last git commit timestamp to generated service template payloads', function () {
|
||||
$command = new Services;
|
||||
$command->setOutput(new OutputStyle(new ArrayInput([]), new NullOutput));
|
||||
$method = new ReflectionMethod($command, 'processFile');
|
||||
|
||||
$payload = $method->invoke($command, 'activepieces.yaml');
|
||||
|
||||
$expectedTimestamp = Process::run([
|
||||
'git',
|
||||
'log',
|
||||
'-1',
|
||||
'--format=%cI',
|
||||
'--',
|
||||
'templates/compose/activepieces.yaml',
|
||||
])->throw()->output();
|
||||
|
||||
expect($payload)
|
||||
->toHaveKey('template_last_updated_at')
|
||||
->and($payload['template_last_updated_at'])
|
||||
->toBe(trim($expectedTimestamp));
|
||||
});
|
||||
@@ -3,6 +3,7 @@
|
||||
use App\Livewire\Project\New\Select;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\ViewErrorBag;
|
||||
|
||||
@@ -22,38 +23,56 @@ it('returns the service templates bundle last updated timestamp', function () {
|
||||
->toBe(CarbonImmutable::createFromTimestamp(filemtime($templatePath))->timezone(config('app.timezone'))->format('M j, Y H:i'));
|
||||
});
|
||||
|
||||
it('returns each service template last updated timestamp', function () {
|
||||
it('returns each service template last updated timestamp from the generated bundle', function () {
|
||||
$component = new Select;
|
||||
$templatePath = base_path('templates/compose/activepieces.yaml');
|
||||
$templates = json_decode(file_get_contents(base_path('templates/'.config('constants.services.file_name'))), true);
|
||||
$templateTimestamp = $templates['activepieces']['template_last_updated_at'];
|
||||
|
||||
$resources = $component->loadServices();
|
||||
|
||||
expect($resources['services']['activepieces'])
|
||||
->toHaveKey('templateLastUpdated')
|
||||
->and($resources['services']['activepieces']['templateLastUpdated'])
|
||||
->toBe(CarbonImmutable::createFromTimestamp(filemtime($templatePath))->timezone(config('app.timezone'))->format('M j, Y H:i'));
|
||||
->toBe(CarbonImmutable::parse($templateTimestamp)->timezone(config('app.timezone'))->format('M j, Y H:i'));
|
||||
});
|
||||
|
||||
it('uses a service template timestamp cache keyed by bundle mtime', function () {
|
||||
$bundleMtime = filemtime(base_path('templates/'.config('constants.services.file_name')));
|
||||
Cache::put("service-template-last-updated-map:{$bundleMtime}", [
|
||||
'activepieces' => 'Cached timestamp',
|
||||
], now()->addDay());
|
||||
it('prefers embedded service template git timestamps from the templates bundle', function () {
|
||||
File::shouldReceive('get')
|
||||
->with(base_path('templates/'.config('constants.services.file_name')))
|
||||
->andReturn(json_encode([
|
||||
'activepieces' => [
|
||||
'documentation' => 'https://coolify.io/docs',
|
||||
'slogan' => 'Open source no-code business automation.',
|
||||
'compose' => '',
|
||||
'tags' => null,
|
||||
'category' => 'automation',
|
||||
'logo' => 'images/default.webp',
|
||||
'minversion' => '0.0.0',
|
||||
'template_last_updated_at' => '2026-05-31T12:34:56+00:00',
|
||||
],
|
||||
]));
|
||||
|
||||
$resources = (new Select)->loadServices();
|
||||
|
||||
expect($resources['services']['activepieces']['templateLastUpdated'])->toBe('Cached timestamp');
|
||||
expect($resources['services']['activepieces']['templateLastUpdated'])->toBe('May 31, 2026 12:34');
|
||||
});
|
||||
|
||||
it('does not use stale service template timestamp cache entries from another bundle mtime', function () {
|
||||
$bundleMtime = filemtime(base_path('templates/'.config('constants.services.file_name')));
|
||||
Cache::put('service-template-last-updated-map:'.($bundleMtime - 1), [
|
||||
'activepieces' => 'Stale cached timestamp',
|
||||
], now()->addDay());
|
||||
it('caches parsed local service templates by bundle mtime', function () {
|
||||
Cache::flush();
|
||||
|
||||
$resources = (new Select)->loadServices();
|
||||
$path = base_path('templates/'.config('constants.services.file_name'));
|
||||
$json = file_get_contents($path);
|
||||
|
||||
expect($resources['services']['activepieces']['templateLastUpdated'])->not->toBe('Stale cached timestamp');
|
||||
File::partialMock()
|
||||
->shouldReceive('get')
|
||||
->once()
|
||||
->with($path)
|
||||
->andReturn($json);
|
||||
|
||||
$first = get_service_templates();
|
||||
$second = get_service_templates();
|
||||
|
||||
expect($first->keys()->all())->toBe($second->keys()->all());
|
||||
});
|
||||
|
||||
it('renders the service templates last updated hint placeholder', function () {
|
||||
|
||||
Reference in new issue
Block a user