ifixkart-admin/.agents/skills/add_tests/SKILL.md
Adithiyan bbd3a3e959 feat: initial commit — full platform snapshot
- Backend: FastAPI app with all models, services, schemas, routes
- Admin Panel: Next.js dashboard with all modules
  (CRM, POS, repairs, warranties, billing, notifications, etc.)
- Ecommerce: storefront (submodule) + product catalog
- AI Agents: .agents/ skill library for Antigravity IDE
- Docs: architecture, billing, notification gateway markdown
- Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
2026-10-13 12:59:47 +05:30

40 lines
1.5 KiB
Markdown

---
name: "Add Tests"
description: "Add or improve tests for existing or changed behavior"
---
# Skill: Add Tests
## 1. Purpose
To write unit, integration, and regression tests ensuring code behavior is verified and protected from future regression.
## 2. When to Use
When implementing new features, modifying API endpoints, or patching database models in the Backend service.
## 3. Preconditions
* Local MySQL test database must be accessible.
* Python testing dependencies (pytest, httpx) must be installed inside Backend virtualenv.
## 4. Step-by-Step Checklist
1. Inspect the code being added or modified to identify core happy paths, edge cases, and error branches.
2. Create a matching test file under `Backend/tests/` (e.g. `test_catalog.py`).
3. Write isolated unit test functions mocking external gateways (Razorpay, ShippingRocket).
4. Run tests locally using `pytest`.
5. Review test coverage metrics.
## 5. Validation Checklist
* 100% of new test cases must compile and execute successfully.
* Assertion coverage covers at least 85% of newly added logic lines.
* Test cleanups are run successfully (no persistent dummy rows left in database).
## 6. Examples
```python
def test_get_brands_fallback(client):
response = client.get('/api/v1/catalog/brands/all')
assert response.status_code == 200
assert len(response.json()) > 0
```
## 7. Failure Cases
* Hardcoding dynamic dates in tests, causing future test failures.
* Mocking the database transactions incorrectly, causing data leaks between test threads.