Skip to content

test: add Vitest unit tests for the api client and formatters - #8

Merged
jamubc merged 4 commits into
mainfrom
test/frontend-units
Jun 15, 2026
Merged

test: add Vitest unit tests for the api client and formatters#8
jamubc merged 4 commits into
mainfrom
test/frontend-units

Conversation

@jamubc

@jamubc jamubc commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Why

The Rust core is well tested but the frontend had no unit tests, despite Vitest being configured. The api client and the dashboard formatters are pure, high-traffic, and easy to break silently. The sibling app covers this layer; matching it closes a real gap.

What Changes

  • Add src/lib/api/client.test.ts: verifies command names and argument shapes for representative wrappers and the structured/unstructured error mapping to ApiError, with the Tauri invoke boundary mocked.
  • Add src/lib/format.test.ts: covers commas, signed, abbrev, abbrevU, and relativeTime.

ADDED Requirements

Requirement: Frontend Unit Coverage

The frontend SHALL carry Vitest unit tests for the api client error mapping and the pure formatting helpers, and npm test MUST pass.

Scenario: Tests run green

  • GIVEN a clean checkout with dependencies installed
  • WHEN a contributor runs npm test
  • THEN the api client and formatter suites execute
  • AND all tests pass

Verification

  1. Tests
    1.1 npm test runs both suites and reports 14 passing tests.
    1.2 The suites are src/lib/api/client.test.ts and src/lib/format.test.ts.
  2. Error mapping
    2.1 A structured { code, message } rejection maps to ApiError carrying that code.
    2.2 A non-structured rejection maps to code UNKNOWN.
  3. Formatters
    3.1 signed(0) is +0 and abbrev(-1_200_000) is -1.2M.
    3.2 relativeTime(null) is never.

jamubc added 4 commits June 15, 2026 12:38
Add openspec/specs/lineage/spec.md with the formal requirements and
scenarios, and expand the README with features, install, test, build,
and release-with-self-update sections mirroring InstantNotes.
Add the Tauri updater and process plugins, wired to the public release
endpoint and verified against the bundled minisign public key. The
dashboard window checks on launch and every 6 hours; Settings shows the
current version and lets the user install an update and relaunch. Checks
fail silently when offline or no release exists.
Add .github/workflows/release.yml (a tag-triggered signed build that
publishes a draft release with the updater manifest), validate.yml (the
org OpenSpec check), CODEOWNERS, and scripts/make-update-manifest.sh for
local releases. The minisign signing secrets are configured on the repo.
Cover the api client command wrappers and error mapping (with the Tauri
invoke boundary mocked) and the pure dashboard formatters: commas,
signed, abbrev, and relativeTime.
@github-actions

Copy link
Copy Markdown

OpenSpec format check failed

This pull request body is missing required OpenSpec sections:

  • Verification checklist

Please edit the body to include them. See the contributing guide for the format.

@jamubc
jamubc changed the base branch from chore/release-ci to main June 15, 2026 19:54
@jamubc
jamubc merged commit 60a9e76 into main Jun 15, 2026
2 of 3 checks passed
@jamubc
jamubc deleted the test/frontend-units branch June 15, 2026 19:58
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