This document captures the important regression test cases added for each developer tool so they can be run after security or middleware changes (for example CSP updates).
pnpm run testWatch mode:
pnpm run test:watch- Runner:
vitest - UI testing:
@testing-library/react - DOM assertions:
@testing-library/jest-dom - Environment:
jsdom
Config and setup:
vitest.config.tstests/setup.ts
Test file: tests/tools/json-tools.test.tsx
- Formats valid JSON
- Input: compact valid JSON (
{"a":1}) - Action: click Format
- Expected: pretty-printed JSON output
- Input: compact valid JSON (
- Clears content and error state
- Input: invalid JSON
- Action: trigger format (to create error), then click Clear
- Expected: editor becomes empty and error message is removed
Test file: tests/tools/compare-tools.test.tsx
- Compares JSON samples and shows diff summary
- Action: click Compare in JSON tab
- Expected: difference summary is shown (e.g.
3 differences)
- Clears both JSON inputs
- Action: click Clear
- Expected: both left and right JSON textareas are empty
Test file: tests/tools/base64-utility.test.tsx
- Encode flow works
- Input:
hello - Action: click Encode
- Expected: output is
aGVsbG8=
- Input:
- Decode flow works
- Input:
aGVsbG8= - Action: switch to decode mode and click Decode
- Expected: decoded output is
hello
- Input:
Test file: tests/tools/jwt-generator.test.tsx
- Encode mode generates token output
- Action: click Generate JWT
- Expected: generated token textarea is populated
- Decode mode validates empty input
- Action: switch to decode mode and submit without token
- Expected: validation message
Paste a JWT to decode.appears
Note: JWT utility functions are mocked in component tests to keep UI tests deterministic.
Test file: tests/tools/qr-code-generator.test.tsx
- Generates QR preview from text
- Input: text content
- Expected: QR preview image is rendered
- Validates URL mode input
- Action: switch to URL mode and enter invalid URL
- Expected: URL validation error is shown
Note:
qrcodegeneration is mocked in tests for stability and speed.
Test file: tests/tools/url-expander.test.tsx
- Shows empty-input validation
- Action: submit without URLs
- Expected:
Enter at least one short URL.error appears
- Renders API expansion results
- Input: one short URL
- Action: submit form
- Expected: processed count and expanded URL are displayed
Note:
fetchis stubbed for success/error path testing without real network dependency.
Test file: tests/tools/uuid-generator.test.tsx
- Generates requested count of UUIDs
- Input: count =
3 - Action: click Generate UUIDs
- Expected: output contains exactly 3 UUID lines
- Input: count =
Note:
crypto.randomUUIDis mocked for deterministic assertions.
Run these after major changes (middleware/CSP, dependency bumps, UI refactors):
pnpm run testpnpm run build- Spot-check key pages:
/tools/json-tools/tools/compare-tools/tools/jwt-generator/tools/short-url-expander
If a test fails, update this file when behavior has intentionally changed.