feat(menu): add label field to menu model and update related functionality
This commit is contained in:
@@ -19,6 +19,7 @@ class TenantMenuControllerTest extends TestCase
|
||||
$tenant = $this->createTenant();
|
||||
$menu = Menu::query()->create([
|
||||
'code' => 'about',
|
||||
'label' => 'Nosotros',
|
||||
'content_type' => Menu::CONTENT_TYPE_STATIC,
|
||||
'static_content_schema' => [
|
||||
'title' => 'required|string|max:20',
|
||||
@@ -51,6 +52,7 @@ class TenantMenuControllerTest extends TestCase
|
||||
$tenant = $this->createTenant();
|
||||
$menu = Menu::query()->create([
|
||||
'code' => 'about',
|
||||
'label' => 'Nosotros',
|
||||
'content_type' => Menu::CONTENT_TYPE_STATIC,
|
||||
'static_content_schema' => [
|
||||
'title' => 'required|string|max:20',
|
||||
@@ -85,6 +87,7 @@ class TenantMenuControllerTest extends TestCase
|
||||
$tenant = $this->createTenant();
|
||||
$menu = Menu::query()->create([
|
||||
'code' => 'catalog',
|
||||
'label' => 'Catálogo',
|
||||
'route' => '/catalog',
|
||||
]);
|
||||
|
||||
|
||||
@@ -26,21 +26,25 @@ class MenuSeederTest extends TestCase
|
||||
->firstOrFail();
|
||||
|
||||
$this->assertSame(Menu::CONTENT_TYPE_DYNAMIC, $account->content_type);
|
||||
$this->assertSame('Mi cuenta', $account->label);
|
||||
$this->assertSame('/mi-cuenta', $account->route);
|
||||
$this->assertSame([
|
||||
'profile',
|
||||
'purchases',
|
||||
'tickets',
|
||||
'account.profile',
|
||||
'account.purchases',
|
||||
'account.tickets',
|
||||
], $account->children->pluck('code')->sort()->values()->all());
|
||||
$this->assertSame([
|
||||
'profile' => '/mi-cuenta/datos-personales',
|
||||
'purchases' => '/mi-cuenta/compras',
|
||||
'tickets' => '/mi-cuenta/tickets',
|
||||
'account.profile' => '/mi-cuenta/datos-personales',
|
||||
'account.purchases' => '/mi-cuenta/compras',
|
||||
'account.tickets' => '/mi-cuenta/tickets',
|
||||
], $account->children->pluck('route', 'code')->sortKeys()->all());
|
||||
|
||||
$this->assertTrue(
|
||||
$tenant->menues()->where('menues.code', 'account')->exists()
|
||||
);
|
||||
$this->assertFalse(
|
||||
Menu::query()->whereIn('code', ['profile', 'purchases', 'tickets'])->exists()
|
||||
);
|
||||
}
|
||||
|
||||
public function test_it_seeds_the_help_menu_hierarchy_and_content_schemas(): void
|
||||
@@ -53,6 +57,7 @@ class MenuSeederTest extends TestCase
|
||||
->firstOrFail();
|
||||
|
||||
$this->assertSame(Menu::CONTENT_TYPE_DYNAMIC, $help->content_type);
|
||||
$this->assertSame('Ayuda', $help->label);
|
||||
$this->assertSame([
|
||||
'help.contact',
|
||||
'help.faq',
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Tests\Feature\Tenant;
|
||||
|
||||
use App\Domains\Attachable\Enums\AttachmentType;
|
||||
use App\Domains\Attachable\Models\Attachment;
|
||||
use App\Domains\Menu\Models\Menu;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@@ -19,18 +21,18 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
$hdrKey = (string) Str::uuid();
|
||||
$ftrKey = (string) Str::uuid();
|
||||
|
||||
$headerAttachment = \App\Domains\Attachable\Models\Attachment::create([
|
||||
$headerAttachment = Attachment::create([
|
||||
'key' => $hdrKey,
|
||||
'path' => 'tenants/' . $hdrKey . '.png',
|
||||
'path' => 'tenants/'.$hdrKey.'.png',
|
||||
'filename' => 'logo_header.png',
|
||||
'type' => \App\Domains\Attachable\Enums\AttachmentType::Image,
|
||||
'type' => AttachmentType::Image,
|
||||
'mime_type' => 'image/png',
|
||||
]);
|
||||
$footerAttachment = \App\Domains\Attachable\Models\Attachment::create([
|
||||
$footerAttachment = Attachment::create([
|
||||
'key' => $ftrKey,
|
||||
'path' => 'tenants/' . $ftrKey . '.png',
|
||||
'path' => 'tenants/'.$ftrKey.'.png',
|
||||
'filename' => 'logo_footer.png',
|
||||
'type' => \App\Domains\Attachable\Enums\AttachmentType::Image,
|
||||
'type' => AttachmentType::Image,
|
||||
'mime_type' => 'image/png',
|
||||
]);
|
||||
|
||||
@@ -105,11 +107,13 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
$tenant = $this->createTenant();
|
||||
$parent = Menu::query()->create([
|
||||
'code' => 'help',
|
||||
'label' => 'Ayuda',
|
||||
'content_type' => Menu::CONTENT_TYPE_DYNAMIC,
|
||||
'route' => '/ayuda',
|
||||
]);
|
||||
$staticChild = Menu::query()->create([
|
||||
'code' => 'help.faq',
|
||||
'label' => 'Preguntas frecuentes',
|
||||
'parent_menu_code' => $parent->code,
|
||||
'content_type' => Menu::CONTENT_TYPE_STATIC,
|
||||
'static_content_schema' => [
|
||||
@@ -120,6 +124,7 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
]);
|
||||
$dynamicChild = Menu::query()->create([
|
||||
'code' => 'help.shipping',
|
||||
'label' => 'Envíos',
|
||||
'parent_menu_code' => $parent->code,
|
||||
'content_type' => Menu::CONTENT_TYPE_DYNAMIC,
|
||||
'route' => '/ayuda/envios',
|
||||
@@ -144,8 +149,10 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
->assertJsonCount(1, 'data.menues')
|
||||
->assertJsonCount(2, 'data.menues.0.submenues')
|
||||
->assertJsonPath('data.menues.0.code', 'help')
|
||||
->assertJsonPath('data.menues.0.label', 'Ayuda')
|
||||
->assertJsonPath('data.menues.0.parent_menu_code', null)
|
||||
->assertJsonPath('data.menues.0.submenues.0.code', 'help.faq')
|
||||
->assertJsonPath('data.menues.0.submenues.0.label', 'Preguntas frecuentes')
|
||||
->assertJsonPath('data.menues.0.submenues.0.parent_menu_code', 'help')
|
||||
->assertJsonPath('data.menues.0.submenues.1.code', 'help.shipping');
|
||||
|
||||
@@ -259,18 +266,18 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
$hdrUuid = (string) Str::uuid();
|
||||
$ftrUuid = (string) Str::uuid();
|
||||
|
||||
$hdrAttachment = \App\Domains\Attachable\Models\Attachment::create([
|
||||
$hdrAttachment = Attachment::create([
|
||||
'key' => $hdrUuid,
|
||||
'path' => 'tenants/' . $hdrUuid . '.png',
|
||||
'path' => 'tenants/'.$hdrUuid.'.png',
|
||||
'filename' => 'hdr.png',
|
||||
'type' => \App\Domains\Attachable\Enums\AttachmentType::Image,
|
||||
'type' => AttachmentType::Image,
|
||||
'mime_type' => 'image/png',
|
||||
]);
|
||||
$ftrAttachment = \App\Domains\Attachable\Models\Attachment::create([
|
||||
$ftrAttachment = Attachment::create([
|
||||
'key' => $ftrUuid,
|
||||
'path' => 'tenants/' . $ftrUuid . '.png',
|
||||
'path' => 'tenants/'.$ftrUuid.'.png',
|
||||
'filename' => 'ftr.png',
|
||||
'type' => \App\Domains\Attachable\Enums\AttachmentType::Image,
|
||||
'type' => AttachmentType::Image,
|
||||
'mime_type' => 'image/png',
|
||||
]);
|
||||
|
||||
@@ -497,18 +504,18 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
$hdrKey = (string) Str::uuid();
|
||||
$ftrKey = (string) Str::uuid();
|
||||
|
||||
$headerAttachment = \App\Domains\Attachable\Models\Attachment::create([
|
||||
$headerAttachment = Attachment::create([
|
||||
'key' => $hdrKey,
|
||||
'path' => 'tenants/' . $hdrKey . '.png',
|
||||
'path' => 'tenants/'.$hdrKey.'.png',
|
||||
'filename' => 'logo_header.png',
|
||||
'type' => \App\Domains\Attachable\Enums\AttachmentType::Image,
|
||||
'type' => AttachmentType::Image,
|
||||
'mime_type' => 'image/png',
|
||||
]);
|
||||
$footerAttachment = \App\Domains\Attachable\Models\Attachment::create([
|
||||
$footerAttachment = Attachment::create([
|
||||
'key' => $ftrKey,
|
||||
'path' => 'tenants/' . $ftrKey . '.png',
|
||||
'path' => 'tenants/'.$ftrKey.'.png',
|
||||
'filename' => 'logo_footer.png',
|
||||
'type' => \App\Domains\Attachable\Enums\AttachmentType::Image,
|
||||
'type' => AttachmentType::Image,
|
||||
'mime_type' => 'image/png',
|
||||
]);
|
||||
|
||||
@@ -534,11 +541,11 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
$base64Image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==';
|
||||
|
||||
$ftrUuid = (string) Str::uuid();
|
||||
$footerAttachment = \App\Domains\Attachable\Models\Attachment::create([
|
||||
$footerAttachment = Attachment::create([
|
||||
'key' => $ftrUuid,
|
||||
'path' => 'tenants/' . $ftrUuid . '.png',
|
||||
'path' => 'tenants/'.$ftrUuid.'.png',
|
||||
'filename' => 'logo_footer.png',
|
||||
'type' => \App\Domains\Attachable\Enums\AttachmentType::Image,
|
||||
'type' => AttachmentType::Image,
|
||||
'mime_type' => 'image/png',
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user