用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/camilopiedra92/YNAB-Clone --skill create-e2e-test命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
MANDATORY for any git commit, push, save, subir, or enviar request. Executes npm run git:sync as a single atomic command — zero exploration, zero loops. Enforces Conventional Commits format.
End-to-end guide for adding a new feature across all architectural layers (schema → repo → schema → DTO → route → hook → component → tests)
Comprehensive code review framework for pull requests and ad-hoc quality checks. Covers correctness, architecture compliance, security, performance, financial logic, testing, and style. Use when reviewing PRs, auditing changes, or checking code quality before merge.
正在显示 SKILL.md
基于 SOC 职业分类
| name | create-e2e-test |
| description | Guide for writing Playwright E2E tests with the project's auth, helpers, and isolation patterns |
Use this skill when adding a new Playwright E2E test spec. See examples/ for annotated reference tests.
| File | Purpose |
|---|---|
playwright.config.ts | Serial execution, 1 worker, port 3001, auth project |
tests/global-setup.ts | Creates fresh ynab_test DB, seeds CSV data, 2 users |
tests/auth.setup.ts | Logs in as TEST_USER, saves session to .auth/user.json |
tests/test-constants.ts | Credentials, URLs, DB names |
tests/e2e-helpers.ts | Navigation helpers |
tests/i18n-helpers.ts | Locale-aware t() translation helper |
tests/<feature-name>.spec.ts
Use the template from examples/example.spec.ts.
All E2E tests MUST use the t() helper for any user-facing text. Never hardcode strings.
import { t, TEST_LOCALE } from "./i18n-helpers";
For specs that manage their own auth (no storageState), pin the test locale cookie:
test.beforeEach(async ({ page }) => {
await page.context().addCookies([
{
name: "NEXT_LOCALE",
value: TEST_LOCALE,
domain: "localhost",
path: "/",
},
]);
});
import {
gotoBudgetPage,
gotoFirstAccount,
getTestBudgetId,
} from "./e2e-helpers";
| Helper | What it does |
|---|---|
gotoBudgetPage(page, request) | Navigate + wait for budget-table, returns budgetId |
gotoFirstAccount(page, request) | Navigate + click first sidebar account |
getTestBudgetId(request) | Fetch budgetId via API (cached) |
budgetUrl(budgetId) | Returns /budgets/{id}/budget |
accountUrl(budgetId, accountId) | Returns /budgets/{id}/accounts/{accountId} |
allAccountsUrl(budgetId) | Returns /budgets/{id}/accounts |
Never hardcode URLs — SaaS routes use /budgets/[id]/budget, not /budget.
data-testid and t() selectors// ✅ CORRECT — locale-independent
page.getByLabel(t("auth.email")).fill("user@test.com");
page.getByRole("button", { name: t("auth.login") }).click();
page.getByTestId("rta-amount");
page.locator('[data-testid^="category-row-"]');
// ❌ WRONG — hardcoded strings break when locale changes
page.getByLabel("Email").fill("user@test.com");
page.getByRole("button", { name: /Iniciar Sesión/i }).click();
await page.getByTestId("save-button").click();
await page.waitForResponse(
(resp) => resp.url().includes("/api/budgets/") && resp.status() === 200,
);
await expect(page.getByTestId("value")).toHaveText("Updated");
npm run test:e2e # full suite
npm run test:e2e -- tests/my-feature.spec.ts # single file
npm run test:e2e -- --ui # debug UI
auth.setup.ts runs first, all specs use TEST_USER sessionTEST_LOCALE=en npx playwright test to run tests in English| Pitfall | Fix |
|---|---|
| Hardcoded UI strings | Use t('key') from i18n-helpers.ts — never hardcode labels or button text |
| Wrong URL | Use helpers, not page.goto('/budget') |
| Intermittent assertion failure | Wait for server roundtrip before asserting |
RTA shows $ 0,00 | Poll for animated value stability |
| Login fails | Ensure locale cookie is set; use t('auth.*') for selectors |
storageState not found | auth-setup project runs as dependency (configured in playwright.config.ts) |
The check-locale-strings.sh CI guard script scans all tests/*.spec.ts files for hardcoded Spanish strings and fails the build if found. Always use t().
| File | Pattern |
|---|---|
| example.spec.ts | Standard test with navigation, mutation, animated values |
| isolation.spec.ts | Tenant isolation with manual login + locale cookie |