@oalacea/daemon 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +268 -58
- package/bin/Dockerfile +158 -16
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +22 -2
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/commands/command.types.d.ts +216 -0
- package/dist/cli/commands/command.types.d.ts.map +1 -0
- package/dist/cli/commands/command.types.js +64 -0
- package/dist/cli/commands/command.types.js.map +1 -0
- package/dist/cli/commands/history.command.d.ts +91 -0
- package/dist/cli/commands/history.command.d.ts.map +1 -0
- package/dist/cli/commands/history.command.js +336 -0
- package/dist/cli/commands/history.command.js.map +1 -0
- package/dist/cli/commands/index.d.ts +14 -3
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +7 -0
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init.command.d.ts +12 -14
- package/dist/cli/commands/init.command.d.ts.map +1 -1
- package/dist/cli/commands/init.command.js +278 -144
- package/dist/cli/commands/init.command.js.map +1 -1
- package/dist/cli/commands/optimize.command.d.ts +110 -0
- package/dist/cli/commands/optimize.command.d.ts.map +1 -0
- package/dist/cli/commands/optimize.command.js +497 -0
- package/dist/cli/commands/optimize.command.js.map +1 -0
- package/dist/cli/commands/report.command.d.ts +110 -0
- package/dist/cli/commands/report.command.d.ts.map +1 -0
- package/dist/cli/commands/report.command.js +532 -0
- package/dist/cli/commands/report.command.js.map +1 -0
- package/dist/cli/commands/review.command.d.ts +110 -0
- package/dist/cli/commands/review.command.d.ts.map +1 -0
- package/dist/cli/commands/review.command.js +520 -0
- package/dist/cli/commands/review.command.js.map +1 -0
- package/dist/cli/commands/score.command.d.ts +47 -0
- package/dist/cli/commands/score.command.d.ts.map +1 -0
- package/dist/cli/commands/score.command.js +261 -0
- package/dist/cli/commands/score.command.js.map +1 -0
- package/dist/cli/utils/index.d.ts +10 -0
- package/dist/cli/utils/index.d.ts.map +1 -0
- package/dist/cli/utils/index.js +10 -0
- package/dist/cli/utils/index.js.map +1 -0
- package/dist/cli/utils/output.d.ts +192 -0
- package/dist/cli/utils/output.d.ts.map +1 -0
- package/dist/cli/utils/output.js +411 -0
- package/dist/cli/utils/output.js.map +1 -0
- package/dist/cli/utils/progress.d.ts +204 -0
- package/dist/cli/utils/progress.d.ts.map +1 -0
- package/dist/cli/utils/progress.js +396 -0
- package/dist/cli/utils/progress.js.map +1 -0
- package/dist/core/types/index.d.ts +1 -0
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/core/types/project.types.d.ts +3 -3
- package/dist/core/types/project.types.d.ts.map +1 -1
- package/dist/core/types/scoring.types.d.ts +301 -0
- package/dist/core/types/scoring.types.d.ts.map +1 -0
- package/dist/core/types/scoring.types.js +8 -0
- package/dist/core/types/scoring.types.js.map +1 -0
- package/dist/services/detection/framework-detector.d.ts.map +1 -1
- package/dist/services/detection/framework-detector.js +74 -5
- package/dist/services/detection/framework-detector.js.map +1 -1
- package/dist/services/index.d.ts +12 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +14 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/optimization/detectors/bug-detector.d.ts +82 -0
- package/dist/services/optimization/detectors/bug-detector.d.ts.map +1 -0
- package/dist/services/optimization/detectors/bug-detector.js +443 -0
- package/dist/services/optimization/detectors/bug-detector.js.map +1 -0
- package/dist/services/optimization/detectors/code-smell-detector.d.ts +108 -0
- package/dist/services/optimization/detectors/code-smell-detector.d.ts.map +1 -0
- package/dist/services/optimization/detectors/code-smell-detector.js +569 -0
- package/dist/services/optimization/detectors/code-smell-detector.js.map +1 -0
- package/dist/services/optimization/detectors/index.d.ts +7 -0
- package/dist/services/optimization/detectors/index.d.ts.map +1 -0
- package/dist/services/optimization/detectors/index.js +7 -0
- package/dist/services/optimization/detectors/index.js.map +1 -0
- package/dist/services/optimization/detectors/perf-detector.d.ts +80 -0
- package/dist/services/optimization/detectors/perf-detector.d.ts.map +1 -0
- package/dist/services/optimization/detectors/perf-detector.js +451 -0
- package/dist/services/optimization/detectors/perf-detector.js.map +1 -0
- package/dist/services/optimization/index.d.ts +61 -0
- package/dist/services/optimization/index.d.ts.map +1 -0
- package/dist/services/optimization/index.js +69 -0
- package/dist/services/optimization/index.js.map +1 -0
- package/dist/services/optimization/optimization.service.d.ts +65 -0
- package/dist/services/optimization/optimization.service.d.ts.map +1 -0
- package/dist/services/optimization/optimization.service.js +511 -0
- package/dist/services/optimization/optimization.service.js.map +1 -0
- package/dist/services/optimization/optimization.types.d.ts +343 -0
- package/dist/services/optimization/optimization.types.d.ts.map +1 -0
- package/dist/services/optimization/optimization.types.js +8 -0
- package/dist/services/optimization/optimization.types.js.map +1 -0
- package/dist/services/optimization/optimizers/code-optimizer.d.ts +87 -0
- package/dist/services/optimization/optimizers/code-optimizer.d.ts.map +1 -0
- package/dist/services/optimization/optimizers/code-optimizer.js +436 -0
- package/dist/services/optimization/optimizers/code-optimizer.js.map +1 -0
- package/dist/services/optimization/optimizers/index.d.ts +7 -0
- package/dist/services/optimization/optimizers/index.d.ts.map +1 -0
- package/dist/services/optimization/optimizers/index.js +7 -0
- package/dist/services/optimization/optimizers/index.js.map +1 -0
- package/dist/services/optimization/optimizers/perf-optimizer.d.ts +64 -0
- package/dist/services/optimization/optimizers/perf-optimizer.d.ts.map +1 -0
- package/dist/services/optimization/optimizers/perf-optimizer.js +330 -0
- package/dist/services/optimization/optimizers/perf-optimizer.js.map +1 -0
- package/dist/services/optimization/optimizers/refact-optimizer.d.ts +82 -0
- package/dist/services/optimization/optimizers/refact-optimizer.d.ts.map +1 -0
- package/dist/services/optimization/optimizers/refact-optimizer.js +354 -0
- package/dist/services/optimization/optimizers/refact-optimizer.js.map +1 -0
- package/dist/services/optimization/patterns/anti-patterns.d.ts +31 -0
- package/dist/services/optimization/patterns/anti-patterns.d.ts.map +1 -0
- package/dist/services/optimization/patterns/anti-patterns.js +501 -0
- package/dist/services/optimization/patterns/anti-patterns.js.map +1 -0
- package/dist/services/optimization/patterns/index.d.ts +5 -0
- package/dist/services/optimization/patterns/index.d.ts.map +1 -0
- package/dist/services/optimization/patterns/index.js +5 -0
- package/dist/services/optimization/patterns/index.js.map +1 -0
- package/dist/services/reporting/export/chart.exporter.d.ts +59 -0
- package/dist/services/reporting/export/chart.exporter.d.ts.map +1 -0
- package/dist/services/reporting/export/chart.exporter.js +350 -0
- package/dist/services/reporting/export/chart.exporter.js.map +1 -0
- package/dist/services/reporting/export/index.d.ts +9 -0
- package/dist/services/reporting/export/index.d.ts.map +1 -0
- package/dist/services/reporting/export/index.js +10 -0
- package/dist/services/reporting/export/index.js.map +1 -0
- package/dist/services/reporting/export/pdf.exporter.d.ts +133 -0
- package/dist/services/reporting/export/pdf.exporter.d.ts.map +1 -0
- package/dist/services/reporting/export/pdf.exporter.js +270 -0
- package/dist/services/reporting/export/pdf.exporter.js.map +1 -0
- package/dist/services/reporting/history.service.d.ts +93 -0
- package/dist/services/reporting/history.service.d.ts.map +1 -0
- package/dist/services/reporting/history.service.js +285 -0
- package/dist/services/reporting/history.service.js.map +1 -0
- package/dist/services/reporting/index.d.ts +15 -0
- package/dist/services/reporting/index.d.ts.map +1 -0
- package/dist/services/reporting/index.js +16 -0
- package/dist/services/reporting/index.js.map +1 -0
- package/dist/services/reporting/report.service.d.ts +102 -0
- package/dist/services/reporting/report.service.d.ts.map +1 -0
- package/dist/services/reporting/report.service.js +240 -0
- package/dist/services/reporting/report.service.js.map +1 -0
- package/dist/services/reporting/reporting.types.d.ts +329 -0
- package/dist/services/reporting/reporting.types.d.ts.map +1 -0
- package/dist/services/reporting/reporting.types.js +8 -0
- package/dist/services/reporting/reporting.types.js.map +1 -0
- package/dist/services/reporting/templates/html.template.d.ts +81 -0
- package/dist/services/reporting/templates/html.template.d.ts.map +1 -0
- package/dist/services/reporting/templates/html.template.js +741 -0
- package/dist/services/reporting/templates/html.template.js.map +1 -0
- package/dist/services/reporting/templates/json.template.d.ts +85 -0
- package/dist/services/reporting/templates/json.template.d.ts.map +1 -0
- package/dist/services/reporting/templates/json.template.js +308 -0
- package/dist/services/reporting/templates/json.template.js.map +1 -0
- package/dist/services/reporting/templates/markdown.template.d.ts +69 -0
- package/dist/services/reporting/templates/markdown.template.d.ts.map +1 -0
- package/dist/services/reporting/templates/markdown.template.js +311 -0
- package/dist/services/reporting/templates/markdown.template.js.map +1 -0
- package/dist/services/reporting/trend-analyzer.d.ts +73 -0
- package/dist/services/reporting/trend-analyzer.d.ts.map +1 -0
- package/dist/services/reporting/trend-analyzer.js +291 -0
- package/dist/services/reporting/trend-analyzer.js.map +1 -0
- package/dist/services/review/analyzers/dependency-analyzer.d.ts +87 -0
- package/dist/services/review/analyzers/dependency-analyzer.d.ts.map +1 -0
- package/dist/services/review/analyzers/dependency-analyzer.js +458 -0
- package/dist/services/review/analyzers/dependency-analyzer.js.map +1 -0
- package/dist/services/review/analyzers/index.d.ts +13 -0
- package/dist/services/review/analyzers/index.d.ts.map +1 -0
- package/dist/services/review/analyzers/index.js +13 -0
- package/dist/services/review/analyzers/index.js.map +1 -0
- package/dist/services/review/analyzers/nestjs-analyzer.d.ts +210 -0
- package/dist/services/review/analyzers/nestjs-analyzer.d.ts.map +1 -0
- package/dist/services/review/analyzers/nestjs-analyzer.js +571 -0
- package/dist/services/review/analyzers/nestjs-analyzer.js.map +1 -0
- package/dist/services/review/analyzers/performance-analyzer.d.ts +91 -0
- package/dist/services/review/analyzers/performance-analyzer.d.ts.map +1 -0
- package/dist/services/review/analyzers/performance-analyzer.js +589 -0
- package/dist/services/review/analyzers/performance-analyzer.js.map +1 -0
- package/dist/services/review/analyzers/security-analyzer.d.ts +96 -0
- package/dist/services/review/analyzers/security-analyzer.d.ts.map +1 -0
- package/dist/services/review/analyzers/security-analyzer.js +512 -0
- package/dist/services/review/analyzers/security-analyzer.js.map +1 -0
- package/dist/services/review/analyzers/static-analyzer.d.ts +90 -0
- package/dist/services/review/analyzers/static-analyzer.d.ts.map +1 -0
- package/dist/services/review/analyzers/static-analyzer.js +423 -0
- package/dist/services/review/analyzers/static-analyzer.js.map +1 -0
- package/dist/services/review/fixers/auto-fixer.d.ts +94 -0
- package/dist/services/review/fixers/auto-fixer.d.ts.map +1 -0
- package/dist/services/review/fixers/auto-fixer.js +404 -0
- package/dist/services/review/fixers/auto-fixer.js.map +1 -0
- package/dist/services/review/fixers/index.d.ts +11 -0
- package/dist/services/review/fixers/index.d.ts.map +1 -0
- package/dist/services/review/fixers/index.js +11 -0
- package/dist/services/review/fixers/index.js.map +1 -0
- package/dist/services/review/fixers/refactor-suggester.d.ts +100 -0
- package/dist/services/review/fixers/refactor-suggester.d.ts.map +1 -0
- package/dist/services/review/fixers/refactor-suggester.js +555 -0
- package/dist/services/review/fixers/refactor-suggester.js.map +1 -0
- package/dist/services/review/fixers/test-generator.d.ts +99 -0
- package/dist/services/review/fixers/test-generator.d.ts.map +1 -0
- package/dist/services/review/fixers/test-generator.js +458 -0
- package/dist/services/review/fixers/test-generator.js.map +1 -0
- package/dist/services/review/index.d.ts +14 -0
- package/dist/services/review/index.d.ts.map +1 -0
- package/dist/services/review/index.js +14 -0
- package/dist/services/review/index.js.map +1 -0
- package/dist/services/review/reporters/fix-reporter.d.ts +67 -0
- package/dist/services/review/reporters/fix-reporter.d.ts.map +1 -0
- package/dist/services/review/reporters/fix-reporter.js +437 -0
- package/dist/services/review/reporters/fix-reporter.js.map +1 -0
- package/dist/services/review/reporters/index.d.ts +10 -0
- package/dist/services/review/reporters/index.d.ts.map +1 -0
- package/dist/services/review/reporters/index.js +10 -0
- package/dist/services/review/reporters/index.js.map +1 -0
- package/dist/services/review/reporters/score-reporter.d.ts +84 -0
- package/dist/services/review/reporters/score-reporter.d.ts.map +1 -0
- package/dist/services/review/reporters/score-reporter.js +560 -0
- package/dist/services/review/reporters/score-reporter.js.map +1 -0
- package/dist/services/review/review.service.d.ts +129 -0
- package/dist/services/review/review.service.d.ts.map +1 -0
- package/dist/services/review/review.service.js +396 -0
- package/dist/services/review/review.service.js.map +1 -0
- package/dist/services/review/review.types.d.ts +443 -0
- package/dist/services/review/review.types.d.ts.map +1 -0
- package/dist/services/review/review.types.js +11 -0
- package/dist/services/review/review.types.js.map +1 -0
- package/dist/services/scoring/dimensions/accessibility.analyzer.d.ts +53 -0
- package/dist/services/scoring/dimensions/accessibility.analyzer.d.ts.map +1 -0
- package/dist/services/scoring/dimensions/accessibility.analyzer.js +260 -0
- package/dist/services/scoring/dimensions/accessibility.analyzer.js.map +1 -0
- package/dist/services/scoring/dimensions/backend-logic.analyzer.d.ts +138 -0
- package/dist/services/scoring/dimensions/backend-logic.analyzer.d.ts.map +1 -0
- package/dist/services/scoring/dimensions/backend-logic.analyzer.js +713 -0
- package/dist/services/scoring/dimensions/backend-logic.analyzer.js.map +1 -0
- package/dist/services/scoring/dimensions/business-logic.analyzer.d.ts +142 -0
- package/dist/services/scoring/dimensions/business-logic.analyzer.d.ts.map +1 -0
- package/dist/services/scoring/dimensions/business-logic.analyzer.js +747 -0
- package/dist/services/scoring/dimensions/business-logic.analyzer.js.map +1 -0
- package/dist/services/scoring/dimensions/code-quality.analyzer.d.ts +142 -0
- package/dist/services/scoring/dimensions/code-quality.analyzer.d.ts.map +1 -0
- package/dist/services/scoring/dimensions/code-quality.analyzer.js +685 -0
- package/dist/services/scoring/dimensions/code-quality.analyzer.js.map +1 -0
- package/dist/services/scoring/dimensions/index.d.ts +18 -0
- package/dist/services/scoring/dimensions/index.d.ts.map +1 -0
- package/dist/services/scoring/dimensions/index.js +27 -0
- package/dist/services/scoring/dimensions/index.js.map +1 -0
- package/dist/services/scoring/dimensions/performance.analyzer.d.ts +125 -0
- package/dist/services/scoring/dimensions/performance.analyzer.d.ts.map +1 -0
- package/dist/services/scoring/dimensions/performance.analyzer.js +615 -0
- package/dist/services/scoring/dimensions/performance.analyzer.js.map +1 -0
- package/dist/services/scoring/dimensions/security.analyzer.d.ts +53 -0
- package/dist/services/scoring/dimensions/security.analyzer.d.ts.map +1 -0
- package/dist/services/scoring/dimensions/security.analyzer.js +327 -0
- package/dist/services/scoring/dimensions/security.analyzer.js.map +1 -0
- package/dist/services/scoring/dimensions/seo.analyzer.d.ts +77 -0
- package/dist/services/scoring/dimensions/seo.analyzer.d.ts.map +1 -0
- package/dist/services/scoring/dimensions/seo.analyzer.js +502 -0
- package/dist/services/scoring/dimensions/seo.analyzer.js.map +1 -0
- package/dist/services/scoring/dimensions/test-coverage.analyzer.d.ts +106 -0
- package/dist/services/scoring/dimensions/test-coverage.analyzer.d.ts.map +1 -0
- package/dist/services/scoring/dimensions/test-coverage.analyzer.js +496 -0
- package/dist/services/scoring/dimensions/test-coverage.analyzer.js.map +1 -0
- package/dist/services/scoring/dimensions/ui-ux.analyzer.d.ts +126 -0
- package/dist/services/scoring/dimensions/ui-ux.analyzer.d.ts.map +1 -0
- package/dist/services/scoring/dimensions/ui-ux.analyzer.js +665 -0
- package/dist/services/scoring/dimensions/ui-ux.analyzer.js.map +1 -0
- package/dist/services/scoring/index.d.ts +10 -0
- package/dist/services/scoring/index.d.ts.map +1 -0
- package/dist/services/scoring/index.js +10 -0
- package/dist/services/scoring/index.js.map +1 -0
- package/dist/services/scoring/scoring-service.d.ts +222 -0
- package/dist/services/scoring/scoring-service.d.ts.map +1 -0
- package/dist/services/scoring/scoring-service.js +636 -0
- package/dist/services/scoring/scoring-service.js.map +1 -0
- package/package.json +11 -3
- package/templates/README.md +183 -0
- package/templates/nestjs/controller.spec.ts +203 -0
- package/templates/nestjs/e2e/api.e2e-spec.ts +451 -0
- package/templates/nestjs/e2e/auth.e2e-spec.ts +533 -0
- package/templates/nestjs/fixtures/test-module.ts +311 -0
- package/templates/nestjs/guard.spec.ts +314 -0
- package/templates/nestjs/interceptor.spec.ts +458 -0
- package/templates/nestjs/module.spec.ts +173 -0
- package/templates/nestjs/pipe.spec.ts +474 -0
- package/templates/nestjs/service.spec.ts +296 -0
- package/templates/rust/Cargo.toml +72 -0
- package/templates/rust/actix-controller.test.rs +114 -0
- package/templates/rust/axum-handler.test.rs +117 -0
- package/templates/rust/integration.test.rs +63 -0
- package/templates/rust/rocket-route.test.rs +106 -0
- package/templates/rust/unit.test.rs +38 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oalacea/daemon",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "AI-powered
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "AI-powered code quality analysis, scoring, and optimization for web applications",
|
|
5
5
|
"author": "Yanis",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -32,7 +32,15 @@
|
|
|
32
32
|
"performance",
|
|
33
33
|
"vitest",
|
|
34
34
|
"playwright",
|
|
35
|
-
"k6"
|
|
35
|
+
"k6",
|
|
36
|
+
"code-quality",
|
|
37
|
+
"scoring",
|
|
38
|
+
"seo",
|
|
39
|
+
"security",
|
|
40
|
+
"accessibility",
|
|
41
|
+
"optimization",
|
|
42
|
+
"rust",
|
|
43
|
+
"nestjs"
|
|
36
44
|
],
|
|
37
45
|
"devDependencies": {
|
|
38
46
|
"@types/node": "^20.19.33",
|
package/templates/README.md
CHANGED
|
@@ -14,6 +14,25 @@ templates/
|
|
|
14
14
|
│ ├── angular-component.test.ts # Angular component template
|
|
15
15
|
│ ├── hook.test.ts # React hooks template
|
|
16
16
|
│ └── api.test.ts # API route template
|
|
17
|
+
├── rust/ # Rust test templates
|
|
18
|
+
│ ├── unit.test.rs # Basic unit test template
|
|
19
|
+
│ ├── integration.test.rs # Integration test template
|
|
20
|
+
│ ├── axum-handler.test.rs # Axum framework handler tests
|
|
21
|
+
│ ├── actix-controller.test.rs # Actix-web controller tests
|
|
22
|
+
│ ├── rocket-route.test.rs # Rocket framework route tests
|
|
23
|
+
│ └── Cargo.toml # Test dependencies configuration
|
|
24
|
+
├── nestjs/ # NestJS test templates
|
|
25
|
+
│ ├── controller.spec.ts # Controller unit tests
|
|
26
|
+
│ ├── service.spec.ts # Service unit tests
|
|
27
|
+
│ ├── module.spec.ts # Module tests
|
|
28
|
+
│ ├── guard.spec.ts # Guard tests
|
|
29
|
+
│ ├── interceptor.spec.ts # Interceptor tests
|
|
30
|
+
│ ├── pipe.spec.ts # Pipe tests
|
|
31
|
+
│ ├── e2e/ # E2E tests
|
|
32
|
+
│ │ ├── api.e2e-spec.ts # API E2E tests
|
|
33
|
+
│ │ └── auth.e2e-spec.ts # Auth E2E tests
|
|
34
|
+
│ └── fixtures/ # Test utilities
|
|
35
|
+
│ └── test-module.ts # Module fixture
|
|
17
36
|
├── playwright/ # Playwright E2E templates
|
|
18
37
|
│ ├── auth.spec.ts
|
|
19
38
|
│ └── crud.spec.ts
|
|
@@ -25,6 +44,8 @@ templates/
|
|
|
25
44
|
|
|
26
45
|
## Framework Support
|
|
27
46
|
|
|
47
|
+
### Frontend Frameworks
|
|
48
|
+
|
|
28
49
|
| Framework | Template | Testing Library |
|
|
29
50
|
|-----------|----------|-----------------|
|
|
30
51
|
| React | `component.test.ts` | `@testing-library/react` |
|
|
@@ -33,6 +54,168 @@ templates/
|
|
|
33
54
|
| Svelte | `svelte-component.test.ts` | `@testing-library/svelte` |
|
|
34
55
|
| Angular | `angular-component.test.ts` | `@angular/core/testing` |
|
|
35
56
|
|
|
57
|
+
### Backend Frameworks
|
|
58
|
+
|
|
59
|
+
| Framework | Templates | Testing Library |
|
|
60
|
+
|-----------|----------|-----------------|
|
|
61
|
+
| NestJS | `*.spec.ts` | `@nestjs/testing` |
|
|
62
|
+
| Rust - Axum | `axum-handler.test.rs` | `axum-test` |
|
|
63
|
+
| Rust - Actix | `actix-controller.test.rs` | `actix-rt` |
|
|
64
|
+
| Rust - Rocket | `rocket-route.test.rs` | Built-in |
|
|
65
|
+
| Rust - Generic | `unit.test.rs`, `integration.test.rs` | Built-in |
|
|
66
|
+
| Express | `api.test.ts` | `supertest` |
|
|
67
|
+
| Fastify | `api.test.ts` | `supertest` |
|
|
68
|
+
|
|
69
|
+
## Rust Templates
|
|
70
|
+
|
|
71
|
+
The Rust templates provide test coverage for common Rust web frameworks and general testing patterns:
|
|
72
|
+
|
|
73
|
+
### Unit Tests
|
|
74
|
+
|
|
75
|
+
- **unit.test.rs**: Basic unit test template including:
|
|
76
|
+
- Test function examples
|
|
77
|
+
- Error handling tests
|
|
78
|
+
- Test fixtures
|
|
79
|
+
- Assertion patterns
|
|
80
|
+
|
|
81
|
+
### Integration Tests
|
|
82
|
+
|
|
83
|
+
- **integration.test.rs**: Integration test template including:
|
|
84
|
+
- API endpoint testing
|
|
85
|
+
- Database operations
|
|
86
|
+
- Test app setup helpers
|
|
87
|
+
- Test database pool creation
|
|
88
|
+
|
|
89
|
+
### Framework-Specific Tests
|
|
90
|
+
|
|
91
|
+
- **axum-handler.test.rs**: Axum framework tests including:
|
|
92
|
+
- Health check endpoint
|
|
93
|
+
- GET/POST handler tests
|
|
94
|
+
- Request/response validation
|
|
95
|
+
- Error status code verification
|
|
96
|
+
|
|
97
|
+
- **actix-controller.test.rs**: Actix-web framework tests including:
|
|
98
|
+
- Controller initialization
|
|
99
|
+
- Route handler testing
|
|
100
|
+
- Query parameter handling
|
|
101
|
+
- JSON payload validation
|
|
102
|
+
|
|
103
|
+
- **rocket-route.test.rs**: Rocket framework tests including:
|
|
104
|
+
- Route testing with blocking client
|
|
105
|
+
- Authentication header handling
|
|
106
|
+
- Form data testing
|
|
107
|
+
- Status code assertions
|
|
108
|
+
|
|
109
|
+
### Configuration
|
|
110
|
+
|
|
111
|
+
- **Cargo.toml**: Test dependencies including:
|
|
112
|
+
- `tokio-test` for async testing
|
|
113
|
+
- `criterion` for benchmarks
|
|
114
|
+
- Framework-specific test utilities
|
|
115
|
+
|
|
116
|
+
## NestJS Templates
|
|
117
|
+
|
|
118
|
+
The NestJS templates provide comprehensive test coverage for all NestJS components:
|
|
119
|
+
|
|
120
|
+
### Unit Tests
|
|
121
|
+
|
|
122
|
+
- **controller.spec.ts**: Tests for controllers including:
|
|
123
|
+
- Route handlers
|
|
124
|
+
- Request/response handling
|
|
125
|
+
- Query parameters
|
|
126
|
+
- DTO validation
|
|
127
|
+
- Error handling
|
|
128
|
+
|
|
129
|
+
- **service.spec.ts**: Tests for services including:
|
|
130
|
+
- Business logic
|
|
131
|
+
- Repository mocking
|
|
132
|
+
- CRUD operations
|
|
133
|
+
- Transaction handling
|
|
134
|
+
- Database errors
|
|
135
|
+
|
|
136
|
+
- **module.spec.ts**: Tests for modules including:
|
|
137
|
+
- Provider availability
|
|
138
|
+
- Dependency injection
|
|
139
|
+
- Module configuration
|
|
140
|
+
- Dynamic modules
|
|
141
|
+
|
|
142
|
+
- **guard.spec.ts**: Tests for guards including:
|
|
143
|
+
- Authentication logic
|
|
144
|
+
- Authorization checks
|
|
145
|
+
- Role validation
|
|
146
|
+
- Public route handling
|
|
147
|
+
|
|
148
|
+
- **interceptor.spec.ts**: Tests for interceptors including:
|
|
149
|
+
- Request/response transformation
|
|
150
|
+
- Logging behavior
|
|
151
|
+
- Caching
|
|
152
|
+
- Timeout handling
|
|
153
|
+
|
|
154
|
+
- **pipe.spec.ts**: Tests for pipes including:
|
|
155
|
+
- Data transformation
|
|
156
|
+
- Validation logic
|
|
157
|
+
- Error handling
|
|
158
|
+
- Custom business rules
|
|
159
|
+
|
|
160
|
+
### E2E Tests
|
|
161
|
+
|
|
162
|
+
- **api.e2e-spec.ts**: Full API testing including:
|
|
163
|
+
- CRUD operations
|
|
164
|
+
- Pagination/filtering/sorting
|
|
165
|
+
- Error handling
|
|
166
|
+
- Performance tests
|
|
167
|
+
- CORS and rate limiting
|
|
168
|
+
|
|
169
|
+
- **auth.e2e-spec.ts**: Authentication testing including:
|
|
170
|
+
- Registration flow
|
|
171
|
+
- Login/logout
|
|
172
|
+
- Token refresh
|
|
173
|
+
- Password reset
|
|
174
|
+
- Role-based access
|
|
175
|
+
|
|
176
|
+
### Fixtures
|
|
177
|
+
|
|
178
|
+
- **test-module.ts**: Common test utilities including:
|
|
179
|
+
- Mock repository factory
|
|
180
|
+
- Mock JWT service
|
|
181
|
+
- Test module builder
|
|
182
|
+
- Mock execution context
|
|
183
|
+
- Test data generators
|
|
184
|
+
|
|
185
|
+
## Patterns Checked
|
|
186
|
+
|
|
187
|
+
The NestJS analyzer verifies:
|
|
188
|
+
|
|
189
|
+
### Dependency Injection
|
|
190
|
+
- Circular dependencies between services
|
|
191
|
+
- Proper provider exports
|
|
192
|
+
- Missing @Injectable decorators
|
|
193
|
+
- Constructor injection patterns
|
|
194
|
+
|
|
195
|
+
### Decorators
|
|
196
|
+
- @Controller with routes
|
|
197
|
+
- @Injectable on services/guards/pipes
|
|
198
|
+
- @UseGuards on protected routes
|
|
199
|
+
- @UsePipes for validation
|
|
200
|
+
- @UseInterceptors for cross-cutting concerns
|
|
201
|
+
|
|
202
|
+
### Single Responsibility
|
|
203
|
+
- Services with too many dependencies (>5)
|
|
204
|
+
- Controllers without route handlers
|
|
205
|
+
- Large service classes (potential refactoring)
|
|
206
|
+
|
|
207
|
+
### Error Handling
|
|
208
|
+
- Proper exception usage
|
|
209
|
+
- HTTP exception decorators
|
|
210
|
+
- Exception filters
|
|
211
|
+
- Error response format
|
|
212
|
+
|
|
213
|
+
### DTOs
|
|
214
|
+
- class-validator decorators
|
|
215
|
+
- class-transformer usage
|
|
216
|
+
- Partial types for updates
|
|
217
|
+
- Nested DTO validation
|
|
218
|
+
|
|
36
219
|
## Usage
|
|
37
220
|
|
|
38
221
|
Templates are used by the test generator agent to create new test files based on the detected framework and patterns.
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NestJS Controller Test Template
|
|
3
|
+
*
|
|
4
|
+
* Tests for NestJS controllers following best practices:
|
|
5
|
+
* - Isolated unit tests (no actual HTTP)
|
|
6
|
+
* - Mocked services and providers
|
|
7
|
+
* - Proper DTO validation
|
|
8
|
+
* - Error handling coverage
|
|
9
|
+
*
|
|
10
|
+
* @package test
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { Test, TestingModule } from '@nestjs/testing';
|
|
14
|
+
import { GameController } from './game.controller';
|
|
15
|
+
import { GameService } from './game.service';
|
|
16
|
+
import { CreateGameDto, UpdateGameDto } from './dto';
|
|
17
|
+
import { NotFoundException, BadRequestException } from '@nestjs/common';
|
|
18
|
+
|
|
19
|
+
describe('GameController', () => {
|
|
20
|
+
let controller: GameController;
|
|
21
|
+
let service: GameService;
|
|
22
|
+
|
|
23
|
+
// Mock service
|
|
24
|
+
const mockGameService = {
|
|
25
|
+
findAll: jest.fn(),
|
|
26
|
+
findOne: jest.fn(),
|
|
27
|
+
create: jest.fn(),
|
|
28
|
+
update: jest.fn(),
|
|
29
|
+
remove: jest.fn(),
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
beforeEach(async () => {
|
|
33
|
+
const module: TestingModule = await Test.createTestingModule({
|
|
34
|
+
controllers: [GameController],
|
|
35
|
+
providers: [
|
|
36
|
+
{
|
|
37
|
+
provide: GameService,
|
|
38
|
+
useValue: mockGameService,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
}).compile();
|
|
42
|
+
|
|
43
|
+
controller = module.get<GameController>(GameController);
|
|
44
|
+
service = module.get<GameService>(GameService);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
jest.clearAllMocks();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should be defined', () => {
|
|
52
|
+
expect(controller).toBeDefined();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('findAll', () => {
|
|
56
|
+
it('should return an array of games', async () => {
|
|
57
|
+
const expectedGames = [
|
|
58
|
+
{ id: '1', name: 'Game 1' },
|
|
59
|
+
{ id: '2', name: 'Game 2' },
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
mockGameService.findAll.mockResolvedValue(expectedGames);
|
|
63
|
+
|
|
64
|
+
const result = await controller.findAll();
|
|
65
|
+
|
|
66
|
+
expect(result).toEqual(expectedGames);
|
|
67
|
+
expect(service.findAll).toHaveBeenCalledTimes(1);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should handle empty results', async () => {
|
|
71
|
+
mockGameService.findAll.mockResolvedValue([]);
|
|
72
|
+
|
|
73
|
+
const result = await controller.findAll();
|
|
74
|
+
|
|
75
|
+
expect(result).toEqual([]);
|
|
76
|
+
expect(service.findAll).toHaveBeenCalledTimes(1);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('findOne', () => {
|
|
81
|
+
it('should return a single game by id', async () => {
|
|
82
|
+
const expectedGame = { id: '1', name: 'Game 1' };
|
|
83
|
+
|
|
84
|
+
mockGameService.findOne.mockResolvedValue(expectedGame);
|
|
85
|
+
|
|
86
|
+
const result = await controller.findOne('1');
|
|
87
|
+
|
|
88
|
+
expect(result).toEqual(expectedGame);
|
|
89
|
+
expect(service.findOne).toHaveBeenCalledWith('1');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should throw NotFoundException when game not found', async () => {
|
|
93
|
+
mockGameService.findOne.mockRejectedValue(
|
|
94
|
+
new NotFoundException('Game not found')
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
await expect(controller.findOne('999')).rejects.toThrow(
|
|
98
|
+
NotFoundException
|
|
99
|
+
);
|
|
100
|
+
expect(service.findOne).toHaveBeenCalledWith('999');
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe('create', () => {
|
|
105
|
+
it('should create a new game', async () => {
|
|
106
|
+
const createGameDto: CreateGameDto = {
|
|
107
|
+
name: 'New Game',
|
|
108
|
+
type: 'action',
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const createdGame = { id: '1', ...createGameDto };
|
|
112
|
+
|
|
113
|
+
mockGameService.create.mockResolvedValue(createdGame);
|
|
114
|
+
|
|
115
|
+
const result = await controller.create(createGameDto);
|
|
116
|
+
|
|
117
|
+
expect(result).toEqual(createdGame);
|
|
118
|
+
expect(service.create).toHaveBeenCalledWith(createGameDto);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should throw BadRequestException for invalid DTO', async () => {
|
|
122
|
+
const invalidDto = { name: '' };
|
|
123
|
+
|
|
124
|
+
mockGameService.create.mockRejectedValue(
|
|
125
|
+
new BadRequestException('Invalid data')
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
await expect(controller.create(invalidDto as any)).rejects.toThrow(
|
|
129
|
+
BadRequestException
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe('update', () => {
|
|
135
|
+
it('should update an existing game', async () => {
|
|
136
|
+
const updateGameDto: UpdateGameDto = {
|
|
137
|
+
name: 'Updated Game',
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const updatedGame = { id: '1', ...updateGameDto };
|
|
141
|
+
|
|
142
|
+
mockGameService.update.mockResolvedValue(updatedGame);
|
|
143
|
+
|
|
144
|
+
const result = await controller.update('1', updateGameDto);
|
|
145
|
+
|
|
146
|
+
expect(result).toEqual(updatedGame);
|
|
147
|
+
expect(service.update).toHaveBeenCalledWith('1', updateGameDto);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('should throw NotFoundException when updating non-existent game', async () => {
|
|
151
|
+
const updateGameDto: UpdateGameDto = { name: 'Updated' };
|
|
152
|
+
|
|
153
|
+
mockGameService.update.mockRejectedValue(
|
|
154
|
+
new NotFoundException('Game not found')
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
await expect(controller.update('999', updateGameDto)).rejects.toThrow(
|
|
158
|
+
NotFoundException
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe('remove', () => {
|
|
164
|
+
it('should delete a game', async () => {
|
|
165
|
+
mockGameService.remove.mockResolvedValue(undefined);
|
|
166
|
+
|
|
167
|
+
await controller.remove('1');
|
|
168
|
+
|
|
169
|
+
expect(service.remove).toHaveBeenCalledWith('1');
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('should throw NotFoundException when deleting non-existent game', async () => {
|
|
173
|
+
mockGameService.remove.mockRejectedValue(
|
|
174
|
+
new NotFoundException('Game not found')
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
await expect(controller.remove('999')).rejects.toThrow(
|
|
178
|
+
NotFoundException
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
describe('query parameters', () => {
|
|
184
|
+
it('should handle query parameters correctly', async () => {
|
|
185
|
+
const expectedGames = [{ id: '1', name: 'Filtered Game' }];
|
|
186
|
+
|
|
187
|
+
mockGameService.findAll.mockResolvedValue(expectedGames);
|
|
188
|
+
|
|
189
|
+
const result = await controller.findAll({
|
|
190
|
+
page: '1',
|
|
191
|
+
limit: '10',
|
|
192
|
+
search: 'test',
|
|
193
|
+
} as any);
|
|
194
|
+
|
|
195
|
+
expect(result).toEqual(expectedGames);
|
|
196
|
+
expect(service.findAll).toHaveBeenCalledWith({
|
|
197
|
+
page: 1,
|
|
198
|
+
limit: 10,
|
|
199
|
+
search: 'test',
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
});
|