@media-quest/engine 0.0.22 → 0.0.23

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 (51) hide show
  1. package/package.json +1 -1
  2. package/src/Delement/DElement.dto.ts +5 -5
  3. package/src/Delement/DElement.ts +88 -88
  4. package/src/Delement/DImg.ts +39 -39
  5. package/src/Delement/DStyle-utils.ts +616 -616
  6. package/src/Delement/DStyle.ts +165 -165
  7. package/src/Delement/DText.ts +13 -13
  8. package/src/Delement/Ddiv.ts +25 -25
  9. package/src/Delement/button-click-action.ts +35 -35
  10. package/src/Delement/css.spec.ts +36 -36
  11. package/src/Delement/css.ts +46 -46
  12. package/src/Delement/element-factory.ts +40 -40
  13. package/src/common/DMaybe.ts +46 -46
  14. package/src/common/DTimestamp.ts +20 -20
  15. package/src/common/DTmestamp.spec.ts +11 -11
  16. package/src/common/result.ts +41 -41
  17. package/src/engine/SchemaDto.ts +24 -24
  18. package/src/engine/SchemaEngine.ts +150 -150
  19. package/src/engine/SchemaResult.ts +10 -10
  20. package/src/engine/dplayer.spec.ts +91 -91
  21. package/src/engine/dplayer.ts +104 -104
  22. package/src/engine/history-que.spec.ts +67 -67
  23. package/src/engine/history-que.ts +17 -17
  24. package/src/engine/next-que.spec.ts +121 -121
  25. package/src/engine/next-que.ts +101 -101
  26. package/src/engine/page-que-ruleengine-action.ts +6 -6
  27. package/src/engine/scale.spec.ts +38 -38
  28. package/src/engine/scale.ts +70 -70
  29. package/src/events/mq-events.ts +63 -63
  30. package/src/page/Page.ts +182 -182
  31. package/src/page/media-player.ts +117 -117
  32. package/src/page/page-component.ts +113 -113
  33. package/src/page/page-result.ts +11 -11
  34. package/src/page/task-manager.ts +240 -240
  35. package/src/page/task-state.ts +55 -55
  36. package/src/page/task.ts +90 -90
  37. package/src/public-api.ts +26 -26
  38. package/src/rules/__test__/complex-condition.spec.ts +15 -15
  39. package/src/rules/__test__/conditon.spec.ts +124 -124
  40. package/src/rules/__test__/numeric-condition.spec.ts +84 -84
  41. package/src/rules/__test__/rule-engine.spec.ts +348 -348
  42. package/src/rules/__test__/rule-evaluation.spec.ts +140 -140
  43. package/src/rules/__test__/string-condition.spec.ts +41 -41
  44. package/src/rules/condition.ts +191 -191
  45. package/src/rules/fact.ts +18 -18
  46. package/src/rules/rule-engine.ts +45 -45
  47. package/src/rules/rule.ts +40 -40
  48. package/src/utils/DUtil.ts +116 -116
  49. package/src/utils/ID.spec.ts +39 -39
  50. package/src/utils/ID.ts +73 -73
  51. package/tsconfig.json +19 -19
@@ -1,348 +1,348 @@
1
- import { RuleEngine } from "../rule-engine";
2
- import { Rule } from "../rule";
3
- import { Fact } from "../fact";
4
- import { Condition } from "../condition";
5
- import { RuleActionPageQue } from "../../engine/page-que-ruleengine-action";
6
- import { PageID } from "../../utils/ID";
7
-
8
- const excludeById = (ids: PageID[]): RuleActionPageQue => {
9
- return {
10
- kind: "excludeByPageId",
11
- pageIds: ids,
12
- };
13
- };
14
-
15
- const excludeByTag = (id: string): RuleActionPageQue => ({ kind: "excludeByTag", tagIds: [id] });
16
-
17
- let engine = new RuleEngine();
18
- // const x = 'x';
19
- // const y = 'y';
20
-
21
- const xIs = (value: number): Fact.Numeric => ({
22
- referenceId: "x",
23
- referenceLabel: "x-label",
24
- label: "value-label x",
25
- value,
26
- kind: "numeric-fact",
27
- });
28
-
29
- const yIs = (value: number): Fact.Numeric => ({
30
- kind: "numeric-fact",
31
- referenceId: "y",
32
- referenceLabel: "y-label",
33
- label: "var-label y",
34
- // valueLabel: 'value-label y',
35
- value,
36
- });
37
-
38
- const xCondition = (operator: Condition.NumericOperator, value: number): Condition.Numeric => ({
39
- kind: "numeric-condition",
40
- referenceId: "x",
41
- referenceLabel: "",
42
- operator,
43
- value,
44
- valueLabel: "",
45
- });
46
-
47
- const trueIf_0_conditions: Condition.Numeric[] = [
48
- xCondition("eq", 0),
49
- xCondition("not-eq", 2),
50
- xCondition("less-then", 1),
51
- xCondition("less-then-inclusive", 0),
52
- xCondition("greater-then", -1),
53
- xCondition("greater-then-inclusive", 0),
54
- ];
55
-
56
- const falseIf_0_conditions: Condition.Numeric[] = [
57
- xCondition("eq", 10),
58
- xCondition("not-eq", 0),
59
- xCondition("less-then", -5),
60
- xCondition("less-then-inclusive", -1),
61
- xCondition("greater-then", 0),
62
- xCondition("greater-then-inclusive", 1),
63
- ];
64
-
65
- const trueIf_0_simple: Condition.Complex[] = [
66
- {
67
- kind: "complex-condition",
68
- name: "test-name",
69
- all: [...trueIf_0_conditions],
70
- some: [...trueIf_0_conditions, ...falseIf_0_conditions],
71
- },
72
- ];
73
-
74
- const falseIf_0_simple: Condition.Complex[] = [
75
- {
76
- kind: "complex-condition",
77
- name: "test-name",
78
- all: [...trueIf_0_conditions, ...falseIf_0_conditions],
79
- some: [...falseIf_0_conditions],
80
- },
81
- ];
82
-
83
- describe("Rule-engine spec", () => {
84
- beforeEach(() => {
85
- engine = new RuleEngine();
86
- });
87
-
88
- it("Empty rule => one error, no actions", () => {
89
- const rule: Rule<any, any> = {
90
- id: "id123",
91
- description: "",
92
- some: [],
93
- all: [],
94
- onFailure: [],
95
- onSuccess: [],
96
- };
97
- const result = engine.solveAll([rule], []);
98
- expect(result.matching.length).toBe(0);
99
- expect(result.errors.length).toBe(1);
100
- });
101
-
102
- it("Empty facts => no actions, no errors.", () => {
103
- const hideAs1 = excludeById([PageID.create()]);
104
- const rule: Rule<any, any> = {
105
- id: "id123",
106
- description: "",
107
- some: [],
108
- all: [...trueIf_0_conditions],
109
- onFailure: [],
110
- onSuccess: [hideAs1],
111
- };
112
- const facts = [yIs(1)];
113
- const rules = [rule];
114
- // engine.addRule(rule);
115
- // engine.addFact(yIs(1)); // X is now missing.
116
- const result = engine.solveAll(rules, facts);
117
-
118
- expect(result.matching.length).toBe(0);
119
- expect(result.errors.length).toBe(0);
120
- });
121
-
122
- it("and-rule 0=0 true -> 2 Actions in ruleMatch", () => {
123
- const rule: Rule<any, any> = {
124
- id: "id123",
125
- description: "",
126
- some: [],
127
- all: [...trueIf_0_conditions],
128
- onFailure: [],
129
- onSuccess: [excludeById([PageID.create(), PageID.create()])],
130
- };
131
- const f1 = xIs(0);
132
- const rules = [rule];
133
- const result = engine.solveAll(rules, [f1]);
134
- const firstMatch = result.matching[0];
135
- expect(firstMatch.actionList.length).toBe(1);
136
- expect(result.matching.length).toBe(1);
137
- expect(result.errors.length).toBe(0);
138
- });
139
-
140
- it("and-rule 0=1 false", () => {
141
- const facts = [xIs(1)];
142
- const rule: Rule<any, any> = {
143
- id: "id123",
144
-
145
- description: "",
146
- some: [],
147
- all: [xCondition("eq", 0)],
148
- onFailure: [],
149
- onSuccess: [excludeById([PageID.create(), PageID.create()])],
150
- };
151
- expect(engine.solve(rule, facts)).toEqual(false);
152
- const results = engine.solveAll([rule], facts);
153
- expect(results.matching.length).toBe(0);
154
- expect(results.errors.length).toBe(0);
155
- });
156
-
157
- it("One true some-rule gives true", () => {
158
- const facts = [xIs(6)];
159
- const rule: Rule<any, any> = {
160
- id: "id123",
161
- description: "",
162
- some: [xCondition("eq", 6)],
163
- all: [],
164
- onFailure: [],
165
- onSuccess: [excludeById([PageID.create()])],
166
- };
167
- expect(engine.solve(rule, facts)).toBe(true);
168
- const result = engine.solveAll([rule], facts);
169
- expect(result.matching.length).toBe(1);
170
- });
171
-
172
- it("One false some-rule gives false", () => {
173
- const facts = [xIs(6)];
174
- const rule: Rule<any, any> = {
175
- id: "id123",
176
-
177
- description: "",
178
- some: [xCondition("eq", 5)],
179
- all: [],
180
- onFailure: [],
181
- onSuccess: [],
182
- };
183
- expect(engine.solve(rule, facts)).toBe(false);
184
- });
185
-
186
- it("All true all-rules, and one true some-rule -> true", () => {
187
- const facts = [xIs(9)];
188
- const rule: Rule<any, any> = {
189
- id: "id123",
190
-
191
- description: "",
192
- some: [xCondition("eq", 5), xCondition("greater-then", 3)],
193
- all: [xCondition("greater-then", 5), xCondition("eq", 9)],
194
- onFailure: [],
195
- onSuccess: [],
196
- };
197
- expect(engine.solve(rule, facts)).toBe(true);
198
- });
199
-
200
- it("Can solve complex rule [some-2 -> true]", () => {
201
- const facts = [xIs(9)];
202
- const rule: Rule<any, any> = {
203
- id: "id123",
204
-
205
- description: "",
206
- some: [
207
- {
208
- kind: "complex-condition",
209
- name: "test-name",
210
- all: [],
211
- some: [xCondition("eq", 5), xCondition("greater-then", 3)],
212
- },
213
- ],
214
- all: [],
215
- onFailure: [],
216
- onSuccess: [excludeByTag("asdf")],
217
- };
218
- expect(engine.solve(rule, facts)).toBe(true);
219
- const result = engine.solveAll([rule], facts);
220
- expect(result.matching.length).toBe(1);
221
- });
222
- it("Can solve complex rule [some-1 -> false]", () => {
223
- const facts = [xIs(0)];
224
- const rule: Rule<any, any> = {
225
- id: "id123",
226
-
227
- description: "",
228
- some: [
229
- {
230
- kind: "complex-condition",
231
- name: "test-name",
232
- all: [],
233
- some: [xCondition("eq", 5)],
234
- },
235
- ],
236
- all: [],
237
- onFailure: [],
238
- onSuccess: [excludeByTag("xbj")],
239
- };
240
- expect(engine.solve(rule, facts)).toBe(false);
241
- const result = engine.solveAll([rule], facts);
242
- expect(result.matching.length).toBe(0);
243
- expect(result.errors.length).toBe(0);
244
- });
245
-
246
- it("Can solve complex rule [some-1-true -> true]", () => {
247
- const facts = [xIs(0)];
248
- const rule: Rule<any, any> = {
249
- id: "id123",
250
-
251
- description: "",
252
- some: [
253
- {
254
- kind: "complex-condition",
255
- name: "test-name",
256
- all: [],
257
- some: [xCondition("greater-then", -5)],
258
- },
259
- ],
260
- all: [],
261
- onFailure: [],
262
- onSuccess: [],
263
- };
264
- expect(engine.solve(rule, facts)).toBe(true);
265
- });
266
-
267
- it("Empty some (nested) returns false (not valid condition)", () => {
268
- const rule: Rule<any, any> = {
269
- id: "id123",
270
-
271
- description: "",
272
- some: [
273
- {
274
- kind: "complex-condition",
275
- name: "test-name",
276
- all: [],
277
- some: [],
278
- },
279
- ],
280
- all: [],
281
- onFailure: [],
282
- onSuccess: [],
283
- };
284
- expect(engine.solve(rule, [])).toBe(false);
285
- });
286
-
287
- it("Empty complex -> false", () => {
288
- const rule: Rule<any, any> = {
289
- id: "id123",
290
-
291
- description: "",
292
- some: [],
293
- all: [],
294
- onFailure: [],
295
- onSuccess: [],
296
- };
297
- expect(engine.solve(rule, [])).toBe(false);
298
- });
299
-
300
- it("Complex all 6 true conditions -> true", () => {
301
- const facts = [xIs(0)];
302
- const action = excludeById([PageID.create()]);
303
- const rule: Rule<any, any> = {
304
- id: "id123",
305
-
306
- description: "",
307
- some: [...falseIf_0_simple, ...trueIf_0_simple],
308
- all: [...trueIf_0_conditions, ...trueIf_0_simple],
309
- onFailure: [],
310
- onSuccess: [action],
311
- };
312
- // CAN SOLVE
313
- expect(engine.solve(rule, facts)).toBe(true);
314
- // engine.addRule(rule);
315
- // expect(engine.getRules().length).toBe(1);
316
-
317
- // const lastAction = engine.actionState?.lastAction as HidePageAction;
318
- // expect(lastAction?.pageId).toBe('as1');
319
- });
320
-
321
- it("True some, but false all -> true", () => {
322
- const facts = [xIs(0)];
323
- const rule: Rule<any, any> = {
324
- id: "id123",
325
-
326
- description: "",
327
- some: [...falseIf_0_simple, ...trueIf_0_simple],
328
- all: [...trueIf_0_conditions, ...trueIf_0_simple, ...falseIf_0_simple],
329
- onFailure: [],
330
- onSuccess: [],
331
- };
332
- expect(engine.solve(rule, facts)).toBe(false);
333
- });
334
-
335
- it("Empty some && true all -> true", () => {
336
- const facts = [xIs(0)];
337
- const rule: Rule<any, any> = {
338
- id: "id123",
339
-
340
- description: "",
341
- some: [],
342
- all: [...trueIf_0_conditions, ...trueIf_0_simple],
343
- onFailure: [],
344
- onSuccess: [],
345
- };
346
- expect(engine.solve(rule, facts)).toBe(true);
347
- });
348
- });
1
+ import { RuleEngine } from "../rule-engine";
2
+ import { Rule } from "../rule";
3
+ import { Fact } from "../fact";
4
+ import { Condition } from "../condition";
5
+ import { RuleActionPageQue } from "../../engine/page-que-ruleengine-action";
6
+ import { PageID } from "../../utils/ID";
7
+
8
+ const excludeById = (ids: PageID[]): RuleActionPageQue => {
9
+ return {
10
+ kind: "excludeByPageId",
11
+ pageIds: ids,
12
+ };
13
+ };
14
+
15
+ const excludeByTag = (id: string): RuleActionPageQue => ({ kind: "excludeByTag", tagIds: [id] });
16
+
17
+ let engine = new RuleEngine();
18
+ // const x = 'x';
19
+ // const y = 'y';
20
+
21
+ const xIs = (value: number): Fact.Numeric => ({
22
+ referenceId: "x",
23
+ referenceLabel: "x-label",
24
+ label: "value-label x",
25
+ value,
26
+ kind: "numeric-fact",
27
+ });
28
+
29
+ const yIs = (value: number): Fact.Numeric => ({
30
+ kind: "numeric-fact",
31
+ referenceId: "y",
32
+ referenceLabel: "y-label",
33
+ label: "var-label y",
34
+ // valueLabel: 'value-label y',
35
+ value,
36
+ });
37
+
38
+ const xCondition = (operator: Condition.NumericOperator, value: number): Condition.Numeric => ({
39
+ kind: "numeric-condition",
40
+ referenceId: "x",
41
+ referenceLabel: "",
42
+ operator,
43
+ value,
44
+ valueLabel: "",
45
+ });
46
+
47
+ const trueIf_0_conditions: Condition.Numeric[] = [
48
+ xCondition("eq", 0),
49
+ xCondition("not-eq", 2),
50
+ xCondition("less-then", 1),
51
+ xCondition("less-then-inclusive", 0),
52
+ xCondition("greater-then", -1),
53
+ xCondition("greater-then-inclusive", 0),
54
+ ];
55
+
56
+ const falseIf_0_conditions: Condition.Numeric[] = [
57
+ xCondition("eq", 10),
58
+ xCondition("not-eq", 0),
59
+ xCondition("less-then", -5),
60
+ xCondition("less-then-inclusive", -1),
61
+ xCondition("greater-then", 0),
62
+ xCondition("greater-then-inclusive", 1),
63
+ ];
64
+
65
+ const trueIf_0_simple: Condition.Complex[] = [
66
+ {
67
+ kind: "complex-condition",
68
+ name: "test-name",
69
+ all: [...trueIf_0_conditions],
70
+ some: [...trueIf_0_conditions, ...falseIf_0_conditions],
71
+ },
72
+ ];
73
+
74
+ const falseIf_0_simple: Condition.Complex[] = [
75
+ {
76
+ kind: "complex-condition",
77
+ name: "test-name",
78
+ all: [...trueIf_0_conditions, ...falseIf_0_conditions],
79
+ some: [...falseIf_0_conditions],
80
+ },
81
+ ];
82
+
83
+ describe("Rule-engine spec", () => {
84
+ beforeEach(() => {
85
+ engine = new RuleEngine();
86
+ });
87
+
88
+ it("Empty rule => one error, no actions", () => {
89
+ const rule: Rule<any, any> = {
90
+ id: "id123",
91
+ description: "",
92
+ some: [],
93
+ all: [],
94
+ onFailure: [],
95
+ onSuccess: [],
96
+ };
97
+ const result = engine.solveAll([rule], []);
98
+ expect(result.matching.length).toBe(0);
99
+ expect(result.errors.length).toBe(1);
100
+ });
101
+
102
+ it("Empty facts => no actions, no errors.", () => {
103
+ const hideAs1 = excludeById([PageID.create()]);
104
+ const rule: Rule<any, any> = {
105
+ id: "id123",
106
+ description: "",
107
+ some: [],
108
+ all: [...trueIf_0_conditions],
109
+ onFailure: [],
110
+ onSuccess: [hideAs1],
111
+ };
112
+ const facts = [yIs(1)];
113
+ const rules = [rule];
114
+ // engine.addRule(rule);
115
+ // engine.addFact(yIs(1)); // X is now missing.
116
+ const result = engine.solveAll(rules, facts);
117
+
118
+ expect(result.matching.length).toBe(0);
119
+ expect(result.errors.length).toBe(0);
120
+ });
121
+
122
+ it("and-rule 0=0 true -> 2 Actions in ruleMatch", () => {
123
+ const rule: Rule<any, any> = {
124
+ id: "id123",
125
+ description: "",
126
+ some: [],
127
+ all: [...trueIf_0_conditions],
128
+ onFailure: [],
129
+ onSuccess: [excludeById([PageID.create(), PageID.create()])],
130
+ };
131
+ const f1 = xIs(0);
132
+ const rules = [rule];
133
+ const result = engine.solveAll(rules, [f1]);
134
+ const firstMatch = result.matching[0];
135
+ expect(firstMatch.actionList.length).toBe(1);
136
+ expect(result.matching.length).toBe(1);
137
+ expect(result.errors.length).toBe(0);
138
+ });
139
+
140
+ it("and-rule 0=1 false", () => {
141
+ const facts = [xIs(1)];
142
+ const rule: Rule<any, any> = {
143
+ id: "id123",
144
+
145
+ description: "",
146
+ some: [],
147
+ all: [xCondition("eq", 0)],
148
+ onFailure: [],
149
+ onSuccess: [excludeById([PageID.create(), PageID.create()])],
150
+ };
151
+ expect(engine.solve(rule, facts)).toEqual(false);
152
+ const results = engine.solveAll([rule], facts);
153
+ expect(results.matching.length).toBe(0);
154
+ expect(results.errors.length).toBe(0);
155
+ });
156
+
157
+ it("One true some-rule gives true", () => {
158
+ const facts = [xIs(6)];
159
+ const rule: Rule<any, any> = {
160
+ id: "id123",
161
+ description: "",
162
+ some: [xCondition("eq", 6)],
163
+ all: [],
164
+ onFailure: [],
165
+ onSuccess: [excludeById([PageID.create()])],
166
+ };
167
+ expect(engine.solve(rule, facts)).toBe(true);
168
+ const result = engine.solveAll([rule], facts);
169
+ expect(result.matching.length).toBe(1);
170
+ });
171
+
172
+ it("One false some-rule gives false", () => {
173
+ const facts = [xIs(6)];
174
+ const rule: Rule<any, any> = {
175
+ id: "id123",
176
+
177
+ description: "",
178
+ some: [xCondition("eq", 5)],
179
+ all: [],
180
+ onFailure: [],
181
+ onSuccess: [],
182
+ };
183
+ expect(engine.solve(rule, facts)).toBe(false);
184
+ });
185
+
186
+ it("All true all-rules, and one true some-rule -> true", () => {
187
+ const facts = [xIs(9)];
188
+ const rule: Rule<any, any> = {
189
+ id: "id123",
190
+
191
+ description: "",
192
+ some: [xCondition("eq", 5), xCondition("greater-then", 3)],
193
+ all: [xCondition("greater-then", 5), xCondition("eq", 9)],
194
+ onFailure: [],
195
+ onSuccess: [],
196
+ };
197
+ expect(engine.solve(rule, facts)).toBe(true);
198
+ });
199
+
200
+ it("Can solve complex rule [some-2 -> true]", () => {
201
+ const facts = [xIs(9)];
202
+ const rule: Rule<any, any> = {
203
+ id: "id123",
204
+
205
+ description: "",
206
+ some: [
207
+ {
208
+ kind: "complex-condition",
209
+ name: "test-name",
210
+ all: [],
211
+ some: [xCondition("eq", 5), xCondition("greater-then", 3)],
212
+ },
213
+ ],
214
+ all: [],
215
+ onFailure: [],
216
+ onSuccess: [excludeByTag("asdf")],
217
+ };
218
+ expect(engine.solve(rule, facts)).toBe(true);
219
+ const result = engine.solveAll([rule], facts);
220
+ expect(result.matching.length).toBe(1);
221
+ });
222
+ it("Can solve complex rule [some-1 -> false]", () => {
223
+ const facts = [xIs(0)];
224
+ const rule: Rule<any, any> = {
225
+ id: "id123",
226
+
227
+ description: "",
228
+ some: [
229
+ {
230
+ kind: "complex-condition",
231
+ name: "test-name",
232
+ all: [],
233
+ some: [xCondition("eq", 5)],
234
+ },
235
+ ],
236
+ all: [],
237
+ onFailure: [],
238
+ onSuccess: [excludeByTag("xbj")],
239
+ };
240
+ expect(engine.solve(rule, facts)).toBe(false);
241
+ const result = engine.solveAll([rule], facts);
242
+ expect(result.matching.length).toBe(0);
243
+ expect(result.errors.length).toBe(0);
244
+ });
245
+
246
+ it("Can solve complex rule [some-1-true -> true]", () => {
247
+ const facts = [xIs(0)];
248
+ const rule: Rule<any, any> = {
249
+ id: "id123",
250
+
251
+ description: "",
252
+ some: [
253
+ {
254
+ kind: "complex-condition",
255
+ name: "test-name",
256
+ all: [],
257
+ some: [xCondition("greater-then", -5)],
258
+ },
259
+ ],
260
+ all: [],
261
+ onFailure: [],
262
+ onSuccess: [],
263
+ };
264
+ expect(engine.solve(rule, facts)).toBe(true);
265
+ });
266
+
267
+ it("Empty some (nested) returns false (not valid condition)", () => {
268
+ const rule: Rule<any, any> = {
269
+ id: "id123",
270
+
271
+ description: "",
272
+ some: [
273
+ {
274
+ kind: "complex-condition",
275
+ name: "test-name",
276
+ all: [],
277
+ some: [],
278
+ },
279
+ ],
280
+ all: [],
281
+ onFailure: [],
282
+ onSuccess: [],
283
+ };
284
+ expect(engine.solve(rule, [])).toBe(false);
285
+ });
286
+
287
+ it("Empty complex -> false", () => {
288
+ const rule: Rule<any, any> = {
289
+ id: "id123",
290
+
291
+ description: "",
292
+ some: [],
293
+ all: [],
294
+ onFailure: [],
295
+ onSuccess: [],
296
+ };
297
+ expect(engine.solve(rule, [])).toBe(false);
298
+ });
299
+
300
+ it("Complex all 6 true conditions -> true", () => {
301
+ const facts = [xIs(0)];
302
+ const action = excludeById([PageID.create()]);
303
+ const rule: Rule<any, any> = {
304
+ id: "id123",
305
+
306
+ description: "",
307
+ some: [...falseIf_0_simple, ...trueIf_0_simple],
308
+ all: [...trueIf_0_conditions, ...trueIf_0_simple],
309
+ onFailure: [],
310
+ onSuccess: [action],
311
+ };
312
+ // CAN SOLVE
313
+ expect(engine.solve(rule, facts)).toBe(true);
314
+ // engine.addRule(rule);
315
+ // expect(engine.getRules().length).toBe(1);
316
+
317
+ // const lastAction = engine.actionState?.lastAction as HidePageAction;
318
+ // expect(lastAction?.pageId).toBe('as1');
319
+ });
320
+
321
+ it("True some, but false all -> true", () => {
322
+ const facts = [xIs(0)];
323
+ const rule: Rule<any, any> = {
324
+ id: "id123",
325
+
326
+ description: "",
327
+ some: [...falseIf_0_simple, ...trueIf_0_simple],
328
+ all: [...trueIf_0_conditions, ...trueIf_0_simple, ...falseIf_0_simple],
329
+ onFailure: [],
330
+ onSuccess: [],
331
+ };
332
+ expect(engine.solve(rule, facts)).toBe(false);
333
+ });
334
+
335
+ it("Empty some && true all -> true", () => {
336
+ const facts = [xIs(0)];
337
+ const rule: Rule<any, any> = {
338
+ id: "id123",
339
+
340
+ description: "",
341
+ some: [],
342
+ all: [...trueIf_0_conditions, ...trueIf_0_simple],
343
+ onFailure: [],
344
+ onSuccess: [],
345
+ };
346
+ expect(engine.solve(rule, facts)).toBe(true);
347
+ });
348
+ });