@friggframework/core 2.0.0--canary.461.61382d8.0 → 2.0.0--canary.461.3d6d8ad.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/database/use-cases/check-migration-status-use-case.js +81 -0
- package/generated/prisma-mongodb/client.d.ts +1 -0
- package/generated/prisma-mongodb/client.js +4 -0
- package/generated/prisma-mongodb/default.d.ts +1 -0
- package/generated/prisma-mongodb/default.js +4 -0
- package/generated/prisma-mongodb/edge.d.ts +1 -0
- package/generated/prisma-mongodb/edge.js +336 -0
- package/generated/prisma-mongodb/index-browser.js +318 -0
- package/generated/prisma-mongodb/index.d.ts +22993 -0
- package/generated/prisma-mongodb/index.js +361 -0
- package/generated/prisma-mongodb/package.json +183 -0
- package/generated/prisma-mongodb/query-engine-debian-openssl-3.0.x +0 -0
- package/generated/prisma-mongodb/query-engine-rhel-openssl-3.0.x +0 -0
- package/generated/prisma-mongodb/runtime/binary.d.ts +1 -0
- package/generated/prisma-mongodb/runtime/binary.js +289 -0
- package/generated/prisma-mongodb/runtime/edge-esm.js +34 -0
- package/generated/prisma-mongodb/runtime/edge.js +34 -0
- package/generated/prisma-mongodb/runtime/index-browser.d.ts +370 -0
- package/generated/prisma-mongodb/runtime/index-browser.js +16 -0
- package/generated/prisma-mongodb/runtime/library.d.ts +3977 -0
- package/generated/prisma-mongodb/runtime/react-native.js +83 -0
- package/generated/prisma-mongodb/runtime/wasm-compiler-edge.js +84 -0
- package/generated/prisma-mongodb/runtime/wasm-engine-edge.js +36 -0
- package/generated/prisma-mongodb/schema.prisma +364 -0
- package/generated/prisma-mongodb/wasm-edge-light-loader.mjs +4 -0
- package/generated/prisma-mongodb/wasm-worker-loader.mjs +4 -0
- package/generated/prisma-mongodb/wasm.d.ts +1 -0
- package/generated/prisma-mongodb/wasm.js +343 -0
- package/generated/prisma-postgresql/client.d.ts +1 -0
- package/generated/prisma-postgresql/client.js +4 -0
- package/generated/prisma-postgresql/default.d.ts +1 -0
- package/generated/prisma-postgresql/default.js +4 -0
- package/generated/prisma-postgresql/edge.d.ts +1 -0
- package/generated/prisma-postgresql/edge.js +358 -0
- package/generated/prisma-postgresql/index-browser.js +340 -0
- package/generated/prisma-postgresql/index.d.ts +25171 -0
- package/generated/prisma-postgresql/index.js +383 -0
- package/generated/prisma-postgresql/package.json +183 -0
- package/generated/prisma-postgresql/query-engine-debian-openssl-3.0.x +0 -0
- package/generated/prisma-postgresql/query-engine-rhel-openssl-3.0.x +0 -0
- package/generated/prisma-postgresql/query_engine_bg.js +2 -0
- package/generated/prisma-postgresql/query_engine_bg.wasm +0 -0
- package/generated/prisma-postgresql/runtime/binary.d.ts +1 -0
- package/generated/prisma-postgresql/runtime/binary.js +289 -0
- package/generated/prisma-postgresql/runtime/edge-esm.js +34 -0
- package/generated/prisma-postgresql/runtime/edge.js +34 -0
- package/generated/prisma-postgresql/runtime/index-browser.d.ts +370 -0
- package/generated/prisma-postgresql/runtime/index-browser.js +16 -0
- package/generated/prisma-postgresql/runtime/library.d.ts +3977 -0
- package/generated/prisma-postgresql/runtime/react-native.js +83 -0
- package/generated/prisma-postgresql/runtime/wasm-compiler-edge.js +84 -0
- package/generated/prisma-postgresql/runtime/wasm-engine-edge.js +36 -0
- package/generated/prisma-postgresql/schema.prisma +347 -0
- package/generated/prisma-postgresql/wasm-edge-light-loader.mjs +4 -0
- package/generated/prisma-postgresql/wasm-worker-loader.mjs +4 -0
- package/generated/prisma-postgresql/wasm.d.ts +1 -0
- package/generated/prisma-postgresql/wasm.js +365 -0
- package/handlers/routers/db-migration.js +52 -0
- package/package.json +5 -5
- package/application/commands/integration-commands.test.js +0 -123
- package/core/Worker.test.js +0 -159
- package/database/encryption/encryption-integration.test.js +0 -553
- package/database/encryption/encryption-schema-registry.test.js +0 -392
- package/database/encryption/field-encryption-service.test.js +0 -525
- package/database/encryption/mongo-decryption-fix-verification.test.js +0 -348
- package/database/encryption/postgres-decryption-fix-verification.test.js +0 -371
- package/database/encryption/postgres-relation-decryption.test.js +0 -245
- package/database/encryption/prisma-encryption-extension.test.js +0 -439
- package/database/repositories/migration-status-repository-s3.test.js +0 -158
- package/database/use-cases/check-encryption-health-use-case.test.js +0 -192
- package/database/use-cases/get-migration-status-use-case.test.js +0 -171
- package/database/use-cases/run-database-migration-use-case.test.js +0 -310
- package/database/use-cases/trigger-database-migration-use-case.test.js +0 -250
- package/database/utils/prisma-runner.test.js +0 -486
- package/encrypt/Cryptor.test.js +0 -144
- package/errors/base-error.test.js +0 -32
- package/errors/fetch-error.test.js +0 -79
- package/errors/halt-error.test.js +0 -11
- package/errors/validation-errors.test.js +0 -120
- package/handlers/auth-flow.integration.test.js +0 -147
- package/handlers/integration-event-dispatcher.test.js +0 -209
- package/handlers/routers/db-migration.test.js +0 -51
- package/handlers/routers/health.test.js +0 -210
- package/handlers/routers/integration-webhook-routers.test.js +0 -126
- package/handlers/use-cases/check-integrations-health-use-case.test.js +0 -125
- package/handlers/webhook-flow.integration.test.js +0 -356
- package/handlers/workers/db-migration.test.js +0 -50
- package/handlers/workers/integration-defined-workers.test.js +0 -184
- package/integrations/tests/integration-router-multi-auth.test.js +0 -369
- package/integrations/tests/use-cases/create-integration.test.js +0 -131
- package/integrations/tests/use-cases/delete-integration-for-user.test.js +0 -150
- package/integrations/tests/use-cases/find-integration-context-by-external-entity-id.test.js +0 -92
- package/integrations/tests/use-cases/get-integration-for-user.test.js +0 -150
- package/integrations/tests/use-cases/get-integration-instance.test.js +0 -176
- package/integrations/tests/use-cases/get-integrations-for-user.test.js +0 -176
- package/integrations/tests/use-cases/get-possible-integrations.test.js +0 -188
- package/integrations/tests/use-cases/update-integration-messages.test.js +0 -142
- package/integrations/tests/use-cases/update-integration-status.test.js +0 -103
- package/integrations/tests/use-cases/update-integration.test.js +0 -141
- package/integrations/use-cases/create-process.test.js +0 -178
- package/integrations/use-cases/get-process.test.js +0 -190
- package/integrations/use-cases/load-integration-context-full.test.js +0 -329
- package/integrations/use-cases/load-integration-context.test.js +0 -114
- package/integrations/use-cases/update-process-metrics.test.js +0 -308
- package/integrations/use-cases/update-process-state.test.js +0 -256
- package/lambda/TimeoutCatcher.test.js +0 -68
- package/logs/logger.test.js +0 -76
- package/modules/module-hydration.test.js +0 -205
- package/modules/requester/requester.test.js +0 -28
- package/queues/queuer-util.test.js +0 -132
- package/user/tests/use-cases/create-individual-user.test.js +0 -24
- package/user/tests/use-cases/create-organization-user.test.js +0 -28
- package/user/tests/use-cases/create-token-for-user-id.test.js +0 -19
- package/user/tests/use-cases/get-user-from-adopter-jwt.test.js +0 -113
- package/user/tests/use-cases/get-user-from-bearer-token.test.js +0 -64
- package/user/tests/use-cases/get-user-from-x-frigg-headers.test.js +0 -346
- package/user/tests/use-cases/login-user.test.js +0 -220
- package/user/tests/user-password-encryption-isolation.test.js +0 -237
- package/user/tests/user-password-hashing.test.js +0 -235
- package/websocket/repositories/websocket-connection-repository.test.js +0 -227
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
process.env.HEALTH_API_KEY = 'test-api-key';
|
|
2
|
-
|
|
3
|
-
jest.mock('../../database/config', () => ({
|
|
4
|
-
DB_TYPE: 'mongodb',
|
|
5
|
-
getDatabaseType: jest.fn(() => 'mongodb'),
|
|
6
|
-
PRISMA_LOG_LEVEL: 'error,warn',
|
|
7
|
-
PRISMA_QUERY_LOGGING: false,
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
jest.mock('mongoose', () => ({
|
|
11
|
-
set: jest.fn(),
|
|
12
|
-
connection: {
|
|
13
|
-
readyState: 1,
|
|
14
|
-
db: {
|
|
15
|
-
admin: () => ({
|
|
16
|
-
ping: jest.fn().mockResolvedValue(true)
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
jest.mock('./../backend-utils', () => ({
|
|
23
|
-
moduleFactory: {
|
|
24
|
-
moduleTypes: ['test-module', 'another-module']
|
|
25
|
-
},
|
|
26
|
-
integrationFactory: {
|
|
27
|
-
integrationTypes: ['test-integration', 'another-integration']
|
|
28
|
-
}
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
jest.mock('./../app-handler-helpers', () => ({
|
|
32
|
-
createAppHandler: jest.fn((name, router) => ({ name, router }))
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
const { router } = require('./health');
|
|
36
|
-
const mongoose = require('mongoose');
|
|
37
|
-
|
|
38
|
-
const mockRequest = (path, headers = {}) => ({
|
|
39
|
-
path,
|
|
40
|
-
headers
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const mockResponse = () => {
|
|
44
|
-
const res = {};
|
|
45
|
-
res.status = jest.fn().mockReturnValue(res);
|
|
46
|
-
res.json = jest.fn().mockReturnValue(res);
|
|
47
|
-
return res;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
describe('Health Check Endpoints', () => {
|
|
51
|
-
beforeEach(() => {
|
|
52
|
-
mongoose.connection.readyState = 1;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe('Middleware - validateApiKey', () => {
|
|
56
|
-
it('should allow access to /health without authentication', async () => {
|
|
57
|
-
expect(true).toBe(true);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe('GET /health', () => {
|
|
62
|
-
it('should return basic health status', async () => {
|
|
63
|
-
const req = mockRequest('/health');
|
|
64
|
-
const res = mockResponse();
|
|
65
|
-
|
|
66
|
-
const routeHandler = router.stack.find(layer =>
|
|
67
|
-
layer.route && layer.route.path === '/health'
|
|
68
|
-
).route.stack[0].handle;
|
|
69
|
-
|
|
70
|
-
await routeHandler(req, res);
|
|
71
|
-
|
|
72
|
-
expect(res.status).toHaveBeenCalledWith(200);
|
|
73
|
-
expect(res.json).toHaveBeenCalledWith({
|
|
74
|
-
status: 'ok',
|
|
75
|
-
timestamp: expect.any(String),
|
|
76
|
-
service: 'frigg-core-api'
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
describe('GET /health/detailed', () => {
|
|
82
|
-
it('should return detailed health status when healthy', async () => {
|
|
83
|
-
const req = mockRequest('/health/detailed', { 'x-api-key': 'test-api-key' });
|
|
84
|
-
const res = mockResponse();
|
|
85
|
-
|
|
86
|
-
const originalPromiseAll = Promise.all;
|
|
87
|
-
Promise.all = jest.fn().mockResolvedValue([
|
|
88
|
-
{ name: 'github', status: 'healthy', reachable: true, statusCode: 200, responseTime: 100 },
|
|
89
|
-
{ name: 'npm', status: 'healthy', reachable: true, statusCode: 200, responseTime: 150 }
|
|
90
|
-
]);
|
|
91
|
-
|
|
92
|
-
const routeHandler = router.stack.find(layer =>
|
|
93
|
-
layer.route && layer.route.path === '/health/detailed'
|
|
94
|
-
).route.stack[0].handle;
|
|
95
|
-
|
|
96
|
-
await routeHandler(req, res);
|
|
97
|
-
|
|
98
|
-
Promise.all = originalPromiseAll;
|
|
99
|
-
|
|
100
|
-
expect(res.status).toHaveBeenCalledWith(200);
|
|
101
|
-
expect(res.json).toHaveBeenCalledWith(expect.objectContaining({
|
|
102
|
-
status: 'healthy',
|
|
103
|
-
service: 'frigg-core-api',
|
|
104
|
-
timestamp: expect.any(String),
|
|
105
|
-
checks: expect.objectContaining({
|
|
106
|
-
database: expect.objectContaining({
|
|
107
|
-
status: 'healthy',
|
|
108
|
-
state: 'connected'
|
|
109
|
-
}),
|
|
110
|
-
integrations: expect.objectContaining({
|
|
111
|
-
status: 'healthy'
|
|
112
|
-
})
|
|
113
|
-
}),
|
|
114
|
-
responseTime: expect.any(Number)
|
|
115
|
-
}));
|
|
116
|
-
|
|
117
|
-
const response = res.json.mock.calls[0][0];
|
|
118
|
-
expect(response).not.toHaveProperty('version');
|
|
119
|
-
expect(response).not.toHaveProperty('uptime');
|
|
120
|
-
expect(response.checks).not.toHaveProperty('memory');
|
|
121
|
-
expect(response.checks.database).not.toHaveProperty('type');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('should return 503 when database is disconnected', async () => {
|
|
125
|
-
mongoose.connection.readyState = 0;
|
|
126
|
-
|
|
127
|
-
const req = mockRequest('/health/detailed', { 'x-api-key': 'test-api-key' });
|
|
128
|
-
const res = mockResponse();
|
|
129
|
-
|
|
130
|
-
const originalPromiseAll = Promise.all;
|
|
131
|
-
Promise.all = jest.fn().mockResolvedValue([
|
|
132
|
-
{ name: 'github', status: 'healthy', reachable: true, statusCode: 200, responseTime: 100 },
|
|
133
|
-
{ name: 'npm', status: 'healthy', reachable: true, statusCode: 200, responseTime: 150 }
|
|
134
|
-
]);
|
|
135
|
-
|
|
136
|
-
const routeHandler = router.stack.find(layer =>
|
|
137
|
-
layer.route && layer.route.path === '/health/detailed'
|
|
138
|
-
).route.stack[0].handle;
|
|
139
|
-
|
|
140
|
-
await routeHandler(req, res);
|
|
141
|
-
|
|
142
|
-
Promise.all = originalPromiseAll;
|
|
143
|
-
|
|
144
|
-
expect(res.status).toHaveBeenCalledWith(503);
|
|
145
|
-
expect(res.json).toHaveBeenCalledWith(expect.objectContaining({
|
|
146
|
-
status: 'unhealthy'
|
|
147
|
-
}));
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
describe('GET /health/live', () => {
|
|
152
|
-
it('should return alive status', async () => {
|
|
153
|
-
const req = mockRequest('/health/live', { 'x-api-key': 'test-api-key' });
|
|
154
|
-
const res = mockResponse();
|
|
155
|
-
|
|
156
|
-
const routeHandler = router.stack.find(layer =>
|
|
157
|
-
layer.route && layer.route.path === '/health/live'
|
|
158
|
-
).route.stack[0].handle;
|
|
159
|
-
|
|
160
|
-
routeHandler(req, res);
|
|
161
|
-
|
|
162
|
-
expect(res.status).toHaveBeenCalledWith(200);
|
|
163
|
-
expect(res.json).toHaveBeenCalledWith({
|
|
164
|
-
status: 'alive',
|
|
165
|
-
timestamp: expect.any(String)
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
describe('GET /health/ready', () => {
|
|
171
|
-
it('should return ready when all checks pass', async () => {
|
|
172
|
-
const req = mockRequest('/health/ready', { 'x-api-key': 'test-api-key' });
|
|
173
|
-
const res = mockResponse();
|
|
174
|
-
|
|
175
|
-
const routeHandler = router.stack.find(layer =>
|
|
176
|
-
layer.route && layer.route.path === '/health/ready'
|
|
177
|
-
).route.stack[0].handle;
|
|
178
|
-
|
|
179
|
-
await routeHandler(req, res);
|
|
180
|
-
|
|
181
|
-
expect(res.status).toHaveBeenCalledWith(200);
|
|
182
|
-
expect(res.json).toHaveBeenCalledWith({
|
|
183
|
-
ready: true,
|
|
184
|
-
timestamp: expect.any(String),
|
|
185
|
-
checks: {
|
|
186
|
-
database: true,
|
|
187
|
-
modules: true
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('should return 503 when database is not connected', async () => {
|
|
193
|
-
mongoose.connection.readyState = 0;
|
|
194
|
-
|
|
195
|
-
const req = mockRequest('/health/ready', { 'x-api-key': 'test-api-key' });
|
|
196
|
-
const res = mockResponse();
|
|
197
|
-
|
|
198
|
-
const routeHandler = router.stack.find(layer =>
|
|
199
|
-
layer.route && layer.route.path === '/health/ready'
|
|
200
|
-
).route.stack[0].handle;
|
|
201
|
-
|
|
202
|
-
await routeHandler(req, res);
|
|
203
|
-
|
|
204
|
-
expect(res.status).toHaveBeenCalledWith(503);
|
|
205
|
-
expect(res.json).toHaveBeenCalledWith(expect.objectContaining({
|
|
206
|
-
ready: false
|
|
207
|
-
}));
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
});
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
jest.mock('../../database/config', () => ({
|
|
2
|
-
DB_TYPE: 'mongodb',
|
|
3
|
-
getDatabaseType: jest.fn(() => 'mongodb'),
|
|
4
|
-
PRISMA_LOG_LEVEL: 'error,warn',
|
|
5
|
-
PRISMA_QUERY_LOGGING: false,
|
|
6
|
-
}));
|
|
7
|
-
|
|
8
|
-
jest.mock('../app-definition-loader', () => {
|
|
9
|
-
const { IntegrationBase } = require('../../integrations/integration-base');
|
|
10
|
-
|
|
11
|
-
class WebhookEnabledIntegration extends IntegrationBase {
|
|
12
|
-
static Definition = {
|
|
13
|
-
name: 'webhook-enabled',
|
|
14
|
-
version: '1.0.0',
|
|
15
|
-
modules: {},
|
|
16
|
-
webhooks: true,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
constructor(params) {
|
|
20
|
-
super(params);
|
|
21
|
-
this.queueWebhook = jest.fn().mockResolvedValue('message-id');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
class AdvancedWebhookIntegration extends IntegrationBase {
|
|
26
|
-
static Definition = {
|
|
27
|
-
name: 'advanced-webhook',
|
|
28
|
-
version: '1.0.0',
|
|
29
|
-
modules: {},
|
|
30
|
-
webhooks: {
|
|
31
|
-
enabled: true,
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
constructor(params) {
|
|
36
|
-
super(params);
|
|
37
|
-
this.events = {
|
|
38
|
-
WEBHOOK_RECEIVED: {
|
|
39
|
-
handler: async ({ req, res }) => {
|
|
40
|
-
// Custom signature verification
|
|
41
|
-
const signature = req.headers['x-webhook-signature'];
|
|
42
|
-
if (signature !== 'valid-signature') {
|
|
43
|
-
return res.status(401).json({ error: 'Invalid signature' });
|
|
44
|
-
}
|
|
45
|
-
await this.queueWebhook({ body: req.body });
|
|
46
|
-
res.status(200).json({ verified: true });
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
this.queueWebhook = jest.fn().mockResolvedValue('message-id');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
class NoWebhookIntegration extends IntegrationBase {
|
|
55
|
-
static Definition = {
|
|
56
|
-
name: 'no-webhook',
|
|
57
|
-
version: '1.0.0',
|
|
58
|
-
modules: {},
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
loadAppDefinition: () => ({
|
|
64
|
-
integrations: [
|
|
65
|
-
WebhookEnabledIntegration,
|
|
66
|
-
AdvancedWebhookIntegration,
|
|
67
|
-
NoWebhookIntegration,
|
|
68
|
-
],
|
|
69
|
-
}),
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe('Integration Webhook Routers', () => {
|
|
74
|
-
let handlers;
|
|
75
|
-
|
|
76
|
-
beforeEach(() => {
|
|
77
|
-
// Clear module cache to get fresh handlers
|
|
78
|
-
jest.resetModules();
|
|
79
|
-
jest.clearAllMocks();
|
|
80
|
-
|
|
81
|
-
// Re-require after mocking
|
|
82
|
-
handlers = require('./integration-webhook-routers').handlers;
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
describe('Handler Creation', () => {
|
|
86
|
-
it('should create webhook handlers for integrations with webhooks: true', () => {
|
|
87
|
-
expect(handlers['webhook-enabledWebhook']).toBeDefined();
|
|
88
|
-
expect(handlers['webhook-enabledWebhook'].handler).toBeDefined();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('should create webhook handlers for integrations with webhooks.enabled: true', () => {
|
|
92
|
-
expect(handlers['advanced-webhookWebhook']).toBeDefined();
|
|
93
|
-
expect(handlers['advanced-webhookWebhook'].handler).toBeDefined();
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('should not create webhook handlers for integrations without webhooks', () => {
|
|
97
|
-
expect(handlers['no-webhookWebhook']).toBeUndefined();
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('should configure handlers to not use database connection', () => {
|
|
101
|
-
// Handlers are created with createAppHandler(..., false)
|
|
102
|
-
// This means shouldUseDatabase = false
|
|
103
|
-
// Actual behavior is tested in integration tests
|
|
104
|
-
expect(handlers['webhook-enabledWebhook']).toBeDefined();
|
|
105
|
-
expect(handlers['advanced-webhookWebhook']).toBeDefined();
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
describe('Webhook Configuration', () => {
|
|
110
|
-
it('should support boolean webhook configuration', () => {
|
|
111
|
-
// webhooks: true should enable webhook handling
|
|
112
|
-
expect(handlers['webhook-enabledWebhook']).toBeDefined();
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('should support object webhook configuration', () => {
|
|
116
|
-
// webhooks: { enabled: true } should enable webhook handling
|
|
117
|
-
expect(handlers['advanced-webhookWebhook']).toBeDefined();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('should skip integrations with webhooks disabled', () => {
|
|
121
|
-
// webhooks: false or missing should not create handlers
|
|
122
|
-
expect(handlers['no-webhookWebhook']).toBeUndefined();
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for CheckIntegrationsHealthUseCase
|
|
3
|
-
*
|
|
4
|
-
* Tests integration and module factory health checking
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const { CheckIntegrationsHealthUseCase } = require('./check-integrations-health-use-case');
|
|
8
|
-
|
|
9
|
-
describe('CheckIntegrationsHealthUseCase', () => {
|
|
10
|
-
describe('execute()', () => {
|
|
11
|
-
it('should return healthy status with module and integration counts', () => {
|
|
12
|
-
const mockModuleFactory = {
|
|
13
|
-
moduleDefinitions: [
|
|
14
|
-
{ moduleName: 'HubSpot' },
|
|
15
|
-
{ moduleName: 'Salesforce' },
|
|
16
|
-
{ moduleName: 'Slack' },
|
|
17
|
-
],
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const mockIntegrationClasses = [
|
|
21
|
-
{ Definition: { name: 'HubSpot-to-Salesforce' } },
|
|
22
|
-
{ Definition: { name: 'Slack-Notifications' } },
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
const useCase = new CheckIntegrationsHealthUseCase({
|
|
26
|
-
moduleFactory: mockModuleFactory,
|
|
27
|
-
integrationClasses: mockIntegrationClasses,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const result = useCase.execute();
|
|
31
|
-
|
|
32
|
-
expect(result.status).toBe('healthy');
|
|
33
|
-
expect(result.modules.count).toBe(3);
|
|
34
|
-
expect(result.modules.available).toEqual(['HubSpot', 'Salesforce', 'Slack']);
|
|
35
|
-
expect(result.integrations.count).toBe(2);
|
|
36
|
-
expect(result.integrations.available).toEqual(['HubSpot-to-Salesforce', 'Slack-Notifications']);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should handle undefined moduleFactory gracefully', () => {
|
|
40
|
-
const mockIntegrationClasses = [
|
|
41
|
-
{ Definition: { name: 'Integration1' } },
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
const useCase = new CheckIntegrationsHealthUseCase({
|
|
45
|
-
moduleFactory: undefined,
|
|
46
|
-
integrationClasses: mockIntegrationClasses,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const result = useCase.execute();
|
|
50
|
-
|
|
51
|
-
expect(result.status).toBe('healthy');
|
|
52
|
-
expect(result.modules.count).toBe(0);
|
|
53
|
-
expect(result.modules.available).toEqual([]);
|
|
54
|
-
expect(result.integrations.count).toBe(1);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('should handle undefined integrationClasses gracefully', () => {
|
|
58
|
-
const mockModuleFactory = {
|
|
59
|
-
moduleDefinitions: [{ moduleName: 'Module1' }],
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const useCase = new CheckIntegrationsHealthUseCase({
|
|
63
|
-
moduleFactory: mockModuleFactory,
|
|
64
|
-
integrationClasses: undefined,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const result = useCase.execute();
|
|
68
|
-
|
|
69
|
-
expect(result.status).toBe('healthy');
|
|
70
|
-
expect(result.modules.count).toBe(1);
|
|
71
|
-
expect(result.integrations.count).toBe(0);
|
|
72
|
-
expect(result.integrations.available).toEqual([]);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should handle both moduleFactory and integrationClasses being undefined', () => {
|
|
76
|
-
const useCase = new CheckIntegrationsHealthUseCase({
|
|
77
|
-
moduleFactory: undefined,
|
|
78
|
-
integrationClasses: undefined,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const result = useCase.execute();
|
|
82
|
-
|
|
83
|
-
expect(result.status).toBe('healthy');
|
|
84
|
-
expect(result.modules.count).toBe(0);
|
|
85
|
-
expect(result.modules.available).toEqual([]);
|
|
86
|
-
expect(result.integrations.count).toBe(0);
|
|
87
|
-
expect(result.integrations.available).toEqual([]);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('should handle non-array moduleDefinitions', () => {
|
|
91
|
-
const mockModuleFactory = {
|
|
92
|
-
moduleDefinitions: 'not-an-array',
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const useCase = new CheckIntegrationsHealthUseCase({
|
|
96
|
-
moduleFactory: mockModuleFactory,
|
|
97
|
-
integrationClasses: [],
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
const result = useCase.execute();
|
|
101
|
-
|
|
102
|
-
expect(result.status).toBe('healthy');
|
|
103
|
-
expect(result.modules.count).toBe(0);
|
|
104
|
-
expect(result.modules.available).toEqual([]);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('should handle moduleFactory with missing moduleDefinitions property', () => {
|
|
108
|
-
const mockModuleFactory = {}; // No moduleDefinitions property
|
|
109
|
-
|
|
110
|
-
const useCase = new CheckIntegrationsHealthUseCase({
|
|
111
|
-
moduleFactory: mockModuleFactory,
|
|
112
|
-
integrationClasses: [],
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const result = useCase.execute();
|
|
116
|
-
|
|
117
|
-
expect(result.status).toBe('healthy');
|
|
118
|
-
expect(result.modules.count).toBe(0);
|
|
119
|
-
expect(result.modules.available).toEqual([]);
|
|
120
|
-
expect(result.integrations.count).toBe(0);
|
|
121
|
-
expect(result.integrations.available).toEqual([]);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|