From 33e2d1775c172a875975547cbb805623b4d10593 Mon Sep 17 00:00:00 2001 From: fulleni Date: Wed, 15 Oct 2025 16:05:19 +0100 Subject: [PATCH 1/6] fix: remove saved filter fixtures - Remove saved filter fixtures from fixtures.dart - Delete saved_filter.dart file as it's no longer needed --- lib/src/fixtures/fixtures.dart | 1 - lib/src/fixtures/saved_filter.dart | 30 ------------------------------ 2 files changed, 31 deletions(-) delete mode 100644 lib/src/fixtures/saved_filter.dart diff --git a/lib/src/fixtures/fixtures.dart b/lib/src/fixtures/fixtures.dart index 0f356bb6..14429def 100644 --- a/lib/src/fixtures/fixtures.dart +++ b/lib/src/fixtures/fixtures.dart @@ -5,7 +5,6 @@ export 'headlines.dart'; export 'languages.dart'; export 'local_ads.dart'; export 'remote_configs.dart'; -export 'saved_filter.dart'; export 'sources.dart'; export 'topics.dart'; export 'user_app_settings.dart'; diff --git a/lib/src/fixtures/saved_filter.dart b/lib/src/fixtures/saved_filter.dart deleted file mode 100644 index c9575cbf..00000000 --- a/lib/src/fixtures/saved_filter.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'package:core/src/fixtures/countries.dart'; -import 'package:core/src/fixtures/fixture_ids.dart'; -import 'package:core/src/fixtures/sources.dart'; -import 'package:core/src/fixtures/topics.dart'; -import 'package:core/src/models/user_presets/saved_filter.dart'; - -/// A list of predefined saved searches for fixture data. -final savedFiltersFixturesData = [ - SavedFilter( - id: kSavedFilterId1, - name: 'UK Tech & Politics', - topics: [ - topicsFixturesData.firstWhere((t) => t.name == 'Technology'), - topicsFixturesData.firstWhere((t) => t.name == 'Politics'), - ], - sources: [sourcesFixturesData.firstWhere((s) => s.name == 'BBC News')], - countries: [ - countriesFixturesData.firstWhere((c) => c.name == 'United Kingdom'), - ], - ), - SavedFilter( - id: kSavedFilterId2, - name: 'US Business News', - topics: [topicsFixturesData.firstWhere((t) => t.name == 'Business')], - sources: const [], - countries: [ - countriesFixturesData.firstWhere((c) => c.name == 'United States'), - ], - ), -]; From d68a099549bab01b68dfeb1cc59ba7a9f682cd4f Mon Sep 17 00:00:00 2001 From: fulleni Date: Wed, 15 Oct 2025 16:06:13 +0100 Subject: [PATCH 2/6] test: update user content preferences and saved filter tests - Replace savedFiltersFixturesData with userContentPreferencesFixturesData in tests - Update test cases to use correct references for mockSavedFilter - Improve test accuracy by using specific saved filter from userContentPreferencesFixturesData --- .../user_preferences/user_content_preferences_test.dart | 4 ++-- test/src/models/user_presets/saved_filter_test.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/src/models/user_preferences/user_content_preferences_test.dart b/test/src/models/user_preferences/user_content_preferences_test.dart index 54e270c0..abaa8665 100644 --- a/test/src/models/user_preferences/user_content_preferences_test.dart +++ b/test/src/models/user_preferences/user_content_preferences_test.dart @@ -8,7 +8,7 @@ void main() { final mockSource = sourcesFixturesData.first; final mockTopic = topicsFixturesData.first; final mockHeadline = headlinesFixturesData.first; - final mockSavedFilter = savedFiltersFixturesData.first; + final mockSavedFilter = userContentPreferencesFixturesData.first.savedFilters.first; // Use the base fixture and copyWith to create a populated version for tests final userContentPreferencesFixture = userContentPreferencesFixturesData @@ -60,7 +60,7 @@ void main() { test('returns a new instance with updated fields', () { final newCountry = countriesFixturesData[1]; final newHeadline = headlinesFixturesData[1]; - final newSavedFilter = savedFiltersFixturesData[1]; + final newSavedFilter = userContentPreferencesFixturesData.first.savedFilters.last; final updatedPreferences = userContentPreferencesFixture.copyWith( followedCountries: [newCountry], diff --git a/test/src/models/user_presets/saved_filter_test.dart b/test/src/models/user_presets/saved_filter_test.dart index 4ce1c49f..6328af45 100644 --- a/test/src/models/user_presets/saved_filter_test.dart +++ b/test/src/models/user_presets/saved_filter_test.dart @@ -3,7 +3,7 @@ import 'package:test/test.dart'; void main() { group('SavedFilter', () { - final mockSavedFilter = savedFiltersFixturesData.first; + final mockSavedFilter = userContentPreferencesFixturesData.first.savedFilters.first; group('constructor', () { test('returns correct instance', () { From ecda9ad7d698d1710b9312c0b8c1e51b1302d7a3 Mon Sep 17 00:00:00 2001 From: fulleni Date: Wed, 15 Oct 2025 16:20:14 +0100 Subject: [PATCH 3/6] chore(fixtures): populate user content preferences demo data Populates the `userContentPreferencesFixturesData` with realistic, interconnected data for the demo user. This includes followed topics, sources, and countries, as well as saved headlines and filters. This provides a richer dataset for client-side development and demonstration, particularly for features related to user personalization and saved filters. --- .../fixtures/user_content_preferences.dart | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/lib/src/fixtures/user_content_preferences.dart b/lib/src/fixtures/user_content_preferences.dart index 0a0fdf55..95c1dea6 100644 --- a/lib/src/fixtures/user_content_preferences.dart +++ b/lib/src/fixtures/user_content_preferences.dart @@ -1,14 +1,41 @@ import 'package:core/src/fixtures/fixture_ids.dart'; +import 'package:core/src/fixtures/headlines.dart'; +import 'package:core/src/fixtures/sources.dart'; +import 'package:core/src/fixtures/topics.dart'; import 'package:core/src/models/user_preferences/user_content_preferences.dart'; +import 'package:core/src/models/user_presets/saved_filter.dart'; /// User Content Preferences Demo Data final List userContentPreferencesFixturesData = [ - const UserContentPreferences( + UserContentPreferences( id: kAdminUserId, - followedCountries: [], - followedSources: [], - followedTopics: [], - savedHeadlines: [], - savedFilters: [], + followedCountries: const [], + followedSources: [ + sourcesFixturesData[0], // TechCrunch + sourcesFixturesData[1], // BBC News + ], + followedTopics: [ + topicsFixturesData[0], // Technology + topicsFixturesData[1], // Sports + topicsFixturesData[6], // Business + topicsFixturesData[7], // Travel + ], + savedHeadlines: [headlinesFixturesData[0], headlinesFixturesData[10]], + savedFilters: [ + SavedFilter( + id: kSavedFilterId1, + name: 'Tech News', + topics: [topicsFixturesData[0]], // Technology + sources: [sourcesFixturesData[0]], // TechCrunch + countries: const [], + ), + SavedFilter( + id: kSavedFilterId2, + name: 'World Biz', + topics: [topicsFixturesData[6]], // Business + sources: const [], + countries: const [], + ), + ], ), ]; From 0dc99f886c9325035eef3a03ed4821131e88ce52 Mon Sep 17 00:00:00 2001 From: fulleni Date: Wed, 15 Oct 2025 16:38:33 +0100 Subject: [PATCH 4/6] fix(headlines): update image URLs to use placeholder service - Replace hardcoded image URLs with placeholders from picsum.photos - Use consistent image dimensions (800x600) for all placeholders - Update image seeds to maintain uniqueness across headlines --- lib/src/fixtures/headlines.dart | 100 ++++++++++++++++---------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/lib/src/fixtures/headlines.dart b/lib/src/fixtures/headlines.dart index b991a8b2..5d251481 100644 --- a/lib/src/fixtures/headlines.dart +++ b/lib/src/fixtures/headlines.dart @@ -13,7 +13,7 @@ final headlinesFixturesData = [ excerpt: 'Researchers announce a significant leap in artificial intelligence, with a new model demonstrating unprecedented capabilities.', url: 'https://example.com/news/ai-breakthrough-1', - imageUrl: 'https://example.com/images/ai-breakthrough.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId1/800/600', source: sourcesFixturesData[0], // TechCrunch eventCountry: countriesFixturesData[0], // United States topic: topicsFixturesData[0], // Technology @@ -27,7 +27,7 @@ final headlinesFixturesData = [ excerpt: 'The city celebrates as the underdog team clinches the national championship in a nail-biting finish.', url: 'https://example.com/news/sports-championship-2', - imageUrl: 'https://example.com/images/sports-win.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId2/800/600', source: sourcesFixturesData[1], // BBC News eventCountry: countriesFixturesData[1], // United Kingdom topic: topicsFixturesData[1], // Sports @@ -41,7 +41,7 @@ final headlinesFixturesData = [ excerpt: 'A summit of world leaders convenes to address urgent climate change issues and propose new international agreements.', url: 'https://example.com/news/politics-climate-3', - imageUrl: 'https://example.com/images/climate-summit.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId3/800/600', source: sourcesFixturesData[2], // The New York Times eventCountry: countriesFixturesData[2], // Canada topic: topicsFixturesData[2], // Politics @@ -55,7 +55,7 @@ final headlinesFixturesData = [ excerpt: 'Astronomers confirm the existence of a new exoplanet, sparking excitement in the scientific community.', url: 'https://example.com/news/science-planet-4', - imageUrl: 'https://example.com/images/new-planet.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId4/800/600', source: sourcesFixturesData[3], // The Guardian eventCountry: countriesFixturesData[3], // Australia topic: topicsFixturesData[3], // Science @@ -69,7 +69,7 @@ final headlinesFixturesData = [ excerpt: 'A new study reveals a promising treatment approach for a common type of cancer, moving closer to a cure.', url: 'https://example.com/news/health-cancer-5', - imageUrl: 'https://example.com/images/cancer-research.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId5/800/600', source: sourcesFixturesData[4], // CNN eventCountry: countriesFixturesData[4], // Germany topic: topicsFixturesData[4], // Health @@ -83,7 +83,7 @@ final headlinesFixturesData = [ excerpt: 'The highly anticipated film shatters previous box office records in its opening weekend, delighting fans worldwide.', url: 'https://example.com/news/entertainment-movie-6', - imageUrl: 'https://example.com/images/movie-record.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId6/800/600', source: sourcesFixturesData[5], // Reuters eventCountry: countriesFixturesData[5], // France topic: topicsFixturesData[5], // Entertainment @@ -97,7 +97,7 @@ final headlinesFixturesData = [ excerpt: 'Major indices surge as strong economic data and corporate earnings drive investor confidence.', url: 'https://example.com/news/business-market-7', - imageUrl: 'https://example.com/images/stock-market.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId7/800/600', source: sourcesFixturesData[6], // Al Jazeera English eventCountry: countriesFixturesData[6], // Japan topic: topicsFixturesData[6], // Business @@ -111,7 +111,7 @@ final headlinesFixturesData = [ excerpt: 'Governments ease travel advisories, opening up new opportunities for international tourism.', url: 'https://example.com/news/travel-restrictions-8', - imageUrl: 'https://example.com/images/travel-lifted.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId8/800/600', source: sourcesFixturesData[7], // Xinhua News Agency eventCountry: countriesFixturesData[7], // China topic: topicsFixturesData[7], // Travel @@ -125,7 +125,7 @@ final headlinesFixturesData = [ excerpt: 'A world-renowned chef brings their culinary expertise to the city with a highly anticipated new dining establishment.', url: 'https://example.com/news/food-restaurant-9', - imageUrl: 'https://example.com/images/new-restaurant.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId9/800/600', source: sourcesFixturesData[8], // The Times of India eventCountry: countriesFixturesData[8], // India topic: topicsFixturesData[8], // Food @@ -139,7 +139,7 @@ final headlinesFixturesData = [ excerpt: 'Schools adopting new pedagogical approaches report significant improvements in student participation and learning outcomes.', url: 'https://example.com/news/education-methods-10', - imageUrl: 'https://example.com/images/education-methods.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId10/800/600', source: sourcesFixturesData[9], // Folha de S.Paulo eventCountry: countriesFixturesData[9], // Brazil topic: topicsFixturesData[9], // Education @@ -153,7 +153,7 @@ final headlinesFixturesData = [ excerpt: 'Experts advise immediate updates as a sophisticated new malware strain targets critical infrastructure worldwide.', url: 'https://example.com/news/cybersecurity-threat-11', - imageUrl: 'https://example.com/images/cyber-threat.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId11/800/600', source: sourcesFixturesData[0], // TechCrunch eventCountry: countriesFixturesData[0], // United States topic: topicsFixturesData[0], // Technology @@ -167,7 +167,7 @@ final headlinesFixturesData = [ excerpt: 'The highly anticipated decision for the next Summer Olympics host city has been revealed, promising a spectacular event.', url: 'https://example.com/news/sports-olympics-12', - imageUrl: 'https://example.com/images/olympics-announcement.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId12/800/600', source: sourcesFixturesData[1], // BBC News eventCountry: countriesFixturesData[1], // United Kingdom topic: topicsFixturesData[1], // Sports @@ -181,7 +181,7 @@ final headlinesFixturesData = [ excerpt: 'Legislators introduce a comprehensive bill designed to address rising healthcare costs and expand access to services.', url: 'https://example.com/news/politics-healthcare-13', - imageUrl: 'https://example.com/images/healthcare-bill.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId13/800/600', source: sourcesFixturesData[2], // The New York Times eventCountry: countriesFixturesData[2], // Canada topic: topicsFixturesData[4], // Health @@ -195,7 +195,7 @@ final headlinesFixturesData = [ excerpt: 'A team of archaeologists makes a groundbreaking discovery, revealing a previously unknown ancient civilization.', url: 'https://example.com/news/science-archaeology-14', - imageUrl: 'https://example.com/images/ancient-city.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId14/800/600', source: sourcesFixturesData[3], // The Guardian eventCountry: countriesFixturesData[3], // Australia topic: topicsFixturesData[3], // Science @@ -209,7 +209,7 @@ final headlinesFixturesData = [ excerpt: 'New recommendations from health organizations aim to improve public nutrition and combat chronic diseases.', url: 'https://example.com/news/health-diet-15', - imageUrl: 'https://example.com/images/dietary-guidelines.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId15/800/600', source: sourcesFixturesData[4], // CNN eventCountry: countriesFixturesData[4], // Germany topic: topicsFixturesData[4], // Health @@ -223,7 +223,7 @@ final headlinesFixturesData = [ excerpt: 'Fans eagerly await the annual music festival as organizers unveil a lineup featuring top artists from various genres.', url: 'https://example.com/news/entertainment-music-16', - imageUrl: 'https://example.com/images/music-festival.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId16/800/600', source: sourcesFixturesData[5], // Reuters eventCountry: countriesFixturesData[5], // France topic: topicsFixturesData[5], // Entertainment @@ -237,7 +237,7 @@ final headlinesFixturesData = [ excerpt: 'A major technology company expands its portfolio with the acquisition of a promising startup, signaling market consolidation.', url: 'https://example.com/news/business-acquisition-17', - imageUrl: 'https://example.com/images/tech-acquisition.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId17/800/600', source: sourcesFixturesData[6], // Al Jazeera English eventCountry: countriesFixturesData[6], // Japan topic: topicsFixturesData[6], // Business @@ -251,7 +251,7 @@ final headlinesFixturesData = [ excerpt: 'The era of space tourism begins as companies unveil plans for regular commercial flights to orbit.', url: 'https://example.com/news/travel-space-18', - imageUrl: 'https://example.com/images/space-tourism.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId18/800/600', source: sourcesFixturesData[7], // Xinhua News Agency eventCountry: countriesFixturesData[7], // China topic: topicsFixturesData[7], // Travel @@ -265,7 +265,7 @@ final headlinesFixturesData = [ excerpt: 'As sustainability concerns grow, lab-grown meat alternatives are becoming a staple in modern diets.', url: 'https://example.com/news/food-lab-meat-19', - imageUrl: 'https://example.com/images/lab-meat.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId19/800/600', source: sourcesFixturesData[8], // The Times of India eventCountry: countriesFixturesData[8], // India topic: topicsFixturesData[8], // Food @@ -279,7 +279,7 @@ final headlinesFixturesData = [ excerpt: 'The shift to digital education continues as more students opt for flexible online courses and certifications.', url: 'https://example.com/news/education-online-20', - imageUrl: 'https://example.com/images/online-learning.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId20/800/600', source: sourcesFixturesData[9], // Folha de S.Paulo eventCountry: countriesFixturesData[9], // Brazil topic: topicsFixturesData[9], // Education @@ -293,7 +293,7 @@ final headlinesFixturesData = [ excerpt: 'Scientists report a significant advancement in quantum computing, bringing the technology closer to practical applications.', url: 'https://example.com/news/tech-quantum-21', - imageUrl: 'https://example.com/images/quantum-computing.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId21/800/600', source: sourcesFixturesData[0], // TechCrunch eventCountry: countriesFixturesData[0], // United States topic: topicsFixturesData[0], // Technology @@ -307,7 +307,7 @@ final headlinesFixturesData = [ excerpt: 'Several top-ranked teams suffer surprising defeats in the latest World Cup qualifiers, reshuffling the global football landscape.', url: 'https://example.com/news/sports-worldcup-22', - imageUrl: 'https://example.com/images/worldcup-upset.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId22/800/600', source: sourcesFixturesData[1], // BBC News eventCountry: countriesFixturesData[1], // United Kingdom topic: topicsFixturesData[1], // Sports @@ -321,7 +321,7 @@ final headlinesFixturesData = [ excerpt: 'Following a closely contested election, a new political party forms the government, promising significant policy changes.', url: 'https://example.com/news/politics-election-23', - imageUrl: 'https://example.com/images/election-results.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId23/800/600', source: sourcesFixturesData[2], // The New York Times eventCountry: countriesFixturesData[2], // Canada topic: topicsFixturesData[2], // Politics @@ -335,7 +335,7 @@ final headlinesFixturesData = [ excerpt: 'Scientists achieve a major milestone in fusion energy, bringing clean, limitless power closer to reality.', url: 'https://example.com/news/science-fusion-24', - imageUrl: 'https://example.com/images/fusion-energy.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId24/800/600', source: sourcesFixturesData[3], // The Guardian eventCountry: countriesFixturesData[3], // Australia topic: topicsFixturesData[3], // Science @@ -349,7 +349,7 @@ final headlinesFixturesData = [ excerpt: 'A new international initiative aims to destigmatize mental health issues and provide greater support resources.', url: 'https://example.com/news/health-mental-25', - imageUrl: 'https://example.com/images/mental-health.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId25/800/600', source: sourcesFixturesData[4], // CNN eventCountry: countriesFixturesData[4], // Germany topic: topicsFixturesData[4], // Health @@ -363,7 +363,7 @@ final headlinesFixturesData = [ excerpt: 'The virtual reality sector of the gaming industry experiences unprecedented expansion, driven by new hardware and immersive titles.', url: 'https://example.com/news/entertainment-vr-26', - imageUrl: 'https://example.com/images/vr-gaming.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId26/800/600', source: sourcesFixturesData[5], // Reuters eventCountry: countriesFixturesData[5], // France topic: topicsFixturesData[5], // Entertainment @@ -377,7 +377,7 @@ final headlinesFixturesData = [ excerpt: 'Ongoing challenges in global logistics are leading to shortages and price increases for a wide range of consumer products.', url: 'https://example.com/news/business-supplychain-27', - imageUrl: 'https://example.com/images/supply-chain.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId27/800/600', source: sourcesFixturesData[6], // Al Jazeera English eventCountry: countriesFixturesData[6], // Japan topic: topicsFixturesData[6], // Business @@ -391,7 +391,7 @@ final headlinesFixturesData = [ excerpt: 'Scientists on an Arctic research mission identify several previously unknown species of marine life, highlighting biodiversity.', url: 'https://example.com/news/travel-arctic-28', - imageUrl: 'https://example.com/images/arctic-discovery.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId28/800/600', source: sourcesFixturesData[7], // Xinhua News Agency eventCountry: countriesFixturesData[7], // China topic: topicsFixturesData[7], // Travel @@ -405,7 +405,7 @@ final headlinesFixturesData = [ excerpt: 'The culinary scene is embracing plant-based diets with an increasing number of restaurants specializing in vegan and vegetarian dishes.', url: 'https://example.com/news/food-plantbased-29', - imageUrl: 'https://example.com/images/plant-based.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId29/800/600', source: sourcesFixturesData[8], // The Times of India eventCountry: countriesFixturesData[8], // India topic: topicsFixturesData[8], // Food @@ -419,7 +419,7 @@ final headlinesFixturesData = [ excerpt: 'New digital tools and platforms are revolutionizing traditional classroom settings, enhancing interactive learning experiences.', url: 'https://example.com/news/education-edtech-30', - imageUrl: 'https://example.com/images/edtech.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId30/800/600', source: sourcesFixturesData[9], // Folha de S.Paulo eventCountry: countriesFixturesData[9], // Brazil topic: topicsFixturesData[9], // Education @@ -433,7 +433,7 @@ final headlinesFixturesData = [ excerpt: "Elon Musk's SpaceX successfully deploys a new batch of Starlink satellites, expanding global internet coverage.", url: 'https://example.com/news/tech-spacex-31', - imageUrl: 'https://example.com/images/spacex-launch.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId31/800/600', source: sourcesFixturesData[0], // TechCrunch eventCountry: countriesFixturesData[0], // United States topic: topicsFixturesData[0], // Technology @@ -447,7 +447,7 @@ final headlinesFixturesData = [ excerpt: 'A celebrated football player declares their retirement, marking the end of an illustrious career.', url: 'https://example.com/news/sports-retirement-32', - imageUrl: 'https://example.com/images/football-retirement.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId32/800/600', source: sourcesFixturesData[1], // BBC News eventCountry: countriesFixturesData[1], // United Kingdom topic: topicsFixturesData[1], // Sports @@ -461,7 +461,7 @@ final headlinesFixturesData = [ excerpt: 'Leaders from the G7 nations issue a unified statement addressing economic challenges and future cooperation.', url: 'https://example.com/news/politics-g7-33', - imageUrl: 'https://example.com/images/g7-summit.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId33/800/600', source: sourcesFixturesData[2], // The New York Times eventCountry: countriesFixturesData[2], // Canada topic: topicsFixturesData[2], // Politics @@ -475,7 +475,7 @@ final headlinesFixturesData = [ excerpt: "Scientists identify a novel therapeutic target for Alzheimer's disease, paving the way for more effective treatments.", url: 'https://example.com/news/science-alzheimers-34', - imageUrl: 'https://example.com/images/alzheimers-research.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId34/800/600', source: sourcesFixturesData[3], // The Guardian eventCountry: countriesFixturesData[3], // Australia topic: topicsFixturesData[4], // Health @@ -489,7 +489,7 @@ final headlinesFixturesData = [ excerpt: 'International efforts to vaccinate the world population against a new virus achieve unprecedented reach.', url: 'https://example.com/news/health-vaccine-35', - imageUrl: 'https://example.com/images/vaccine-campaign.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId35/800/600', source: sourcesFixturesData[4], // CNN eventCountry: countriesFixturesData[4], // Germany topic: topicsFixturesData[4], // Health @@ -503,7 +503,7 @@ final headlinesFixturesData = [ excerpt: 'The competition in the streaming market heats up as several new services enter the fray, offering diverse content.', url: 'https://example.com/news/entertainment-streaming-36', - imageUrl: 'https://example.com/images/streaming-wars.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId36/800/600', source: sourcesFixturesData[5], // Reuters eventCountry: countriesFixturesData[5], // France topic: topicsFixturesData[5], // Entertainment @@ -517,7 +517,7 @@ final headlinesFixturesData = [ excerpt: 'Digital currency values fluctuate wildly, prompting investors to reassess their strategies.', url: 'https://example.com/news/business-crypto-37', - imageUrl: 'https://example.com/images/crypto-volatility.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId37/800/600', source: sourcesFixturesData[6], // Al Jazeera English eventCountry: countriesFixturesData[6], // Japan topic: topicsFixturesData[0], // Technology @@ -531,7 +531,7 @@ final headlinesFixturesData = [ excerpt: 'Travel industry shifts towards eco-friendly practices, offering responsible options for environmentally conscious travelers.', url: 'https://example.com/news/travel-sustainable-38', - imageUrl: 'https://example.com/images/sustainable-tourism.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId38/800/600', source: sourcesFixturesData[7], // Xinhua News Agency eventCountry: countriesFixturesData[7], // China topic: topicsFixturesData[7], // Travel @@ -545,7 +545,7 @@ final headlinesFixturesData = [ excerpt: 'International conference focuses on strategies to combat food insecurity and ensure equitable access to nutrition worldwide.', url: 'https://example.com/news/food-security-39', - imageUrl: 'https://example.com/images/food-security.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId39/800/600', source: sourcesFixturesData[8], // The Times of India eventCountry: countriesFixturesData[8], // India topic: topicsFixturesData[8], // Food @@ -559,7 +559,7 @@ final headlinesFixturesData = [ excerpt: 'Schools integrate advanced robotics into their curriculum, providing hands-on learning experiences for students.', url: 'https://example.com/news/education-robotics-40', - imageUrl: 'https://example.com/images/robotics-education.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId40/800/600', source: sourcesFixturesData[9], // Folha de S.Paulo eventCountry: countriesFixturesData[9], // Brazil topic: topicsFixturesData[9], // Education @@ -573,7 +573,7 @@ final headlinesFixturesData = [ excerpt: 'Discussions around the ethical implications of artificial intelligence gain traction, with calls for stricter regulations.', url: 'https://example.com/news/tech-ethics-41', - imageUrl: 'https://example.com/images/ai-ethics.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId41/800/600', source: sourcesFixturesData[0], // TechCrunch eventCountry: countriesFixturesData[0], // United States topic: topicsFixturesData[0], // Technology @@ -587,7 +587,7 @@ final headlinesFixturesData = [ excerpt: 'The competitive gaming sector attracts record investments, solidifying its position as a major entertainment industry.', url: 'https://example.com/news/sports-esports-42', - imageUrl: 'https://example.com/images/esports-boom.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId42/800/600', source: sourcesFixturesData[1], // BBC News eventCountry: countriesFixturesData[1], // United Kingdom topic: topicsFixturesData[1], // Sports @@ -601,7 +601,7 @@ final headlinesFixturesData = [ excerpt: "Global powers unite to impose new economic sanctions in response to a nation's controversial actions.", url: 'https://example.com/news/politics-sanctions-43', - imageUrl: 'https://example.com/images/sanctions.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId43/800/600', source: sourcesFixturesData[2], // The New York Times eventCountry: countriesFixturesData[2], // Canada topic: topicsFixturesData[2], // Politics @@ -615,7 +615,7 @@ final headlinesFixturesData = [ excerpt: 'Oceanographers exploring the deepest parts of the ocean encounter a never-before-seen marine organism.', url: 'https://example.com/news/science-deepsea-44', - imageUrl: 'https://example.com/images/deepsea-creature.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId44/800/600', source: sourcesFixturesData[3], // The Guardian eventCountry: countriesFixturesData[3], // Australia topic: topicsFixturesData[3], // Science @@ -629,7 +629,7 @@ final headlinesFixturesData = [ excerpt: 'International health organizations unveil a comprehensive strategy to prevent and respond to future pandemics.', url: 'https://example.com/news/health-pandemic-45', - imageUrl: 'https://example.com/images/pandemic-plan.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId45/800/600', source: sourcesFixturesData[4], // CNN eventCountry: countriesFixturesData[4], // Germany topic: topicsFixturesData[4], // Health @@ -643,7 +643,7 @@ final headlinesFixturesData = [ excerpt: 'Ongoing labor disputes in Hollywood lead to widespread production halts, affecting upcoming movie and TV releases.', url: 'https://example.com/news/entertainment-strikes-46', - imageUrl: 'https://example.com/images/hollywood-strikes.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId46/800/600', source: sourcesFixturesData[5], // Reuters eventCountry: countriesFixturesData[5], // France topic: topicsFixturesData[5], // Entertainment @@ -657,7 +657,7 @@ final headlinesFixturesData = [ excerpt: 'Despite global uncertainties, several emerging economies demonstrate robust growth and attract foreign investment.', url: 'https://example.com/news/business-emerging-47', - imageUrl: 'https://example.com/images/emerging-markets.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId47/800/600', source: sourcesFixturesData[6], // Al Jazeera English eventCountry: countriesFixturesData[6], // Japan topic: topicsFixturesData[6], // Business @@ -671,7 +671,7 @@ final headlinesFixturesData = [ excerpt: 'Travelers seek unique experiences in off-the-beaten-path destinations, boosting local economies in remote areas.', url: 'https://example.com/news/travel-adventure-48', - imageUrl: 'https://example.com/images/adventure-tourism.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId48/800/600', source: sourcesFixturesData[7], // Xinhua News Agency eventCountry: countriesFixturesData[7], // China topic: topicsFixturesData[7], // Travel @@ -685,7 +685,7 @@ final headlinesFixturesData = [ excerpt: 'Innovations in eco-friendly packaging solutions are transforming the food industry, reducing environmental impact.', url: 'https://example.com/news/food-packaging-49', - imageUrl: 'https://example.com/images/sustainable-packaging.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId49/800/600', source: sourcesFixturesData[8], // The Times of India eventCountry: countriesFixturesData[8], // India topic: topicsFixturesData[8], // Food @@ -699,7 +699,7 @@ final headlinesFixturesData = [ excerpt: "New educational models focus on customized learning paths, adapting to each student's pace and preferences.", url: 'https://example.com/news/education-personalized-50', - imageUrl: 'https://example.com/images/personalized-learning.jpg', + imageUrl: 'https://picsum.photos/seed/kHeadlineId50/800/600', source: sourcesFixturesData[9], // Folha de S.Paulo eventCountry: countriesFixturesData[9], // Brazil topic: topicsFixturesData[9], // Education From c35d3de523a7c175990a075ad52386bd7343b92b Mon Sep 17 00:00:00 2001 From: fulleni Date: Wed, 15 Oct 2025 16:45:36 +0100 Subject: [PATCH 5/6] test(user_preferences): update UserContentPreferences tests - Simplify test setup by using fixture data directly - Update tests to verify populated lists in fixture data - Remove redundant tests and simplify existing ones - Adjust assertions to match new fixture data structure --- .../user_content_preferences_test.dart | 59 ++++++------------- 1 file changed, 17 insertions(+), 42 deletions(-) diff --git a/test/src/models/user_preferences/user_content_preferences_test.dart b/test/src/models/user_preferences/user_content_preferences_test.dart index abaa8665..53b9bf96 100644 --- a/test/src/models/user_preferences/user_content_preferences_test.dart +++ b/test/src/models/user_preferences/user_content_preferences_test.dart @@ -3,49 +3,32 @@ import 'package:test/test.dart'; void main() { group('UserContentPreferences', () { - // Get fixtures to build a populated test subject - final mockCountry = countriesFixturesData.first; - final mockSource = sourcesFixturesData.first; - final mockTopic = topicsFixturesData.first; - final mockHeadline = headlinesFixturesData.first; - final mockSavedFilter = userContentPreferencesFixturesData.first.savedFilters.first; - - // Use the base fixture and copyWith to create a populated version for tests - final userContentPreferencesFixture = userContentPreferencesFixturesData - .first - .copyWith( - followedCountries: [mockCountry], - followedSources: [mockSource], - followedTopics: [mockTopic], - savedHeadlines: [], - savedFilters: [mockSavedFilter], - ); + // Use the first item from the fixtures as the test subject. + // This ensures tests are based on the canonical fixture data. + final userContentPreferencesFixture = + userContentPreferencesFixturesData.first; group('constructor', () { test('returns correct instance', () { expect(userContentPreferencesFixture, isA()); }); - test('returns correct instance with empty lists from fixture', () { - // The base fixture should have empty lists - final defaultPreferences = userContentPreferencesFixturesData.first; - expect(defaultPreferences.followedCountries, isEmpty); - expect(defaultPreferences.followedSources, isEmpty); - expect(defaultPreferences.followedTopics, isEmpty); - expect(defaultPreferences.savedHeadlines, isEmpty); - expect(defaultPreferences.savedFilters, isEmpty); + test('returns correct instance with populated lists from fixture', () { + // The base fixture should now have populated lists + final preferences = userContentPreferencesFixturesData.first; + expect(preferences.followedCountries, isEmpty); // This list is empty + expect(preferences.followedSources, isNotEmpty); + expect(preferences.followedTopics, isNotEmpty); + expect(preferences.savedHeadlines, isNotEmpty); + expect(preferences.savedFilters, isNotEmpty); }); }); group('fromJson/toJson', () { test('round trip with all fields populated', () { - final preferencesWithSaved = userContentPreferencesFixture.copyWith( - savedHeadlines: [mockHeadline], - savedFilters: [mockSavedFilter], - ); - final json = preferencesWithSaved.toJson(); + final json = userContentPreferencesFixture.toJson(); final result = UserContentPreferences.fromJson(json); - expect(result, equals(preferencesWithSaved)); + expect(result, equals(userContentPreferencesFixture)); }); test('round trip with empty lists', () { @@ -59,30 +42,22 @@ void main() { group('copyWith', () { test('returns a new instance with updated fields', () { final newCountry = countriesFixturesData[1]; - final newHeadline = headlinesFixturesData[1]; - final newSavedFilter = userContentPreferencesFixturesData.first.savedFilters.last; final updatedPreferences = userContentPreferencesFixture.copyWith( followedCountries: [newCountry], - savedFilters: [mockSavedFilter, newSavedFilter], - savedHeadlines: [mockHeadline, newHeadline], ); expect(updatedPreferences.id, userContentPreferencesFixture.id); expect(updatedPreferences.followedCountries, [newCountry]); + // Verify other fields remain unchanged expect( updatedPreferences.followedSources, userContentPreferencesFixture.followedSources, ); expect( - updatedPreferences.followedTopics, - userContentPreferencesFixture.followedTopics, + updatedPreferences.savedFilters, + userContentPreferencesFixture.savedFilters, ); - expect(updatedPreferences.savedFilters, [ - mockSavedFilter, - newSavedFilter, - ]); - expect(updatedPreferences.savedHeadlines, [mockHeadline, newHeadline]); }); test( From d0902ed6d1b469b4968c17773f10b614e78e07db Mon Sep 17 00:00:00 2001 From: fulleni Date: Wed, 15 Oct 2025 16:49:28 +0100 Subject: [PATCH 6/6] fix(fixtures): populate `followedCountries` in user preferences fixture - Update CHANGELOG.md with fixes and improvements for version 1.2.1 - Populate `followedCountries` in user preferences fixture - Align `user_content_preferences_test` with fixture data - Use dynamic image URLs for headline fixtures - Refactor tests to use fixtures directly instead of manual setup - Bump version from 1.2.0 to 1.2.1 --- CHANGELOG.md | 7 +++++++ pubspec.yaml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd759778..d4a2ad6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 1.2.1 - 2025-10-15 + +- fix(fixtures): populate `followedCountries` in user preferences fixture. +- fix(test): align `user_content_preferences_test` with fixture data. +- chore(fixtures): use dynamic image URLs for headline fixtures. +- chore(test): refactor tests to use fixtures directly instead of manual setup. + # 1.2.0 - 2025-10-12 - feat: add SavedFilter model for storing user-defined filter combinations. diff --git a/pubspec.yaml b/pubspec.yaml index 68487652..e762925d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: core description: Shared utilities and models. publish_to: none repository: https://github.com/flutter-news-app-full-source-code/core -version: 1.2.0 +version: 1.2.1 environment: sdk: ^3.9.0