Skip to content

test: add comprehensive unit test suite for URL parsing, i18n, and version comparison#44

Merged
flexiondotorg merged 3 commits intomainfrom
tests
Mar 24, 2026
Merged

test: add comprehensive unit test suite for URL parsing, i18n, and version comparison#44
flexiondotorg merged 3 commits intomainfrom
tests

Conversation

@flexiondotorg
Copy link
Copy Markdown
Member

Summary

Add comprehensive test coverage to the Electron app following a refactoring that extracted a monolithic app.whenReady() into testable modules.

Changes

  • Set up Vitest framework with TypeScript support
  • Implement Priority 1 tests: URL parsing functions (extractStorefrontFromURL, buildAppleMusicURL) with 18 test cases
  • Implement Priority 2 tests: Version comparison (isNewer) with 7 test cases
  • Implement Priority 3 tests: Locale fallback chain (getLocalizedString) with 5 test cases
  • Implement Priority 8 tests: Translation record consistency (78 data integrity tests across 26 translation keys)
  • Add unit-test job to GitHub Actions workflow
  • Total: 108 passing tests

Testing

  • All 108 tests pass locally with npm test
  • CI pipeline includes new unit-test job blocking builds on test failure
  • Tests cover pure functions with zero dependencies; no mocking of app startup logic required

Related Issues

None

Add comprehensive test coverage for URL parsing functions:
- Set up Vitest configuration with globals and Node environment
- Create 18 unit tests for parseStartUrl and parseLastPageUrl functions
- Export URL parsing functions from src/main.ts for testability
- Add test setup file with mock configurations for all dependencies

Update build tooling:
- Rename justfile `test` recipe to `validate` for build config checks
- Add new `test` recipe that runs npm test
- Rename GitHub Actions `test` job to `test-config`
- Add new `test-code` job for running unit tests in CI

Add test dependencies:
- vitest, @vitest/ui, @vitest/coverage-v8
- Update npm scripts with test and coverage commands

Signed-off-by: Martin Wimpress <code@wimpress.io>
- Export isNewer function from update module for testing
- Add i18n.test.ts: 5 tests for locale fallback chain in
  getLocalizedString
- Add update.test.ts: 7 tests for version comparison in isNewer
- Add i18n-consistency.test.ts: 78 tests verifying translation record
  structure across 26 translation keys (language parity and English
  fallback)
- Total: 90 new passing tests (108 cumulative)

Signed-off-by: Martin Wimpress <code@wimpress.io>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 12 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="test/i18n-consistency.test.ts">

<violation number="1" location="test/i18n-consistency.test.ts:23">
P2: Do not skip missing translation records; fail the test when a listed i18n export is absent.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Add explicit test assertion to catch missing exports in
TRANSLATION_RECORDS array. Previously a typo or forgotten export would
be silently skipped; now the test fails and the missing export is
reported as a test failure.

Signed-off-by: Martin Wimpress <code@wimpress.io>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Auto-approved: Adds a comprehensive Vitest test suite and CI integration. Source changes are limited to exporting functions for testability, which is low-risk.

@flexiondotorg flexiondotorg merged commit dc6795b into main Mar 24, 2026
12 checks passed
@flexiondotorg flexiondotorg deleted the tests branch March 24, 2026 20:23
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.

1 participant