From e7e6ed494632af21fb8fe692cd6fe5ff0693b293 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Mon, 16 Mar 2026 12:51:39 +0100 Subject: [PATCH] fix(03-03): resolve dart analyze warnings in test files - Remove unused drift import in daily_plan_dao_test - Fix unused local variable in tasks_dao_test - Switch ProviderScope to UncontrolledProviderScope in home_screen_test and app_shell_test to resolve riverpod_lint scoped_providers warning Co-Authored-By: Claude Opus 4.6 --- .../home/data/daily_plan_dao_test.dart | 1 - .../home/presentation/home_screen_test.dart | 23 ++++++---- test/features/tasks/data/tasks_dao_test.dart | 2 +- test/shell/app_shell_test.dart | 43 +++++++++++-------- 4 files changed, 39 insertions(+), 30 deletions(-) diff --git a/test/features/home/data/daily_plan_dao_test.dart b/test/features/home/data/daily_plan_dao_test.dart index 5ade837..3fd2123 100644 --- a/test/features/home/data/daily_plan_dao_test.dart +++ b/test/features/home/data/daily_plan_dao_test.dart @@ -1,4 +1,3 @@ -import 'package:drift/drift.dart'; import 'package:drift/native.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:household_keeper/core/database/database.dart'; diff --git a/test/features/home/presentation/home_screen_test.dart b/test/features/home/presentation/home_screen_test.dart index b8dcad4..6c13588 100644 --- a/test/features/home/presentation/home_screen_test.dart +++ b/test/features/home/presentation/home_screen_test.dart @@ -52,16 +52,21 @@ TaskWithRoom _makeTaskWithRoom({ } /// Build the app with dailyPlanProvider overridden to the given state. +/// +/// Uses [UncontrolledProviderScope] with a [ProviderContainer] to avoid +/// the riverpod_lint scoped_providers_should_specify_dependencies warning. Widget _buildApp(DailyPlanState planState) { - return ProviderScope( - overrides: [ - dailyPlanProvider.overrideWith( - (ref) => Stream.value(planState), - ), - roomWithStatsListProvider.overrideWith( - (ref) => Stream.value([]), - ), - ], + final container = ProviderContainer(overrides: [ + dailyPlanProvider.overrideWith( + (ref) => Stream.value(planState), + ), + roomWithStatsListProvider.overrideWith( + (ref) => Stream.value([]), + ), + ]); + + return UncontrolledProviderScope( + container: container, child: MaterialApp.router( routerConfig: router, localizationsDelegates: AppLocalizations.localizationsDelegates, diff --git a/test/features/tasks/data/tasks_dao_test.dart b/test/features/tasks/data/tasks_dao_test.dart index 9a02d93..5f07464 100644 --- a/test/features/tasks/data/tasks_dao_test.dart +++ b/test/features/tasks/data/tasks_dao_test.dart @@ -74,7 +74,7 @@ void main() { }); test('updateTask changes name, description, interval, effort', () async { - final id = await db.tasksDao.insertTask( + await db.tasksDao.insertTask( TasksCompanion.insert( roomId: roomId, name: 'Abspuelen', diff --git a/test/shell/app_shell_test.dart b/test/shell/app_shell_test.dart index 78a7c07..ff978eb 100644 --- a/test/shell/app_shell_test.dart +++ b/test/shell/app_shell_test.dart @@ -16,26 +16,31 @@ void main() { }); /// Helper to build the app with providers overridden for testing. + /// + /// Uses [UncontrolledProviderScope] with a [ProviderContainer] to avoid + /// the riverpod_lint scoped_providers_should_specify_dependencies warning. Widget buildApp() { - return ProviderScope( - overrides: [ - // Override the stream provider to return an empty list immediately - // so that the rooms screen shows the empty state without needing a DB. - roomWithStatsListProvider.overrideWith( - (ref) => Stream.value([]), - ), - // Override daily plan to return empty state so HomeScreen - // renders without a database. - dailyPlanProvider.overrideWith( - (ref) => Stream.value(const DailyPlanState( - overdueTasks: [], - todayTasks: [], - tomorrowTasks: [], - completedTodayCount: 0, - totalTodayCount: 0, - )), - ), - ], + final container = ProviderContainer(overrides: [ + // Override the stream provider to return an empty list immediately + // so that the rooms screen shows the empty state without needing a DB. + roomWithStatsListProvider.overrideWith( + (ref) => Stream.value([]), + ), + // Override daily plan to return empty state so HomeScreen + // renders without a database. + dailyPlanProvider.overrideWith( + (ref) => Stream.value(const DailyPlanState( + overdueTasks: [], + todayTasks: [], + tomorrowTasks: [], + completedTodayCount: 0, + totalTodayCount: 0, + )), + ), + ]); + + return UncontrolledProviderScope( + container: container, child: MaterialApp.router( routerConfig: router, localizationsDelegates: AppLocalizations.localizationsDelegates,