feat(website-extras): enhance toggle functionality and update related tests; add additional info configuration to tenant extras
This commit is contained in:
@@ -195,6 +195,8 @@ class AdminAppWebsiteExtraControllerTest extends TestCase
|
||||
|
||||
$this->patchJson('/api/v1/adminapp/tenant/website-extras/contactConfig/toggle')
|
||||
->assertOk()
|
||||
->assertJsonPath('code', 'tenant.website_extra_toggled')
|
||||
->assertJsonPath('message', 'El estado de la sección se actualizó correctamente.')
|
||||
->assertJsonPath('data.definitions.contactConfig.is_enabled', true);
|
||||
|
||||
$this->assertTrue($websiteExtra->refresh()->is_enabled);
|
||||
@@ -206,13 +208,21 @@ class AdminAppWebsiteExtraControllerTest extends TestCase
|
||||
$this->assertFalse($websiteExtra->refresh()->is_enabled);
|
||||
}
|
||||
|
||||
public function test_toggle_returns_not_found_for_an_extra_without_a_tenant_value(): void
|
||||
public function test_toggle_enables_an_extra_without_a_tenant_value(): void
|
||||
{
|
||||
$tenant = $this->createTenant('acme');
|
||||
Sanctum::actingAs($this->createAdminAppUser($tenant));
|
||||
|
||||
$this->patchJson('/api/v1/adminapp/tenant/website-extras/contactConfig/toggle')
|
||||
->assertNotFound();
|
||||
->assertOk()
|
||||
->assertJsonPath('data.definitions.contactConfig.is_enabled', true)
|
||||
->assertJsonPath('data.extras.contactConfig', []);
|
||||
|
||||
$this->assertDatabaseHas('websites_extras', [
|
||||
'website_code' => $tenant->codigo,
|
||||
'website_type_extra_id' => $this->websiteType->extras()->firstOrFail()->id,
|
||||
'is_enabled' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
private function createTenant(string $code): Tenant
|
||||
|
||||
@@ -31,7 +31,18 @@ class StoreTenantWithExtrasTest extends TestCase
|
||||
'title' => 'Festival',
|
||||
'location' => 'Buenos Aires',
|
||||
'dates_text' => '10 y 11 de octubre de 2026',
|
||||
'dates' => ['2026-10-10', '2026-10-11'],
|
||||
'dates' => [
|
||||
[
|
||||
'date' => '2026-10-10',
|
||||
'start_time' => '09:00',
|
||||
'end_time' => '18:00',
|
||||
],
|
||||
[
|
||||
'date' => '2026-10-11',
|
||||
'start_time' => '10:00',
|
||||
'end_time' => '17:00',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]));
|
||||
@@ -52,7 +63,18 @@ class StoreTenantWithExtrasTest extends TestCase
|
||||
'title' => 'Festival',
|
||||
'location' => 'Buenos Aires',
|
||||
'dates_text' => '10 y 11 de octubre de 2026',
|
||||
'dates' => ['2026-10-10', '2026-10-11'],
|
||||
'dates' => [
|
||||
[
|
||||
'date' => '2026-10-10',
|
||||
'start_time' => '09:00',
|
||||
'end_time' => '18:00',
|
||||
],
|
||||
[
|
||||
'date' => '2026-10-11',
|
||||
'start_time' => '10:00',
|
||||
'end_time' => '17:00',
|
||||
],
|
||||
],
|
||||
],
|
||||
$tenant->websiteExtras()->sole()->config
|
||||
);
|
||||
@@ -80,12 +102,16 @@ class StoreTenantWithExtrasTest extends TestCase
|
||||
'website_type_code' => 'onticket',
|
||||
'extras' => [
|
||||
'eventConfig' => [
|
||||
'dates' => ['not-a-date'],
|
||||
'dates' => [[
|
||||
'date' => 'not-a-date',
|
||||
'start_time' => '09:00',
|
||||
'end_time' => '18:00',
|
||||
]],
|
||||
],
|
||||
],
|
||||
]))
|
||||
->assertUnprocessable()
|
||||
->assertJsonValidationErrors(['extras.eventConfig.dates.0']);
|
||||
->assertJsonValidationErrors(['extras.eventConfig.dates.0.date']);
|
||||
|
||||
$this->assertDatabaseMissing('tenants', ['codigo' => 'festival']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user