Skip to content

Conversation

@ashvin2005
Copy link
Contributor

🧪 Unit Tests: Browser Details Module

Fixes #34

Summary

Adds comprehensive unit test suite for browser_details.rs module covering parse_browser_kind normalization logic and Chrome/Firefox profile fallbacks with temporary directories.

✅ Acceptance Criteria Met

1. ✅ cargo test passes on Windows and Linux

  • All tests use tempfile for cross-platform temporary directories
  • Platform-specific tests with #[cfg(target_os = "windows")]
  • GitHub Actions CI runs on Ubuntu, Windows, and macOS
  • No panics on non-existing paths

2. ✅ All supported aliases resolve to correct enum

Chrome aliases tested:

  • "Google Chrome"BrowserKind::Chrome
  • "google-chrome"BrowserKind::Chrome
  • "chrome"BrowserKind::Chrome
  • "Chrome"BrowserKind::Chrome
  • "GOOGLE CHROME"BrowserKind::Chrome

Firefox, Edge, Brave, Opera, Vivaldi aliases also tested

3. ✅ Chrome profile tests cover required cases

  • gaia_name: test_chrome_profiles_with_gaia_name() - verifies gaia_name is preferred
  • name: test_chrome_profiles_with_name_fallback() - verifies name fallback
  • missing-profile: test_chrome_profiles_missing_profile_directory() - returns empty vec

What's Added

Test Coverage (17 tests):

Add unit tests covering parse_browser_kind normalization and Chrome/Firefox profile detection with fallbacks.

- Add parse_browser_kind tests for all browser aliases
  - Chrome: 'Google Chrome', 'google-chrome', 'chrome', 'Chrome', 'GOOGLE CHROME'
  - Firefox: 'Firefox', 'firefox', 'Mozilla Firefox', 'FIREFOX'
  - Edge, Brave, Opera, Vivaldi, Unknown
- Add Chrome profile tests covering:
  - gaia_name (preferred name field)
  - name fallback (when gaia_name missing)
  - missing-profile (returns empty vec without panic)
  - non-existing paths, missing Local State, invalid JSON
- Add Firefox profile tests with profiles.ini parsing
- Use tempfile crate for temporary directories/files simulation
- All tests return empty vec on errors (no panics)
- Wire tests into cargo test (compiles on Windows CI)
- Add GitHub Actions CI workflow for Windows/Linux/macOS
- Add comprehensive test documentation

Fixes ACM-VIT#34
@theg1239 theg1239 closed this Oct 21, 2025
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.

backend: add unit tests for browser details module

2 participants