feat(forms): expose grouped admin sale statuses
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Tests\Feature\Forms;
|
||||
|
||||
use App\Domains\Attachable\Enums\AttachmentType;
|
||||
use App\Domains\Attachable\Models\Attachment;
|
||||
use App\Domains\Auth\Models\User;
|
||||
use App\Domains\Authorization\Enums\RoleCode;
|
||||
use App\Domains\Purchase\Models\Purchase;
|
||||
@@ -34,12 +36,7 @@ class AdminAppSaleFormControllerTest extends TestCase
|
||||
|
||||
public function test_an_adminapp_user_can_get_the_sale_form(): void
|
||||
{
|
||||
$tenant = Tenant::query()->create([
|
||||
'codigo' => 'acme',
|
||||
'nombre' => 'Acme',
|
||||
'dominio' => 'acme.test',
|
||||
'website_type_code' => 'onticket',
|
||||
]);
|
||||
$tenant = $this->createTenant('acme');
|
||||
Sanctum::actingAs(User::factory()->create([
|
||||
'rol_codigo' => RoleCode::AdminApp->value,
|
||||
'tenant_codigo' => $tenant->codigo,
|
||||
@@ -47,13 +44,15 @@ class AdminAppSaleFormControllerTest extends TestCase
|
||||
|
||||
$this->getJson('/api/v1/adminapp/forms/sale')
|
||||
->assertOk()
|
||||
->assertJsonCount(count(Purchase::statuses()), 'data.statuses')
|
||||
->assertJsonPath('data.statuses.0.code', Purchase::STATUS_CREATED)
|
||||
->assertJsonPath('data.statuses.0.name', 'Creada')
|
||||
->assertJsonPath('data.statuses.1.code', Purchase::STATUS_PENDING_PAYMENT)
|
||||
->assertJsonPath('data.statuses.2.code', Purchase::STATUS_IN_REVIEW)
|
||||
->assertJsonPath('data.statuses.3.code', Purchase::STATUS_PAID)
|
||||
->assertJsonPath('data.statuses.6.code', Purchase::STATUS_EXPIRED);
|
||||
->assertJsonCount(count(Purchase::adminStatusCodes()), 'data.statuses')
|
||||
->assertJsonPath('data.statuses.0.value', Purchase::ADMIN_STATUS_INCOMPLETE)
|
||||
->assertJsonPath('data.statuses.0.label', 'Por completar datos')
|
||||
->assertJsonPath('data.statuses.0.real_statuses.0', Purchase::STATUS_CREATED)
|
||||
->assertJsonPath('data.statuses.1.value', Purchase::ADMIN_STATUS_AWAITING_PAYMENT)
|
||||
->assertJsonPath('data.statuses.1.real_statuses.0', Purchase::STATUS_PENDING_PAYMENT)
|
||||
->assertJsonPath('data.statuses.1.real_statuses.1', Purchase::STATUS_IN_REVIEW)
|
||||
->assertJsonPath('data.statuses.2.value', Purchase::ADMIN_STATUS_CONFIRMED)
|
||||
->assertJsonPath('data.statuses.3.value', Purchase::ADMIN_STATUS_CANCELLED);
|
||||
}
|
||||
|
||||
public function test_a_customer_cannot_get_the_sale_form(): void
|
||||
@@ -65,4 +64,34 @@ class AdminAppSaleFormControllerTest extends TestCase
|
||||
|
||||
$this->getJson('/api/v1/adminapp/forms/sale')->assertForbidden();
|
||||
}
|
||||
|
||||
private function createTenant(string $code): Tenant
|
||||
{
|
||||
$headerLogo = $this->createAttachment("{$code}-header");
|
||||
$footerLogo = $this->createAttachment("{$code}-footer");
|
||||
|
||||
return Tenant::query()->create([
|
||||
'codigo' => $code,
|
||||
'nombre' => ucfirst($code),
|
||||
'dominio' => "{$code}.test",
|
||||
'primary_color' => '#000000',
|
||||
'secondary_color' => '#ffffff',
|
||||
'danger_color' => '#dc3545',
|
||||
'header_bg_color' => '#ffffff',
|
||||
'footer_bg_color' => '#000000',
|
||||
'header_logo_id' => $headerLogo->id,
|
||||
'footer_logo_id' => $footerLogo->id,
|
||||
'website_type_code' => 'onticket',
|
||||
]);
|
||||
}
|
||||
|
||||
private function createAttachment(string $name): Attachment
|
||||
{
|
||||
return Attachment::query()->create([
|
||||
'path' => "test/{$name}.png",
|
||||
'filename' => "{$name}.png",
|
||||
'type' => AttachmentType::Image,
|
||||
'mime_type' => 'image/png',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user