import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:moody/views/settings_page/widgets/settings_selection_widget.dart'; void main() { group('SettingsSection Tests', () { testWidgets('displays title and items', (WidgetTester tester) async { final items = [ SettingsItem(title: 'Item 1', detail: 'Detail 1'), SettingsItem(title: 'Item 2', detail: 'Detail 2', trailingText: 'More', url: 'https://example.com'), ]; await tester.pumpWidget(MaterialApp( home: Scaffold( body: SettingsSection(title: 'Settings', items: items), ), )); expect(find.text('Settings'), findsOneWidget); await tester.tap(find.text('Item 1')); await tester.pumpAndSettle(); // Wait for the ExpansionTile to expand expect(find.text('Detail 1'), findsOneWidget); // Test for the second item await tester.tap(find.text('Item 2')); await tester.pumpAndSettle(); expect(find.text('Detail 2'), findsOneWidget); expect(find.text('More'), findsOneWidget); }); testWidgets('taps on items work', (WidgetTester tester) async { bool itemTapped = false; final items = [ SettingsItem(title: 'Tap Item', detail: 'Tap Detail', onTap: () { itemTapped = true; }), ]; await tester.pumpWidget(MaterialApp( home: Scaffold( body: SettingsSection(title: 'Settings', items: items), ), )); // Expand the ExpansionTile to reveal the ListTile await tester.tap(find.text('Tap Item')); await tester.pumpAndSettle(); // Tap the specific ListTile await tester.tap(find.text('Tap Detail')); await tester.pump(); expect(itemTapped, isTrue); }); }); }