create-fluxstack 1.0.13 → 1.0.14

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 (214) hide show
  1. package/.env.example +29 -29
  2. package/app/client/README.md +69 -69
  3. package/app/client/index.html +14 -13
  4. package/app/client/src/App.tsx +157 -524
  5. package/app/client/src/components/ErrorBoundary.tsx +107 -0
  6. package/app/client/src/components/ErrorDisplay.css +365 -0
  7. package/app/client/src/components/ErrorDisplay.tsx +258 -0
  8. package/app/client/src/components/FluxStackConfig.tsx +1321 -0
  9. package/app/client/src/components/HybridLiveCounter.tsx +140 -0
  10. package/app/client/src/components/LiveClock.tsx +286 -0
  11. package/app/client/src/components/MainLayout.tsx +390 -0
  12. package/app/client/src/components/SidebarNavigation.tsx +391 -0
  13. package/app/client/src/components/StateDemo.tsx +178 -0
  14. package/app/client/src/components/SystemMonitor.tsx +1038 -0
  15. package/app/client/src/components/Teste.tsx +104 -0
  16. package/app/client/src/components/UserProfile.tsx +809 -0
  17. package/app/client/src/hooks/useAuth.ts +39 -0
  18. package/app/client/src/hooks/useNotifications.ts +56 -0
  19. package/app/client/src/lib/eden-api.ts +189 -53
  20. package/app/client/src/lib/errors.ts +340 -0
  21. package/app/client/src/lib/hooks/useErrorHandler.ts +258 -0
  22. package/app/client/src/lib/index.ts +45 -0
  23. package/app/client/src/main.tsx +3 -2
  24. package/app/client/src/pages/ApiDocs.tsx +182 -0
  25. package/app/client/src/pages/Demo.tsx +174 -0
  26. package/app/client/src/pages/HybridLive.tsx +263 -0
  27. package/app/client/src/pages/Overview.tsx +155 -0
  28. package/app/client/src/store/README.md +43 -0
  29. package/app/client/src/store/index.ts +16 -0
  30. package/app/client/src/store/slices/uiSlice.ts +151 -0
  31. package/app/client/src/store/slices/userSlice.ts +161 -0
  32. package/app/client/src/test/README.md +257 -0
  33. package/app/client/src/test/setup.ts +70 -0
  34. package/app/client/src/test/types.ts +12 -0
  35. package/app/client/src/vite-env.d.ts +1 -1
  36. package/app/client/tsconfig.app.json +44 -43
  37. package/app/client/tsconfig.json +7 -7
  38. package/app/client/tsconfig.node.json +25 -25
  39. package/app/client/zustand-setup.md +65 -0
  40. package/app/server/controllers/users.controller.ts +68 -68
  41. package/app/server/index.ts +9 -1
  42. package/app/server/live/CounterComponent.ts +191 -0
  43. package/app/server/live/FluxStackConfig.ts +529 -0
  44. package/app/server/live/LiveClockComponent.ts +214 -0
  45. package/app/server/live/SidebarNavigation.ts +156 -0
  46. package/app/server/live/SystemMonitor.ts +594 -0
  47. package/app/server/live/SystemMonitorIntegration.ts +151 -0
  48. package/app/server/live/TesteComponent.ts +87 -0
  49. package/app/server/live/UserProfileComponent.ts +135 -0
  50. package/app/server/live/register-components.ts +28 -0
  51. package/app/server/middleware/auth.ts +136 -0
  52. package/app/server/middleware/errorHandling.ts +250 -0
  53. package/app/server/middleware/index.ts +10 -0
  54. package/app/server/middleware/rateLimit.ts +193 -0
  55. package/app/server/middleware/requestLogging.ts +215 -0
  56. package/app/server/middleware/validation.ts +270 -0
  57. package/app/server/routes/index.ts +14 -2
  58. package/app/server/routes/upload.ts +92 -0
  59. package/app/server/routes/users.routes.ts +2 -9
  60. package/app/server/services/NotificationService.ts +302 -0
  61. package/app/server/services/UserService.ts +222 -0
  62. package/app/server/services/index.ts +46 -0
  63. package/core/cli/commands/plugin-deps.ts +263 -0
  64. package/core/cli/generators/README.md +339 -0
  65. package/core/cli/generators/component.ts +770 -0
  66. package/core/cli/generators/controller.ts +299 -0
  67. package/core/cli/generators/index.ts +144 -0
  68. package/core/cli/generators/interactive.ts +228 -0
  69. package/core/cli/generators/prompts.ts +83 -0
  70. package/core/cli/generators/route.ts +513 -0
  71. package/core/cli/generators/service.ts +465 -0
  72. package/core/cli/generators/template-engine.ts +154 -0
  73. package/core/cli/generators/types.ts +71 -0
  74. package/core/cli/generators/utils.ts +192 -0
  75. package/core/cli/index.ts +69 -0
  76. package/core/cli/plugin-discovery.ts +16 -85
  77. package/core/client/fluxstack.ts +17 -0
  78. package/core/client/hooks/index.ts +7 -0
  79. package/core/client/hooks/state-validator.ts +130 -0
  80. package/core/client/hooks/useAuth.ts +49 -0
  81. package/core/client/hooks/useChunkedUpload.ts +258 -0
  82. package/core/client/hooks/useHybridLiveComponent.ts +967 -0
  83. package/core/client/hooks/useWebSocket.ts +373 -0
  84. package/core/client/index.ts +47 -0
  85. package/core/client/state/createStore.ts +193 -0
  86. package/core/client/state/index.ts +15 -0
  87. package/core/config/env-dynamic.ts +1 -1
  88. package/core/config/env.ts +2 -1
  89. package/core/config/runtime-config.ts +3 -3
  90. package/core/config/schema.ts +84 -49
  91. package/core/framework/server.ts +30 -0
  92. package/core/index.ts +25 -0
  93. package/core/live/ComponentRegistry.ts +399 -0
  94. package/core/live/types.ts +164 -0
  95. package/core/plugins/built-in/live-components/commands/create-live-component.ts +1201 -0
  96. package/core/plugins/built-in/live-components/index.ts +27 -0
  97. package/core/plugins/built-in/logger/index.ts +1 -1
  98. package/core/plugins/built-in/monitoring/index.ts +1 -1
  99. package/core/plugins/built-in/static/index.ts +1 -1
  100. package/core/plugins/built-in/swagger/index.ts +1 -1
  101. package/core/plugins/built-in/vite/index.ts +1 -1
  102. package/core/plugins/dependency-manager.ts +384 -0
  103. package/core/plugins/index.ts +5 -1
  104. package/core/plugins/manager.ts +7 -3
  105. package/core/plugins/registry.ts +88 -10
  106. package/core/plugins/types.ts +11 -11
  107. package/core/server/framework.ts +43 -0
  108. package/core/server/index.ts +11 -1
  109. package/core/server/live/ComponentRegistry.ts +1017 -0
  110. package/core/server/live/FileUploadManager.ts +272 -0
  111. package/core/server/live/LiveComponentPerformanceMonitor.ts +930 -0
  112. package/core/server/live/SingleConnectionManager.ts +0 -0
  113. package/core/server/live/StateSignature.ts +644 -0
  114. package/core/server/live/WebSocketConnectionManager.ts +688 -0
  115. package/core/server/live/websocket-plugin.ts +435 -0
  116. package/core/server/middleware/errorHandling.ts +141 -0
  117. package/core/server/middleware/index.ts +16 -0
  118. package/core/server/plugins/static-files-plugin.ts +232 -0
  119. package/core/server/services/BaseService.ts +95 -0
  120. package/core/server/services/ServiceContainer.ts +144 -0
  121. package/core/server/services/index.ts +9 -0
  122. package/core/templates/create-project.ts +46 -2
  123. package/core/testing/index.ts +10 -0
  124. package/core/testing/setup.ts +74 -0
  125. package/core/types/build.ts +38 -14
  126. package/core/types/types.ts +319 -0
  127. package/core/utils/env-runtime.ts +7 -0
  128. package/core/utils/errors/handlers.ts +264 -39
  129. package/core/utils/errors/index.ts +528 -18
  130. package/core/utils/errors/middleware.ts +114 -0
  131. package/core/utils/logger/formatters.ts +222 -0
  132. package/core/utils/logger/index.ts +167 -48
  133. package/core/utils/logger/middleware.ts +253 -0
  134. package/core/utils/logger/performance.ts +384 -0
  135. package/core/utils/logger/transports.ts +365 -0
  136. package/create-fluxstack.ts +296 -296
  137. package/fluxstack.config.ts +17 -1
  138. package/package-template.json +66 -66
  139. package/package.json +31 -6
  140. package/public/README.md +16 -0
  141. package/vite.config.ts +29 -14
  142. package/.claude/settings.local.json +0 -74
  143. package/.github/workflows/ci-build-tests.yml +0 -480
  144. package/.github/workflows/dependency-management.yml +0 -324
  145. package/.github/workflows/release-validation.yml +0 -355
  146. package/.kiro/specs/fluxstack-architecture-optimization/design.md +0 -700
  147. package/.kiro/specs/fluxstack-architecture-optimization/requirements.md +0 -127
  148. package/.kiro/specs/fluxstack-architecture-optimization/tasks.md +0 -330
  149. package/CLAUDE.md +0 -200
  150. package/Dockerfile +0 -58
  151. package/Dockerfile.backend +0 -52
  152. package/Dockerfile.frontend +0 -54
  153. package/README-Docker.md +0 -85
  154. package/ai-context/00-QUICK-START.md +0 -86
  155. package/ai-context/README.md +0 -88
  156. package/ai-context/development/eden-treaty-guide.md +0 -362
  157. package/ai-context/development/patterns.md +0 -382
  158. package/ai-context/development/plugins-guide.md +0 -572
  159. package/ai-context/examples/crud-complete.md +0 -626
  160. package/ai-context/project/architecture.md +0 -399
  161. package/ai-context/project/overview.md +0 -213
  162. package/ai-context/recent-changes/eden-treaty-refactor.md +0 -281
  163. package/ai-context/recent-changes/type-inference-fix.md +0 -223
  164. package/ai-context/reference/environment-vars.md +0 -384
  165. package/ai-context/reference/troubleshooting.md +0 -407
  166. package/app/client/src/components/TestPage.tsx +0 -453
  167. package/bun.lock +0 -1063
  168. package/bunfig.toml +0 -16
  169. package/core/__tests__/integration.test.ts +0 -227
  170. package/core/build/index.ts +0 -186
  171. package/core/config/__tests__/config-loader.test.ts +0 -554
  172. package/core/config/__tests__/config-merger.test.ts +0 -657
  173. package/core/config/__tests__/env-converter.test.ts +0 -372
  174. package/core/config/__tests__/env-processor.test.ts +0 -431
  175. package/core/config/__tests__/env.test.ts +0 -452
  176. package/core/config/__tests__/integration.test.ts +0 -418
  177. package/core/config/__tests__/loader.test.ts +0 -331
  178. package/core/config/__tests__/schema.test.ts +0 -129
  179. package/core/config/__tests__/validator.test.ts +0 -318
  180. package/core/framework/__tests__/server.test.ts +0 -233
  181. package/core/plugins/__tests__/built-in.test.ts.disabled +0 -366
  182. package/core/plugins/__tests__/manager.test.ts +0 -398
  183. package/core/plugins/__tests__/monitoring.test.ts +0 -401
  184. package/core/plugins/__tests__/registry.test.ts +0 -335
  185. package/core/utils/__tests__/errors.test.ts +0 -139
  186. package/core/utils/__tests__/helpers.test.ts +0 -297
  187. package/core/utils/__tests__/logger.test.ts +0 -141
  188. package/create-test-app.ts +0 -156
  189. package/docker-compose.microservices.yml +0 -75
  190. package/docker-compose.simple.yml +0 -57
  191. package/docker-compose.yml +0 -71
  192. package/eslint.config.js +0 -23
  193. package/flux-cli.ts +0 -214
  194. package/nginx-lb.conf +0 -37
  195. package/publish.sh +0 -63
  196. package/run-clean.ts +0 -26
  197. package/run-env-tests.ts +0 -313
  198. package/tailwind.config.js +0 -34
  199. package/tests/__mocks__/api.ts +0 -56
  200. package/tests/fixtures/users.ts +0 -69
  201. package/tests/integration/api/users.routes.test.ts +0 -221
  202. package/tests/setup.ts +0 -29
  203. package/tests/unit/app/client/App-simple.test.tsx +0 -56
  204. package/tests/unit/app/client/App.test.tsx.skip +0 -237
  205. package/tests/unit/app/client/eden-api.test.ts +0 -186
  206. package/tests/unit/app/client/simple.test.tsx +0 -23
  207. package/tests/unit/app/controllers/users.controller.test.ts +0 -150
  208. package/tests/unit/core/create-project.test.ts.skip +0 -95
  209. package/tests/unit/core/framework.test.ts +0 -144
  210. package/tests/unit/core/plugins/logger.test.ts.skip +0 -268
  211. package/tests/unit/core/plugins/vite.test.ts.disabled +0 -188
  212. package/tests/utils/test-helpers.ts +0 -61
  213. package/vitest.config.ts +0 -50
  214. package/workspace.json +0 -6
@@ -1,453 +0,0 @@
1
- import React, { useState, useEffect } from 'react'
2
- import { api, getErrorMessage } from '../lib/eden-api'
3
-
4
- interface TestResult {
5
- name: string
6
- status: 'pending' | 'success' | 'error'
7
- message: string
8
- details?: any
9
- duration?: number
10
- }
11
-
12
- interface EnvTest {
13
- name: string
14
- variable: string
15
- expected?: string
16
- description: string
17
- }
18
-
19
- const TestPage: React.FC = () => {
20
- const [testResults, setTestResults] = useState<TestResult[]>([])
21
- const [isRunning, setIsRunning] = useState(false)
22
-
23
- // Environment variables available in the frontend (VITE_ prefix)
24
- const envTests: EnvTest[] = [
25
- {
26
- name: 'API URL',
27
- variable: 'VITE_API_URL',
28
- expected: 'http://localhost:3000',
29
- description: 'Base URL for API calls'
30
- },
31
- {
32
- name: 'App Name',
33
- variable: 'VITE_APP_NAME',
34
- description: 'Application name from environment'
35
- },
36
- {
37
- name: 'App Version',
38
- variable: 'VITE_APP_VERSION',
39
- description: 'Application version from environment'
40
- },
41
- {
42
- name: 'Environment',
43
- variable: 'VITE_NODE_ENV',
44
- description: 'Current environment (dev/prod)'
45
- }
46
- ]
47
-
48
- // Add a test result
49
- const addTestResult = (result: TestResult) => {
50
- setTestResults(prev => [...prev, result])
51
- }
52
-
53
- // Update a test result
54
- const updateTestResult = (name: string, updates: Partial<TestResult>) => {
55
- setTestResults(prev =>
56
- prev.map(result =>
57
- result.name === name ? { ...result, ...updates } : result
58
- )
59
- )
60
- }
61
-
62
- // Test environment variables
63
- const testEnvironmentVariables = async () => {
64
- const startTime = Date.now()
65
-
66
- addTestResult({
67
- name: 'Environment Variables',
68
- status: 'pending',
69
- message: 'Testing environment variable loading...'
70
- })
71
-
72
- try {
73
- const results = envTests.map(test => {
74
- const value = import.meta.env[test.variable]
75
- return {
76
- name: test.name,
77
- variable: test.variable,
78
- value: value || 'undefined',
79
- expected: test.expected,
80
- description: test.description,
81
- isValid: test.expected ? value === test.expected : value !== undefined
82
- }
83
- })
84
-
85
- const allValid = results.every(r => r.isValid)
86
- const duration = Date.now() - startTime
87
-
88
- updateTestResult('Environment Variables', {
89
- status: allValid ? 'success' : 'error',
90
- message: allValid
91
- ? `All environment variables loaded correctly (${results.length} variables)`
92
- : 'Some environment variables are missing or incorrect',
93
- details: results,
94
- duration
95
- })
96
- } catch (error) {
97
- updateTestResult('Environment Variables', {
98
- status: 'error',
99
- message: `Environment test failed: ${getErrorMessage(error)}`,
100
- duration: Date.now() - startTime
101
- })
102
- }
103
- }
104
-
105
- // Test API health check
106
- const testApiHealth = async () => {
107
- const startTime = Date.now()
108
-
109
- addTestResult({
110
- name: 'API Health Check',
111
- status: 'pending',
112
- message: 'Testing API connection...'
113
- })
114
-
115
- try {
116
- const { data: response, error } = await api.health.get()
117
-
118
- if (error) {
119
- throw new Error(`API Error: ${error.status}`)
120
- }
121
-
122
- const duration = Date.now() - startTime
123
-
124
- updateTestResult('API Health Check', {
125
- status: 'success',
126
- message: `API is healthy: ${response.status}`,
127
- details: response,
128
- duration
129
- })
130
- } catch (error) {
131
- updateTestResult('API Health Check', {
132
- status: 'error',
133
- message: `API health check failed: ${getErrorMessage(error)}`,
134
- duration: Date.now() - startTime
135
- })
136
- }
137
- }
138
-
139
- // Test users API
140
- const testUsersApi = async () => {
141
- const startTime = Date.now()
142
-
143
- addTestResult({
144
- name: 'Users API Test',
145
- status: 'pending',
146
- message: 'Testing users CRUD operations...'
147
- })
148
-
149
- try {
150
- // ✨ Test getting users - Eden Treaty nativo
151
- const { data: usersResponse, error: getUsersError } = await api.users.get()
152
-
153
- if (getUsersError) {
154
- throw new Error(`Get users failed: ${getUsersError.status}`)
155
- }
156
-
157
- // ✨ Test creating a user - Eden Treaty com inferência perfeita
158
- const { data: newUser, error: createError } = await api.users.post({
159
- name: "Test User",
160
- email: "test@example.com"
161
- })
162
-
163
- if (createError) {
164
- throw new Error(`Create user failed: ${createError.status}`)
165
- }
166
-
167
- // ✨ Eden Treaty agora infere automaticamente: newUser é UserResponse
168
- if (!newUser.success || !newUser.user) {
169
- throw new Error('User creation failed')
170
- }
171
-
172
- // ✨ Test getting the created user - inferência automática de tipos
173
- const { data: createdUser, error: getError } = await api.users({ id: newUser.user.id }).get()
174
-
175
- if (getError) {
176
- throw new Error(`Get user failed: ${getError.status}`)
177
- }
178
-
179
- // ✨ Eden Treaty infere: createdUser é { user: User }
180
- if (!createdUser || !createdUser.user) {
181
- throw new Error('User not found')
182
- }
183
-
184
- // ✨ Test deleting the user - inferência automática
185
- const { data: deleteResult, error: deleteError } = await api.users({ id: newUser.user.id }).delete()
186
-
187
- if (deleteError) {
188
- throw new Error(`Delete user failed: ${deleteError.status}`)
189
- }
190
-
191
- const duration = Date.now() - startTime
192
-
193
- updateTestResult('Users API Test', {
194
- status: 'success',
195
- message: `Users API working correctly (CRUD operations completed)`,
196
- details: {
197
- initialUsers: usersResponse.users.length,
198
- createdUser: createdUser,
199
- newUser: newUser,
200
- deleteResult: deleteResult,
201
- operations: ['GET', 'POST', 'GET by ID', 'DELETE']
202
- },
203
- duration
204
- })
205
- } catch (error) {
206
- updateTestResult('Users API Test', {
207
- status: 'error',
208
- message: `Users API test failed: ${getErrorMessage(error)}`,
209
- duration: Date.now() - startTime
210
- })
211
- }
212
- }
213
-
214
- // Test Eden Treaty type safety
215
- const testEdenTreaty = async () => {
216
- const startTime = Date.now()
217
-
218
- addTestResult({
219
- name: 'Eden Treaty Type Safety',
220
- status: 'pending',
221
- message: 'Testing Eden Treaty integration...'
222
- })
223
-
224
- try {
225
- // Test that api object has expected methods
226
- const hasHealthEndpoint = typeof api.health?.get === 'function'
227
- const hasUsersEndpoint = typeof api.users?.get === 'function'
228
- const hasUsersPost = typeof api.users?.post === 'function'
229
-
230
- const typeChecks = {
231
- hasHealthEndpoint,
232
- hasUsersEndpoint,
233
- hasUsersPost,
234
- apiObjectExists: !!api,
235
- apiCallExists: typeof apiCall === 'function'
236
- }
237
-
238
- const allChecksPass = Object.values(typeChecks).every(Boolean)
239
- const duration = Date.now() - startTime
240
-
241
- updateTestResult('Eden Treaty Type Safety', {
242
- status: allChecksPass ? 'success' : 'error',
243
- message: allChecksPass
244
- ? 'Eden Treaty is properly configured with type safety'
245
- : 'Eden Treaty configuration issues detected',
246
- details: typeChecks,
247
- duration
248
- })
249
- } catch (error) {
250
- updateTestResult('Eden Treaty Type Safety', {
251
- status: 'error',
252
- message: `Eden Treaty test failed: ${getErrorMessage(error)}`,
253
- duration: Date.now() - startTime
254
- })
255
- }
256
- }
257
-
258
- // Test frontend configuration
259
- const testFrontendConfig = async () => {
260
- const startTime = Date.now()
261
-
262
- addTestResult({
263
- name: 'Frontend Configuration',
264
- status: 'pending',
265
- message: 'Testing frontend configuration...'
266
- })
267
-
268
- try {
269
- const config = {
270
- mode: import.meta.env.MODE,
271
- baseUrl: import.meta.env.BASE_URL,
272
- prod: import.meta.env.PROD,
273
- dev: import.meta.env.DEV,
274
- ssrMode: import.meta.env.SSR
275
- }
276
-
277
- const hasValidConfig = !!(config.mode && config.baseUrl !== undefined)
278
- const duration = Date.now() - startTime
279
-
280
- updateTestResult('Frontend Configuration', {
281
- status: hasValidConfig ? 'success' : 'error',
282
- message: hasValidConfig
283
- ? `Frontend configuration loaded (mode: ${config.mode})`
284
- : 'Frontend configuration incomplete',
285
- details: config,
286
- duration
287
- })
288
- } catch (error) {
289
- updateTestResult('Frontend Configuration', {
290
- status: 'error',
291
- message: `Frontend config test failed: ${getErrorMessage(error)}`,
292
- duration: Date.now() - startTime
293
- })
294
- }
295
- }
296
-
297
- // Run all tests
298
- const runAllTests = async () => {
299
- setIsRunning(true)
300
- setTestResults([])
301
-
302
- await testEnvironmentVariables()
303
- await new Promise(resolve => setTimeout(resolve, 100)) // Small delay between tests
304
-
305
- await testFrontendConfig()
306
- await new Promise(resolve => setTimeout(resolve, 100))
307
-
308
- await testEdenTreaty()
309
- await new Promise(resolve => setTimeout(resolve, 100))
310
-
311
- await testApiHealth()
312
- await new Promise(resolve => setTimeout(resolve, 100))
313
-
314
- await testUsersApi()
315
-
316
- setIsRunning(false)
317
- }
318
-
319
- // Clear results
320
- const clearResults = () => {
321
- setTestResults([])
322
- }
323
-
324
- // Get status color
325
- const getStatusColor = (status: TestResult['status']) => {
326
- switch (status) {
327
- case 'success': return 'text-green-600'
328
- case 'error': return 'text-red-600'
329
- case 'pending': return 'text-yellow-600'
330
- default: return 'text-gray-600'
331
- }
332
- }
333
-
334
- // Get status icon
335
- const getStatusIcon = (status: TestResult['status']) => {
336
- switch (status) {
337
- case 'success': return '✅'
338
- case 'error': return '❌'
339
- case 'pending': return '⏳'
340
- default: return '⚪'
341
- }
342
- }
343
-
344
- return (
345
- <div className="container mx-auto p-6 max-w-4xl">
346
- <div className="mb-8">
347
- <h1 className="text-3xl font-bold text-gray-900 mb-2">
348
- FluxStack Frontend Tests
349
- </h1>
350
- <p className="text-gray-600">
351
- Test environment variables, API connectivity, and frontend configuration
352
- </p>
353
- </div>
354
-
355
- {/* Control buttons */}
356
- <div className="mb-6 flex gap-3">
357
- <button
358
- onClick={runAllTests}
359
- disabled={isRunning}
360
- className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed"
361
- >
362
- {isRunning ? 'Running Tests...' : 'Run All Tests'}
363
- </button>
364
-
365
- <button
366
- onClick={clearResults}
367
- disabled={isRunning}
368
- className="px-4 py-2 bg-gray-600 text-white rounded-lg hover:bg-gray-700 disabled:opacity-50"
369
- >
370
- Clear Results
371
- </button>
372
- </div>
373
-
374
- {/* Environment Variables Preview */}
375
- <div className="mb-6 bg-gray-50 rounded-lg p-4">
376
- <h2 className="text-lg font-semibold mb-3">Environment Variables Preview</h2>
377
- <div className="grid grid-cols-1 md:grid-cols-2 gap-3 text-sm">
378
- {envTests.map(test => (
379
- <div key={test.variable} className="flex justify-between items-center p-2 bg-white rounded border">
380
- <span className="font-medium">{test.name}:</span>
381
- <code className="text-blue-600 bg-blue-50 px-2 py-1 rounded">
382
- {import.meta.env[test.variable] || 'undefined'}
383
- </code>
384
- </div>
385
- ))}
386
- </div>
387
- </div>
388
-
389
- {/* Test Results */}
390
- <div className="space-y-4">
391
- <h2 className="text-xl font-semibold">Test Results</h2>
392
-
393
- {testResults.length === 0 && (
394
- <div className="text-center py-8 text-gray-500">
395
- No tests run yet. Click "Run All Tests" to start.
396
- </div>
397
- )}
398
-
399
- {testResults.map((result, index) => (
400
- <div
401
- key={index}
402
- className="border rounded-lg p-4 bg-white shadow-sm"
403
- >
404
- <div className="flex items-center justify-between mb-2">
405
- <div className="flex items-center gap-2">
406
- <span className="text-xl">{getStatusIcon(result.status)}</span>
407
- <h3 className="font-semibold">{result.name}</h3>
408
- {result.duration && (
409
- <span className="text-xs text-gray-500">
410
- ({result.duration}ms)
411
- </span>
412
- )}
413
- </div>
414
- <span className={`text-sm font-medium ${getStatusColor(result.status)}`}>
415
- {result.status.toUpperCase()}
416
- </span>
417
- </div>
418
-
419
- <p className={`text-sm ${getStatusColor(result.status)} mb-2`}>
420
- {result.message}
421
- </p>
422
-
423
- {result.details && (
424
- <details className="mt-2">
425
- <summary className="cursor-pointer text-sm font-medium text-gray-700 hover:text-gray-900">
426
- View Details
427
- </summary>
428
- <pre className="mt-2 text-xs bg-gray-100 p-3 rounded overflow-auto">
429
- {JSON.stringify(result.details, null, 2)}
430
- </pre>
431
- </details>
432
- )}
433
- </div>
434
- ))}
435
- </div>
436
-
437
- {/* Summary */}
438
- {testResults.length > 0 && (
439
- <div className="mt-6 p-4 bg-blue-50 rounded-lg">
440
- <h3 className="font-semibold text-blue-900 mb-2">Test Summary</h3>
441
- <div className="text-sm text-blue-800">
442
- <div>Total: {testResults.length} tests</div>
443
- <div>Passed: {testResults.filter(r => r.status === 'success').length}</div>
444
- <div>Failed: {testResults.filter(r => r.status === 'error').length}</div>
445
- <div>Pending: {testResults.filter(r => r.status === 'pending').length}</div>
446
- </div>
447
- </div>
448
- )}
449
- </div>
450
- )
451
- }
452
-
453
- export default TestPage