test: add Vitest unit tests for the api client and formatters - #8
Merged
Conversation
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.
OpenSpec format check failedThis pull request body is missing required OpenSpec sections:
Please edit the body to include them. See the contributing guide for the format. |
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.
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
src/lib/api/client.test.ts: verifies command names and argument shapes for representative wrappers and the structured/unstructured error mapping toApiError, with the Tauriinvokeboundary mocked.src/lib/format.test.ts: coverscommas,signed,abbrev,abbrevU, andrelativeTime.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 testMUST pass.Scenario: Tests run green
npm testVerification
1.1
npm testruns both suites and reports 14 passing tests.1.2 The suites are
src/lib/api/client.test.tsandsrc/lib/format.test.ts.2.1 A structured
{ code, message }rejection maps toApiErrorcarrying that code.2.2 A non-structured rejection maps to code
UNKNOWN.3.1
signed(0)is+0andabbrev(-1_200_000)is-1.2M.3.2
relativeTime(null)isnever.