'Energia', 'slug' => 'energia', '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'); $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); $this->assertSame($first, $this->getJson('/api/v1/home')->assertOk()->json()); $sector->update(['name' => 'Energia actualizada']); $this->assertNull(Cache::get('portal_home_v2_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]); $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('/oportunidades/solar')->assertInertia(fn (Assert $page) => $page ->component('investment/detail')->where('record.reference', 'NAV-1')); $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 ->where('initialView', 'interest')->missing('initialOpportunity')); $opportunity->update(['status' => 'draft']); $this->get('/oportunidades/solar')->assertNotFound(); $this->get('/manifestar-interesse/solar')->assertNotFound(); $sector->update(['is_active' => false]); $this->get('/sectores/energia')->assertNotFound(); $this->get('/oportunidades/inexistente')->assertNotFound(); } }