@nocobase/flow-engine 2.1.0-alpha.21 → 2.1.0-alpha.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/flow-engine",
3
- "version": "2.1.0-alpha.21",
3
+ "version": "2.1.0-alpha.22",
4
4
  "private": false,
5
5
  "description": "A standalone flow engine for NocoBase, managing workflows, models, and actions.",
6
6
  "main": "lib/index.js",
@@ -8,8 +8,8 @@
8
8
  "dependencies": {
9
9
  "@formily/antd-v5": "1.x",
10
10
  "@formily/reactive": "2.x",
11
- "@nocobase/sdk": "2.1.0-alpha.21",
12
- "@nocobase/shared": "2.1.0-alpha.21",
11
+ "@nocobase/sdk": "2.1.0-alpha.22",
12
+ "@nocobase/shared": "2.1.0-alpha.22",
13
13
  "ahooks": "^3.7.2",
14
14
  "axios": "^1.7.0",
15
15
  "dayjs": "^1.11.9",
@@ -37,5 +37,5 @@
37
37
  ],
38
38
  "author": "NocoBase Team",
39
39
  "license": "Apache-2.0",
40
- "gitHead": "b4c2b469f321ecaec7863a8ae371a02fe6a35aa2"
40
+ "gitHead": "81ed83f158f172cca607b36beaf8428b14ba16ad"
41
41
  }
@@ -90,11 +90,21 @@ describe('FlowModelRenderer', () => {
90
90
 
91
91
  test('should clear stale beforeRender state after unmount when reusing the same model', async () => {
92
92
  const statefulEngine = new FlowEngine();
93
+ const onMountSpy = vi.fn();
94
+ const onUnmountSpy = vi.fn();
93
95
 
94
96
  class StatefulModel extends FlowModel {
95
97
  render(): any {
96
98
  return <div>Stateful Content</div>;
97
99
  }
100
+
101
+ protected onMount(): void {
102
+ onMountSpy();
103
+ }
104
+
105
+ protected onUnmount(): void {
106
+ onUnmountSpy();
107
+ }
98
108
  }
99
109
 
100
110
  const statefulModel = new StatefulModel({
@@ -107,8 +117,14 @@ describe('FlowModelRenderer', () => {
107
117
  await waitFor(() => {
108
118
  expect(executorSpy).toHaveBeenCalledTimes(1);
109
119
  });
120
+ await waitFor(() => {
121
+ expect(onMountSpy).toHaveBeenCalledTimes(1);
122
+ });
110
123
 
111
124
  firstRender.unmount();
125
+ await waitFor(() => {
126
+ expect(onUnmountSpy).toHaveBeenCalledTimes(1);
127
+ });
112
128
 
113
129
  executorSpy.mockClear();
114
130
  statefulModel.setStepParams('anyFlow', 'anyStep', { x: 1 });
@@ -119,6 +135,9 @@ describe('FlowModelRenderer', () => {
119
135
  await waitFor(() => {
120
136
  expect(executorSpy).toHaveBeenCalledTimes(1);
121
137
  });
138
+ await waitFor(() => {
139
+ expect(onMountSpy).toHaveBeenCalledTimes(2);
140
+ });
122
141
  const [target, eventName, inputArgs, options] = executorSpy.mock.calls[0];
123
142
  expect(target).toBe(statefulModel);
124
143
  expect(eventName).toBe('beforeRender');
@@ -126,5 +145,8 @@ describe('FlowModelRenderer', () => {
126
145
  expect(options).toMatchObject({ useCache: true });
127
146
 
128
147
  secondRender.unmount();
148
+ await waitFor(() => {
149
+ expect(onUnmountSpy).toHaveBeenCalledTimes(2);
150
+ });
129
151
  });
130
152
  });