@nocobase/plugin-workflow-test 0.19.0-alpha.3 → 0.19.0-alpha.5

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.
@@ -221,6 +221,7 @@ export declare class ConditionYesNode {
221
221
  basicRadio: Locator;
222
222
  mathRadio: Locator;
223
223
  formulaRadio: Locator;
224
+ conditionExpressionEditBox: Locator;
224
225
  submitButton: Locator;
225
226
  cancelButton: Locator;
226
227
  addNodeButton: Locator;
@@ -234,6 +235,7 @@ export declare class ConditionBranchNode {
234
235
  basicRadio: Locator;
235
236
  mathRadio: Locator;
236
237
  formulaRadio: Locator;
238
+ conditionExpressionEditBox: Locator;
237
239
  submitButton: Locator;
238
240
  cancelButton: Locator;
239
241
  addNoBranchNode: Locator;
@@ -431,11 +431,11 @@ class ManualNode {
431
431
  this.assigneesDropDown = page.getByTestId("select-single");
432
432
  this.configureUserInterfaceButton = page.getByRole("button", { name: "Configure user interface" });
433
433
  this.addBlockButton = page.getByLabel("schema-initializer-Grid-AddBlockButton-workflows");
434
- this.triggerDataMenu = page.getByLabel("Data blocks-triggerData");
435
- this.nodeDataMenu = page.getByLabel("nodes", { exact: true });
434
+ this.triggerDataMenu = page.getByRole("menuitem", { name: "Trigger data" });
435
+ this.nodeDataMenu = page.getByRole("menuitem", { name: "Node result right" });
436
436
  this.customFormMenu = page.getByRole("menuitem", { name: "Custom form" });
437
- this.createRecordFormMenu = page.getByRole("menuitem", { name: "Create record form" });
438
- this.updateRecordFormMenu = page.getByRole("menuitem", { name: "Update record form" });
437
+ this.createRecordFormMenu = page.getByRole("menuitem", { name: "Create record form right" });
438
+ this.updateRecordFormMenu = page.getByRole("menuitem", { name: "Update record form right" });
439
439
  this.submitButton = page.getByLabel("action-Action-Submit-workflows");
440
440
  this.cancelButton = page.getByLabel("action-Action-Cancel-workflows");
441
441
  this.addNodeButton = page.getByLabel(`add-button-manual-${nodeName}`, { exact: true });
@@ -449,6 +449,7 @@ class ConditionYesNode {
449
449
  basicRadio;
450
450
  mathRadio;
451
451
  formulaRadio;
452
+ conditionExpressionEditBox;
452
453
  submitButton;
453
454
  cancelButton;
454
455
  addNodeButton;
@@ -457,6 +458,7 @@ class ConditionYesNode {
457
458
  this.node = page.getByLabel(`Condition-${nodeName}`, { exact: true });
458
459
  this.nodeTitle = page.getByLabel(`Condition-${nodeName}`, { exact: true }).getByRole("textbox");
459
460
  this.nodeConfigure = page.getByLabel(`Condition-${nodeName}`, { exact: true }).getByRole("button", { name: "Configure" });
461
+ this.conditionExpressionEditBox = page.getByLabel("textbox");
460
462
  this.basicRadio = page.getByLabel("Basic");
461
463
  this.mathRadio = page.getByLabel("Math.js");
462
464
  this.formulaRadio = page.getByLabel("Formula.js");
@@ -473,6 +475,7 @@ class ConditionBranchNode {
473
475
  basicRadio;
474
476
  mathRadio;
475
477
  formulaRadio;
478
+ conditionExpressionEditBox;
476
479
  submitButton;
477
480
  cancelButton;
478
481
  addNoBranchNode;
@@ -483,6 +486,7 @@ class ConditionBranchNode {
483
486
  this.node = page.getByLabel(`Condition-${nodeName}`, { exact: true });
484
487
  this.nodeTitle = page.getByLabel(`Condition-${nodeName}`, { exact: true }).getByRole("textbox");
485
488
  this.nodeConfigure = page.getByLabel(`Condition-${nodeName}`, { exact: true }).getByRole("button", { name: "Configure" });
489
+ this.conditionExpressionEditBox = page.getByLabel("textbox");
486
490
  this.submitButton = page.getByLabel("action-Action-Submit-workflows");
487
491
  this.cancelButton = page.getByLabel("action-Action-Cancel-workflows");
488
492
  this.addNodeButton = page.getByLabel(`add-button-condition-${nodeName}`, { exact: true });
@@ -10,6 +10,7 @@ export declare const apiGetWorkflowNodeExecutions: (id: number) => Promise<any>;
10
10
  export declare const apiUpdateRecord: (collectionName: string, id: number, data: any) => Promise<any>;
11
11
  export declare const apiGetRecord: (collectionName: string, id: number) => Promise<any>;
12
12
  export declare const apiGetList: (collectionName: string) => Promise<any>;
13
+ export declare const apiFilterList: (collectionName: string, filter: string) => Promise<any>;
13
14
  export declare const apiCreateRecordTriggerFormEvent: (collectionName: string, triggerWorkflows: string, data: any) => Promise<any>;
14
15
  export declare const apiSubmitRecordTriggerFormEvent: (triggerWorkflows: string, data: any) => Promise<any>;
15
16
  declare const _default: {
@@ -27,5 +28,6 @@ declare const _default: {
27
28
  apiGetList: (collectionName: string) => Promise<any>;
28
29
  apiCreateRecordTriggerFormEvent: (collectionName: string, triggerWorkflows: string, data: any) => Promise<any>;
29
30
  apiSubmitRecordTriggerFormEvent: (triggerWorkflows: string, data: any) => Promise<any>;
31
+ apiFilterList: (collectionName: string, filter: string) => Promise<any>;
30
32
  };
31
33
  export default _default;
@@ -21,6 +21,7 @@ __export(e2eUtils_exports, {
21
21
  apiCreateWorkflow: () => apiCreateWorkflow,
22
22
  apiCreateWorkflowNode: () => apiCreateWorkflowNode,
23
23
  apiDeleteWorkflow: () => apiDeleteWorkflow,
24
+ apiFilterList: () => apiFilterList,
24
25
  apiGetList: () => apiGetList,
25
26
  apiGetRecord: () => apiGetRecord,
26
27
  apiGetWorkflow: () => apiGetWorkflow,
@@ -212,6 +213,20 @@ const apiGetList = async (collectionName) => {
212
213
  }
213
214
  return await result.json();
214
215
  };
216
+ const apiFilterList = async (collectionName, filter) => {
217
+ const api = await import_e2e.request.newContext({
218
+ storageState: process.env.PLAYWRIGHT_AUTH_FILE
219
+ });
220
+ const state = await api.storageState();
221
+ const headers = getHeaders(state);
222
+ const result = await api.get(`/api/${collectionName}:list?${filter}`, {
223
+ headers
224
+ });
225
+ if (!result.ok()) {
226
+ throw new Error(await result.text());
227
+ }
228
+ return await result.json();
229
+ };
215
230
  const apiCreateRecordTriggerFormEvent = async (collectionName, triggerWorkflows, data) => {
216
231
  const api = await import_e2e.request.newContext({
217
232
  storageState: process.env.PLAYWRIGHT_AUTH_FILE
@@ -297,7 +312,8 @@ var e2eUtils_default = module.exports = {
297
312
  apiGetRecord,
298
313
  apiGetList,
299
314
  apiCreateRecordTriggerFormEvent,
300
- apiSubmitRecordTriggerFormEvent
315
+ apiSubmitRecordTriggerFormEvent,
316
+ apiFilterList
301
317
  };
302
318
  // Annotate the CommonJS export names for ESM import in node:
303
319
  0 && (module.exports = {
@@ -305,6 +321,7 @@ var e2eUtils_default = module.exports = {
305
321
  apiCreateWorkflow,
306
322
  apiCreateWorkflowNode,
307
323
  apiDeleteWorkflow,
324
+ apiFilterList,
308
325
  apiGetList,
309
326
  apiGetRecord,
310
327
  apiGetWorkflow,
@@ -1,8 +1,8 @@
1
1
  module.exports = {
2
- "@nocobase/client": "0.19.0-alpha.3",
3
- "@nocobase/utils": "0.19.0-alpha.3",
2
+ "@nocobase/client": "0.19.0-alpha.5",
3
+ "@nocobase/utils": "0.19.0-alpha.5",
4
4
  "lodash": "4.17.21",
5
- "@nocobase/test": "0.19.0-alpha.3",
6
- "@nocobase/server": "0.19.0-alpha.3",
7
- "@nocobase/database": "0.19.0-alpha.3"
5
+ "@nocobase/test": "0.19.0-alpha.5",
6
+ "@nocobase/server": "0.19.0-alpha.5",
7
+ "@nocobase/database": "0.19.0-alpha.5"
8
8
  };
@@ -36,6 +36,7 @@ var import_path = __toESM(require("path"));
36
36
  var import_server = require("@nocobase/server");
37
37
  var import_test = require("@nocobase/test");
38
38
  var import_functions = __toESM(require("./functions"));
39
+ var import_triggers = __toESM(require("./triggers"));
39
40
  var import_instructions = __toESM(require("./instructions"));
40
41
  function sleep(ms) {
41
42
  return new Promise((resolve) => {
@@ -57,6 +58,7 @@ async function getApp(options = {}) {
57
58
  [
58
59
  "workflow",
59
60
  {
61
+ triggers: import_triggers.default,
60
62
  instructions: import_instructions.default,
61
63
  functions: import_functions.default
62
64
  }
@@ -8,7 +8,7 @@ declare const _default: {
8
8
  };
9
9
  };
10
10
  error: {
11
- run(node: any, input: any, processor: any): any;
11
+ run(node: any, input: any, processor: any): never;
12
12
  };
13
13
  pending: {
14
14
  run(node: any, input: any, processor: any): {
@@ -33,7 +33,6 @@ var instructions_default = {
33
33
  error: {
34
34
  run(node, input, processor) {
35
35
  throw new Error("definite error");
36
- return null;
37
36
  }
38
37
  },
39
38
  pending: {
@@ -0,0 +1,20 @@
1
+ declare const _default: {
2
+ syncTrigger: {
3
+ new (workflow: any): {
4
+ readonly workflow: any;
5
+ on(): void;
6
+ off(): void;
7
+ sync: boolean;
8
+ validateEvent(): boolean;
9
+ };
10
+ };
11
+ asyncTrigger: {
12
+ new (workflow: any): {
13
+ readonly workflow: any;
14
+ on(): void;
15
+ off(): void;
16
+ validateEvent(): boolean;
17
+ };
18
+ };
19
+ };
20
+ export default _default;
@@ -0,0 +1,49 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var triggers_exports = {};
19
+ __export(triggers_exports, {
20
+ default: () => triggers_default
21
+ });
22
+ module.exports = __toCommonJS(triggers_exports);
23
+ var triggers_default = {
24
+ syncTrigger: class {
25
+ constructor(workflow) {
26
+ this.workflow = workflow;
27
+ }
28
+ on() {
29
+ }
30
+ off() {
31
+ }
32
+ sync = true;
33
+ validateEvent() {
34
+ return true;
35
+ }
36
+ },
37
+ asyncTrigger: class {
38
+ constructor(workflow) {
39
+ this.workflow = workflow;
40
+ }
41
+ on() {
42
+ }
43
+ off() {
44
+ }
45
+ validateEvent() {
46
+ return true;
47
+ }
48
+ }
49
+ };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@nocobase/plugin-workflow-test",
3
3
  "displayName": "Workflow: test kit",
4
4
  "displayName.zh-CN": "工作流:测试工具包",
5
- "version": "0.19.0-alpha.3",
5
+ "version": "0.19.0-alpha.5",
6
6
  "license": "AGPL-3.0",
7
7
  "main": "dist/server/index.js",
8
8
  "types": "./dist/server/index.d.ts",
@@ -11,5 +11,5 @@
11
11
  "@nocobase/server": "0.x",
12
12
  "@nocobase/test": "0.x"
13
13
  },
14
- "gitHead": "3cee597df101a3f8f0f1e2a6f75fc2dddd02ac74"
14
+ "gitHead": "580eca25451ec731d17ddef285d0b8c52c48d501"
15
15
  }
@@ -435,11 +435,11 @@ export class ManualNode {
435
435
  this.assigneesDropDown = page.getByTestId('select-single');
436
436
  this.configureUserInterfaceButton = page.getByRole('button', { name: 'Configure user interface' });
437
437
  this.addBlockButton = page.getByLabel('schema-initializer-Grid-AddBlockButton-workflows');
438
- this.triggerDataMenu = page.getByLabel('Data blocks-triggerData');
439
- this.nodeDataMenu = page.getByLabel('nodes', { exact: true });
438
+ this.triggerDataMenu = page.getByRole('menuitem', { name: 'Trigger data' });
439
+ this.nodeDataMenu = page.getByRole('menuitem', { name: 'Node result right' });
440
440
  this.customFormMenu = page.getByRole('menuitem', { name: 'Custom form' });
441
- this.createRecordFormMenu = page.getByRole('menuitem', { name: 'Create record form' });
442
- this.updateRecordFormMenu = page.getByRole('menuitem', { name: 'Update record form' });
441
+ this.createRecordFormMenu = page.getByRole('menuitem', { name: 'Create record form right' });
442
+ this.updateRecordFormMenu = page.getByRole('menuitem', { name: 'Update record form right' });
443
443
  this.submitButton = page.getByLabel('action-Action-Submit-workflows');
444
444
  this.cancelButton = page.getByLabel('action-Action-Cancel-workflows');
445
445
  this.addNodeButton = page.getByLabel(`add-button-manual-${nodeName}`, { exact: true });
@@ -454,6 +454,7 @@ export class ConditionYesNode {
454
454
  basicRadio: Locator;
455
455
  mathRadio: Locator;
456
456
  formulaRadio: Locator;
457
+ conditionExpressionEditBox: Locator;
457
458
  submitButton: Locator;
458
459
  cancelButton: Locator;
459
460
  addNodeButton: Locator;
@@ -464,6 +465,7 @@ export class ConditionYesNode {
464
465
  this.nodeConfigure = page
465
466
  .getByLabel(`Condition-${nodeName}`, { exact: true })
466
467
  .getByRole('button', { name: 'Configure' });
468
+ this.conditionExpressionEditBox = page.getByLabel('textbox');
467
469
  // await page.getByLabel('variable-constant').first().click();
468
470
  // await page.getByLabel('variable-button').first().click();
469
471
  // await page.getByLabel('select-operator-calc').first().click();
@@ -487,6 +489,7 @@ export class ConditionBranchNode {
487
489
  basicRadio: Locator;
488
490
  mathRadio: Locator;
489
491
  formulaRadio: Locator;
492
+ conditionExpressionEditBox: Locator;
490
493
  submitButton: Locator;
491
494
  cancelButton: Locator;
492
495
  addNoBranchNode: Locator;
@@ -499,6 +502,7 @@ export class ConditionBranchNode {
499
502
  this.nodeConfigure = page
500
503
  .getByLabel(`Condition-${nodeName}`, { exact: true })
501
504
  .getByRole('button', { name: 'Configure' });
505
+ this.conditionExpressionEditBox = page.getByLabel('textbox');
502
506
  this.submitButton = page.getByLabel('action-Action-Submit-workflows');
503
507
  this.cancelButton = page.getByLabel('action-Action-Cancel-workflows');
504
508
  this.addNodeButton = page.getByLabel(`add-button-condition-${nodeName}`, { exact: true });
@@ -605,6 +605,44 @@ export const apiGetList = async (collectionName: string) => {
605
605
  return await result.json();
606
606
  };
607
607
 
608
+ // 查询业务表list
609
+ export const apiFilterList = async (collectionName: string, filter: string) => {
610
+ const api = await request.newContext({
611
+ storageState: process.env.PLAYWRIGHT_AUTH_FILE,
612
+ });
613
+ const state = await api.storageState();
614
+ const headers = getHeaders(state);
615
+ const result = await api.get(`/api/${collectionName}:list?${filter}`, {
616
+ headers,
617
+ });
618
+
619
+ if (!result.ok()) {
620
+ throw new Error(await result.text());
621
+ }
622
+ /*
623
+ {
624
+ "data": [
625
+ {
626
+ "id": 1,
627
+ "createdAt": "2023-12-12T02:43:53.793Z",
628
+ "updatedAt": "2023-12-12T05:41:33.300Z",
629
+ "key": "fzk3j2oj4el",
630
+ "title": "a11",
631
+ "enabled": true,
632
+ "description": null
633
+ }
634
+ ],
635
+ "meta": {
636
+ "count": 1,
637
+ "page": 1,
638
+ "pageSize": 20,
639
+ "totalPage": 1
640
+ }
641
+ }
642
+ */
643
+ return await result.json();
644
+ };
645
+
608
646
  // 添加业务表单条数据触发工作流表单事件,triggerWorkflows=key1!field,key2,key3!field.subfield
609
647
  export const apiCreateRecordTriggerFormEvent = async (collectionName: string, triggerWorkflows: string, data: any) => {
610
648
  const api = await request.newContext({
@@ -744,4 +782,5 @@ export default module.exports = {
744
782
  apiGetList,
745
783
  apiCreateRecordTriggerFormEvent,
746
784
  apiSubmitRecordTriggerFormEvent,
785
+ apiFilterList,
747
786
  };
@@ -4,6 +4,7 @@ import { ApplicationOptions, Plugin } from '@nocobase/server';
4
4
  import { MockServer, createMockServer } from '@nocobase/test';
5
5
 
6
6
  import functions from './functions';
7
+ import triggers from './triggers';
7
8
  import instructions from './instructions';
8
9
 
9
10
  export interface MockServerOptions extends ApplicationOptions {
@@ -38,6 +39,7 @@ export async function getApp(options: MockServerOptions = {}): Promise<MockServe
38
39
  [
39
40
  'workflow',
40
41
  {
42
+ triggers,
41
43
  instructions,
42
44
  functions,
43
45
  },
@@ -13,7 +13,6 @@ export default {
13
13
  error: {
14
14
  run(node, input, processor) {
15
15
  throw new Error('definite error');
16
- return null;
17
16
  },
18
17
  },
19
18
 
@@ -0,0 +1,19 @@
1
+ export default {
2
+ syncTrigger: class {
3
+ constructor(public readonly workflow) {}
4
+ on() {}
5
+ off() {}
6
+ sync = true;
7
+ validateEvent() {
8
+ return true;
9
+ }
10
+ },
11
+ asyncTrigger: class {
12
+ constructor(public readonly workflow) {}
13
+ on() {}
14
+ off() {}
15
+ validateEvent() {
16
+ return true;
17
+ }
18
+ },
19
+ };