Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds new Jest unit test suites (plus an Angular mock) to increase coverage across core shared services and error classes.
Changes:
- Added
jest.mock('angular')shim to support testing Angular-dependent services in Jest. - Introduced/expanded unit tests for shared services (API client, sync/upgrade, settings, utility, crypto, backup/restore, bookmark helpers) and webext bookmark ID mapping.
- Added unit tests for metadata parsing and shared error classes.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/mock-angular.ts | Adds an Angular module mock (isUndefined, isArray, isString, copy) for Jest. |
| src/modules/webext/shared/bookmark-id-mapper/bookmark-id-mapper.service.spec.ts | New tests for bookmark ID mapping CRUD behaviors backed by StoreService. |
| src/modules/shared/working/working.service.spec.ts | New tests validating working status state transitions. |
| src/modules/shared/utility/utility.service.spec.ts | Extensive tests for utility helpers (versions, parsing, tags, ids, asyncWhile, etc.) with dependency mocks. |
| src/modules/shared/upgrade/upgrade.service.spec.ts | Tests upgrade map initialization and upgrade/upgradeBookmarks error cases. |
| src/modules/shared/sync/sync.service.spec.ts | Tests key SyncService guards/decision helpers and some queue/enablement behaviors. |
| src/modules/shared/settings/settings.service.spec.ts | Tests getter/setter behavior for settings keys and dark mode state update. |
| src/modules/shared/metadata/get-metadata.spec.ts | Tests metadata extraction precedence (OG/Twitter/title/keywords) and HTML entity decoding. |
| src/modules/shared/errors/errors.spec.ts | Tests BaseError wrapping behavior and basic inheritance/defaults for key error classes. |
| src/modules/shared/crypto/crypto.service.spec.ts | Tests crypto helpers plus encrypt/decrypt/hash flows with mocked crypto + encoding libs. |
| src/modules/shared/bookmark/bookmark-helper/bookmark-helper.service.spec.ts | Broad coverage for bookmark cleaning, traversal, search helpers, and mutations. |
| src/modules/shared/backup-restore/backup-restore.service.spec.ts | Tests backup creation, schedule handling, restore format handling, and download path. |
| src/modules/shared/api/api-xbrowsersync/api-xbrowsersync.service.spec.ts | Tests network checks, HTTP error mapping, service status validation, and formatting helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces comprehensive unit tests for several core services and error classes in the application. The new test suites provide coverage for service logic, error handling, and edge cases, helping to ensure reliability and maintainability.
New unit test suites added:
Testing for core services:
ApiXbrowsersyncServicecovering network checks, error mapping, service status validation, and utility methods.BackupRestoreServicecovering backup creation, filename generation, sync info retrieval, backup scheduling, backup restoration (for multiple formats), and file download logic.CryptoServicecovering array concatenation, encryption/decryption logic, password hashing, and error handling, with mocks for cryptography and encoding dependencies.Testing for error classes:
errors, verifying construction, inheritance, message/stack handling, and default properties for all major error types.