跳到正文
cccskills
免费在 GitHub 公开

testing

DraftForge test infrastructure for writing backend unit tests, Playwright E2E tests, and managing test data population. This skill should be used when writing new tests, adding test fixtures, creating populate functions for new features, adding Playwright E2E specs, using login/auth fixtures, creating test users/orgs/leagues/tournaments, or understanding the test data architecture. Covers backend Django tests via Docker, Playwright config (projects, workers, sharding), test auth endpoints that expose backend login to frontend, and feature-isolated test data patterns.

中文简介正在准备中。当前显示原文说明。

集成工具DockerPlaywright
查看安装方法

包含的文件(7)

  • SKILL.md5.2 KB
  • references/backend-test-endpoints.md7.1 KB
  • references/feature-isolation.md4.1 KB
  • references/mobile-iteration-workflow.md5.2 KB
  • references/playwright-config.md2.6 KB
  • references/playwright-fixtures.md10.8 KB
  • references/populate-system.md5.1 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

DraftForge Testing Infrastructure

Self-Updating

This skill documents live code. When modifying test infrastructure, update the relevant reference file. To verify current state, read the source files referenced in each section.

Critical Rules

  1. Always use data-testid selectors in Playwright tests and demos. Never use getByLabel, getByText, or getByRole('combobox') for element interaction. See playwright-fixtures.md for the full policy and exceptions.
  2. Use postWithCsrf/patchWithCsrf for all POST/PATCH calls to DRF ViewSet endpoints (not test endpoints). See playwright-fixtures.md for CSRF handling.

Architecture Overview

Two-layer test data system:

  1. Data definitions (backend/tests/data/) - Pydantic models (TestUser, TestOrganization, TestLeague, TestTeam, TestTournament)
  2. Populate functions (backend/tests/populate/) - Create DB records from data definitions

Backend exposes /api/tests/* endpoints (TEST=true only) so Playwright can login, reset state, and create test-specific data.

Key Principle: Feature-Isolated Test Data

Each feature's E2E tests MUST use dedicated test data. Never reuse another feature's org/league/tournament.

See references/feature-isolation.md for the full pattern.

Running Tests

# Backend (Docker - use --entrypoint "" to bypass daphne)
docker compose -f docker/docker-compose.test.yaml run --rm --entrypoint "" backend \
  python manage.py test app.tests.test_csv_import -v 2

# Playwright
just test::pw::headless              # All tests
just test::pw::spec csv-import       # Specific suite
just test::pw::ui                    # Interactive UI mode

# Full setup (down, update, build, populate, up)
just test::setup

# Repopulate test data only
just db::populate::all

Cacheops and Test State Resets

Django cacheops is active in the test environment (1-hour TTL for Organization, League, etc.). M2M changes (.add(), .remove(), .clear()) do NOT auto-invalidate cacheops cache.

When writing test reset endpoints or backend views that modify M2M fields:

from cacheops import invalidate_obj

org.admins.clear()
org.admins.add(admin_user)
invalidate_obj(org)  # REQUIRED after M2M changes

Without invalidate_obj(), subsequent GET requests return stale cached data — a common cause of flaky E2E tests where state resets appear to not take effect.

See references/backend-test-endpoints.md for the full pattern.

Reference Files

ReferenceWhen to read
populate-system.mdAdding test data, new populate functions, understanding data models
playwright-fixtures.mdWriting E2E tests, using login fixtures, auth patterns
backend-test-endpoints.mdAdding new test API endpoints, understanding backend-frontend test bridge
feature-isolation.mdCreating dedicated test data for a new feature's E2E tests
playwright-config.mdTest runner config, projects, workers, sharding, timeouts
mobile-iteration-workflow.mdIterating on mobile overflow / hydration regressions across the brand, ui-styling, i18n-react, playwright skills

Quick Reference: Current Test Data

EntityNamePKsteam_league_id
OrgDTX1-
OrgTest Organization2-
OrgCSV Import Org3-
OrgEvents Test Org7-
LeagueDTX League117929
LeagueTest League217930
LeagueCSV Import League317931
LeagueEvents Test League717935
UserPKRoleLogin fixture
kettleofketchup1001superuserloginAdmin()
hurk_1002staffloginStaff()
bucketoffish551003regularloginUser()
org_admin_tester1020org admin (org 1)loginOrgAdmin()
org_staff_tester1021org staff (org 1)loginOrgStaff()
league_admin_tester1030league adminloginLeagueAdmin()
league_staff_tester1031league staffloginLeagueStaff()
event_org_admin1080org admin (org 7)loginEventAdmin()
event_player_11081regularloginEventPlayer()

NOTE: When this table drifts from source, read backend/tests/data/users.py and backend/tests/data/organizations.py for truth.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

aesthetic

免费

Create aesthetically beautiful interfaces following proven design principles. Use when building UI/UX, analyzing designs from inspiration sites, generating design images with ai-multimodal, implementing visual hierarchy and color theory, adding micro-interactions, or creating design documentation. Includes workflows for capturing and analyzing inspiration screenshots with chrome-devtools and ai-multimodal, iterative design image generation until aesthetic standards are met, and comprehensive design system guidance covering BEAUTIFUL (aesthetic principles), RIGHT (functionality/accessibility), SATISFYING (micro-interactions), and PEAK (storytelling) stages. Integrates with chrome-devtools, ai-multimodal, media-processing, ui-styling, and web-frameworks skills.

中文简介正在准备中。当前显示原文说明。

kettleofketchup/DraftForge152026年10月19日 更新

Proper usage of Bash and file operation tools. Use this skill when executing shell commands, writing files, or when tempted to use echo/cat/heredoc to pipe content to files. Prevents permission circumvention patterns like piping multiline content through echo instead of using Write tool. Covers Bash tool, Write tool, Edit tool, and Read tool best practices.

中文简介正在准备中。当前显示原文说明。

kettleofketchup/DraftForge152026年10月19日 更新

brand

免费

DraftForge brand/theming review. Flags raw <button> over PrimaryButton/SecondaryButton, hardcoded violet/slate over brand tokens, inline styles, missing UserAvatar/EntityBreadcrumb.

中文简介正在准备中。当前显示原文说明。

kettleofketchup/DraftForge152026年10月19日 更新

Browser automation, debugging, and performance analysis using Puppeteer CLI scripts. Use for automating browsers, taking screenshots, analyzing performance, monitoring network traffic, web scraping, form automation, and JavaScript debugging.

中文简介正在准备中。当前显示原文说明。

kettleofketchup/DraftForge152026年10月19日 更新

Django Redis caching with django-cacheops. This skill should be used when implementing caching, adding cache invalidation, optimizing API performance, modifying models that affect cached data, or debugging cache-related issues in the Django backend.

中文简介正在准备中。当前显示原文说明。

kettleofketchup/DraftForge152026年10月19日 更新

Frontend development guidelines for React/TypeScript applications. Modern patterns including Suspense, lazy loading, useSuspenseQuery, file organization with features directory, MUI v7 styling, TanStack Router, performance optimization, and TypeScript best practices. Use when creating components, pages, features, fetching data, styling, routing, or working with frontend code.

中文简介正在准备中。当前显示原文说明。

kettleofketchup/DraftForge152026年10月19日 更新

查看 kettleofketchup 的全部技能

报告此技能的问题