-
-
Notifications
You must be signed in to change notification settings - Fork 43
test: add configuration and preferences unit tests #1403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add tests for DefaultPreferences - Add ViewConfig serialization and events tests - Add GlobalConfiguration save/auto-save tests - Add ExtensionConfig, FontConfig tests - Add TelemetryConfig/BackupConfig event tests - Add EditorConfig serialization tests These improve coverage for settings/serialization and event propagation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive unit tests for the Beutl.Configuration module to improve test coverage and validate configuration functionality.
- Adds unit tests for all major configuration classes including DefaultPreferences, ViewConfig, GlobalConfiguration, and specialized configs
- Tests cover serialization/deserialization, event handling, persistence, and error scenarios
- Adds project reference to Beutl.Configuration to enable testing
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/Beutl.UnitTests/Configuration/ViewConfigTests.cs | Tests for ViewConfig recent files/projects management and window state serialization |
tests/Beutl.UnitTests/Configuration/TelemetryAndBackupConfigTests.cs | Tests for ConfigurationChanged event handling in TelemetryConfig and BackupConfig |
tests/Beutl.UnitTests/Configuration/GlobalConfigurationTests.cs | Tests for GlobalConfiguration save functionality and auto-save behavior |
tests/Beutl.UnitTests/Configuration/FontConfigTests.cs | Tests for FontConfig directory synchronization during deserialization |
tests/Beutl.UnitTests/Configuration/ExtensionConfigTests.cs | Tests for ExtensionConfig serialization/deserialization of editor extensions and decoder priority |
tests/Beutl.UnitTests/Configuration/EditorConfigTests.cs | Tests for EditorConfig LibraryTabDisplayModes serialization round-trip |
tests/Beutl.UnitTests/Configuration/DefaultPreferencesTests.cs | Tests for DefaultPreferences CRUD operations, persistence, and error handling |
tests/Beutl.UnitTests/Beutl.UnitTests.csproj | Adds project reference to Beutl.Configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- TypeFormat round-trip (non-generic) and global-namespace type - BeutlEnvironment paths and BEUTL_HOME behavior - Preferences.Default uses BEUTL_HOME and persists - FFmpeg extension settings raise ConfigurationChanged via AffectsConfig Also reference Extensibility and FFmpeg extension in test project.
- NotAutoSerialized exclusion in CoreObject serialization - Property-level JsonConverter path exercised with custom converter - Default override via CoreProperty.OverrideDefaultValue in derived type - Hierarchical attachment/detachment events from BeutlApplication and Project items - JsonSerializationContext collection (IDictionary/arrays) round-trips - JsonDeepClone produces independent copies Note: Removed a flaky DataAnnotations validation check; will revisit with Rational-based validator later.
- CoreObjectExtensions: GetObservable, GetPropertyChangedObservable, FindById - RecordableCommands: Create/Append/ToCommand/WithStoables Ran coverage; small overall increase (repo is large).
- LibraryRegistrar: ensure registration wiring for Source/Drawable/Effects and FindItem - EnumExtensions: HasAllFlags/HasAnyFlag across underlying sizes - CultureNameValidation: basic valid/invalid culture names - CorePropertyJsonConverter: round-trip by name and owner - HierarchicalExtensions: find root/parent and enumerate children
- ProjectItemContainer: TryGetOrCreateItem cache, restore-on-newer-file, typed generic, remove/isCreated - Project: save items as relative paths and variables, restore rebuilds items and variables, auto-save on collection change
- ReferenceResolver: waits for root attach and descendant attach to resolve - Remove flaky CoreObject property-graph find test All targeted tests passing.
- JsonSerializationContext: IReference<Obj> serialized to Guid and deserialized back - Remove invalid CoreObject property graph test All new tests passing.
Code Review: Configuration and Preferences Unit Tests✅ Overall AssessmentThis PR does an excellent job adding comprehensive unit test coverage for the configuration and preferences system. The tests are well-structured, thorough, and follow good testing practices. 👍 StrengthsCode Quality
Test Coverage
Best Practices
🔍 Minor Suggestions for Improvement
✅ Security & Performance
📝 Test Coverage AnalysisThe PR adds tests for:
🎯 ConclusionThis is a high-quality PR that significantly improves test coverage for the configuration system. The tests are well-written, comprehensive, and follow established patterns. The minor suggestions above are optional improvements that could enhance maintainability but are not blocking issues. Recommendation: ✅ Approve Great work on improving the test coverage! The tests will help catch regressions and make the configuration system more robust. |
- GroupLibraryItem: merge behavior combines same-name groups and items - Remove flaky CoreObjectFind tests All tests green.
Pull Request ReviewThank you for this comprehensive addition of unit tests for the Configuration and Core modules! This is a valuable contribution that enhances the test coverage of the Beutl project. ✅ StrengthsCode Quality
Test Design
🔍 Observations & Suggestions1. Potential Race ConditionsIn GlobalConfigurationTests.cs lines 58-77, the auto-save test modifies global singleton state. Consider adding [NonParallelizable] attribute if tests might run concurrently. 2. Environment Variable CleanupIn PreferencesDefaultTests.cs and BeutlEnvironmentTests.cs, environment variables are modified but not always restored. Consider wrapping in try/finally blocks to ensure cleanup. 3. Async Test PatternIn ReferenceResolverTests.cs, ensure all async tests properly await their operations and handle potential timeouts. 4. Magic NumbersConsider extracting magic numbers to named constants for better maintainability and self-documentation. 5. Test Data BuildersFor complex object creation (like in ViewConfigTests.cs), consider using the builder pattern to reduce duplication. 🐛 Potential Issues1. Observable Handler CountIn CoreObjectExtensionsTests.cs lines 36-40, the comment mentions "handler attached twice" resulting in 3 events. Verify if this is expected behavior. 2. File System DependenciesSome tests directly interact with the file system. Consider:
3. Static State DependenciesTests depending on BeutlApplication.Current and GlobalConfiguration.Instance might have ordering dependencies. Consider resetting these between tests. 🎯 Performance Considerations
🔒 Security
📋 Test Coverage GapsConsider adding tests for:
✅ Overall AssessmentThis PR significantly improves test coverage and follows good testing practices. The tests are well-written, maintainable, and provide excellent coverage of configuration and core functionality. With the minor improvements suggested above, this will be an excellent addition to the codebase. Recommendation: Approve with minor suggestions Great work on improving the test coverage! The tests are thorough and well-structured. 🎉 |
- JsonSerializationContext.Resolve immediate branch covered - RectOperator/TextBlockOperator/GeometryOperator default property values verified using property adapters All tests passing.],
No TODO comments were found. |
Minimum allowed line rate is |
Code Review: Unit Tests for Configuration and PreferencesThank you for this comprehensive test suite addition! The PR adds 1578 lines of valuable unit tests covering configuration, preferences, and core functionality. Here is my detailed review: ✅ StrengthsCode Quality & Best Practices:
Test Coverage:
🔍 Areas for Improvement1. Resource Management: 2. Environment Variable Isolation: 3. Potential Race Conditions: 🐛 Potential Issues1. Directory Creation Without Cleanup: 2. Type Safety in Assertions: 💡 Suggestions1. Test Data Builders: 2. Parameterized Tests: 3. Thread Safety Testing: 🔒 Security Considerations
✅ Performance Considerations
Overall AssessmentThis is a high-quality test suite that significantly improves the project test coverage. The tests are well-written, comprehensive, and follow good testing practices. With the minor improvements suggested above (particularly around resource cleanup and environment isolation), this will be an excellent addition to the codebase. Recommendation: Approve with minor suggestions ✅ The PR achieves its goal of adding comprehensive unit tests for configuration and preferences. The issues mentioned are minor and do not block merging, but addressing them would make the test suite more robust. |
This PR adds unit tests covering Beutl.Configuration and preferences logic.
Changes:
Project file:
Notes:
No production code changed.