test(tenant): cover split website types and migration
This commit is contained in:
@@ -10,7 +10,8 @@ use App\Domains\Authorization\Models\Role;
|
||||
use App\Domains\Catalog\Models\Category;
|
||||
use App\Domains\Menu\Models\Menu;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use App\Domains\Tenant\Models\WebsiteType;
|
||||
use App\Domains\Tenant\Models\AdminWebsiteType;
|
||||
use App\Domains\Tenant\Models\StorefrontWebsiteType;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@@ -217,50 +218,31 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
$this->getJson('/api/tenants/bootstrap/acme.com')->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_it_resolves_browser_branding_from_the_tenant_before_the_website_type(): void
|
||||
public function test_storefront_branding_comes_from_tenant_even_with_a_different_admin_type(): void
|
||||
{
|
||||
$typeFavicon = Attachment::query()->create([
|
||||
'key' => (string) Str::uuid(),
|
||||
'path' => 'website-types/type-favicon.png',
|
||||
'filename' => 'type-favicon.png',
|
||||
'type' => AttachmentType::Image,
|
||||
'mime_type' => 'image/png',
|
||||
$admin = AdminWebsiteType::query()->create([
|
||||
'codigo' => 'admin-brand',
|
||||
'nombre' => 'Admin Brand',
|
||||
'site_title' => 'Admin title',
|
||||
]);
|
||||
$tenantFavicon = Attachment::query()->create([
|
||||
$favicon = Attachment::query()->create([
|
||||
'key' => (string) Str::uuid(),
|
||||
'path' => 'tenants/tenant-favicon.png',
|
||||
'filename' => 'tenant-favicon.png',
|
||||
'type' => AttachmentType::Image,
|
||||
'mime_type' => 'image/png',
|
||||
]);
|
||||
$websiteType = WebsiteType::query()->create([
|
||||
'codigo' => 'store',
|
||||
'nombre' => 'Tienda',
|
||||
'site_title' => 'Website type title',
|
||||
'favicon_id' => $typeFavicon->id,
|
||||
]);
|
||||
$tenant = $this->createTenant([
|
||||
'website_type_code' => $websiteType->codigo,
|
||||
]);
|
||||
|
||||
$typeResponse = $this->getJson('/api/tenants/bootstrap?dominio=acme.com&path=%2F');
|
||||
|
||||
$typeResponse
|
||||
->assertOk()
|
||||
->assertJsonPath('data.site_title', 'Website type title');
|
||||
$this->assertStringContainsString($typeFavicon->key, $typeResponse->json('data.favicon'));
|
||||
|
||||
$tenant->update([
|
||||
$this->createTenant([
|
||||
'admin_website_type_code' => $admin->codigo,
|
||||
'site_title' => 'Tenant title',
|
||||
'favicon_id' => $tenantFavicon->id,
|
||||
'favicon_id' => $favicon->id,
|
||||
]);
|
||||
|
||||
$tenantResponse = $this->getJson('/api/tenants/bootstrap?dominio=acme.com&path=%2F');
|
||||
|
||||
$tenantResponse
|
||||
->assertOk()
|
||||
->assertJsonPath('data.site_title', 'Tenant title');
|
||||
$this->assertStringContainsString($tenantFavicon->key, $tenantResponse->json('data.favicon'));
|
||||
$response = $this->getJson('/api/tenants/bootstrap?dominio=acme.com&path=%2F');
|
||||
$response->assertOk()
|
||||
->assertJsonPath('data.site_title', 'Tenant title')
|
||||
->assertJsonPath('data.admin_website_type_code', 'admin-brand');
|
||||
$this->assertStringContainsString($favicon->key, $response->json('data.favicon'));
|
||||
}
|
||||
|
||||
public function test_it_uses_default_browser_branding_when_none_is_configured(): void
|
||||
@@ -315,11 +297,11 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
public function test_it_returns_only_enabled_website_extras_in_the_bootstrap(): void
|
||||
{
|
||||
$tenant = $this->createTenant();
|
||||
$websiteType = WebsiteType::query()->create([
|
||||
$websiteType = StorefrontWebsiteType::query()->create([
|
||||
'codigo' => 'store',
|
||||
'nombre' => 'Tienda',
|
||||
]);
|
||||
$tenant->update(['website_type_code' => $websiteType->codigo]);
|
||||
$tenant->update(['storefront_website_type_code' => $websiteType->codigo]);
|
||||
|
||||
$enabledExtra = $websiteType->extras()->create([
|
||||
'codigo' => 'contact',
|
||||
@@ -355,11 +337,11 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
{
|
||||
Storage::fake('s3');
|
||||
$tenant = $this->createTenant();
|
||||
$websiteType = WebsiteType::query()->create([
|
||||
$websiteType = StorefrontWebsiteType::query()->create([
|
||||
'codigo' => 'event-store',
|
||||
'nombre' => 'Eventos',
|
||||
]);
|
||||
$tenant->update(['website_type_code' => $websiteType->codigo]);
|
||||
$tenant->update(['storefront_website_type_code' => $websiteType->codigo]);
|
||||
$heroDefinition = $websiteType->extras()->create([
|
||||
'codigo' => 'heroConfig',
|
||||
'nombre' => 'Banner',
|
||||
|
||||
Reference in New Issue
Block a user