Deploy Ladill Link / deploy (push) Successful in 31s
Only direct Link redirects use destination_url; catalog QR slugs proxy through the platform resolver instead of malformed summary URLs. Co-authored-by: Cursor <cursoragent@cursor.com>
64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\ShortLink;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Str;
|
|
use Tests\TestCase;
|
|
|
|
class LinkRedirectTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private function user(): User
|
|
{
|
|
return User::create([
|
|
'public_id' => (string) Str::uuid(),
|
|
'name' => 'Test',
|
|
'email' => 'test+'.uniqid().'@example.com',
|
|
]);
|
|
}
|
|
|
|
public function test_direct_redirect_links_go_to_destination_url(): void
|
|
{
|
|
$user = $this->user();
|
|
ShortLink::create([
|
|
'user_id' => $user->id,
|
|
'slug' => 'direct1',
|
|
'source_app' => 'link',
|
|
'source_kind' => 'redirect',
|
|
'is_managed_here' => true,
|
|
'destination_url' => 'https://example.com/target',
|
|
'is_active' => true,
|
|
]);
|
|
|
|
$this->get('https://ladl.link/direct1')
|
|
->assertRedirect('https://example.com/target');
|
|
}
|
|
|
|
public function test_catalog_qr_links_proxy_to_platform_instead_of_bad_destination(): void
|
|
{
|
|
$user = $this->user();
|
|
ShortLink::create([
|
|
'user_id' => $user->id,
|
|
'slug' => 'qrpage',
|
|
'source_app' => 'qrplus',
|
|
'source_kind' => 'qr',
|
|
'is_managed_here' => false,
|
|
'destination_url' => 'https://ladl.link/qrpage · Link list page',
|
|
'is_active' => true,
|
|
]);
|
|
|
|
Http::fake([
|
|
'https://ladill.com/q/qrpage' => Http::response('<html>QR page</html>', 200),
|
|
]);
|
|
|
|
$this->get('https://ladl.link/qrpage')
|
|
->assertOk()
|
|
->assertSee('QR page');
|
|
}
|
|
}
|