@friggframework/devtools 2.0.0--canary.545.ae2019f.0 → 2.0.0--canary.549.a579cca.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.
Files changed (127) hide show
  1. package/frigg-cli/README.md +1 -1
  2. package/frigg-cli/__tests__/unit/commands/build.test.js +1 -1
  3. package/frigg-cli/__tests__/unit/commands/doctor.test.js +2 -0
  4. package/frigg-cli/__tests__/unit/commands/install.test.js +19 -23
  5. package/frigg-cli/__tests__/unit/dependencies.test.js +2 -2
  6. package/frigg-cli/build-command/index.js +11 -123
  7. package/frigg-cli/deploy-command/index.js +1 -83
  8. package/frigg-cli/doctor-command/index.js +16 -37
  9. package/frigg-cli/generate-iam-command.js +1 -21
  10. package/frigg-cli/index.js +6 -21
  11. package/frigg-cli/index.test.js +2 -7
  12. package/frigg-cli/init-command/backend-first-handler.js +42 -124
  13. package/frigg-cli/init-command/index.js +1 -2
  14. package/frigg-cli/init-command/template-handler.js +3 -13
  15. package/frigg-cli/install-command/backend-js.js +3 -3
  16. package/frigg-cli/install-command/environment-variables.js +19 -16
  17. package/frigg-cli/install-command/environment-variables.test.js +13 -12
  18. package/frigg-cli/install-command/index.js +9 -14
  19. package/frigg-cli/install-command/integration-file.js +3 -3
  20. package/frigg-cli/install-command/logger.js +12 -0
  21. package/frigg-cli/install-command/validate-package.js +9 -5
  22. package/frigg-cli/jest.config.js +1 -4
  23. package/frigg-cli/repair-command/index.js +128 -121
  24. package/frigg-cli/start-command/index.js +2 -324
  25. package/frigg-cli/ui-command/index.js +36 -58
  26. package/frigg-cli/utils/repo-detection.js +37 -85
  27. package/infrastructure/create-frigg-infrastructure.js +0 -93
  28. package/infrastructure/docs/iam-policy-templates.md +1 -1
  29. package/infrastructure/domains/networking/vpc-builder.test.js +4 -2
  30. package/infrastructure/domains/networking/vpc-resolver.test.js +1 -1
  31. package/infrastructure/domains/shared/resource-discovery.js +5 -5
  32. package/infrastructure/domains/shared/types/app-definition.js +0 -21
  33. package/infrastructure/domains/shared/types/discovery-result.test.js +1 -1
  34. package/infrastructure/domains/shared/utilities/base-definition-factory.js +1 -10
  35. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +2 -2
  36. package/infrastructure/infrastructure-composer.js +0 -2
  37. package/infrastructure/infrastructure-composer.test.js +2 -2
  38. package/management-ui/README.md +109 -245
  39. package/package.json +7 -8
  40. package/frigg-cli/__tests__/application/use-cases/AddApiModuleToIntegrationUseCase.test.js +0 -326
  41. package/frigg-cli/__tests__/application/use-cases/CreateApiModuleUseCase.test.js +0 -337
  42. package/frigg-cli/__tests__/domain/entities/ApiModule.test.js +0 -373
  43. package/frigg-cli/__tests__/domain/entities/AppDefinition.test.js +0 -313
  44. package/frigg-cli/__tests__/domain/services/IntegrationValidator.test.js +0 -269
  45. package/frigg-cli/__tests__/domain/value-objects/IntegrationName.test.js +0 -82
  46. package/frigg-cli/__tests__/infrastructure/adapters/IntegrationJsUpdater.test.js +0 -408
  47. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemApiModuleRepository.test.js +0 -583
  48. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemAppDefinitionRepository.test.js +0 -314
  49. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemIntegrationRepository.test.js +0 -383
  50. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -406
  51. package/frigg-cli/__tests__/unit/commands/provider-dispatch.test.js +0 -383
  52. package/frigg-cli/__tests__/unit/commands/repair.test.js +0 -275
  53. package/frigg-cli/__tests__/unit/start-command/application/RunPreflightChecksUseCase.test.js +0 -411
  54. package/frigg-cli/__tests__/unit/start-command/infrastructure/DatabaseAdapter.test.js +0 -405
  55. package/frigg-cli/__tests__/unit/start-command/infrastructure/DockerAdapter.test.js +0 -496
  56. package/frigg-cli/__tests__/unit/start-command/presentation/InteractivePromptAdapter.test.js +0 -474
  57. package/frigg-cli/__tests__/unit/utils/output.test.js +0 -196
  58. package/frigg-cli/application/use-cases/AddApiModuleToIntegrationUseCase.js +0 -93
  59. package/frigg-cli/application/use-cases/CreateApiModuleUseCase.js +0 -93
  60. package/frigg-cli/application/use-cases/CreateIntegrationUseCase.js +0 -103
  61. package/frigg-cli/container.js +0 -172
  62. package/frigg-cli/docs/OUTPUT_MIGRATION_GUIDE.md +0 -286
  63. package/frigg-cli/domain/entities/ApiModule.js +0 -272
  64. package/frigg-cli/domain/entities/AppDefinition.js +0 -227
  65. package/frigg-cli/domain/entities/Integration.js +0 -198
  66. package/frigg-cli/domain/exceptions/DomainException.js +0 -24
  67. package/frigg-cli/domain/ports/IApiModuleRepository.js +0 -53
  68. package/frigg-cli/domain/ports/IAppDefinitionRepository.js +0 -43
  69. package/frigg-cli/domain/ports/IIntegrationRepository.js +0 -61
  70. package/frigg-cli/domain/services/IntegrationValidator.js +0 -185
  71. package/frigg-cli/domain/value-objects/IntegrationId.js +0 -42
  72. package/frigg-cli/domain/value-objects/IntegrationName.js +0 -60
  73. package/frigg-cli/domain/value-objects/SemanticVersion.js +0 -70
  74. package/frigg-cli/infrastructure/UnitOfWork.js +0 -46
  75. package/frigg-cli/infrastructure/adapters/BackendJsUpdater.js +0 -197
  76. package/frigg-cli/infrastructure/adapters/FileSystemAdapter.js +0 -224
  77. package/frigg-cli/infrastructure/adapters/IntegrationJsUpdater.js +0 -249
  78. package/frigg-cli/infrastructure/adapters/SchemaValidator.js +0 -92
  79. package/frigg-cli/infrastructure/repositories/FileSystemApiModuleRepository.js +0 -373
  80. package/frigg-cli/infrastructure/repositories/FileSystemAppDefinitionRepository.js +0 -116
  81. package/frigg-cli/infrastructure/repositories/FileSystemIntegrationRepository.js +0 -277
  82. package/frigg-cli/package-lock.json +0 -16226
  83. package/frigg-cli/start-command/application/RunPreflightChecksUseCase.js +0 -376
  84. package/frigg-cli/start-command/infrastructure/DatabaseAdapter.js +0 -591
  85. package/frigg-cli/start-command/infrastructure/DockerAdapter.js +0 -306
  86. package/frigg-cli/start-command/presentation/InteractivePromptAdapter.js +0 -329
  87. package/frigg-cli/templates/backend/.env.example +0 -62
  88. package/frigg-cli/templates/backend/.eslintrc.json +0 -12
  89. package/frigg-cli/templates/backend/.prettierrc +0 -6
  90. package/frigg-cli/templates/backend/docker-compose.yml +0 -22
  91. package/frigg-cli/templates/backend/index.js +0 -96
  92. package/frigg-cli/templates/backend/infrastructure.js +0 -12
  93. package/frigg-cli/templates/backend/jest.config.js +0 -17
  94. package/frigg-cli/templates/backend/package.json +0 -50
  95. package/frigg-cli/templates/backend/src/api-modules/.gitkeep +0 -10
  96. package/frigg-cli/templates/backend/src/base/.gitkeep +0 -7
  97. package/frigg-cli/templates/backend/src/integrations/.gitkeep +0 -10
  98. package/frigg-cli/templates/backend/src/integrations/ExampleIntegration.js +0 -65
  99. package/frigg-cli/templates/backend/src/utils/.gitkeep +0 -7
  100. package/frigg-cli/templates/backend/test/setup.js +0 -30
  101. package/frigg-cli/templates/backend/ui-extensions/.gitkeep +0 -0
  102. package/frigg-cli/templates/backend/ui-extensions/README.md +0 -77
  103. package/frigg-cli/utils/__tests__/provider-helper.test.js +0 -55
  104. package/frigg-cli/utils/__tests__/repo-detection.test.js +0 -436
  105. package/frigg-cli/utils/output.js +0 -382
  106. package/frigg-cli/utils/provider-helper.js +0 -75
  107. package/frigg-cli/validate-command/__tests__/adapters/validate-command.test.js +0 -205
  108. package/frigg-cli/validate-command/__tests__/application/validate-app-use-case.test.js +0 -104
  109. package/frigg-cli/validate-command/__tests__/domain/fix-suggestion.test.js +0 -153
  110. package/frigg-cli/validate-command/__tests__/domain/validation-error.test.js +0 -162
  111. package/frigg-cli/validate-command/__tests__/domain/validation-result.test.js +0 -152
  112. package/frigg-cli/validate-command/__tests__/infrastructure/api-module-validator.test.js +0 -332
  113. package/frigg-cli/validate-command/__tests__/infrastructure/app-definition-validator.test.js +0 -191
  114. package/frigg-cli/validate-command/__tests__/infrastructure/integration-class-validator.test.js +0 -146
  115. package/frigg-cli/validate-command/__tests__/infrastructure/template-validation.test.js +0 -155
  116. package/frigg-cli/validate-command/adapters/cli/validate-command.js +0 -199
  117. package/frigg-cli/validate-command/application/use-cases/validate-app-use-case.js +0 -35
  118. package/frigg-cli/validate-command/domain/entities/validation-result.js +0 -74
  119. package/frigg-cli/validate-command/domain/value-objects/fix-suggestion.js +0 -74
  120. package/frigg-cli/validate-command/domain/value-objects/validation-error.js +0 -68
  121. package/frigg-cli/validate-command/infrastructure/validators/api-module-validator.js +0 -181
  122. package/frigg-cli/validate-command/infrastructure/validators/app-definition-validator.js +0 -128
  123. package/frigg-cli/validate-command/infrastructure/validators/integration-class-validator.js +0 -113
  124. package/infrastructure/domains/admin-scripts/admin-script-builder.js +0 -200
  125. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -499
  126. package/infrastructure/domains/admin-scripts/index.js +0 -5
  127. package/infrastructure/jest.config.js +0 -16
@@ -1,411 +0,0 @@
1
- /**
2
- * RunPreflightChecksUseCase Tests
3
- * Orchestrates pre-flight checks before starting Frigg
4
- *
5
- * Tests follow TDD pattern - written BEFORE implementation
6
- */
7
-
8
- const { RunPreflightChecksUseCase } = require('../../../../start-command/application/RunPreflightChecksUseCase');
9
-
10
- describe('RunPreflightChecksUseCase', () => {
11
- let useCase;
12
- let mockDockerAdapter;
13
- let mockDatabaseAdapter;
14
-
15
- beforeEach(() => {
16
- jest.clearAllMocks();
17
-
18
- // Reset environment
19
- delete process.env.DATABASE_URL;
20
-
21
- mockDockerAdapter = {
22
- isDockerInstalled: jest.fn(),
23
- isDockerRunning: jest.fn(),
24
- findDockerComposeFile: jest.fn(),
25
- startDockerDesktop: jest.fn(),
26
- startDockerCompose: jest.fn(),
27
- waitForDockerReady: jest.fn(),
28
- waitForLocalStack: jest.fn()
29
- };
30
-
31
- mockDatabaseAdapter = {
32
- getDatabaseType: jest.fn(),
33
- isDatabaseReachable: jest.fn(),
34
- getConnectionDetails: jest.fn()
35
- };
36
-
37
- useCase = new RunPreflightChecksUseCase({
38
- dockerAdapter: mockDockerAdapter,
39
- databaseAdapter: mockDatabaseAdapter
40
- });
41
- });
42
-
43
- describe('execute() - All checks pass', () => {
44
- beforeEach(() => {
45
- process.env.DATABASE_URL = 'mongodb://localhost:27017/frigg';
46
- mockDockerAdapter.isDockerInstalled.mockResolvedValue(true);
47
- mockDockerAdapter.isDockerRunning.mockResolvedValue(true);
48
- mockDockerAdapter.findDockerComposeFile.mockResolvedValue('/test/docker-compose.yml');
49
- mockDockerAdapter.waitForLocalStack.mockResolvedValue({ ready: true });
50
- mockDatabaseAdapter.getDatabaseType.mockReturnValue('mongodb');
51
- mockDatabaseAdapter.isDatabaseReachable.mockResolvedValue({ reachable: true });
52
- mockDatabaseAdapter.getConnectionDetails.mockReturnValue({
53
- type: 'mongodb',
54
- host: 'localhost',
55
- port: 27017,
56
- database: 'frigg'
57
- });
58
- });
59
-
60
- it('should return all checks passed when everything is ready', async () => {
61
- const result = await useCase.execute({ projectPath: '/test/project' });
62
-
63
- expect(result.allPassed).toBe(true);
64
- // 5 checks: DATABASE_URL, docker_installed, docker_running, database_reachable, localstack_reachable
65
- expect(result.checks).toHaveLength(5);
66
- });
67
-
68
- it('should include DATABASE_URL check result', async () => {
69
- const result = await useCase.execute({ projectPath: '/test/project' });
70
-
71
- const dbUrlCheck = result.checks.find(c => c.name === 'database_url');
72
- expect(dbUrlCheck.status).toBe('passed');
73
- });
74
-
75
- it('should include Docker installed check result', async () => {
76
- const result = await useCase.execute({ projectPath: '/test/project' });
77
-
78
- const dockerCheck = result.checks.find(c => c.name === 'docker_installed');
79
- expect(dockerCheck.status).toBe('passed');
80
- });
81
-
82
- it('should include Docker running check result', async () => {
83
- const result = await useCase.execute({ projectPath: '/test/project' });
84
-
85
- const dockerRunningCheck = result.checks.find(c => c.name === 'docker_running');
86
- expect(dockerRunningCheck.status).toBe('passed');
87
- });
88
-
89
- it('should include database reachable check result', async () => {
90
- const result = await useCase.execute({ projectPath: '/test/project' });
91
-
92
- const dbCheck = result.checks.find(c => c.name === 'database_reachable');
93
- expect(dbCheck.status).toBe('passed');
94
- });
95
- });
96
-
97
- describe('execute() - DATABASE_URL check', () => {
98
- it('should fail when DATABASE_URL is not set', async () => {
99
- delete process.env.DATABASE_URL;
100
-
101
- const result = await useCase.execute({ projectPath: '/test/project' });
102
-
103
- expect(result.allPassed).toBe(false);
104
- const dbUrlCheck = result.checks.find(c => c.name === 'database_url');
105
- expect(dbUrlCheck.status).toBe('failed');
106
- expect(dbUrlCheck.message).toContain('DATABASE_URL');
107
- });
108
-
109
- it('should provide resolution option for missing DATABASE_URL', async () => {
110
- delete process.env.DATABASE_URL;
111
-
112
- const result = await useCase.execute({ projectPath: '/test/project' });
113
-
114
- const dbUrlCheck = result.checks.find(c => c.name === 'database_url');
115
- expect(dbUrlCheck.canResolve).toBe(true);
116
- expect(dbUrlCheck.resolution.type).toBe('create_env');
117
- });
118
-
119
- it('should pass when DATABASE_URL is set', async () => {
120
- process.env.DATABASE_URL = 'mongodb://localhost:27017/frigg';
121
- mockDatabaseAdapter.getDatabaseType.mockReturnValue('mongodb');
122
-
123
- const result = await useCase.execute({ projectPath: '/test/project' });
124
-
125
- const dbUrlCheck = result.checks.find(c => c.name === 'database_url');
126
- expect(dbUrlCheck.status).toBe('passed');
127
- });
128
- });
129
-
130
- describe('execute() - Docker installed check', () => {
131
- beforeEach(() => {
132
- process.env.DATABASE_URL = 'mongodb://localhost:27017/frigg';
133
- mockDatabaseAdapter.getDatabaseType.mockReturnValue('mongodb');
134
- });
135
-
136
- it('should fail when Docker is not installed', async () => {
137
- mockDockerAdapter.isDockerInstalled.mockResolvedValue(false);
138
-
139
- const result = await useCase.execute({ projectPath: '/test/project' });
140
-
141
- const dockerCheck = result.checks.find(c => c.name === 'docker_installed');
142
- expect(dockerCheck.status).toBe('failed');
143
- expect(dockerCheck.message).toContain('Docker is not installed');
144
- });
145
-
146
- it('should not provide auto-resolution for Docker not installed', async () => {
147
- mockDockerAdapter.isDockerInstalled.mockResolvedValue(false);
148
-
149
- const result = await useCase.execute({ projectPath: '/test/project' });
150
-
151
- const dockerCheck = result.checks.find(c => c.name === 'docker_installed');
152
- expect(dockerCheck.canResolve).toBe(false);
153
- expect(dockerCheck.resolution.type).toBe('manual');
154
- expect(dockerCheck.resolution.instructions).toBeDefined();
155
- });
156
-
157
- it('should pass when Docker is installed', async () => {
158
- mockDockerAdapter.isDockerInstalled.mockResolvedValue(true);
159
- mockDockerAdapter.isDockerRunning.mockResolvedValue(true);
160
- mockDockerAdapter.waitForLocalStack.mockResolvedValue({ ready: true });
161
- mockDatabaseAdapter.isDatabaseReachable.mockResolvedValue({ reachable: true });
162
-
163
- const result = await useCase.execute({ projectPath: '/test/project' });
164
-
165
- const dockerCheck = result.checks.find(c => c.name === 'docker_installed');
166
- expect(dockerCheck.status).toBe('passed');
167
- });
168
- });
169
-
170
- describe('execute() - Docker running check', () => {
171
- beforeEach(() => {
172
- process.env.DATABASE_URL = 'mongodb://localhost:27017/frigg';
173
- mockDatabaseAdapter.getDatabaseType.mockReturnValue('mongodb');
174
- mockDockerAdapter.isDockerInstalled.mockResolvedValue(true);
175
- mockDockerAdapter.waitForLocalStack.mockResolvedValue({ ready: true });
176
- });
177
-
178
- it('should fail when Docker daemon is not running', async () => {
179
- mockDockerAdapter.isDockerRunning.mockResolvedValue(false);
180
-
181
- const result = await useCase.execute({ projectPath: '/test/project' });
182
-
183
- const dockerRunningCheck = result.checks.find(c => c.name === 'docker_running');
184
- expect(dockerRunningCheck.status).toBe('failed');
185
- expect(dockerRunningCheck.message).toContain('Docker is not running');
186
- });
187
-
188
- it('should provide resolution option to start Docker', async () => {
189
- mockDockerAdapter.isDockerRunning.mockResolvedValue(false);
190
-
191
- const result = await useCase.execute({ projectPath: '/test/project' });
192
-
193
- const dockerRunningCheck = result.checks.find(c => c.name === 'docker_running');
194
- expect(dockerRunningCheck.canResolve).toBe(true);
195
- expect(dockerRunningCheck.resolution.type).toBe('start_docker');
196
- });
197
-
198
- it('should pass when Docker is running', async () => {
199
- mockDockerAdapter.isDockerRunning.mockResolvedValue(true);
200
- mockDockerAdapter.waitForLocalStack.mockResolvedValue({ ready: true });
201
- mockDatabaseAdapter.isDatabaseReachable.mockResolvedValue({ reachable: true });
202
-
203
- const result = await useCase.execute({ projectPath: '/test/project' });
204
-
205
- const dockerRunningCheck = result.checks.find(c => c.name === 'docker_running');
206
- expect(dockerRunningCheck.status).toBe('passed');
207
- });
208
- });
209
-
210
- describe('execute() - Database reachable check', () => {
211
- beforeEach(() => {
212
- process.env.DATABASE_URL = 'mongodb://localhost:27017/frigg';
213
- mockDatabaseAdapter.getDatabaseType.mockReturnValue('mongodb');
214
- mockDockerAdapter.isDockerInstalled.mockResolvedValue(true);
215
- mockDockerAdapter.isDockerRunning.mockResolvedValue(true);
216
- mockDockerAdapter.waitForLocalStack.mockResolvedValue({ ready: true });
217
- });
218
-
219
- it('should fail when database is not reachable', async () => {
220
- mockDatabaseAdapter.isDatabaseReachable.mockResolvedValue({
221
- reachable: false,
222
- error: 'ECONNREFUSED'
223
- });
224
- mockDockerAdapter.findDockerComposeFile.mockResolvedValue('/test/docker-compose.yml');
225
-
226
- const result = await useCase.execute({ projectPath: '/test/project' });
227
-
228
- const dbCheck = result.checks.find(c => c.name === 'database_reachable');
229
- expect(dbCheck.status).toBe('failed');
230
- expect(dbCheck.message).toContain('Database is not reachable');
231
- });
232
-
233
- it('should provide docker-compose resolution when file exists', async () => {
234
- mockDatabaseAdapter.isDatabaseReachable.mockResolvedValue({
235
- reachable: false,
236
- error: 'ECONNREFUSED'
237
- });
238
- mockDockerAdapter.findDockerComposeFile.mockResolvedValue('/test/docker-compose.yml');
239
-
240
- const result = await useCase.execute({ projectPath: '/test/project' });
241
-
242
- const dbCheck = result.checks.find(c => c.name === 'database_reachable');
243
- expect(dbCheck.canResolve).toBe(true);
244
- expect(dbCheck.resolution.type).toBe('start_docker_compose');
245
- expect(dbCheck.resolution.composePath).toBe('/test/docker-compose.yml');
246
- });
247
-
248
- it('should suggest manual setup when no docker-compose exists', async () => {
249
- mockDatabaseAdapter.isDatabaseReachable.mockResolvedValue({
250
- reachable: false,
251
- error: 'ECONNREFUSED'
252
- });
253
- mockDockerAdapter.findDockerComposeFile.mockResolvedValue(null);
254
-
255
- const result = await useCase.execute({ projectPath: '/test/project' });
256
-
257
- const dbCheck = result.checks.find(c => c.name === 'database_reachable');
258
- expect(dbCheck.canResolve).toBe(false);
259
- expect(dbCheck.resolution.type).toBe('manual');
260
- });
261
-
262
- it('should pass when database is reachable', async () => {
263
- mockDatabaseAdapter.isDatabaseReachable.mockResolvedValue({ reachable: true });
264
-
265
- const result = await useCase.execute({ projectPath: '/test/project' });
266
-
267
- const dbCheck = result.checks.find(c => c.name === 'database_reachable');
268
- expect(dbCheck.status).toBe('passed');
269
- });
270
- });
271
-
272
- describe('execute() - LocalStack reachable check', () => {
273
- beforeEach(() => {
274
- process.env.DATABASE_URL = 'mongodb://localhost:27017/frigg';
275
- mockDatabaseAdapter.getDatabaseType.mockReturnValue('mongodb');
276
- mockDockerAdapter.isDockerInstalled.mockResolvedValue(true);
277
- mockDockerAdapter.isDockerRunning.mockResolvedValue(true);
278
- mockDatabaseAdapter.isDatabaseReachable.mockResolvedValue({ reachable: true });
279
- });
280
-
281
- it('should fail when LocalStack is not reachable', async () => {
282
- mockDockerAdapter.waitForLocalStack.mockResolvedValue({ ready: false });
283
- mockDockerAdapter.findDockerComposeFile.mockResolvedValue('/test/docker-compose.yml');
284
-
285
- const result = await useCase.execute({ projectPath: '/test/project' });
286
-
287
- const localstackCheck = result.checks.find(c => c.name === 'localstack_reachable');
288
- expect(localstackCheck.status).toBe('failed');
289
- expect(localstackCheck.message).toContain('LocalStack is not reachable');
290
- });
291
-
292
- it('should provide docker-compose resolution when LocalStack is not reachable', async () => {
293
- mockDockerAdapter.waitForLocalStack.mockResolvedValue({ ready: false });
294
- mockDockerAdapter.findDockerComposeFile.mockResolvedValue('/test/docker-compose.yml');
295
-
296
- const result = await useCase.execute({ projectPath: '/test/project' });
297
-
298
- const localstackCheck = result.checks.find(c => c.name === 'localstack_reachable');
299
- expect(localstackCheck.canResolve).toBe(true);
300
- expect(localstackCheck.resolution.type).toBe('start_docker_compose');
301
- });
302
-
303
- it('should pass when LocalStack is reachable', async () => {
304
- mockDockerAdapter.waitForLocalStack.mockResolvedValue({ ready: true });
305
-
306
- const result = await useCase.execute({ projectPath: '/test/project' });
307
-
308
- const localstackCheck = result.checks.find(c => c.name === 'localstack_reachable');
309
- expect(localstackCheck.status).toBe('passed');
310
- });
311
-
312
- it('should skip LocalStack check when AWS_ENDPOINT points to real AWS', async () => {
313
- process.env.AWS_ENDPOINT = 'https://sqs.us-east-1.amazonaws.com';
314
- mockDockerAdapter.waitForLocalStack.mockResolvedValue({ ready: true });
315
-
316
- const result = await useCase.execute({ projectPath: '/test/project' });
317
-
318
- // Should not include LocalStack check when using real AWS
319
- const localstackCheck = result.checks.find(c => c.name === 'localstack_reachable');
320
- expect(localstackCheck).toBeUndefined();
321
-
322
- delete process.env.AWS_ENDPOINT;
323
- });
324
- });
325
-
326
- describe('execute() - Short-circuit behavior', () => {
327
- it('should skip Docker checks if DATABASE_URL is missing', async () => {
328
- delete process.env.DATABASE_URL;
329
-
330
- await useCase.execute({ projectPath: '/test/project' });
331
-
332
- // Docker checks should not be called since DATABASE_URL failed
333
- expect(mockDockerAdapter.isDockerInstalled).not.toHaveBeenCalled();
334
- });
335
-
336
- it('should skip Docker running check if Docker not installed', async () => {
337
- process.env.DATABASE_URL = 'mongodb://localhost:27017/frigg';
338
- mockDatabaseAdapter.getDatabaseType.mockReturnValue('mongodb');
339
- mockDockerAdapter.isDockerInstalled.mockResolvedValue(false);
340
-
341
- await useCase.execute({ projectPath: '/test/project' });
342
-
343
- expect(mockDockerAdapter.isDockerRunning).not.toHaveBeenCalled();
344
- });
345
-
346
- it('should skip database reachable check if Docker not running', async () => {
347
- process.env.DATABASE_URL = 'mongodb://localhost:27017/frigg';
348
- mockDatabaseAdapter.getDatabaseType.mockReturnValue('mongodb');
349
- mockDockerAdapter.isDockerInstalled.mockResolvedValue(true);
350
- mockDockerAdapter.isDockerRunning.mockResolvedValue(false);
351
-
352
- await useCase.execute({ projectPath: '/test/project' });
353
-
354
- expect(mockDatabaseAdapter.isDatabaseReachable).not.toHaveBeenCalled();
355
- });
356
- });
357
-
358
- describe('getFailedChecks()', () => {
359
- it('should return only failed checks', async () => {
360
- process.env.DATABASE_URL = 'mongodb://localhost:27017/frigg';
361
- mockDatabaseAdapter.getDatabaseType.mockReturnValue('mongodb');
362
- mockDockerAdapter.isDockerInstalled.mockResolvedValue(true);
363
- mockDockerAdapter.isDockerRunning.mockResolvedValue(false);
364
-
365
- const result = await useCase.execute({ projectPath: '/test/project' });
366
- const failed = useCase.getFailedChecks(result);
367
-
368
- expect(failed).toHaveLength(1);
369
- expect(failed[0].name).toBe('docker_running');
370
- });
371
- });
372
-
373
- describe('getResolvableChecks()', () => {
374
- it('should return only checks that can be auto-resolved', async () => {
375
- process.env.DATABASE_URL = 'mongodb://localhost:27017/frigg';
376
- mockDatabaseAdapter.getDatabaseType.mockReturnValue('mongodb');
377
- mockDockerAdapter.isDockerInstalled.mockResolvedValue(true);
378
- mockDockerAdapter.isDockerRunning.mockResolvedValue(false);
379
-
380
- const result = await useCase.execute({ projectPath: '/test/project' });
381
- const resolvable = useCase.getResolvableChecks(result);
382
-
383
- expect(resolvable).toHaveLength(1);
384
- expect(resolvable[0].canResolve).toBe(true);
385
- });
386
- });
387
-
388
- describe('Check result structure', () => {
389
- it('should include all required fields in check results', async () => {
390
- delete process.env.DATABASE_URL;
391
-
392
- const result = await useCase.execute({ projectPath: '/test/project' });
393
-
394
- const check = result.checks[0];
395
- expect(check).toHaveProperty('name');
396
- expect(check).toHaveProperty('status');
397
- expect(check).toHaveProperty('message');
398
- expect(check).toHaveProperty('canResolve');
399
- expect(check).toHaveProperty('resolution');
400
- });
401
-
402
- it('should include resolution details for failed checks', async () => {
403
- delete process.env.DATABASE_URL;
404
-
405
- const result = await useCase.execute({ projectPath: '/test/project' });
406
-
407
- const check = result.checks.find(c => c.name === 'database_url');
408
- expect(check.resolution).toHaveProperty('type');
409
- });
410
- });
411
- });