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 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import 'package:drift/drift.dart';
|
|
||||||
import 'package:drift/native.dart';
|
import 'package:drift/native.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:household_keeper/core/database/database.dart';
|
import 'package:household_keeper/core/database/database.dart';
|
||||||
|
|||||||
@@ -52,16 +52,21 @@ TaskWithRoom _makeTaskWithRoom({
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Build the app with dailyPlanProvider overridden to the given state.
|
/// 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) {
|
Widget _buildApp(DailyPlanState planState) {
|
||||||
return ProviderScope(
|
final container = ProviderContainer(overrides: [
|
||||||
overrides: [
|
dailyPlanProvider.overrideWith(
|
||||||
dailyPlanProvider.overrideWith(
|
(ref) => Stream.value(planState),
|
||||||
(ref) => Stream.value(planState),
|
),
|
||||||
),
|
roomWithStatsListProvider.overrideWith(
|
||||||
roomWithStatsListProvider.overrideWith(
|
(ref) => Stream.value([]),
|
||||||
(ref) => Stream.value([]),
|
),
|
||||||
),
|
]);
|
||||||
],
|
|
||||||
|
return UncontrolledProviderScope(
|
||||||
|
container: container,
|
||||||
child: MaterialApp.router(
|
child: MaterialApp.router(
|
||||||
routerConfig: router,
|
routerConfig: router,
|
||||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('updateTask changes name, description, interval, effort', () async {
|
test('updateTask changes name, description, interval, effort', () async {
|
||||||
final id = await db.tasksDao.insertTask(
|
await db.tasksDao.insertTask(
|
||||||
TasksCompanion.insert(
|
TasksCompanion.insert(
|
||||||
roomId: roomId,
|
roomId: roomId,
|
||||||
name: 'Abspuelen',
|
name: 'Abspuelen',
|
||||||
|
|||||||
@@ -16,26 +16,31 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/// Helper to build the app with providers overridden for testing.
|
/// 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() {
|
Widget buildApp() {
|
||||||
return ProviderScope(
|
final container = ProviderContainer(overrides: [
|
||||||
overrides: [
|
// Override the stream provider to return an empty list immediately
|
||||||
// Override the stream provider to return an empty list immediately
|
// so that the rooms screen shows the empty state without needing a DB.
|
||||||
// so that the rooms screen shows the empty state without needing a DB.
|
roomWithStatsListProvider.overrideWith(
|
||||||
roomWithStatsListProvider.overrideWith(
|
(ref) => Stream.value([]),
|
||||||
(ref) => Stream.value([]),
|
),
|
||||||
),
|
// Override daily plan to return empty state so HomeScreen
|
||||||
// Override daily plan to return empty state so HomeScreen
|
// renders without a database.
|
||||||
// renders without a database.
|
dailyPlanProvider.overrideWith(
|
||||||
dailyPlanProvider.overrideWith(
|
(ref) => Stream.value(const DailyPlanState(
|
||||||
(ref) => Stream.value(const DailyPlanState(
|
overdueTasks: [],
|
||||||
overdueTasks: [],
|
todayTasks: [],
|
||||||
todayTasks: [],
|
tomorrowTasks: [],
|
||||||
tomorrowTasks: [],
|
completedTodayCount: 0,
|
||||||
completedTodayCount: 0,
|
totalTodayCount: 0,
|
||||||
totalTodayCount: 0,
|
)),
|
||||||
)),
|
),
|
||||||
),
|
]);
|
||||||
],
|
|
||||||
|
return UncontrolledProviderScope(
|
||||||
|
container: container,
|
||||||
child: MaterialApp.router(
|
child: MaterialApp.router(
|
||||||
routerConfig: router,
|
routerConfig: router,
|
||||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||||
|
|||||||
Reference in New Issue
Block a user