A whole lot of stuff
This commit is contained in:
parent
faf319322a
commit
ad850d2be6
50 changed files with 3013 additions and 213 deletions
104
test/faq_screen_test.dart
Normal file
104
test/faq_screen_test.dart
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:fuel_tax_tracker/screens/faq_screen.dart';
|
||||
|
||||
/// Covers [FaqScreen] itself (question list, collapsed-by-default,
|
||||
/// deep-linking a specific entry open) and [FaqActionButton], the shared
|
||||
/// "?" AppBar action reused across every tab — see settings_screen_test.dart
|
||||
/// for the Settings landing page's own FAQ entry, and
|
||||
/// backup_reminder_test.dart for the "Learn More" link into a specific
|
||||
/// entry.
|
||||
void main() {
|
||||
testWidgets('every question starts collapsed with no initiallyExpandedQuestion given',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(const MaterialApp(home: FaqScreen()));
|
||||
|
||||
expect(find.text('What is the Missouri Motor Fuel Tax Refund?'), findsOneWidget);
|
||||
expect(find.textContaining('12.5¢ per gallon'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('groups questions under section headers', (tester) async {
|
||||
await tester.pumpWidget(const MaterialApp(home: FaqScreen()));
|
||||
|
||||
// The first section header is visible without scrolling; the last
|
||||
// one only reachable by scrolling all the way down — checking both
|
||||
// confirms headers span the whole list, not just its start.
|
||||
expect(find.text('Missouri Motor Fuel Tax Refund'), findsOneWidget);
|
||||
|
||||
await tester.scrollUntilVisible(find.text('Advertisements'), 300,
|
||||
scrollable: find.byType(Scrollable));
|
||||
expect(find.text('Advertisements'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('tapping a question expands its answer', (tester) async {
|
||||
await tester.pumpWidget(const MaterialApp(home: FaqScreen()));
|
||||
|
||||
await tester.scrollUntilVisible(find.text('How do I remove ads?'), 300,
|
||||
scrollable: find.byType(Scrollable));
|
||||
// scrollUntilVisible stops as soon as any part is on-screen, which can
|
||||
// leave it right at the bottom edge — nudge further so its center
|
||||
// (what tap() targets) is comfortably inside the viewport.
|
||||
await tester.drag(find.byType(Scrollable), const Offset(0, -100));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('How do I remove ads?'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.textContaining("doesn't auto-renew"), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('includes a contact email for problem receipts/VINs/errors', (tester) async {
|
||||
await tester.pumpWidget(const MaterialApp(home: FaqScreen()));
|
||||
|
||||
await tester.scrollUntilVisible(
|
||||
find.text("Found a receipt, VIN, or error the app couldn't handle?"), 300,
|
||||
scrollable: find.byType(Scrollable));
|
||||
await tester.tap(find.text("Found a receipt, VIN, or error the app couldn't handle?"));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.textContaining('ohbrer+ShowMeTheFuelRefund@gmail.com'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('the refund program question covers both highway and non-highway refunds',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(const MaterialApp(home: FaqScreen()));
|
||||
|
||||
await tester.tap(find.text('What is the Missouri Motor Fuel Tax Refund?'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.textContaining('Highway use — up to 12.5¢ per gallon'), findsOneWidget);
|
||||
expect(find.textContaining('Non-highway use — up to 29.5¢ per gallon'), findsOneWidget);
|
||||
expect(find.textContaining("isn't tax advice"), findsOneWidget);
|
||||
expect(find.textContaining('consult a tax professional'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('initiallyExpandedQuestion starts that one entry open, others collapsed',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(home: FaqScreen(initiallyExpandedQuestion: 'Is my data backed up?')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Its section (Data Safety) is further down the page now that
|
||||
// questions are grouped — scroll to it before checking its content.
|
||||
await tester.scrollUntilVisible(find.text('Is my data backed up?'), 300,
|
||||
scrollable: find.byType(Scrollable));
|
||||
|
||||
expect(find.textContaining('Not by default'), findsOneWidget);
|
||||
expect(find.textContaining('12.5¢ per gallon'), findsNothing,
|
||||
reason: 'only the targeted question starts expanded');
|
||||
});
|
||||
|
||||
testWidgets('FaqActionButton pushes FaqScreen', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(appBar: AppBar(actions: const [FaqActionButton()])),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byIcon(Icons.help_outline));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(FaqScreen), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue