Testing
flutter test # run everything
flutter test test/role_gate_test.dart
flutter test --coverage # writes coverage/lcov.info (CI uploads it as an artifact)
| File |
What it covers |
test/widget_test.dart |
Bottom navigation tabs and tap callbacks; SnackbarHelper |
test/menu_helpers_test.dart |
Google Drive link conversion; badge colours |
test/billing_test.dart |
INR currency formatting; relative order-time labels |
test/admin_order_model_test.dart |
Order.fromFirestore (via fake_cloud_firestore) and OrderItem.fromMap parsing and defaults |
test/table_state_test.dart |
Clearing the current table |
test/role_gate_test.dart |
isRoleAllowed for the chef and admin apps |
Writing new tests
- Pure logic (formatting, parsing, role checks) gets a plain
test().
- Anything that reads Firestore should use
fake_cloud_firestore
instead of a real project. It's already a dev dependency.
- Widgets get a
testWidgets() wrapped in a minimal MaterialApp, like widget_test.dart does.
- Name the file after the code under test:
lib/user/services/order_service.dart → test/order_service_test.dart.