Skip to content

Testing and Verification

Both backend templates ship executable contract tests asserting the same docs/contract/api.md, and all three frontend templates include Vitest unit tests and Playwright E2E tests. The scaffold CLI itself has no automated tests, so generator changes still use a manual verification process.

终端窗口
# Python: 32 assertions
cd templates/backend-python
uv sync --extra dev
uv run ruff check .
uv run pytest -q
# Java: 28 assertions
cd templates/backend-java
mvn spotless:check
mvn test

They cover the endpoint set, the response envelope (data must exist), resource field shapes, pagination clamping, token invalidation after logout, no partial writes on failure, SSRF rejection, and the export archive format.

Both suites also assert that every endpoint has a real response schema in OpenAPI: each one must have structured content, and successful responses must point at a concrete ApiResponse<T> generic. That is what lets a client generate types straight from /openapi.json instead of facing blank responses.

When changing the API, change the contract first, then both implementations and both test suites.

All three frontend templates ship Vitest unit tests and Playwright E2E tests:

终端窗口
cd templates/frontend-react # or templates/frontend-vue / templates/frontend-svelte
npm test
npm run test:e2e # first run: npx playwright install chromium

React/Vue use Testing Library; Svelte uses Vitest browser mode (vitest-browser-svelte) and can run svelte-check via npm run check.

  1. Generate a test project

    终端窗口
    npm run dev

    Choose a frontend / backend combination and a project name to generate into the working directory.

  2. Verify the frontend

    终端窗口
    cd <project>/frontend
    npm install
    npm run build

    The build should complete without errors. During development, npm run dev lets you check page rendering and API integration.

  3. Verify the backend

    终端窗口
    # Python
    cd <project>/backend
    uv sync
    JWT_SECRET_KEY="$(openssl rand -base64 48)" uv run uvicorn app.main:app --reload --host 127.0.0.1 --port 8088
    # Java
    cd <project>/backend
    mvn spring-boot:run

    Confirm the backend starts, initializes the database and writes seed data, and that you can log in with admin / 123456. API docs are at http://localhost:8088/docs in both stacks.

  4. Verify Docker

    终端窗口
    docker build -t test .
    docker run -p 5173:5173 -e JWT_SECRET_KEY="$(openssl rand -base64 48)" test

    Visit http://localhost:5173 to confirm the frontend loads and login works.

  1. Log in as an administrator, open Menu & Permissions, drag to reorder groups and move an item across groups, refresh, and confirm the order persists.
  2. Create a custom menu, grant it to a role, and confirm it appears in the dynamic sidebar; delete it and confirm its operation permissions and grants disappear.
  3. Hide a menu, confirm the sidebar entry disappears while the route still opens directly, then show it again.
  4. Export full data, confirm the download and one-time password dialog, and verify the password cannot be displayed again after closing.
  5. Import the archive with the correct password and confirm ordinary APIs return 503 during import and the job ends with success.
  6. After a successful import, confirm old tokens return 401 and an administrator from the archive can log in.
  7. Try a wrong password, damaged archive, and incompatible version; confirm rollback and that ordinary APIs recover.

At minimum, verify the combinations affected by your changes. Because frontend and backend pair freely, when changing a frontend template you should also verify it against both the Python and Java backends; the same applies when changing a backend template.

  • npm run build (scaffold) passes
  • Backend contract tests pass (pytest / mvn test)
  • The generated project’s frontend build passes
  • The backend starts and completes migrations and initialization
  • admin / 123456 can log in
  • /docs opens in both stacks
  • Permission menus display correctly by role
  • Menu ordering, cross-group moves, and custom-menu permissions work
  • The export archive decrypts and contains the full table manifest
  • A successful import freezes ordinary requests and invalidates every session
  • A failed import rolls back and releases the freeze
  • Old tokens return 401 after logout
  • The Docker image builds and runs