plugin-build-visualization-block 0.1.4 → 0.2.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/LICENSE +201 -0
- package/README.md +21 -0
- package/client.d.ts +2 -2
- package/client.js +1 -1
- package/dist/client/59.6bac6ada1dacea82.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/385.1e235c5081822f07.js +10 -0
- package/dist/client-v2/59.cdb723e410dac32b.js +10 -0
- package/dist/client-v2/index.js +37 -1
- package/dist/externalVersion.js +12 -7
- package/dist/locale/en-US.json +77 -37
- package/dist/locale/vi-VN.json +58 -40
- package/dist/locale/zh-CN.json +79 -40
- package/dist/node_modules/zod/index.cjs +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/actions/build.js +8 -720
- package/dist/server/collections/workflow-runs.js +51 -0
- package/dist/server/pipeline/analyzer.js +18 -4
- package/dist/server/plugin.js +17 -20
- package/dist/server/tools/build-visualization-block.js +9 -26
- package/dist/server/workflow-domain.js +209 -0
- package/dist/server/workflow.js +466 -0
- package/dist/shared/blockSpec.js +1 -1
- package/dist/shared/workflow.js +58 -0
- package/package.json +14 -3
- package/server.d.ts +2 -2
- package/server.js +1 -1
- package/src/client/locale.ts +18 -18
- package/src/client/plugin.tsx +11 -0
- package/src/client/workflow.ts +28 -0
- package/src/client-v2/__tests__/buildApi.test.ts +68 -0
- package/src/client-v2/__tests__/modelOptions.test.ts +190 -0
- package/src/client-v2/__tests__/nativeModels.test.ts +77 -0
- package/src/client-v2/buildApi.ts +93 -0
- package/src/client-v2/components/AISelectors.tsx +85 -0
- package/src/client-v2/components/BuildForm.tsx +186 -0
- package/src/client-v2/components/CollectionMultiSelect.tsx +63 -0
- package/src/client-v2/components/NativePreview.tsx +53 -0
- package/src/client-v2/locale.ts +5 -0
- package/src/client-v2/modelOptions.ts +201 -0
- package/src/client-v2/models/BuildVisualizationBlockModel.tsx +95 -0
- package/src/client-v2/nativeBlock.ts +28 -0
- package/src/client-v2/pages/SettingsPage.tsx +77 -0
- package/src/client-v2/plugin.tsx +17 -4
- package/src/client-v2/workflow-fields.tsx +23 -0
- package/src/client-v2/workflow.ts +28 -0
- package/src/locale/en-US.json +77 -37
- package/src/locale/namespace.ts +6 -6
- package/src/locale/vi-VN.json +58 -40
- package/src/locale/zh-CN.json +79 -40
- package/src/server/__tests__/build-action.test.ts +121 -117
- package/src/server/__tests__/plugin.test.ts +19 -34
- package/src/server/actions/build.ts +268 -1318
- package/src/server/collections/workflow-runs.ts +30 -0
- package/src/server/pipeline/analyzer.ts +395 -368
- package/src/server/plugin.ts +26 -35
- package/src/server/tools/build-visualization-block.ts +18 -28
- package/src/server/workflow-domain.ts +235 -0
- package/src/server/workflow.ts +519 -0
- package/src/shared/blockSpec.ts +10 -1
- package/src/shared/workflow.ts +26 -0
- package/dist/client-v2/812.6b4f5e757b898c82.js +0 -10
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { getApp } from '@nocobase/plugin-workflow-test';
|
|
11
|
+
import { Instruction, JOB_STATUS, type WorkflowModel } from '@nocobase/plugin-workflow';
|
|
12
|
+
import { vi } from 'vitest';
|
|
13
|
+
import { requestBuild } from '../workflow-domain';
|
|
14
|
+
import { WORKFLOW_KEY, RUNS_COLLECTION } from '../../shared/workflow';
|
|
2
15
|
|
|
3
16
|
import type { Context, Next } from '@nocobase/actions';
|
|
4
|
-
import {
|
|
17
|
+
import type { MockServer } from '@nocobase/test';
|
|
5
18
|
|
|
6
19
|
import { COLLECTION_NAME } from '../../shared/constants';
|
|
7
|
-
import { build
|
|
20
|
+
import { build } from '../actions/build';
|
|
8
21
|
import PluginBuildVisualizationBlockServer from '../plugin';
|
|
9
22
|
import { buildVisualizationBlockTool } from '../tools';
|
|
10
23
|
|
|
11
24
|
/**
|
|
12
|
-
* Integration tests for the build action
|
|
25
|
+
* Integration tests for the build action and native workflow pipeline.
|
|
13
26
|
*
|
|
14
27
|
* Coverage:
|
|
15
28
|
* - Req 10.1 — the `build` action creates a `queued` record and returns
|
|
@@ -103,59 +116,35 @@ function makeCtx(opts: {
|
|
|
103
116
|
}
|
|
104
117
|
|
|
105
118
|
describe('plugin-build-visualization-block build action + pipeline', () => {
|
|
106
|
-
let app: MockServer
|
|
107
|
-
let
|
|
108
|
-
|
|
119
|
+
let app: MockServer;
|
|
120
|
+
let plugin: PluginBuildVisualizationBlockServer;
|
|
121
|
+
let workflow: WorkflowModel;
|
|
109
122
|
beforeAll(async () => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// queue treats it as a worker and a background poller would claim queued
|
|
127
|
-
// records the moment they are created. Stop that poller so the
|
|
128
|
-
// queued-state assertions are deterministic; the pipeline test drives a
|
|
129
|
-
// record through `processQueuedBuild` explicitly instead.
|
|
130
|
-
unregisterBuildQueue(app);
|
|
131
|
-
} catch (error) {
|
|
132
|
-
// The mock-server harness needs a reachable test database. If it cannot
|
|
133
|
-
// boot here, record the reason and let each test skip with a clear
|
|
134
|
-
// message rather than reporting a false failure.
|
|
135
|
-
bootError = error;
|
|
136
|
-
// eslint-disable-next-line no-console
|
|
137
|
-
console.warn(
|
|
138
|
-
`[plugin-build-visualization-block] Skipping build-action tests; mock server could not start: ${String(error)}`,
|
|
139
|
-
);
|
|
140
|
-
}
|
|
123
|
+
app = await getApp({ plugins: [], skipSupervisor: true });
|
|
124
|
+
await app.pm.add(PluginBuildVisualizationBlockServer, { name: 'plugin-build-visualization-block', enabled: true });
|
|
125
|
+
plugin = app.pm.get('plugin-build-visualization-block');
|
|
126
|
+
await plugin.beforeLoad();
|
|
127
|
+
app.db.collection({
|
|
128
|
+
name: TEST_COLLECTION,
|
|
129
|
+
fields: [
|
|
130
|
+
{ type: 'string', name: 'title' },
|
|
131
|
+
{ type: 'string', name: 'status' },
|
|
132
|
+
],
|
|
133
|
+
});
|
|
134
|
+
await app.db.sync();
|
|
135
|
+
await plugin.load();
|
|
136
|
+
await plugin.workflowService.start();
|
|
137
|
+
workflow = (await app.db.getRepository('workflows').findOne({ filter: { key: WORKFLOW_KEY } })) as WorkflowModel;
|
|
138
|
+
plugin.workflowService.workflow.triggers.get('collection').off(workflow);
|
|
141
139
|
});
|
|
142
|
-
|
|
143
140
|
afterAll(async () => {
|
|
141
|
+
await plugin?.workflowService.stop();
|
|
144
142
|
await app?.destroy();
|
|
145
143
|
});
|
|
146
|
-
|
|
147
|
-
/** Returns the booted app or skips the calling test with a clear reason. */
|
|
148
|
-
const requireApp = (): MockServer | undefined => {
|
|
149
|
-
if (!app) {
|
|
150
|
-
// eslint-disable-next-line no-console
|
|
151
|
-
console.warn(`[plugin-build-visualization-block] Test skipped — mock server unavailable: ${String(bootError)}`);
|
|
152
|
-
}
|
|
153
|
-
return app;
|
|
154
|
-
};
|
|
144
|
+
const requireApp = () => app;
|
|
155
145
|
|
|
156
146
|
it('creates a queued record and returns immediately (Req 10.1)', async () => {
|
|
157
147
|
const server = requireApp();
|
|
158
|
-
if (!server) return;
|
|
159
148
|
|
|
160
149
|
const { ctx, thrown, getBody } = makeCtx({
|
|
161
150
|
values: {
|
|
@@ -172,12 +161,7 @@ describe('plugin-build-visualization-block build action + pipeline', () => {
|
|
|
172
161
|
userId: 1,
|
|
173
162
|
});
|
|
174
163
|
|
|
175
|
-
//
|
|
176
|
-
// from claiming queued records mid-assertion), which also unsubscribed the
|
|
177
|
-
// in-process event-queue channel. On this single all-jobs (worker) node the
|
|
178
|
-
// `build` action's `enqueueBuild` would otherwise try to publish to that
|
|
179
|
-
// now-unsubscribed channel and throw. Stub `publish` to a no-op so enqueue
|
|
180
|
-
// succeeds without kicking off processing — the record must stay `queued`.
|
|
164
|
+
// Hold dispatch while verifying the immediate action response.
|
|
181
165
|
const eventQueue = server.eventQueue as unknown as {
|
|
182
166
|
publish: (...args: unknown[]) => Promise<void>;
|
|
183
167
|
};
|
|
@@ -261,7 +245,6 @@ describe('plugin-build-visualization-block build action + pipeline', () => {
|
|
|
261
245
|
|
|
262
246
|
it('AI tool invoke creates a queued build record using saved defaults', async () => {
|
|
263
247
|
const server = requireApp();
|
|
264
|
-
if (!server) return;
|
|
265
248
|
|
|
266
249
|
const settingsRepo = server.db.getRepository('aiVisualizationBuildSettings');
|
|
267
250
|
const existingSettings = await settingsRepo.findOne();
|
|
@@ -314,75 +297,50 @@ describe('plugin-build-visualization-block build action + pipeline', () => {
|
|
|
314
297
|
});
|
|
315
298
|
|
|
316
299
|
describe('worker pipeline with a stubbed AI provider (Req 5.5 / 5.6 / 12.1)', () => {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
300
|
+
const driveBuild = async (
|
|
301
|
+
server: MockServer,
|
|
302
|
+
invoke: ChatModelStub['invoke'],
|
|
303
|
+
expectedJobs = 3,
|
|
304
|
+
): Promise<BuildRecordView> => {
|
|
305
|
+
const originalGet = server.pm.get.bind(server.pm);
|
|
306
|
+
const pm = vi.spyOn(server.pm, 'get').mockImplementation((name) => {
|
|
307
|
+
if (name === 'ai')
|
|
308
|
+
return { aiManager: { getLLMService: async () => ({ provider: { chatModel: { invoke } } }) } };
|
|
309
|
+
return originalGet(name);
|
|
310
|
+
});
|
|
311
|
+
const trigger = plugin.workflowService.workflow.triggers.get('collection');
|
|
312
|
+
trigger.on(workflow);
|
|
313
|
+
try {
|
|
314
|
+
const record = await requestBuild(plugin.workflowService, {
|
|
328
315
|
requirement: 'Pipeline run',
|
|
329
316
|
collections: [TEST_COLLECTION],
|
|
330
317
|
primaryCollection: TEST_COLLECTION,
|
|
331
318
|
dataSource: 'main',
|
|
332
319
|
llmService: 'openai',
|
|
333
|
-
model: '
|
|
334
|
-
status: 'building',
|
|
335
|
-
buildPhase: 'queued',
|
|
336
|
-
buildRunId: runId,
|
|
337
|
-
buildQueuedAt: new Date(),
|
|
338
|
-
},
|
|
339
|
-
});
|
|
340
|
-
const buildId = String((created as unknown as { id: number | string }).id);
|
|
341
|
-
|
|
342
|
-
const aiStub: AiPluginStub = {
|
|
343
|
-
aiManager: {
|
|
344
|
-
getLLMService: async () => ({ provider: { chatModel: { invoke } } }),
|
|
345
|
-
},
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
const pm = server.pm as unknown as { get: (name: unknown) => unknown };
|
|
349
|
-
const originalGet = pm.get;
|
|
350
|
-
const previousRole = process.env.APP_ROLE;
|
|
351
|
-
pm.get = (name: unknown) => (name === 'ai' ? aiStub : originalGet.call(server.pm, name));
|
|
352
|
-
process.env.APP_ROLE = 'worker';
|
|
353
|
-
|
|
354
|
-
try {
|
|
355
|
-
await processQueuedBuild(server, {
|
|
356
|
-
buildId,
|
|
357
|
-
runId,
|
|
358
|
-
userId: null,
|
|
359
|
-
queuedAt: new Date().toISOString(),
|
|
320
|
+
model: 'test-model',
|
|
360
321
|
});
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
322
|
+
await vi.waitFor(
|
|
323
|
+
async () => {
|
|
324
|
+
await record.reload();
|
|
325
|
+
expect(record.buildPhase).toBe('completed');
|
|
326
|
+
const run = await server.db.getRepository(RUNS_COLLECTION).findOne({ filterByTk: record.buildRunId });
|
|
327
|
+
const execution = await server.db.getRepository('executions').findOne({ filterByTk: run.executionId });
|
|
328
|
+
expect(execution.status).toBe(1);
|
|
329
|
+
const jobs = await server.db.getRepository('jobs').find({ filter: { executionId: execution.id } });
|
|
330
|
+
expect(jobs).toHaveLength(expectedJobs);
|
|
331
|
+
expect(jobs.every((job) => job.status === 1)).toBe(true);
|
|
332
|
+
},
|
|
333
|
+
{ timeout: 15_000 },
|
|
369
334
|
);
|
|
370
|
-
return
|
|
335
|
+
return record as unknown as BuildRecordView;
|
|
371
336
|
} finally {
|
|
372
|
-
pm.
|
|
373
|
-
|
|
374
|
-
delete process.env.APP_ROLE;
|
|
375
|
-
} else {
|
|
376
|
-
process.env.APP_ROLE = previousRole;
|
|
377
|
-
}
|
|
337
|
+
pm.mockRestore();
|
|
338
|
+
trigger.off(workflow);
|
|
378
339
|
}
|
|
379
|
-
|
|
380
|
-
return (await repo.findOne({ filterByTk: buildId })) as unknown as BuildRecordView;
|
|
381
340
|
};
|
|
382
341
|
|
|
383
342
|
it('valid BlockSpec referencing a real field → completed without fallback (Req 12.1)', async () => {
|
|
384
343
|
const server = requireApp();
|
|
385
|
-
if (!server) return;
|
|
386
344
|
|
|
387
345
|
const validSpec = {
|
|
388
346
|
version: 1,
|
|
@@ -393,7 +351,6 @@ describe('plugin-build-visualization-block build action + pipeline', () => {
|
|
|
393
351
|
table: { fields: ['title'] },
|
|
394
352
|
};
|
|
395
353
|
const record = await driveBuild(server, async () => ({ content: JSON.stringify(validSpec) }));
|
|
396
|
-
if (!record) return;
|
|
397
354
|
|
|
398
355
|
expect(record.status).toBe('completed');
|
|
399
356
|
expect(record.buildPhase).toBe('completed');
|
|
@@ -401,14 +358,63 @@ describe('plugin-build-visualization-block build action + pipeline', () => {
|
|
|
401
358
|
expect(record.blockSchema).toBeTruthy();
|
|
402
359
|
});
|
|
403
360
|
|
|
361
|
+
it('preserves an administrator-added node and carries the analyzed spec across it', async () => {
|
|
362
|
+
const service = plugin.workflowService;
|
|
363
|
+
class Passthrough extends Instruction {
|
|
364
|
+
run() {
|
|
365
|
+
return { status: JOB_STATUS.RESOLVED, result: 'administrative step' };
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
service.workflow.registerInstruction('test-administrative-step', new Passthrough(service.workflow));
|
|
369
|
+
await workflow.update({ enabled: false });
|
|
370
|
+
const nodes = await workflow.getNodes();
|
|
371
|
+
const analyzeNode = nodes.find((node) => node.type === 'visualization-analyze');
|
|
372
|
+
const validateNode = nodes.find((node) => node.type === 'visualization-validate');
|
|
373
|
+
const extra = await workflow.createNode({
|
|
374
|
+
type: 'test-administrative-step',
|
|
375
|
+
key: 'test-administrative-step',
|
|
376
|
+
config: {},
|
|
377
|
+
upstreamId: analyzeNode.id,
|
|
378
|
+
downstreamId: validateNode.id,
|
|
379
|
+
});
|
|
380
|
+
await analyzeNode.update({ downstreamId: extra.id });
|
|
381
|
+
await validateNode.update({ upstreamId: extra.id });
|
|
382
|
+
workflow = (await app.db.getRepository('workflows').findOne({ filterByTk: workflow.id })) as WorkflowModel;
|
|
383
|
+
await workflow.update({ enabled: true });
|
|
384
|
+
service.workflow.triggers.get('collection').off(workflow);
|
|
385
|
+
try {
|
|
386
|
+
const record = await driveBuild(
|
|
387
|
+
app,
|
|
388
|
+
async () => ({
|
|
389
|
+
content: JSON.stringify({
|
|
390
|
+
version: 1,
|
|
391
|
+
blockType: 'table',
|
|
392
|
+
title: 'Posts',
|
|
393
|
+
primaryCollection: TEST_COLLECTION,
|
|
394
|
+
dataSource: 'main',
|
|
395
|
+
table: { fields: ['title'] },
|
|
396
|
+
}),
|
|
397
|
+
}),
|
|
398
|
+
4,
|
|
399
|
+
);
|
|
400
|
+
expect(record.status).toBe('completed');
|
|
401
|
+
} finally {
|
|
402
|
+
await workflow.update({ enabled: false });
|
|
403
|
+
await analyzeNode.update({ downstreamId: validateNode.id });
|
|
404
|
+
await validateNode.update({ upstreamId: analyzeNode.id });
|
|
405
|
+
await extra.destroy();
|
|
406
|
+
workflow = (await app.db.getRepository('workflows').findOne({ filterByTk: workflow.id })) as WorkflowModel;
|
|
407
|
+
await workflow.update({ enabled: true });
|
|
408
|
+
service.workflow.triggers.get('collection').off(workflow);
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
|
|
404
412
|
it('garbage provider output → completed via analyzer fallback (Req 5.5)', async () => {
|
|
405
413
|
const server = requireApp();
|
|
406
|
-
if (!server) return;
|
|
407
414
|
|
|
408
415
|
const record = await driveBuild(server, async () => ({
|
|
409
416
|
content: 'I am not JSON at all, just prose from a confused model.',
|
|
410
417
|
}));
|
|
411
|
-
if (!record) return;
|
|
412
418
|
|
|
413
419
|
expect(record.status).toBe('completed');
|
|
414
420
|
expect(record.buildPhase).toBe('completed');
|
|
@@ -418,12 +424,10 @@ describe('plugin-build-visualization-block build action + pipeline', () => {
|
|
|
418
424
|
|
|
419
425
|
it('provider invocation throws → completed via fallback (Req 5.6)', async () => {
|
|
420
426
|
const server = requireApp();
|
|
421
|
-
if (!server) return;
|
|
422
427
|
|
|
423
428
|
const record = await driveBuild(server, async () => {
|
|
424
429
|
throw new Error('LLM transport failure');
|
|
425
430
|
});
|
|
426
|
-
if (!record) return;
|
|
427
431
|
|
|
428
432
|
// Graceful degradation: a transport failure never leaves the build broken
|
|
429
433
|
// — it completes using the grounded fallback spec. The analyzer records
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { getApp } from '@nocobase/plugin-workflow-test';
|
|
11
|
+
import type { MockServer } from '@nocobase/test';
|
|
2
12
|
import { COLLECTION_NAME, SETTINGS_COLLECTION_NAME } from '../../shared/constants';
|
|
3
13
|
import PluginBuildVisualizationBlockServer from '../plugin';
|
|
4
14
|
|
|
@@ -14,42 +24,22 @@ import PluginBuildVisualizationBlockServer from '../plugin';
|
|
|
14
24
|
* this file on its own with `yarn test <path> --run`.
|
|
15
25
|
*/
|
|
16
26
|
describe('plugin-build-visualization-block schema bootstrap', () => {
|
|
17
|
-
let app: MockServer
|
|
18
|
-
let bootError: unknown;
|
|
19
|
-
|
|
27
|
+
let app: MockServer;
|
|
20
28
|
beforeAll(async () => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// boot in this environment, record the reason and let each test skip with
|
|
28
|
-
// a clear message rather than reporting a false failure.
|
|
29
|
-
bootError = error;
|
|
30
|
-
// eslint-disable-next-line no-console
|
|
31
|
-
console.warn(
|
|
32
|
-
`[plugin-build-visualization-block] Skipping bootstrap tests; mock server could not start: ${String(error)}`,
|
|
33
|
-
);
|
|
34
|
-
}
|
|
29
|
+
app = await getApp({ plugins: [], skipSupervisor: true });
|
|
30
|
+
await app.pm.add(PluginBuildVisualizationBlockServer, { name: 'plugin-build-visualization-block', enabled: true });
|
|
31
|
+
const plugin = app.pm.get(PluginBuildVisualizationBlockServer);
|
|
32
|
+
await plugin.beforeLoad();
|
|
33
|
+
await app.db.sync();
|
|
34
|
+
await plugin.load();
|
|
35
35
|
});
|
|
36
|
-
|
|
37
36
|
afterAll(async () => {
|
|
38
37
|
await app?.destroy();
|
|
39
38
|
});
|
|
40
|
-
|
|
41
|
-
/** Returns the booted app or skips the calling test with a clear reason. */
|
|
42
|
-
const requireApp = (): MockServer | undefined => {
|
|
43
|
-
if (!app) {
|
|
44
|
-
// eslint-disable-next-line no-console
|
|
45
|
-
console.warn(`[plugin-build-visualization-block] Test skipped — mock server unavailable: ${String(bootError)}`);
|
|
46
|
-
}
|
|
47
|
-
return app;
|
|
48
|
-
};
|
|
39
|
+
const requireApp = () => app;
|
|
49
40
|
|
|
50
41
|
it('registers the aiVisualizationBuilds collection', () => {
|
|
51
42
|
const server = requireApp();
|
|
52
|
-
if (!server) return;
|
|
53
43
|
|
|
54
44
|
const collection = server.db.getCollection(COLLECTION_NAME);
|
|
55
45
|
expect(collection).toBeTruthy();
|
|
@@ -57,7 +47,6 @@ describe('plugin-build-visualization-block schema bootstrap', () => {
|
|
|
57
47
|
|
|
58
48
|
it('registers the singleton settings collection', () => {
|
|
59
49
|
const server = requireApp();
|
|
60
|
-
if (!server) return;
|
|
61
50
|
|
|
62
51
|
const collection = server.db.getCollection(SETTINGS_COLLECTION_NAME);
|
|
63
52
|
expect(collection).toBeTruthy();
|
|
@@ -79,7 +68,6 @@ describe('plugin-build-visualization-block schema bootstrap', () => {
|
|
|
79
68
|
|
|
80
69
|
it('defines the key Build_Record fields', () => {
|
|
81
70
|
const server = requireApp();
|
|
82
|
-
if (!server) return;
|
|
83
71
|
|
|
84
72
|
const collection = server.db.getCollection(COLLECTION_NAME);
|
|
85
73
|
expect(collection).toBeTruthy();
|
|
@@ -105,7 +93,6 @@ describe('plugin-build-visualization-block schema bootstrap', () => {
|
|
|
105
93
|
|
|
106
94
|
it('can create and read back a build record', async () => {
|
|
107
95
|
const server = requireApp();
|
|
108
|
-
if (!server) return;
|
|
109
96
|
|
|
110
97
|
const repo = server.db.getRepository(COLLECTION_NAME);
|
|
111
98
|
expect(repo).toBeTruthy();
|
|
@@ -139,7 +126,6 @@ describe('plugin-build-visualization-block schema bootstrap', () => {
|
|
|
139
126
|
|
|
140
127
|
it('applies sensible defaults for status / buildPhase / usedFallback', async () => {
|
|
141
128
|
const server = requireApp();
|
|
142
|
-
if (!server) return;
|
|
143
129
|
|
|
144
130
|
const repo = server.db.getRepository(COLLECTION_NAME);
|
|
145
131
|
const created = await repo.create({
|
|
@@ -156,7 +142,6 @@ describe('plugin-build-visualization-block schema bootstrap', () => {
|
|
|
156
142
|
|
|
157
143
|
it('runs the schema bootstrap idempotently across repeated upgrades', async () => {
|
|
158
144
|
const server = requireApp();
|
|
159
|
-
if (!server) return;
|
|
160
145
|
|
|
161
146
|
const plugin = server.pm.get(PluginBuildVisualizationBlockServer);
|
|
162
147
|
expect(plugin).toBeTruthy();
|