Skip to content

Setup up flutter tests, minimal starter tests#324

Open
jasikpark wants to merge 37 commits intomainfrom
pr-323-tests
Open

Setup up flutter tests, minimal starter tests#324
jasikpark wants to merge 37 commits intomainfrom
pr-323-tests

Conversation

@jasikpark
Copy link
Contributor

@jasikpark jasikpark commented Jan 30, 2026

Adds some initial tests, focused on the changes in #323. We don't really have any Flutter tests at the moment, so the main goal is just getting us a baseline of tests to start improving from.

Base automatically changed from sites to main January 30, 2026 19:13
@jasikpark jasikpark linked an issue Jan 30, 2026 that may be closed by this pull request
@jasikpark
Copy link
Contributor Author

hell yeah, finally got the tests running in CI, just gotta fix some of the golden tests and whatnot...

@jasikpark
Copy link
Contributor Author

jasikpark commented Jan 30, 2026

just deleted the failing tests 💀 I figure it'd be good to get a minimal non-flaky set in, and then build from there 🏗️

ok, I think I got things fixed? We'll certainly find out...

@jasikpark jasikpark marked this pull request as ready for review January 30, 2026 23:01
@jasikpark jasikpark requested a review from nbrownus January 30, 2026 23:01
@jasikpark
Copy link
Contributor Author

bruh

@jasikpark
Copy link
Contributor Author

jasikpark commented Jan 31, 2026

TODO for @jasikpark on monday: implement https://fluttergoldens.com/running-goldens/running-on-github/ to see failure screenshots

@jasikpark jasikpark force-pushed the pr-323-tests branch 3 times, most recently from 954a236 to 8b74ec4 Compare February 10, 2026 16:50
jasikpark and others added 17 commits February 10, 2026 10:56
This commit adds a complete test suite covering the UI modernization changes
introduced in PR #323, including:

- SiteItem widget tests (21 tests)
  - Site name and badge rendering
  - Connection status display
  - Error state handling
  - Switch behavior and enable/disable logic
  - Typography and theming

- SettingsScreen tests (13 tests)
  - All settings sections rendering
  - Debug functionality (moved from MainScreen)
  - Debug site constants validation
  - Settings interactions

- Utils service tests (14 tests)
  - popError dialog functionality
  - Error message display
  - Stack trace inclusion
  - Multiple error dialogs
  - Text size calculations
  - Item count formatting

- Theme tests (15 tests)
  - Light and dark theme generation
  - Badge theme configuration (new in PR #323)
  - Custom color application
  - Medium and high contrast variants
  - Theme consistency

Test infrastructure:
- test_helpers.dart with MockSite and createTestApp utilities
- Comprehensive README.md with usage examples and best practices
- All 63 tests passing

These tests validate the key changes in PR #323:
✓ Modernized SiteItem UI with integrated toggle and details button
✓ Badge component for managed sites
✓ Material theme consistency across iOS widgets
✓ Debug functionality moved to SettingsScreen
✓ Utils.popError refactored to use global navigator key
This workflow runs on every push and pull request to main/master:
- Sets up Flutter 3.29.0
- Runs flutter analyze for static analysis
- Runs all 63 tests with coverage
- Uploads coverage report as artifact (downloadable from Actions tab)

The workflow ensures that all tests pass before merging PRs.
Ignore test coverage files and directories:
- coverage/ - Generated coverage reports
- test/.test_coverage.dart - Test coverage helper file
- *.coverage - Coverage data files

This prevents test artifacts from being committed to the repository.
- Add missing imports for debug constants in settings_screen_test.dart
- Mark release mode test as skipped in debug mode with skip parameter
- Rename test to accurately reflect what it verifies
- Add super.dispose() call in MockSite to ensure proper cleanup
- Add concise Testing section to README.md with essential test commands
- Remove test/README.md to reduce documentation duplication
- Keep only the how-to-run information, under 10 lines as requested
Replace smoke tests that only verify widget existence with behavioral tests that validate actual user interactions. Tests now verify switch interactivity, conditional rendering logic, and UI responsiveness.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds comprehensive golden (snapshot) tests for MainScreen and SiteDetailScreen to catch visual regressions. Tests cover various states including connected/disconnected sites, error states, managed sites, and edge cases like long names.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@jasikpark jasikpark changed the title Add test suite for PR #323 Setup up flutter tests, minimal starter tests Feb 10, 2026
flutter test --coverage
```

Run golden tests (update with `--update-goldens` flag):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should remove this since we aren't doing goldens yet

@@ -89,6 +89,14 @@ packages:
url: "https://pub.dev"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this been rebased on main since the flutter upgrade? If so, might want to run a flutter pub get, seems there is some cruft here.

import '../test_helpers.dart';

/// Helper to find text within RichText widgets
Finder findRichText(String text) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this belong in test/test_helpers.dart?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Flutter tests

2 participants