Build a reusable end-to-end test foundation for the admin console, then use the model multidimensional pricing page as the first covered workflow.
The foundation must verify the real frontend/backend contract, authentication, persistence, and page routing. It should be easy to run locally and suitable for CI later.
In scope:
web/./console/setting?tab=ratio.Out of scope for the first pass:
Use real backend + temporary SQLite + Playwright.
The project already has @playwright/test in web/package.json. The backend can start with go run main.go, and when no users exist it creates the root user with username root and password 123456. Running against a temporary SQLite database gives each test run a clean system without requiring external services.
This approach is slower than API mocks, but it catches the issues that matter for this feature: frontend/backend response shape, save/load behavior, auth redirects, and persistence across page reloads.
Playwright will run from the web/ directory.
Backend:
go run main.go from the repository root.PORT=3001SQLITE_PATH=<temp-dir>/e2e.db?_busy_timeout=30000SESSION_SECRET=e2e_session_secret_for_local_tests/api/setup or another lightweight HTTP endpoint before running tests.Frontend:
webServer.bun run dev -- --host 127.0.0.1 --port 5173VITE_REACT_APP_SERVER_URL=http://127.0.0.1:3001http://127.0.0.1:5173Browser auth:
root / 123456.web/e2e/.auth/root.json.Proposed files:
web/playwright.config.jsweb/e2e/global-setup.jsweb/e2e/global-teardown.jsweb/e2e/auth.setup.jsweb/e2e/model-pricing.spec.jsweb/e2e/utils/process.jsweb/e2e/utils/wait.jsProposed package scripts:
e2e: playwright teste2e:ui: playwright test --uie2e:headed: playwright test --headede2e:install: playwright install chromiumThe first E2E test should cover the critical user path:
/console/setting?tab=ratio.模型多维计费 tab.e2e-video-pricing-model.duration and quality.The test should also observe the network response for save/load requests and assert successful API envelopes where practical. This makes contract mismatches visible even if the UI shows a generic toast.
Prefer stable selectors instead of brittle text-only selectors for controls that are hard to disambiguate.
The implementation should add data-testid only where current markup cannot be selected reliably:
Visible text can still be used for high-level navigation when the text is unique and user-facing.
Each E2E run uses a new temporary SQLite database path. This prevents tests from depending on local developer data and avoids cleanup requirements for most tables.
Within the UI, test-created models should use an e2e- prefix. If the same database is reused during debugging, tests can safely identify their own records.
Playwright should collect useful artifacts on failure:
These defaults keep normal runs fast while still making UI failures diagnosable.
The initial implementation should work locally first. CI can later run:
cd web && bun installcd web && bun run e2e:installcd web && bun run e2eNo external database or service should be required for the first workflow.
Backend startup can be slow.
Ports can be occupied locally.
E2E_BACKEND_PORT and E2E_FRONTEND_PORT.Chinese UI text may be rendered through i18n and encoding-sensitive files.
data-testid for critical controls and keep user-facing text assertions limited to stable labels.Playwright browsers may not be installed.
bun run e2e:install and document it in script names.cd web && bun run e2e starts the backend and frontend automatically.