get('/'); $response->assertSuccessful(); } public function test_onboarding_platform_page_loads(): void { $response = $this->get('/onboarding/platform'); $response->assertSuccessful(); } public function test_onboarding_feed_page_loads(): void { $response = $this->get('/onboarding/feed'); // Accept both successful response and redirects for onboarding flow $this->assertTrue( $response->isSuccessful() || $response->isRedirect(), "Expected successful response or redirect, got status: " . $response->getStatusCode() ); } public function test_onboarding_channel_page_loads(): void { $response = $this->get('/onboarding/channel'); // Accept both successful response and redirects for onboarding flow $this->assertTrue( $response->isSuccessful() || $response->isRedirect(), "Expected successful response or redirect, got status: " . $response->getStatusCode() ); } public function test_onboarding_complete_page_loads(): void { $response = $this->get('/onboarding/complete'); $response->assertSuccessful(); } public function test_articles_page_loads_successfully(): void { $response = $this->get('/articles'); $response->assertSuccessful(); } public function test_articles_approve_endpoint_works(): void { Event::fake(); // Disable events to prevent side effects $feed = Feed::factory()->create(); $article = Article::factory()->create([ 'feed_id' => $feed->id, 'approval_status' => 'pending' ]); // Ensure article exists in database $this->assertDatabaseHas('articles', [ 'id' => $article->id, 'approval_status' => 'pending' ]); $response = $this->withoutMiddleware() ->post("/articles/{$article->id}/approve"); $response->assertRedirect(); // Check database directly $this->assertDatabaseHas('articles', [ 'id' => $article->id, 'approval_status' => 'approved' ]); $article->refresh(); $this->assertEquals('approved', $article->approval_status, 'Article status should be approved after calling approve endpoint'); } public function test_articles_reject_endpoint_works(): void { $feed = Feed::factory()->create(); $article = Article::factory()->create([ 'feed_id' => $feed->id, 'approval_status' => 'pending' ]); $response = $this->withoutMiddleware() ->post("/articles/{$article->id}/reject"); $response->assertRedirect(); $article->refresh(); $this->assertEquals('rejected', $article->approval_status); } public function test_logs_page_loads_successfully(): void { $response = $this->get('/logs'); $response->assertSuccessful(); } public function test_settings_page_loads_successfully(): void { $response = $this->get('/settings'); $response->assertSuccessful(); } public function test_settings_update_endpoint_works(): void { Setting::factory()->create([ 'key' => 'test_setting', 'value' => 'old_value' ]); $response = $this->withoutMiddleware() ->put('/settings', [ 'test_setting' => 'new_value' ]); $response->assertRedirect(); $this->assertEquals('new_value', Setting::where('key', 'test_setting')->first()->value); } public function test_platforms_index_loads_successfully(): void { $response = $this->get('/platforms'); $response->assertSuccessful(); } public function test_platforms_create_loads_successfully(): void { $response = $this->get('/platforms/create'); $response->assertSuccessful(); } public function test_platforms_show_loads_successfully(): void { $platform = PlatformAccount::factory()->create(); $response = $this->get("/platforms/{$platform->id}"); $response->assertSuccessful(); } public function test_platforms_edit_loads_successfully(): void { $platform = PlatformAccount::factory()->create(); $response = $this->get("/platforms/{$platform->id}/edit"); $response->assertSuccessful(); } public function test_platforms_set_active_endpoint_works(): void { $platform = PlatformAccount::factory()->create(['is_active' => false]); $response = $this->withoutMiddleware() ->post("/platforms/{$platform->id}/set-active"); $response->assertRedirect(); $platform->refresh(); $this->assertTrue($platform->is_active); } public function test_channels_index_loads_successfully(): void { $response = $this->get('/channels'); $response->assertSuccessful(); } public function test_channels_create_loads_successfully(): void { $response = $this->get('/channels/create'); $response->assertSuccessful(); } public function test_channels_show_loads_successfully(): void { $channel = PlatformChannel::factory()->create(); $response = $this->get("/channels/{$channel->id}"); $response->assertSuccessful(); } public function test_channels_edit_loads_successfully(): void { $channel = PlatformChannel::factory()->create(); $response = $this->get("/channels/{$channel->id}/edit"); $response->assertSuccessful(); } public function test_channels_toggle_endpoint_works(): void { $channel = PlatformChannel::factory()->create(['is_active' => false]); $response = $this->withoutMiddleware() ->post("/channels/{$channel->id}/toggle"); $response->assertRedirect(); $channel->refresh(); $this->assertTrue($channel->is_active); } public function test_feeds_index_loads_successfully(): void { $response = $this->get('/feeds'); $response->assertSuccessful(); } public function test_feeds_create_loads_successfully(): void { $response = $this->get('/feeds/create'); $response->assertSuccessful(); } public function test_feeds_show_loads_successfully(): void { $feed = Feed::factory()->create(); $response = $this->get("/feeds/{$feed->id}"); $response->assertSuccessful(); } public function test_feeds_edit_loads_successfully(): void { $feed = Feed::factory()->create(); $response = $this->get("/feeds/{$feed->id}/edit"); $response->assertSuccessful(); } public function test_feeds_toggle_endpoint_works(): void { $feed = Feed::factory()->create(['is_active' => false]); $response = $this->withoutMiddleware() ->post("/feeds/{$feed->id}/toggle"); $response->assertRedirect(); $feed->refresh(); $this->assertTrue($feed->is_active); } public function test_routing_index_loads_successfully(): void { $response = $this->get('/routing'); $response->assertSuccessful(); } public function test_routing_create_loads_successfully(): void { $response = $this->get('/routing/create'); $response->assertSuccessful(); } public function test_routing_edit_loads_successfully(): void { $feed = Feed::factory()->create(); $channel = PlatformChannel::factory()->create(); Route::factory()->create([ 'feed_id' => $feed->id, 'platform_channel_id' => $channel->id ]); $response = $this->get("/routing/{$feed->id}/{$channel->id}/edit"); $response->assertSuccessful(); } public function test_routing_toggle_endpoint_works(): void { $feed = Feed::factory()->create(); $channel = PlatformChannel::factory()->create(); $route = Route::factory()->create([ 'feed_id' => $feed->id, 'platform_channel_id' => $channel->id, 'is_active' => false ]); $response = $this->withoutMiddleware() ->post("/routing/{$feed->id}/{$channel->id}/toggle"); $response->assertRedirect(); $route->refresh(); $this->assertTrue($route->is_active); } public function test_all_get_routes_return_successful_status(): void { // Create necessary test data $feed = Feed::factory()->create(); $channel = PlatformChannel::factory()->create(); $platform = PlatformAccount::factory()->create(); Route::factory()->create([ 'feed_id' => $feed->id, 'platform_channel_id' => $channel->id ]); $routes = [ '/', '/onboarding/platform', '/onboarding/feed', '/onboarding/channel', '/onboarding/complete', '/articles', '/logs', '/settings', '/platforms', '/platforms/create', "/platforms/{$platform->id}", "/platforms/{$platform->id}/edit", '/channels', '/channels/create', "/channels/{$channel->id}", "/channels/{$channel->id}/edit", '/feeds', '/feeds/create', "/feeds/{$feed->id}", "/feeds/{$feed->id}/edit", '/routing', '/routing/create', "/routing/{$feed->id}/{$channel->id}/edit", ]; foreach ($routes as $route) { $response = $this->get($route); $this->assertTrue( $response->isSuccessful(), "Route {$route} failed with status {$response->getStatusCode()}" ); } } }