Skip to content

Add additional tests for improved coverage#529

Merged
natpicone merged 3 commits intomasterfrom
tests
Mar 19, 2026
Merged

Add additional tests for improved coverage#529
natpicone merged 3 commits intomasterfrom
tests

Conversation

@natpicone
Copy link
Copy Markdown
Collaborator

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:

  • Added a test suite for ApiXbrowsersyncService covering network checks, error mapping, service status validation, and utility methods.
  • Added a test suite for BackupRestoreService covering backup creation, filename generation, sync info retrieval, backup scheduling, backup restoration (for multiple formats), and file download logic.
  • Added a test suite for CryptoService covering array concatenation, encryption/decryption logic, password hashing, and error handling, with mocks for cryptography and encoding dependencies.

Testing for error classes:

  • Added a test suite for error classes in errors, verifying construction, inheritance, message/stack handling, and default properties for all major error types.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread src/modules/webext/shared/bookmark-id-mapper/bookmark-id-mapper.service.spec.ts Outdated
Comment thread src/modules/shared/settings/settings.service.spec.ts Outdated
Comment thread src/modules/shared/upgrade/upgrade.service.spec.ts Outdated
Comment thread src/modules/shared/backup-restore/backup-restore.service.spec.ts Outdated
Comment thread src/modules/shared/utility/utility.service.spec.ts Outdated
Comment thread src/modules/shared/utility/utility.service.spec.ts Outdated
Comment thread src/modules/shared/crypto/crypto.service.spec.ts
Comment thread src/modules/shared/crypto/crypto.service.spec.ts Outdated
Comment thread src/modules/shared/api/api-xbrowsersync/api-xbrowsersync.service.spec.ts Outdated
Comment thread src/modules/shared/bookmark/bookmark-helper/bookmark-helper.service.spec.ts Outdated
natpicone and others added 2 commits March 19, 2026 18:06
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@natpicone natpicone marked this pull request as ready for review March 19, 2026 21:39
@natpicone natpicone merged commit 5c2adff into master Mar 19, 2026
4 checks passed
@natpicone natpicone deleted the tests branch March 19, 2026 21:40
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.

2 participants