Skip to main content

audit-tests

Audit & fix unit tests for permission-gated components

来源信息

仓库
trycompai/comp
最近来源活动
2026年4月27日 13:56
检测到的 SKILL.md 语言
英语
星标
2,057
Forks
440

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
audit-tests
description
Audit & fix unit tests for permission-gated components
Check that unit tests exist and pass for permission-gated components. **Write missing tests immediately.** ## Infrastructure - **Framework**: Vitest with jsdom - **Component testing**: `@testing-library/react` + `@testing-library/jest-dom` - **Setup**: `apps/app/src/test-utils/setup.ts` - **Permission mocks**: `apps/app/src/test-utils/mocks/permissions.ts` - **Run**: `cd apps/app && bunx vitest run` ## Required Test Pattern Every component importing `usePermissions` MUST have tests covering: 1. **Admin (write) user**: mutation elements visible/enabled 2. **Auditor (read-only)**: mutation elements hidden/disabled 3. **Data always visible**: read-only content renders regardless of permissions Use `setMockPermissions`, `ADMIN_PERMISSIONS`, `AUDITOR_PERMISSIONS` from test utils. ## Process 1. Find components with `usePermissions` in `$ARGUMENTS` 2. Check for corresponding `.test.tsx` files 3. Write missing tests following the pattern above 4. Fix any failing tests 5. Run: `cd apps/app && bunx vitest run`
在 GitHub 查看