fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Tests\Feature;
|
||||
|
||||
use App\Models\Opportunity;
|
||||
use App\Models\Sector;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
@@ -15,32 +16,33 @@ class PublicPortalNavigationTest extends TestCase
|
||||
|
||||
public function test_home_cache_contains_only_plain_data_and_survives_restricted_unserialization(): void
|
||||
{
|
||||
$sector = Sector::create(['name' => 'Energia', 'slug' => 'energia', 'is_active' => true]);
|
||||
$sector = Sector::create(['name' => 'Energia', 'slug' => 'energia-especifica', 'published_at' => now(), 'is_active' => true]);
|
||||
Opportunity::create(['sector_id' => $sector->id, 'reference' => 'CACHE-1', 'title' => 'Solar',
|
||||
'slug' => 'solar', 'status' => 'published', 'published_at' => now()->subMinute(), 'is_featured' => true]);
|
||||
$first = $this->getJson('/api/v1/home')->assertOk()->json();
|
||||
$cached = Cache::get('portal_home_v2_pt');
|
||||
$cached = Cache::get('portal_home_sector_organization_v1_pt');
|
||||
$this->assertIsArray($cached['sectors']);
|
||||
$this->assertIsArray($cached['featuredOpportunities']);
|
||||
$restored = unserialize(serialize($cached), ['allowed_classes' => false]);
|
||||
$this->assertSame($cached, $restored);
|
||||
Cache::put('portal_home_v2_pt', $restored);
|
||||
Cache::put('portal_home_sector_organization_v1_pt', $restored);
|
||||
$this->assertSame($first, $this->getJson('/api/v1/home')->assertOk()->json());
|
||||
$sector->update(['name' => 'Energia actualizada']);
|
||||
$this->assertNull(Cache::get('portal_home_v2_pt'));
|
||||
$this->assertNull(Cache::get('portal_home_sector_organization_v1_pt'));
|
||||
$this->getJson('/api/v1/home')->assertJsonPath('data.sectors.0.name', 'Energia actualizada');
|
||||
}
|
||||
|
||||
public function test_public_links_open_the_expected_views_without_authentication(): void
|
||||
{
|
||||
$sector = Sector::create(['name' => 'Energia', 'slug' => 'energia', 'is_active' => true]);
|
||||
$sector = Sector::create(['name' => 'Energia', 'slug' => 'energia-especifica', 'published_at' => now(), 'is_active' => true]);
|
||||
$opportunity = Opportunity::create(['sector_id' => $sector->id, 'reference' => 'NAV-1', 'title' => 'Solar',
|
||||
'slug' => 'solar', 'status' => 'published', 'published_at' => now()->subMinute()]);
|
||||
$this->get('/oportunidades?q=solar')->assertInertia(fn (Assert $page) => $page
|
||||
->component('investment/catalogue')->where('filters.q', 'solar')->has('results.data', 1));
|
||||
$this->get('/sectores/energia')->assertInertia(fn (Assert $page) => $page->component('portal/services')->where('section', 'sector')->where('sector.slug', 'energia')->has('opportunities', 1));
|
||||
$this->get('/sectores/energia-especifica')->assertInertia(fn (Assert $page) => $page->component('portal/services')->where('section', 'sector')->where('sector.slug', 'energia-especifica')->has('opportunities', 1));
|
||||
$this->get('/oportunidades/solar')->assertInertia(fn (Assert $page) => $page
|
||||
->component('investment/detail')->where('record.reference', 'NAV-1'));
|
||||
$this->actingAs(User::factory()->create());
|
||||
$this->get('/manifestar-interesse/solar')->assertInertia(fn (Assert $page) => $page
|
||||
->where('initialView', 'interest')->where('initialOpportunity.reference', 'NAV-1'));
|
||||
$this->get('/manifestar-interesse')->assertInertia(fn (Assert $page) => $page
|
||||
@@ -49,7 +51,7 @@ class PublicPortalNavigationTest extends TestCase
|
||||
$this->get('/oportunidades/solar')->assertNotFound();
|
||||
$this->get('/manifestar-interesse/solar')->assertNotFound();
|
||||
$sector->update(['is_active' => false]);
|
||||
$this->get('/sectores/energia')->assertNotFound();
|
||||
$this->get('/sectores/energia-especifica')->assertNotFound();
|
||||
$this->get('/oportunidades/inexistente')->assertNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user