feat(website-type): add footer logo support in WebsiteType model, controller, and resource; update seeder and tests

This commit is contained in:
2026-07-31 14:16:58 -03:00
parent f603a82b5e
commit dd76d5d951
11 changed files with 111 additions and 28 deletions

View File

@@ -2,6 +2,7 @@
namespace Tests\Feature\Tenant;
use App\Domains\Attachable\Models\Attachment;
use App\Domains\Tenant\Models\WebsiteType;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
@@ -12,6 +13,8 @@ class BootstrapAdminAppControllerTest extends TestCase
public function test_it_publicly_bootstraps_the_admin_app_by_domain(): void
{
$footerLogo = Attachment::factory()->create();
WebsiteType::query()->create([
'codigo' => 'shopit',
'nombre' => 'ShopIt',
@@ -27,6 +30,7 @@ class BootstrapAdminAppControllerTest extends TestCase
'background_color' => '#f8f8f8',
'border_color' => '#eaeaea',
'login_header_footer_color' => '#313131',
'footer_logo' => $footerLogo->id,
]);
$this->getJson('/api/v1/adminapp/bootstrap/ADMIN.SHOPIT.TEST')
@@ -37,7 +41,8 @@ class BootstrapAdminAppControllerTest extends TestCase
->assertJsonPath('data.primary_color', '#112233')
->assertJsonPath('data.warning_color', '#ffaa00')
->assertJsonPath('data.login_header_footer_color', '#313131')
->assertJsonPath('data.site_logo', null);
->assertJsonPath('data.site_logo', null)
->assertJsonPath('data.footer_logo', $footerLogo->getTemporaryUrl(1440));
}
public function test_it_returns_not_found_for_an_unknown_domain(): void

View File

@@ -12,7 +12,7 @@ class WebsiteTypeServiceTest extends TestCase
{
use RefreshDatabase;
public function test_it_creates_a_website_type_and_uploads_its_logo_to_s3(): void
public function test_it_creates_a_website_type_and_uploads_its_logos_to_s3(): void
{
Storage::fake('s3');
@@ -32,14 +32,19 @@ class WebsiteTypeServiceTest extends TestCase
'border_color' => '#dddddd',
'login_header_footer_color' => '#333333',
'site_logo' => UploadedFile::fake()->image('site-logo.png'),
'footer_logo' => UploadedFile::fake()->image('footer-logo.png'),
]);
$siteLogo = $websiteType->siteLogo()->firstOrFail();
$footerLogo = $websiteType->footerLogo()->firstOrFail();
$this->assertSame('marketplace', $websiteType->codigo);
$this->assertSame($siteLogo->id, $websiteType->site_logo);
$this->assertSame($footerLogo->id, $websiteType->footer_logo);
$this->assertStringStartsWith('website-types/', $siteLogo->path);
$this->assertStringStartsWith('website-types/', $footerLogo->path);
Storage::disk('s3')->assertExists($siteLogo->path);
Storage::disk('s3')->assertExists($footerLogo->path);
$this->assertDatabaseHas('website_type', [
'codigo' => 'marketplace',
'dominio' => 'marketplace.test',
@@ -51,6 +56,7 @@ class WebsiteTypeServiceTest extends TestCase
'border_color' => '#dddddd',
'login_header_footer_color' => '#333333',
'site_logo' => $siteLogo->id,
'footer_logo' => $footerLogo->id,
]);
}
}