|
| 1 | +# ObjectDocs Testing Guide |
| 2 | + |
| 3 | +This document describes how to test ObjectDocs across different scenarios and environments. |
| 4 | + |
| 5 | +## Test Scripts Overview |
| 6 | + |
| 7 | +ObjectDocs provides multiple test scripts to validate the complete lifecycle of documentation site creation, from initialization to production deployment. |
| 8 | + |
| 9 | +### Available Test Scripts |
| 10 | + |
| 11 | +#### 1. `test-site.sh` - Complete Lifecycle Test |
| 12 | + |
| 13 | +**Purpose**: Comprehensive end-to-end test covering the entire ObjectDocs workflow. |
| 14 | + |
| 15 | +**What it tests**: |
| 16 | +- ✅ Project initialization (`pnpm init`) |
| 17 | +- ✅ CLI installation (`@objectdocs/cli`) |
| 18 | +- ✅ ObjectDocs initialization (`objectdocs init`) |
| 19 | +- ✅ Content creation (MDX files, configuration) |
| 20 | +- ✅ Development server startup and accessibility |
| 21 | +- ✅ Production build compilation |
| 22 | +- ✅ Production server startup and accessibility |
| 23 | + |
| 24 | +**Usage**: |
| 25 | +```bash |
| 26 | +./test-site.sh |
| 27 | +``` |
| 28 | + |
| 29 | +**Duration**: ~2-5 minutes (includes server startup tests) |
| 30 | + |
| 31 | +**Requirements**: |
| 32 | +- Node.js |
| 33 | +- pnpm |
| 34 | +- curl (for HTTP testing) |
| 35 | +- Available port 7777 |
| 36 | + |
| 37 | +**Output**: Detailed step-by-step progress with color-coded success/failure indicators. |
| 38 | + |
| 39 | +#### 2. `test-quick.sh` - Quick Build Test |
| 40 | + |
| 41 | +**Purpose**: Fast CI/CD-friendly test that validates build process without running servers. |
| 42 | + |
| 43 | +**What it tests**: |
| 44 | +- ✅ Project initialization |
| 45 | +- ✅ CLI installation |
| 46 | +- ✅ ObjectDocs initialization |
| 47 | +- ✅ Content creation |
| 48 | +- ✅ Build compilation |
| 49 | +- ✅ Build output verification |
| 50 | + |
| 51 | +**Usage**: |
| 52 | +```bash |
| 53 | +./test-quick.sh |
| 54 | +``` |
| 55 | + |
| 56 | +**Duration**: ~1-2 minutes |
| 57 | + |
| 58 | +**Requirements**: |
| 59 | +- Node.js |
| 60 | +- pnpm |
| 61 | + |
| 62 | +**Output**: Minimal output focused on build success. |
| 63 | + |
| 64 | +#### 3. `examples/starter/validate.sh` - Starter Template Validation |
| 65 | + |
| 66 | +**Purpose**: Validates the example starter template structure and configuration. |
| 67 | + |
| 68 | +**What it tests**: |
| 69 | +- ✅ package.json configuration |
| 70 | +- ✅ Content directory structure |
| 71 | +- ✅ Configuration files (docs.site.json, meta.json) |
| 72 | +- ✅ MDX frontmatter validity |
| 73 | +- ✅ Dependencies installation |
| 74 | +- ✅ Vercel configuration |
| 75 | +- ✅ .gitignore setup |
| 76 | + |
| 77 | +**Usage**: |
| 78 | +```bash |
| 79 | +cd examples/starter |
| 80 | +./validate.sh |
| 81 | +``` |
| 82 | + |
| 83 | +**Duration**: < 10 seconds |
| 84 | + |
| 85 | +**Requirements**: None (static file validation only) |
| 86 | + |
| 87 | +## Testing Scenarios |
| 88 | + |
| 89 | +### 1. Local Development Testing |
| 90 | + |
| 91 | +When working on ObjectDocs itself: |
| 92 | + |
| 93 | +```bash |
| 94 | +# In the monorepo root |
| 95 | +pnpm install |
| 96 | +pnpm build |
| 97 | + |
| 98 | +# Run comprehensive test |
| 99 | +./test-site.sh |
| 100 | +``` |
| 101 | + |
| 102 | +### 2. CI/CD Testing |
| 103 | + |
| 104 | +For automated testing in CI/CD pipelines: |
| 105 | + |
| 106 | +```bash |
| 107 | +# Quick test (recommended for CI) |
| 108 | +./test-quick.sh |
| 109 | + |
| 110 | +# Or full test if time permits |
| 111 | +./test-site.sh |
| 112 | +``` |
| 113 | + |
| 114 | +Add to your CI configuration: |
| 115 | +```yaml |
| 116 | +# .github/workflows/test.yml |
| 117 | +- name: Run ObjectDocs tests |
| 118 | + run: | |
| 119 | + chmod +x ./test-quick.sh |
| 120 | + ./test-quick.sh |
| 121 | +``` |
| 122 | +
|
| 123 | +### 3. Testing Standalone Installation |
| 124 | +
|
| 125 | +To test as an end user would experience it (outside monorepo): |
| 126 | +
|
| 127 | +```bash |
| 128 | +# Create a temporary directory |
| 129 | +mkdir /tmp/objectdocs-standalone-test |
| 130 | +cd /tmp/objectdocs-standalone-test |
| 131 | + |
| 132 | +# Initialize project |
| 133 | +pnpm init -y |
| 134 | + |
| 135 | +# Install CLI from npm (or local tarball) |
| 136 | +pnpm add -D @objectdocs/cli |
| 137 | + |
| 138 | +# Configure scripts |
| 139 | +cat > package.json << 'EOF' |
| 140 | +{ |
| 141 | + "name": "test-site", |
| 142 | + "scripts": { |
| 143 | + "dev": "objectdocs dev", |
| 144 | + "build": "objectdocs build", |
| 145 | + "start": "objectdocs start" |
| 146 | + }, |
| 147 | + "devDependencies": { |
| 148 | + "@objectdocs/cli": "latest" |
| 149 | + } |
| 150 | +} |
| 151 | +EOF |
| 152 | + |
| 153 | +# Initialize ObjectDocs |
| 154 | +pnpm objectdocs init |
| 155 | + |
| 156 | +# Create content |
| 157 | +mkdir -p content/docs |
| 158 | +# ... add your content files |
| 159 | + |
| 160 | +# Test |
| 161 | +pnpm build |
| 162 | +pnpm start |
| 163 | +``` |
| 164 | + |
| 165 | +### 4. Testing with npm pack |
| 166 | + |
| 167 | +For pre-release testing: |
| 168 | + |
| 169 | +```bash |
| 170 | +# In the monorepo |
| 171 | +cd packages/cli |
| 172 | +pnpm pack |
| 173 | +# Creates objectdocs-cli-X.X.X.tgz |
| 174 | + |
| 175 | +# In a test directory |
| 176 | +mkdir /tmp/test-tarball |
| 177 | +cd /tmp/test-tarball |
| 178 | +pnpm init -y |
| 179 | +pnpm add -D ../../packages/cli/objectdocs-cli-X.X.X.tgz |
| 180 | + |
| 181 | +# Continue with normal setup |
| 182 | +``` |
| 183 | + |
| 184 | +## Manual Testing Checklist |
| 185 | + |
| 186 | +When preparing for a release, manually verify: |
| 187 | + |
| 188 | +### Development Workflow |
| 189 | +- [ ] `pnpm objectdocs init` creates `.objectdocs` directory |
| 190 | +- [ ] `pnpm dev` starts development server on port 7777 |
| 191 | +- [ ] Hot reload works when editing MDX files |
| 192 | +- [ ] Hot reload works when editing `meta.json` |
| 193 | +- [ ] Hot reload works when editing `docs.site.json` |
| 194 | + |
| 195 | +### Build Process |
| 196 | +- [ ] `pnpm build` completes without errors |
| 197 | +- [ ] Build output is created in `content/.objectdocs/.next` |
| 198 | +- [ ] No TypeScript errors |
| 199 | +- [ ] No ESLint errors (if configured) |
| 200 | + |
| 201 | +### Production Server |
| 202 | +- [ ] `pnpm start` runs the production build |
| 203 | +- [ ] All pages are accessible |
| 204 | +- [ ] Navigation works correctly |
| 205 | +- [ ] Search functionality works (if enabled) |
| 206 | +- [ ] Dark mode toggle works |
| 207 | + |
| 208 | +### Content Features |
| 209 | +- [ ] MDX frontmatter is parsed correctly |
| 210 | +- [ ] Code blocks render with syntax highlighting |
| 211 | +- [ ] Callouts and custom components render |
| 212 | +- [ ] Internal links work |
| 213 | +- [ ] External links work |
| 214 | +- [ ] Images load correctly |
| 215 | + |
| 216 | +### Configuration |
| 217 | +- [ ] Branding (name, logo) appears correctly |
| 218 | +- [ ] Navigation links appear in header |
| 219 | +- [ ] Sidebar structure matches `meta.json` |
| 220 | +- [ ] SEO meta tags are generated |
| 221 | + |
| 222 | +## Troubleshooting |
| 223 | + |
| 224 | +### Common Test Failures |
| 225 | + |
| 226 | +#### "Port 7777 already in use" |
| 227 | + |
| 228 | +**Solution**: |
| 229 | +```bash |
| 230 | +# Kill any process using port 7777 |
| 231 | +lsof -ti:7777 | xargs kill -9 |
| 232 | + |
| 233 | +# Or use a different port |
| 234 | +PORT=8888 ./test-site.sh |
| 235 | +``` |
| 236 | + |
| 237 | +#### "Build timeout" |
| 238 | + |
| 239 | +**Cause**: Build taking longer than 5 minutes. |
| 240 | + |
| 241 | +**Solution**: Increase `BUILD_TIMEOUT` in test script or check for build errors: |
| 242 | +```bash |
| 243 | +cd /tmp/objectdocs-test-* |
| 244 | +pnpm build |
| 245 | +``` |
| 246 | + |
| 247 | +#### "Cannot find module '@objectdocs/site'" |
| 248 | + |
| 249 | +**Cause**: CLI not finding the site package. |
| 250 | + |
| 251 | +**Solution**: Ensure you've built the monorepo first: |
| 252 | +```bash |
| 253 | +cd /home/runner/work/objectdocs/objectdocs |
| 254 | +pnpm install |
| 255 | +pnpm build |
| 256 | +``` |
| 257 | + |
| 258 | +#### "Dev server failed to start" |
| 259 | + |
| 260 | +**Cause**: Port conflict or build error. |
| 261 | + |
| 262 | +**Solution**: Check the server logs: |
| 263 | +```bash |
| 264 | +cat /tmp/dev-server.log |
| 265 | +``` |
| 266 | + |
| 267 | +### Debug Mode |
| 268 | + |
| 269 | +Run tests with verbose output: |
| 270 | + |
| 271 | +```bash |
| 272 | +# Enable bash debug mode |
| 273 | +bash -x ./test-site.sh |
| 274 | + |
| 275 | +# Or add set -x to the script temporarily |
| 276 | +``` |
| 277 | + |
| 278 | +## Test Coverage |
| 279 | + |
| 280 | +### What is Tested |
| 281 | +- ✅ CLI installation and initialization |
| 282 | +- ✅ Content creation workflow |
| 283 | +- ✅ Development server functionality |
| 284 | +- ✅ Production build process |
| 285 | +- ✅ Production server functionality |
| 286 | +- ✅ Configuration file validation |
| 287 | +- ✅ MDX file parsing |
| 288 | + |
| 289 | +### What is NOT Tested (Yet) |
| 290 | +- ⚠️ Translation features (`objectdocs translate`) |
| 291 | +- ⚠️ Interactive UI components |
| 292 | +- ⚠️ Search functionality |
| 293 | +- ⚠️ Browser-based E2E tests |
| 294 | +- ⚠️ Multiple language support |
| 295 | +- ⚠️ Theme customization |
| 296 | + |
| 297 | +## Contributing Test Improvements |
| 298 | + |
| 299 | +When adding new features to ObjectDocs, please: |
| 300 | + |
| 301 | +1. **Update test scripts** if the feature affects the core workflow |
| 302 | +2. **Add manual test steps** to this document |
| 303 | +3. **Document new configuration** that should be validated |
| 304 | +4. **Add edge cases** to the test suite |
| 305 | + |
| 306 | +### Adding a New Test Script |
| 307 | + |
| 308 | +1. Create the script in the root directory |
| 309 | +2. Make it executable: `chmod +x test-name.sh` |
| 310 | +3. Document it in this file |
| 311 | +4. Add it to CI configuration if appropriate |
| 312 | + |
| 313 | +### Test Script Standards |
| 314 | + |
| 315 | +All test scripts should: |
| 316 | +- Use `set -e` to exit on errors |
| 317 | +- Include color-coded output |
| 318 | +- Clean up temporary files on exit |
| 319 | +- Provide clear success/failure messages |
| 320 | +- Include a summary section |
| 321 | +- Be idempotent (can run multiple times safely) |
| 322 | + |
| 323 | +## References |
| 324 | + |
| 325 | +- [examples/starter/TESTING.md](./examples/starter/TESTING.md) - Standalone testing guide |
| 326 | +- [examples/starter/validate.sh](./examples/starter/validate.sh) - Template validation script |
| 327 | +- [README.md](./README.md) - Main project documentation |
0 commit comments