unsloth/studio
Daniel Han a2ab0dda30 studio/frontend: add Vitest suite for auth + 422 helper
Pins the behavioural invariants that landed in PR #5490 (the frontend
half of the #5375-regression fix-up backlog) so a future hardening
pass cannot quietly undo them. Today these surfaces have only typecheck
+ bundle-build coverage; this lifts the floor.

What's pinned (35 tests across 3 files, ~360 ms):

- src/lib/__tests__/format-fastapi-error.test.ts (17)
  formatFastApiDetail + readFastApiError: string passthrough, array
  detail joined as "field: msg" / "; ", nested loc joined by ".",
  missing msg / missing loc / empty array / mixed valid+junk, plus
  Response shapes for 422 / 400 / 500 / 503 / non-JSON / object-detail
  + message fallback. Regression target: rendering `[object Object]`
  or `Request failed (422)` instead of "field: msg".

- src/features/auth/__tests__/session.test.ts (10)
  storeAuthTokens writes only the two JWT keys (never the must-change
  key -- the CodeQL data-flow pin); clearAuthTokens removes all three;
  setMustChangePassword writes the literal "1" / removes the key
  (presence-encoded so the stored value stays a constant, not a
  derived boolean); isOnboardingDone treats only the literal "true"
  as done.

- src/features/auth/__tests__/api.test.ts (8)
  refreshSession singleflight (5 racing callers -> 1 /api/auth/refresh
  request); in-flight slot clears so subsequent calls refetch;
  non-OK response clears tokens; no refresh token -> no fetch;
  logoutGeneration drops the new token pair when logout() lands
  mid-refresh; logout() clears local state on 204; logout() retries
  with a rotated access token on 401; logout() still clears state on
  network failure.

Wiring:
- vitest 4 + happy-dom 18 as devDependencies.
- vitest.config.ts mirrors the @/ alias from tsconfig.app.json.
- New `test` / `test:watch` scripts.

Workflow step (CI gating) is intentionally NOT included in this PR
because the publishing token lacks `workflow` scope. After merge, add
this between the Typecheck and Build steps in
.github/workflows/studio-frontend-ci.yml:

  - name: Unit tests (Vitest)
    run: npm run test

`npm run typecheck` / `test` / `build` all clean locally.
2026-05-18 08:07:45 +00:00
..
backend studio: extend offline DNS auto-detect to inference parent + training (#5512) 2026-05-18 00:31:33 -07:00
frontend studio/frontend: add Vitest suite for auth + 422 helper 2026-05-18 08:07:45 +00:00
src-tauri studio: expose launcher capability bits on unauth /api/health (#5486) 2026-05-17 21:29:24 -07:00
__init__.py Final cleanup 2026-03-12 18:28:04 +00:00
install_llama_prebuilt.py tests/studio: lock in Windows GPU detection fix (#5106) with a synthetic CI test (#5376) 2026-05-18 00:06:01 -07:00
install_python_stack.py studio: skip flash-attn install on Blackwell GPUs (sm_100+) (#5420) 2026-05-14 18:13:50 +04:00
LICENSE.AGPL-3.0 Add AGPL-3.0 license to studio folder 2026-03-09 19:36:25 +00:00
setup.bat Final cleanup 2026-03-12 18:28:04 +00:00
setup.ps1 CI: scope GITHUB_TOKEN permissions, add MLX CI, unblock ~60 skipped tests (#5312) 2026-05-11 03:19:13 -07:00
setup.sh Route CPU-only Linux x86_64 to ggml-org/llama.cpp prebuilts (#5302) 2026-05-05 23:22:22 -07:00
Unsloth_Studio_Colab.ipynb studio: add --local to setup.sh + overlay unsloth-zoo from git main (#5252) 2026-05-02 08:51:56 +04:00