mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 17:21:04 +00:00
Merge branch 'next' into decouple-storage-from-sentinel
This commit is contained in:
@@ -214,3 +214,90 @@ it('sends immediate notifications when outdated traefik is detected', function (
|
||||
expect($notification->servers)->toHaveCount(1);
|
||||
expect($notification->servers->first()->outdatedInfo['type'])->toBe('patch_update');
|
||||
});
|
||||
|
||||
it('notification generates correct server proxy URLs', function () {
|
||||
$team = Team::factory()->create();
|
||||
$server = Server::factory()->create([
|
||||
'name' => 'Test Server',
|
||||
'team_id' => $team->id,
|
||||
'uuid' => 'test-uuid-123',
|
||||
]);
|
||||
|
||||
$server->outdatedInfo = [
|
||||
'current' => '3.5.0',
|
||||
'latest' => '3.5.6',
|
||||
'type' => 'patch_update',
|
||||
];
|
||||
|
||||
$notification = new TraefikVersionOutdated(collect([$server]));
|
||||
$mail = $notification->toMail($team);
|
||||
|
||||
// Verify the mail has the transformed servers with URLs
|
||||
expect($mail->viewData['servers'])->toHaveCount(1);
|
||||
expect($mail->viewData['servers'][0]['name'])->toBe('Test Server');
|
||||
expect($mail->viewData['servers'][0]['uuid'])->toBe('test-uuid-123');
|
||||
expect($mail->viewData['servers'][0]['url'])->toBe(base_url().'/server/test-uuid-123/proxy');
|
||||
expect($mail->viewData['servers'][0]['outdatedInfo'])->toBeArray();
|
||||
});
|
||||
|
||||
it('notification transforms multiple servers with URLs correctly', function () {
|
||||
$team = Team::factory()->create();
|
||||
$server1 = Server::factory()->create([
|
||||
'name' => 'Server 1',
|
||||
'team_id' => $team->id,
|
||||
'uuid' => 'uuid-1',
|
||||
]);
|
||||
$server1->outdatedInfo = [
|
||||
'current' => '3.5.0',
|
||||
'latest' => '3.5.6',
|
||||
'type' => 'patch_update',
|
||||
];
|
||||
|
||||
$server2 = Server::factory()->create([
|
||||
'name' => 'Server 2',
|
||||
'team_id' => $team->id,
|
||||
'uuid' => 'uuid-2',
|
||||
]);
|
||||
$server2->outdatedInfo = [
|
||||
'current' => '3.4.0',
|
||||
'latest' => '3.6.0',
|
||||
'type' => 'minor_upgrade',
|
||||
'upgrade_target' => 'v3.6',
|
||||
];
|
||||
|
||||
$servers = collect([$server1, $server2]);
|
||||
$notification = new TraefikVersionOutdated($servers);
|
||||
$mail = $notification->toMail($team);
|
||||
|
||||
// Verify both servers have URLs
|
||||
expect($mail->viewData['servers'])->toHaveCount(2);
|
||||
|
||||
expect($mail->viewData['servers'][0]['name'])->toBe('Server 1');
|
||||
expect($mail->viewData['servers'][0]['url'])->toBe(base_url().'/server/uuid-1/proxy');
|
||||
|
||||
expect($mail->viewData['servers'][1]['name'])->toBe('Server 2');
|
||||
expect($mail->viewData['servers'][1]['url'])->toBe(base_url().'/server/uuid-2/proxy');
|
||||
});
|
||||
|
||||
it('notification uses base_url helper not config app.url', function () {
|
||||
$team = Team::factory()->create();
|
||||
$server = Server::factory()->create([
|
||||
'name' => 'Test Server',
|
||||
'team_id' => $team->id,
|
||||
'uuid' => 'test-uuid',
|
||||
]);
|
||||
|
||||
$server->outdatedInfo = [
|
||||
'current' => '3.5.0',
|
||||
'latest' => '3.5.6',
|
||||
'type' => 'patch_update',
|
||||
];
|
||||
|
||||
$notification = new TraefikVersionOutdated(collect([$server]));
|
||||
$mail = $notification->toMail($team);
|
||||
|
||||
// Verify URL starts with base_url() not config('app.url')
|
||||
$generatedUrl = $mail->viewData['servers'][0]['url'];
|
||||
expect($generatedUrl)->toStartWith(base_url());
|
||||
expect($generatedUrl)->not->toContain('localhost');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user