Skip to content

Testing

dweller long gone edited this page May 22, 2026 · 1 revision

Testing

Private Key Gadgets currently uses TypeScript checks and the production build to protect the public package contract, browser application wiring, and reusable API surface.

Run the standard checks from the main repository:

npm run check
npm run build

There is not currently a separate npm test script. Treat npm run check and npm run build as the required baseline before handing normal code changes back.

What npm run check Covers

npm run check runs:

tsc --noEmit

This verifies the TypeScript project without writing build output.

TypeScript API Contracts

The check protects exported TypeScript contracts for:

  • PvkGadgetsCore from @pkistudio/pvkgadgets and @pkistudio/pvkgadgets/core.
  • PKCS#12 helpers from @pkistudio/pvkgadgets/pkcs12.
  • initPrivateKeyGadgets from @pkistudio/pvkgadgets/app.
  • Local PkiStudioJS adapter and type definitions.

Browser Host Boundaries

The check helps keep browser application code aligned with host callback types such as confirmation, file saving, and DER viewer opening.

VS Code-specific lifecycle and dialog behavior should remain outside this package and flow through those host callbacks.

PKI Data Shapes

The check protects the TypeScript shapes used for DER-backed data:

  • PKCS#8 private keys.
  • SPKI public keys.
  • X.509 certificates.
  • SubjectDN RDNSequence data.
  • PKCS#10 CSRs.
  • PKCS#12 import and export records.

What npm run build Covers

npm run build runs:

tsc --noEmit
vite build
tsc -p tsconfig.types.json

This verifies both the browser bundle and generated declaration files.

Vite Application Entries

The production build covers the browser application entries:

  • index.html and src/main.ts for the main Private Key Gadgets app.
  • viewer.html and src/viewer.ts for the standalone PkiStudioJS viewer page.

Package Entry Points

The build verifies that package outputs can be produced for:

  • dist/core.js
  • dist/pkcs12.js
  • dist/app.js
  • dist/styles.css

It also generates declaration files through tsconfig.types.json.

Dependency Integration

The build catches integration issues with browser-shipped dependencies such as:

  • @pkistudio/pkistudiojs
  • asn1js
  • pkijs
  • pvtsutils

This is especially important because PKCS#12 parsing and writing should continue to use structured PKIjs and asn1js APIs.

What the Standard Checks Do Not Cover

The current checks do not replace full browser verification.

They do not currently cover:

  • Full browser UI interaction flows.
  • Visual regression checks.
  • Cross-browser WebCrypto support differences.
  • Clipboard permission behavior across browsers.
  • Native save-file picker behavior and download fallback behavior.
  • Real-world PKCS#12 file corpora.
  • Certificate mismatch confirmation flows.
  • SubjectDN editing synchronization through the embedded viewer.
  • CSR and self-signed certificate creation from the UI.
  • GitHub release or npm publish workflows.

Use browser verification when changing menus, dialogs, clipboard flows, save behavior, tree selection, splitters, embedded PkiStudioJS behavior, SubjectDN editing, certificate loading, CSR generation, or self-signed certificate generation.

Related Checks

For package or release-related changes, also run:

npm run pack:dry-run

Use the local development server when browser verification is needed:

npm run dev -- --port 5173 --strictPort

Then open:

http://localhost:5173/

In VS Code, the Start pvkgadgets server task starts the same server.

Suggested Browser Smoke Checks

For user-facing application changes, verify the relevant parts of this list:

  • Generate at least one supported key pair from New.
  • Select PrivateKey and PublicKey child items and confirm the ASN.1 viewer updates.
  • Create or edit a SubjectDN item.
  • Generate a CSR when a usable SubjectDN exists.
  • Generate a self-signed certificate when a usable SubjectDN exists.
  • Import a PKCS#12 file with the expected password behavior.
  • Export selected key pairs as PKCS#12.
  • Confirm read-only viewer behavior for PrivateKey, PublicKey, Certificate, and CSR items.
  • Confirm editable viewer behavior for SubjectDN items.

How to Update This Page

Update this page when the project adds a dedicated test suite, changes standard checks, adds package entry points, changes browser verification expectations, or adds important public API guarantees.

Clone this wiki locally