IMGIITRoorkee / IMGIITRoorkee/placement-flutter
Replace the default counter widget test with a real smoke test
- Dominant language
- Dart
- Stars
- 3
- Forks
- 10
- Avg merge
- 8d 21h
- Merged PRs (30d)
- 4
Description
**Problem**
The only test in the repo is the untouched `flutter create` counter stub. It asserts a counter increments, which this app has never done, so **`flutter test` is red today** and no test gate can be added until it is dealt with.
Fixing the assertion alone does not make it green. Two further failures survive:
- The splash screen schedules a 2-second `Timer` that is never cancelled, because its `State` has no `dispose()`. That trips the pending-timer assertion at teardown.
- The splash screen constructs `AuthService()`, whose private constructor calls `initState()` **without awaiting**, reaching `Hive.initFlutter()`. Under `flutter_test` that throws `MissingPluginException` and surfaces as an unhandled async error.
**Where**
- `test/widget_test.dart:19` asserts `find.text('0')`, but `lib/main.dart:41` sets `initialRoute: '/'` and `lib/services/routing/placement_routes.dart:15-16` maps `/` to `SplashPage`, which renders a logo, "Placement Online", a spinner and a credit line. There is no `'0'`, and the only icon is `Icons.favorite`, so the `find.byIcon(Icons.add)` tap at `:23` is never reached.
- `lib/screens/splash/splash.dart:23` (uncancelled Timer), `:22` (`AuthService()`)
- `lib/services/auth/auth_service.dart:93` (`Hive.initFlutter()`)
**Expected**
`flutter test` passes and asserts something true about this app.
**Fix sketch**
- Delete the stub.
- Add one test that pumps `MyApp()` and asserts the splash screen renders its title, using `pumpAndSettle` and a `path_provider` channel mock.
- Cancel the Timer in a `dispose()` override. That is a prerequisite here and worth doing on its own merits.
**Verification**
Make the new assertion false and confirm `flutter test` fails; restore it and confirm it passes with no pending-timer warning.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with test/widget_test.dart and run flutter test to reproduce the counter-stub, pending-timer, and plugin failures. Read lib/main.dart, lib/services/routing/placement_routes.dart, lib/screens/splash/splash.dart, and lib/services/auth/auth_service.dart. Replace the stub with a splash-title smoke test using the path_provider channel mock, cancel the splash Timer on disposal, and verify flutter test passes without pending-timer warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100