Merge remote-tracking branch 'origin/next' into api-sensitive-data-scrubber

This commit is contained in:
Andras Bacsai committed 2026-06-15 12:30:15 +02:00
commit 2ebe2e8dbb
187 files changed
+4319 -952

No files matched your search

+16 -1
View File
@@ -36,10 +36,25 @@ it('uses geist mono for shared logs and terminal rendering', function () {
->toContain('class="flex flex-col font-logs"')
->toContain('class="font-logs text-neutral-400 mb-2"')
->and($activityMonitorView)
->toContain('<pre class="font-logs whitespace-pre-wrap"')
->toContain('<pre class="font-logs min-w-0 max-w-full whitespace-pre-wrap wrap-anywhere"')
->and($dockerCleanupView)
->toContain('class="flex-1 text-sm font-logs text-gray-700 dark:text-gray-300"')
->toContain('class="font-logs text-sm text-gray-600 dark:text-gray-300 whitespace-pre-wrap"')
->and($terminalClient)
->toContain('"Geist Mono"');
});
it('constrains activity monitor logs inside the available viewport', function () {
$activityMonitorView = file_get_contents(resource_path('views/livewire/activity-monitor.blade.php'));
expect($activityMonitorView)
->toContain('flex flex-col w-full min-w-0 max-w-full')
->toContain('<pre class="font-logs min-w-0 max-w-full whitespace-pre-wrap wrap-anywhere"');
});
it('bounds database startup activity monitor to the slide over height', function () {
$databaseHeadingView = file_get_contents(resource_path('views/livewire/project/database/heading.blade.php'));
expect($databaseHeadingView)
->toContain('<div wire:ignore class="h-full min-h-0 min-w-0 max-w-full">');
});
+146
View File
@@ -0,0 +1,146 @@
<?php
it('uses native mobile menus for databases and services', function () {
$applicationHeading = file_get_contents(resource_path('views/livewire/project/application/heading.blade.php'));
$databaseHeading = file_get_contents(resource_path('views/livewire/project/database/heading.blade.php'));
$serviceHeading = file_get_contents(resource_path('views/livewire/project/service/heading.blade.php'));
$applicationMobileActions = mobileActionsMarkup($applicationHeading, 'application-mobile-actions', 'application-mobile-section');
$databaseMobileActions = mobileActionsMarkup($databaseHeading, 'database-mobile-actions', 'database-mobile-section');
$serviceMobileActions = mobileActionsMarkup($serviceHeading, 'service-mobile-actions', 'service-mobile-section');
expect(mobileActionsAreBeforeSelect($applicationHeading, 'application-mobile-actions', 'application-mobile-section'))->toBeTrue();
expect(mobileActionsAreBeforeSelect($databaseHeading, 'database-mobile-actions', 'database-mobile-section'))->toBeTrue();
expect(mobileActionsAreBeforeSelect($serviceHeading, 'service-mobile-actions', 'service-mobile-section'))->toBeTrue();
expect($applicationHeading)
->toContain('application-mobile-actions')
->toContain("'route' => 'project.application.command'")
->toContain("'navigate' => false")
->toContain("value.startsWith('location|')")
->toContain('window.location.href = url')
->toContain('application-mobile-stop-trigger')
->toContain('application-mobile-deploy-trigger')
->toContain('application-mobile-restart-trigger')
->toContain('application-mobile-force-deploy-trigger')
->not->toContain('<optgroup label="Actions">');
expect($applicationMobileActions)
->toContain('mb-3')
->toContain('Actions')
->toContain('<x-forms.button isError class="shrink-0"')
->not->toContain('button type="button" class="button shrink-0 text-error"')
->toContain('M7 4v16l13 -8z')
->toContain('M19.933 13.041a8 8 0 1 1-9.925-8.788c3.899-1 7.935 1.007 9.425 4.747')
->toContain('M6 5m0 1a1 1 0 0 1 1 -1h2');
expect($applicationHeading)
->toContain('application-mobile-section-label')
->toContain('Section');
expect($databaseHeading)
->toContain('database-mobile-section')
->toContain('database-mobile-actions')
->toContain('<optgroup label="Database">')
->toContain('<optgroup label="Configuration">')
->toContain("'route' => 'project.database.command'")
->toContain("'navigate' => false")
->toContain("value.startsWith('location|')")
->toContain('window.location.href = url')
->toContain('window.Livewire?.navigate ? window.Livewire.navigate(url) : window.location.href = url')
->toContain("window.Livewire?.hook?.('morphed'")
->toContain('x-model="selected"')
->toContain('database-restart-trigger')
->toContain('database-stop-trigger')
->toContain('database-start-trigger')
->toContain('scrollbar hidden min-h-10')
->not->toContain('<optgroup label="Links">')
->not->toContain('<optgroup label="Actions">')
->not->toContain('@selected');
expect($databaseMobileActions)
->toContain('mb-3')
->toContain('Actions')
->toContain('<x-forms.button isError class="shrink-0"')
->not->toContain('button type="button" class="button shrink-0 text-error"')
->toContain('M7 4v16l13 -8z')
->toContain('M19.933 13.041a8 8 0 1 1-9.925-8.788c3.899-1 7.935 1.007 9.425 4.747')
->toContain('M6 5m0 1a1 1 0 0 1 1 -1h2');
expect($databaseHeading)
->toContain('database-mobile-section-label')
->toContain('Section');
expect($serviceHeading)
->toContain('service-mobile-section')
->toContain('service-mobile-actions')
->toContain('<optgroup label="Service">')
->toContain('<optgroup label="Configuration">')
->toContain('<optgroup label="Resource">')
->toContain('<optgroup label="Links">')
->toContain("'route' => 'project.service.command'")
->toContain("'navigate' => false")
->toContain("value.startsWith('location|')")
->toContain('window.location.href = url')
->toContain('window.Livewire?.navigate ? window.Livewire.navigate(url) : window.location.href = url')
->toContain("window.Livewire?.hook?.('morphed'")
->toContain('x-model="selected"')
->toContain('service-restart-trigger')
->toContain('service-stop-trigger')
->toContain('service-forceDeploy-trigger')
->toContain('service-pullAndRestart-trigger')
->toContain('scrollbar hidden min-h-10')
->toContain('mb-4 w-full md:mb-0 md:hidden')
->toContain('hidden flex-wrap items-center gap-2 md:flex')
->toContain('flex flex-nowrap')
->toContain('overflow-x-auto')
->not->toContain('<optgroup label="Actions">')
->not->toContain('order-first flex flex-wrap items-center gap-2 sm:order-last')
->not->toContain('@selected');
expect($serviceMobileActions)
->toContain('mb-3')
->toContain('Actions')
->toContain('<x-forms.button isError class="shrink-0"')
->not->toContain('button type="button" class="button shrink-0 text-error"')
->toContain('M7 4v16l13 -8z')
->toContain('M19.933 13.041a8 8 0 1 1-9.925-8.788c3.899-1 7.935 1.007 9.425 4.747')
->toContain('M6 5m0 1a1 1 0 0 1 1 -1h2');
expect($serviceHeading)
->toContain('service-mobile-section-label')
->toContain('Section');
});
function mobileActionsMarkup(string $heading, string $actionsId, string $selectId): string
{
$actionsPosition = strpos($heading, 'id="'.$actionsId.'"');
$selectPosition = strpos($heading, 'id="'.$selectId.'"');
if ($actionsPosition === false || $selectPosition === false || $actionsPosition > $selectPosition) {
return '';
}
return substr($heading, $actionsPosition, $selectPosition - $actionsPosition);
}
function mobileActionsAreBeforeSelect(string $heading, string $actionsId, string $selectId): bool
{
$actionsPosition = strpos($heading, 'id="'.$actionsId.'"');
$selectPosition = strpos($heading, 'id="'.$selectId.'"');
return $actionsPosition !== false && $selectPosition !== false && $actionsPosition < $selectPosition;
}
it('keeps configuration sidebars hidden until desktop breakpoint', function () {
expect(file_get_contents(resource_path('views/livewire/project/database/configuration.blade.php')))
->toContain('sub-menu-wrapper hidden md:flex');
expect(file_get_contents(resource_path('views/livewire/project/service/configuration.blade.php')))
->toContain('sub-menu-wrapper hidden md:flex');
expect(file_get_contents(resource_path('views/livewire/project/service/index.blade.php')))
->toContain('sub-menu-wrapper hidden md:flex');
expect(file_get_contents(resource_path('views/components/service-database/sidebar.blade.php')))
->toContain('sub-menu-wrapper hidden md:flex');
});
@@ -0,0 +1,60 @@
<?php
use App\Actions\Application\CleanupPreviewDeployment;
use App\Jobs\ProcessGithubPullRequestWebhook;
use App\Models\Application;
use App\Models\ApplicationPreview;
use App\Models\Environment;
use App\Models\InstanceSettings;
use App\Models\Project;
use App\Models\Server;
use App\Models\StandaloneDocker;
use App\Models\Team;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
beforeEach(function () {
InstanceSettings::unguarded(fn () => InstanceSettings::firstOrCreate(['id' => 0]));
$this->team = Team::factory()->create();
$this->server = Server::factory()->create(['team_id' => $this->team->id]);
$this->destination = StandaloneDocker::where('server_id', $this->server->id)->first();
$this->project = Project::factory()->create(['team_id' => $this->team->id]);
$this->environment = Environment::factory()->create(['project_id' => $this->project->id]);
$this->application = Application::factory()->create([
'environment_id' => $this->environment->id,
'destination_id' => $this->destination->id,
'destination_type' => $this->destination->getMorphClass(),
]);
});
it('cleans up a closed pull request preview when pull request comment cleanup fails', function () {
$preview = ApplicationPreview::create([
'application_id' => $this->application->id,
'pull_request_id' => 42,
'pull_request_html_url' => 'https://github.com/example/repo/pull/42',
]);
CleanupPreviewDeployment::shouldRun()
->once()
->withArgs(fn (Application $application, int $pullRequestId, ApplicationPreview $applicationPreview): bool => $application->is($this->application)
&& $pullRequestId === 42
&& $applicationPreview->is($preview))
->andReturn([
'cancelled_deployments' => 0,
'killed_containers' => 0,
'status' => 'success',
]);
$job = new class(applicationId: $this->application->id, githubAppId: null, action: 'closed', pullRequestId: 42, pullRequestHtmlUrl: 'https://github.com/example/repo/pull/42', pullRequestTitle: null, beforeSha: null, afterSha: null, commitSha: 'HEAD', authorAssociation: 'OWNER', fullName: 'example/repo') extends ProcessGithubPullRequestWebhook
{
protected function dispatchPullRequestClosedUpdate(Application $application, ApplicationPreview $preview): void
{
throw new RuntimeException('GitHub comment cleanup failed.');
}
};
$job->handle();
});
@@ -87,6 +87,35 @@ it('renders responsive checkbox classes on the application configuration page',
$response->assertSuccessful();
$response->assertSee('Use a Build Server?');
$response->assertSee('application-mobile-section');
$response->assertSee('Application menu');
$response->assertSee('<optgroup label="Application">', false);
$response->assertSee('<optgroup label="Configuration">', false);
$response->assertSee('<optgroup label="Links">', false);
$response->assertSee('<optgroup label="Actions">', false);
$response->assertSee('value="navigate|application|', false);
$response->assertSee('value="navigate|configuration|', false);
$response->assertSee('window.Livewire?.navigate ? window.Livewire.navigate(url) : window.location.href = url', false);
$response->assertSee('value="action:force-deploy"', false);
$response->assertSee('application-mobile-stop-trigger');
$response->assertSee('application-mobile-deploy-trigger');
$response->assertSee('application-mobile-restart-trigger');
$response->assertSee('application-mobile-force-deploy-trigger');
$response->assertSee('Confirm Application Deployment?');
$response->assertSee('Confirm Application Restart?');
$response->assertSee('Confirm Application Force Deployment?');
$response->assertSee('sub-menu-wrapper hidden md:flex', false);
$response->assertSee('scrollbar hidden min-h-10', false);
$response->assertSee(route('project.application.deployment.index', [
'project_uuid' => $this->project->uuid,
'environment_uuid' => $this->environment->uuid,
'application_uuid' => $this->application->uuid,
]));
$response->assertSee(route('project.application.environment-variables', [
'project_uuid' => $this->project->uuid,
'environment_uuid' => $this->environment->uuid,
'application_uuid' => $this->application->uuid,
]));
$response->assertSee('form-control flex max-w-full flex-row items-center gap-4 py-1 pr-2', false);
$response->assertSee('label flex w-full max-w-full min-w-0 items-center gap-4 px-0', false);
$response->assertSee('flex min-w-0 grow gap-2 break-words', false);
@@ -0,0 +1,27 @@
<?php
it('uses left aligned single color status badges in the server header', function () {
$navbarView = file_get_contents(resource_path('views/livewire/server/navbar.blade.php'));
$badgeView = file_get_contents(resource_path('views/components/status-badge.blade.php'));
expect($navbarView)
->toContain('data-testid="server-status-summary"')
->toContain('<x-status-badge')
->toContain('label="Proxy"')
->toContain('label="Sentinel"')
->toContain('as="button"')
->toContain("wire:click='checkProxyStatus'")
->toContain('status="Refresh"')
->toContain('border-transparent')
->toContain('wire:loading.attr="disabled"')
->not->toContain('status="Refreshing..."')
->not->toContain('justify-between')
->not->toContain('<x-status.stopped status="Proxy Exited" noLoading />')
->not->toContain('<x-status.running status="Sentinel In Sync" noLoading />');
expect($badgeView)
->not->toContain('text-neutral-500')
->not->toContain('dark:text-neutral-400')
->toContain('<button')
->toContain("merge(['type' => 'button'])");
});
+47
View File
@@ -0,0 +1,47 @@
<?php
use App\Models\Environment;
use App\Models\Project;
use App\Models\Server;
use App\Models\Service;
use App\Models\StandaloneDocker;
use App\Models\Team;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
function serviceExtraFieldsTestServiceWithApplicationImage(string $image): Service
{
$team = Team::factory()->create();
$project = Project::factory()->create(['team_id' => $team->id]);
$environment = Environment::factory()->create(['project_id' => $project->id]);
$server = Server::factory()->create();
$destination = StandaloneDocker::factory()->create(['server_id' => $server->id]);
$service = Service::factory()->create([
'environment_id' => $environment->id,
'server_id' => $server->id,
'destination_id' => $destination->id,
'destination_type' => StandaloneDocker::class,
]);
$service->applications()->create([
'name' => 'app',
'image' => $image,
]);
return $service;
}
it('only adds Grafana extra fields for Grafana server images', function (string $image, bool $shouldHaveGrafanaFields) {
$fields = serviceExtraFieldsTestServiceWithApplicationImage($image)->extraFields();
expect($fields->has('Grafana'))->toBe($shouldHaveGrafanaFields);
})->with([
'grafana oss' => ['grafana/grafana-oss:latest', true],
'grafana enterprise' => ['grafana/grafana-enterprise:latest', true],
'grafana default' => ['grafana/grafana:latest', true],
'loki' => ['grafana/loki:latest', false],
'promtail' => ['grafana/promtail:latest', false],
'tempo' => ['grafana/tempo:latest', false],
]);
+114
View File
@@ -0,0 +1,114 @@
<?php
it('renders application and database statuses as shared status badges', function (string $status, string $expectedText) {
$resource = new class($status)
{
public function __construct(public string $status) {}
};
$html = view('components.status.index', [
'resource' => $resource,
'showRefreshButton' => false,
])->render();
expect($html)
->toContain('inline-flex h-5 max-w-full items-center gap-1 rounded-sm border')
->toContain($expectedText)
->not->toContain('badge-success')
->not->toContain('badge-warning')
->not->toContain('badge-error');
})->with([
'running healthy' => ['running:healthy', 'Running (healthy)'],
'starting unknown' => ['starting:unknown', 'Starting (unknown)'],
'degraded unhealthy' => ['degraded:unhealthy', 'Degraded (unhealthy)'],
'exited unhealthy' => ['exited:unhealthy', 'Exited'],
]);
it('renders service container statuses as shared status badges', function () {
$html = view('components.status.services', [
'complexStatus' => 'running:healthy',
'showRefreshButton' => false,
])->render();
expect($html)
->toContain('inline-flex h-5 max-w-full items-center gap-1 rounded-sm border')
->toContain('Running (healthy)')
->not->toContain('badge-success');
});
it('uses a shared refresh badge for resource status refresh actions', function () {
$statusIndex = file_get_contents(resource_path('views/components/status/index.blade.php'));
$serviceStatus = file_get_contents(resource_path('views/components/status/services.blade.php'));
expect($statusIndex)
->toContain('<x-status-badge as="button"')
->toContain("wire:click='manualCheckStatus'")
->toContain('wire:loading.attr="disabled"')
->not->toContain('status="Refreshing..."')
->toContain('wire:loading.attr="disabled"')
->not->toContain('status="Refreshing..."')
->not->toContain('<svg');
expect(file_get_contents(resource_path('views/livewire/project/service/resource-card.blade.php')))
->toContain('<x-status-badge')
->toContain('formatContainerStatus($resource->status)');
expect($serviceStatus)
->toContain('<x-status-badge as="button"')
->toContain("wire:click='manualCheckStatus'")
->not->toContain('<svg');
});
it('renders health warning helpers as badges instead of warning icons', function () {
$html = view('components.status.running', [
'status' => 'running:unknown',
])->render();
$runningStatus = file_get_contents(resource_path('views/components/status/running.blade.php'));
expect($html)
->toContain('No health check')
->toContain('inline-flex h-5 max-w-full items-center gap-1 rounded-sm border')
->not->toContain('<svg');
expect($runningStatus)
->toContain('<x-status-badge')
->toContain('class="flex items-center gap-1"')
->not->toContain('class="px-2"')
->not->toContain('viewBox="0 0 256 256"');
});
it('renders restart counts as warning badges', function () {
$resource = new class
{
public string $status = 'running:unknown';
public int $restart_count = 9;
public ?int $max_restart_count = null;
public ?string $last_restart_type = null;
public $last_restart_at;
public function __construct()
{
$this->last_restart_at = now();
}
};
$html = view('components.status.index', [
'resource' => $resource,
'showRefreshButton' => false,
])->render();
$statusIndex = file_get_contents(resource_path('views/components/status/index.blade.php'));
expect($html)
->toContain('9x restarts')
->toContain('border-yellow-300 bg-yellow-50')
->not->toContain('(9x restarts)');
expect($statusIndex)
->toContain('<x-status-badge')
->toContain('restart_count')
->not->toContain('class="text-xs dark:text-warning"');
});
@@ -5,6 +5,7 @@ use App\Models\Subscription;
use App\Models\Team;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Stripe\Exception\InvalidRequestException;
use Stripe\Service\InvoiceService;
use Stripe\Service\RefundService;
use Stripe\Service\SubscriptionService;
@@ -85,6 +86,28 @@ describe('checkEligibility', function () {
expect($result['current_period_end'])->toBe($periodEnd);
});
test('returns eligible when subscription is set to cancel at period end', function () {
$this->subscription->update(['stripe_cancel_at_period_end' => true]);
$periodEnd = now()->addDays(20)->timestamp;
$stripeSubscription = (object) [
'status' => 'active',
'start_date' => now()->subDays(10)->timestamp,
'current_period_end' => $periodEnd,
];
$this->mockSubscriptions
->shouldReceive('retrieve')
->with('sub_test_123')
->andReturn($stripeSubscription);
$action = new RefundSubscription($this->mockStripe);
$result = $action->checkEligibility($this->team);
expect($result['eligible'])->toBeTrue();
expect($result['days_remaining'])->toBe(20);
});
test('returns ineligible when subscription is not active', function () {
$periodEnd = now()->addDays(25)->timestamp;
$stripeSubscription = (object) [
@@ -141,7 +164,7 @@ describe('checkEligibility', function () {
$this->mockSubscriptions
->shouldReceive('retrieve')
->with('sub_test_123')
->andThrow(new \Stripe\Exception\InvalidRequestException('No such subscription'));
->andThrow(new InvalidRequestException('No such subscription'));
$action = new RefundSubscription($this->mockStripe);
$result = $action->checkEligibility($this->team);
@@ -269,6 +292,7 @@ describe('execute', function () {
$stripeSubscription = (object) [
'status' => 'active',
'start_date' => now()->subDays(10)->timestamp,
'current_period_end' => now()->addDays(20)->timestamp,
];
$this->mockSubscriptions
@@ -298,7 +322,7 @@ describe('execute', function () {
$this->mockSubscriptions
->shouldReceive('cancel')
->with('sub_test_123')
->andThrow(new \Exception('Stripe cancel API error'));
->andThrow(new Exception('Stripe cancel API error'));
$action = new RefundSubscription($this->mockStripe);
$result = $action->execute($this->team);
@@ -0,0 +1,70 @@
<?php
use App\Actions\Stripe\RefundSubscription;
use App\Livewire\Subscription\Actions;
use App\Models\InstanceSettings;
use App\Models\Subscription;
use App\Models\Team;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
uses(RefreshDatabase::class);
beforeEach(function () {
config()->set('constants.coolify.self_hosted', false);
config()->set('subscription.provider', 'stripe');
config()->set('subscription.stripe_api_key', 'sk_test_fake');
InstanceSettings::unguarded(fn () => InstanceSettings::query()->create(['id' => 0]));
$this->team = Team::factory()->create();
$this->user = User::factory()->create();
$this->team->members()->attach($this->user->id, ['role' => 'owner']);
Subscription::create([
'team_id' => $this->team->id,
'stripe_subscription_id' => 'sub_test_123',
'stripe_customer_id' => 'cus_test_123',
'stripe_invoice_paid' => true,
'stripe_plan_id' => 'price_test_123',
'stripe_cancel_at_period_end' => false,
'stripe_past_due' => false,
]);
$this->actingAs($this->user);
session(['currentTeam' => $this->team]);
});
describe('cancelImmediately with refund option', function () {
test('refunds and cancels via RefundSubscription when refund checkbox is selected', function () {
$mock = Mockery::mock(RefundSubscription::class);
$mock->shouldReceive('execute')->once()->andReturn(['success' => true, 'error' => null]);
$this->instance(RefundSubscription::class, $mock);
Livewire::test(Actions::class)
->call('cancelImmediately', 'password', ['refundLatestPayment'])
->assertDispatched('success')
->assertRedirect(route('subscription.index'));
});
test('dispatches error when refund fails', function () {
$mock = Mockery::mock(RefundSubscription::class);
$mock->shouldReceive('execute')->once()->andReturn(['success' => false, 'error' => 'No paid invoice found to refund.']);
$this->instance(RefundSubscription::class, $mock);
Livewire::test(Actions::class)
->call('cancelImmediately', 'password', ['refundLatestPayment'])
->assertDispatched('error');
});
test('rejects invalid password before refunding', function () {
$mock = Mockery::mock(RefundSubscription::class);
$mock->shouldNotReceive('execute');
$this->instance(RefundSubscription::class, $mock);
Livewire::test(Actions::class)
->call('cancelImmediately', 'wrong-password', ['refundLatestPayment'])
->assertReturned('Invalid password.');
});
});
+13
View File
@@ -0,0 +1,13 @@
<?php
test('expanded navbar theme item cycles themes without a right side selector', function () {
$navbar = file_get_contents(__DIR__.'/../../resources/views/components/navbar.blade.php');
expect(substr_count($navbar, '@click.stop="cycleTheme()"'))->toBe(2)
->and($navbar)->not->toContain('aria-label="Theme switcher"')
->and($navbar)->not->toContain('ml-auto flex items-center gap-0.5')
->and($navbar)->not->toContain('@click.stop="setTheme(\'light\')"')
->and($navbar)->not->toContain('@click.stop="setTheme(\'system\')"')
->and($navbar)->not->toContain('@click.stop="setTheme(\'dark\')"')
->and($navbar)->toContain('<span class="text-left menu-item-label">Theme</span>');
});