audit-tests

Audit and fix unit tests for permission-gated UI components using usePermissions.

1.8k|375|Updated Jan 15, 2025
One-click install
npx skills add https://github.com/trycompai/comp --skill audit-tests-trycompai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: audit-tests
Source: https://github.com/trycompai/comp/tree/main/.agents/skills/audit-tests
Command: npx skills add https://github.com/trycompai/comp --skill audit-tests-trycompai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Audit and fix missing or failing unit tests for components that use permissions to enforce access control.

Core Features & Use Cases

  • Detect components importing usePermissions and verify visibility and enabled states for Admin (write) and Auditor (read-only) roles.
  • Enforce a consistent test pattern across all permission-gated components using provided test-utils mocks.
  • Quick feedback on test gaps to ensure read-visible content is preserved and mutations are properly gated.

Quick Start

Run the app's unit tests and implement any missing permission tests following the prescribed pattern.

Frequently Asked Questions about audit-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test permission-gated UI components for Admin and Auditor roles in Vitest?

To test permission-gated UI components, audit unit tests to verify Admin (write) and Auditor (read-only) role behaviors. Ensure mutation elements are properly hidden or disabled for Auditors while read-only content remains visible using provided test-utils mocks in a Vitest/jsdom environment.

What is the correct test pattern for usePermissions components using testing-library?

The correct test pattern for usePermissions components involves leveraging provided test-utils mocks to validate authorization behavior. You must verify visibility and enabled states across different roles to ensure mutation elements are properly gated and read-only content stays accessible.

Why are mutation elements still visible for Auditor roles in my unit tests?

Mutation elements remain visible in unit tests when permission-gated components lack proper role-based assertions. You need to audit and fix these tests to ensure mutation elements are properly hidden or disabled for Auditor (read-only) roles while preserving read-only content visibility.

Can I use this audit to enforce consistent test patterns across all permission-gated components?

Yes, you can use this audit to enforce a consistent test pattern across all permission-gated components. It detects components importing usePermissions and validates visibility and enabled states using prescribed test-utils mocks in a Vitest/jsdom testing environment.

How do I fix missing unit tests for components using usePermissions?

To fix missing unit tests for components using usePermissions, run the application's unit tests and implement the missing permission tests following the prescribed pattern. This ensures read-visible content is preserved and mutations are properly gated for different roles.