Files
smoothschedule/frontend/QUICK_TEST_GUIDE.md
poduck 6421ec60b7 feat(contracts): Multi-signer e-signature system with PDF overlay
- Add multi-signer contract creation with staff/customer selection
- Add signer-specific signing URLs (/sign/s/{token})
- Add sequential and parallel signing modes
- Fix can_sign check in frontend (use top-level response field)
- Fix required field validation to work for all template types
- Fix PDF overlay generation for HTML templates with generated PDFs
- Add signature pre-fill support in template field editor
- Add signature remember/re-apply feature during signing
- Update PDFOverlayService to read from contract.original_pdf_path

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 02:28:29 -05:00

118 lines
2.7 KiB
Markdown

# Quick Test Guide - useTenantExists Hook
## Setup (One-time)
```bash
cd /home/poduck/Desktop/smoothschedule2/frontend
./install-test-deps.sh
```
Then add to `package.json`:
```json
{
"scripts": {
"test": "vitest",
"test:ui": "vitest --ui",
"test:run": "vitest run",
"test:coverage": "vitest run --coverage"
}
}
```
## Run Tests
```bash
# Run all tests (watch mode)
npm run test
# Run once (CI mode)
npm run test:run
# Run with UI
npm run test:ui
# Run with coverage
npm run test:coverage
# Run only useTenantExists tests
npm run test -- useTenantExists
# Run specific test by name
npm run test -- -t "returns exists: true"
```
## Files Created
| File | Location | Purpose |
|------|----------|---------|
| **Test Suite** | `src/hooks/__tests__/useTenantExists.test.ts` | 19 comprehensive tests |
| **Vitest Config** | `vitest.config.ts` | Test runner configuration |
| **Test Setup** | `src/test/setup.ts` | Global test setup |
| **Install Script** | `install-test-deps.sh` | Dependency installation |
## Test Coverage
**All Required Tests Implemented:**
1. Returns exists: true when API returns 200
2. Returns exists: false when API returns 404
3. Returns exists: false when subdomain is null
4. Returns exists: false on other API errors
5. Shows loading state while fetching
6. Caches results (5 minute staleTime)
7. Does not make API call when subdomain is null
Plus **12 additional tests** for edge cases and error handling.
## Expected Output
```
✓ src/hooks/__tests__/useTenantExists.test.ts (19)
✓ useTenantExists
✓ API Success Cases (2)
✓ API Error Cases (4)
✓ Null Subdomain Cases (3)
✓ Loading States (2)
✓ Caching Behavior (2)
✓ Query Key Behavior (1)
✓ Edge Cases (3)
✓ Query Retry Behavior (2)
Test Files 1 passed (1)
Tests 19 passed (19)
```
## Troubleshooting
| Issue | Solution |
|-------|----------|
| `Cannot find module 'vitest'` | Run `./install-test-deps.sh` |
| `beforeAll is not defined` | Check `vitest.config.ts` has `globals: true` |
| `document is not defined` | Ensure `environment: 'jsdom'` in config |
| Tests timeout | Increase `testTimeout` in config |
## Documentation
- **TEST_SUMMARY.md** - Complete test suite documentation
- **SETUP_TESTING.md** - Detailed setup instructions
- **TESTING.md** - Comprehensive testing guide
- **src/hooks/__tests__/README.md** - Hook testing patterns
## Next Steps
1. ✓ Test files created
2. → Install dependencies: `./install-test-deps.sh`
3. → Update package.json scripts
4. → Run tests: `npm run test`
5. → Check coverage: `npm run test:coverage`
---
**Quick Start:**
```bash
cd /home/poduck/Desktop/smoothschedule2/frontend
./install-test-deps.sh
# Add scripts to package.json
npm run test
```