@media-quest/builder 0.0.7 → 0.0.9

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.
@@ -4,6 +4,8 @@ import { BuilderPage } from "./Builder-page";
4
4
  import type { BuilderTagDto } from "./BuilderTag";
5
5
  import { BuilderTag } from "./BuilderTag";
6
6
  import type { BuilderObjectId } from "./BuilderObject";
7
+ import { PageID, SchemaID } from "@media-quest/engine";
8
+ import { PagePrefix, SchemaPrefix } from "./prefix";
7
9
 
8
10
  const tag1: BuilderTagDto = BuilderTag.create("tag1", "This tag is defined in schemaDto1").toJson();
9
11
 
@@ -11,292 +13,292 @@ const tag2: BuilderTagDto = BuilderTag.create("tag2", "This tag is defined in sc
11
13
  const tag3: BuilderTagDto = BuilderTag.create("tag3", "This tag is defined in schemaDto1").toJson();
12
14
 
13
15
  const schemaDto1: BuilderSchemaDto = {
14
- backgroundColor: "gray",
15
- baseHeight: 1200,
16
- baseWidth: 1022,
17
- mainImage: false,
18
- id: "dto1",
19
- name: "dto1-name",
20
- tags: [tag1, tag2, tag3],
21
- pages: [
22
- {
23
- id: "page1" as BuilderObjectId.PageID,
24
- _type: "info-page",
25
- prefix: "p1",
26
- mainText: {
27
- text: "hello from test",
28
- autoplay: false,
29
- autoplayDelay: 0,
30
- audioFile: false,
31
- },
16
+ backgroundColor: "gray",
17
+ baseHeight: 1200,
18
+ baseWidth: 1022,
19
+ mainImage: false,
20
+ id: SchemaID.create(),
21
+ name: "dto1-name",
22
+ tags: [tag1, tag2, tag3],
23
+ pages: [
24
+ {
25
+ id: PageID.ensure("a".repeat(24)),
26
+ _type: "info-page",
27
+ prefix: PagePrefix.fromStringOrThrow("p1"),
28
+ mainText: {
29
+ text: "hello from test",
30
+ autoplay: false,
31
+ autoplayDelay: 0,
32
+ audioFile: false,
33
+ },
32
34
 
33
- nextButton: {
34
- id: "next-button-text-id" as BuilderObjectId.QuestionOptionID,
35
- label: "Neste",
36
- value: -1,
37
- },
38
- defaultQuestion: {
39
- id: "q1" as BuilderObjectId.QuestionID,
40
- prefix: "one-prefix",
41
- _type: "select-one",
42
- text: "q1-text",
43
- options: [
44
- {
45
- id: "opt-nei" as BuilderObjectId.QuestionOptionID,
46
- value: 0,
47
- label: "Nei",
48
- },
49
- {
50
- id: "opt-ja" as BuilderObjectId.QuestionOptionID,
51
- value: 1,
52
- label: "Ja",
53
- },
54
- {
55
- id: "opt-vet-ikke" as BuilderObjectId.QuestionOptionID,
56
- value: 9,
57
- label: "Vet ikke",
58
- },
59
- ],
60
- },
61
- tags: [
62
- tag1.tag,
63
- tag2.tag,
64
- // { tag: 'can_read', description: 'The patient can read' },
65
- // { tag: 'is grown up', description: 'Is grownUp.' }
66
- ],
67
- questions: [],
68
- autoplaySequence: [],
69
- },
35
+ nextButton: {
36
+ id: "next-button-text-id" as BuilderObjectId.QuestionOptionID,
37
+ label: "Neste",
38
+ value: -1,
39
+ },
40
+ defaultQuestion: {
41
+ id: "q1" as BuilderObjectId.QuestionID,
42
+ prefix: "one-prefix",
43
+ _type: "select-one",
44
+ text: "q1-text",
45
+ options: [
46
+ {
47
+ id: "opt-nei" as BuilderObjectId.QuestionOptionID,
48
+ value: 0,
49
+ label: "Nei",
50
+ },
51
+ {
52
+ id: "opt-ja" as BuilderObjectId.QuestionOptionID,
53
+ value: 1,
54
+ label: "Ja",
55
+ },
56
+ {
57
+ id: "opt-vet-ikke" as BuilderObjectId.QuestionOptionID,
58
+ value: 9,
59
+ label: "Vet ikke",
60
+ },
61
+ ],
62
+ },
63
+ tags: [
64
+ tag1.tag,
65
+ tag2.tag,
66
+ // { tag: 'can_read', description: 'The patient can read' },
67
+ // { tag: 'is grown up', description: 'Is grownUp.' }
68
+ ],
69
+ questions: [],
70
+ autoplaySequence: [],
71
+ },
72
+ {
73
+ id: PageID.ensure("b".repeat(24)),
74
+ _type: "multi-select",
75
+ prefix: PagePrefix.fromStringOrThrow("page2-prefix"),
76
+ tags: [tag3.tag],
77
+ mainText: {
78
+ text: "hello from test",
79
+ autoplay: false,
80
+ autoplayDelay: 0,
81
+ audioFile: false,
82
+ },
83
+ nextButton: {
84
+ id: "next-button-id-page2" as BuilderObjectId.QuestionOptionID,
85
+ label: "Neste",
86
+ value: -1,
87
+ },
88
+ defaultQuestion: {
89
+ id: "default-q" as BuilderObjectId.QuestionID,
90
+ prefix: "one-prefix",
91
+ _type: "select-one",
92
+ text: "q1",
93
+ options: [],
94
+ },
95
+ questions: [
70
96
  {
71
- id: "page2" as BuilderObjectId.PageID,
72
- _type: "multi-select",
73
- prefix: "page2-prefix",
74
- tags: [tag3.tag],
75
- mainText: {
76
- text: "hello from test",
77
- autoplay: false,
78
- autoplayDelay: 0,
79
- audioFile: false,
97
+ id: "q1" as BuilderObjectId.QuestionID,
98
+ prefix: "one-prefix",
99
+ _type: "select-one",
100
+ text: "q1-text",
101
+ options: [
102
+ {
103
+ id: "opt-nei" as BuilderObjectId.QuestionOptionID,
104
+ value: 0,
105
+ label: "Nei",
80
106
  },
81
- nextButton: {
82
- id: "next-button-id-page2" as BuilderObjectId.QuestionOptionID,
83
- label: "Neste",
84
- value: -1,
107
+ {
108
+ id: "opt-ja" as BuilderObjectId.QuestionOptionID,
109
+ value: 1,
110
+ label: "Ja",
85
111
  },
86
- defaultQuestion: {
87
- id: "default-q" as BuilderObjectId.QuestionID,
88
- prefix: "one-prefix",
89
- _type: "select-one",
90
- text: "q1",
91
- options: [],
112
+ {
113
+ id: "opt-vet-ikke" as BuilderObjectId.QuestionOptionID,
114
+ value: 9,
115
+ label: "Vet ikke",
92
116
  },
93
- questions: [
94
- {
95
- id: "q1" as BuilderObjectId.QuestionID,
96
- prefix: "one-prefix",
97
- _type: "select-one",
98
- text: "q1-text",
99
- options: [
100
- {
101
- id: "opt-nei" as BuilderObjectId.QuestionOptionID,
102
- value: 0,
103
- label: "Nei",
104
- },
105
- {
106
- id: "opt-ja" as BuilderObjectId.QuestionOptionID,
107
- value: 1,
108
- label: "Ja",
109
- },
110
- {
111
- id: "opt-vet-ikke" as BuilderObjectId.QuestionOptionID,
112
- value: 9,
113
- label: "Vet ikke",
114
- },
115
- ],
116
- },
117
- ],
118
- autoplaySequence: [],
117
+ ],
119
118
  },
120
- ],
121
- rules: [],
122
- prefix: "d1",
119
+ ],
120
+ autoplaySequence: [],
121
+ },
122
+ ],
123
+ rules: [],
124
+ prefix: SchemaPrefix.fromValueOrThrow("d1").value,
123
125
  };
124
126
 
125
- let builderSchema = BuilderSchema.create("a-id", "test", "a");
127
+ const SCHEMA_ID = SchemaID.create();
128
+ const schemaPrefixA = SchemaPrefix.castOrCreateRandom("a").value;
129
+ let builderSchema = BuilderSchema.create(SCHEMA_ID, "test", schemaPrefixA);
126
130
 
127
131
  beforeEach(() => {
128
- builderSchema = BuilderSchema.create("a-id", "test-name", "a");
132
+ builderSchema = BuilderSchema.create(SCHEMA_ID, "test-name", schemaPrefixA);
129
133
  });
130
134
 
131
135
  describe("Builder schema", () => {
132
- test("Can add pages.", () => {
133
- builderSchema.addPage("question");
134
- builderSchema.addPage("info-page");
135
- expect(builderSchema.pages.length).toBe(2);
136
- const dto = builderSchema.compile().schema;
137
- expect(dto.pages.length).toBe(2);
138
- expect(dto.id).toBe(builderSchema.id);
139
- expect(dto.prefix).toBe(builderSchema.prefix);
140
- expect(dto.baseHeight).toBe(builderSchema.baseHeight);
141
- expect(dto.baseWidth).toBe(builderSchema.baseWidth);
142
- expect(dto.backgroundColor).toBe(builderSchema.backgroundColor);
143
- });
136
+ test("Can add pages.", () => {
137
+ builderSchema.addPage("question");
138
+ builderSchema.addPage("info-page");
139
+ expect(builderSchema.pages.length).toBe(2);
140
+ const dto = builderSchema.compile().schema;
141
+ expect(dto.pages.length).toBe(2);
142
+ expect(dto.id).toBe(builderSchema.id);
143
+ expect(dto.baseHeight).toBe(builderSchema.baseHeight);
144
+ expect(dto.baseWidth).toBe(builderSchema.baseWidth);
145
+ expect(dto.backgroundColor).toBe(builderSchema.backgroundColor);
146
+ });
144
147
 
145
- test("Can delete page by passing reference", () => {
146
- const p1 = builderSchema.addPage("question");
147
- const p2 = builderSchema.addPage("question");
148
- const p3 = builderSchema.addPage("info-page");
149
- expect(builderSchema.pages.length).toBe(3);
150
- const result = builderSchema.deletePage(p1);
151
- expect(builderSchema.pages.length).toBe(2);
152
- expect(result).toBe(true);
153
- const result2 = builderSchema.deletePage(p2);
154
- expect(result2).toBe(true);
155
- expect(builderSchema.pages.length).toBe(1);
156
- expect(builderSchema.pages[0]).toBe(p3);
157
- const result3 = builderSchema.deletePage(p2);
158
- expect(result3).toBe(false);
159
- const result4 = builderSchema.deletePage(p3);
160
- expect(result4).toBe(true);
161
- });
148
+ test("Can delete page by passing reference", () => {
149
+ const p1 = builderSchema.addPage("question");
150
+ const p2 = builderSchema.addPage("question");
151
+ const p3 = builderSchema.addPage("info-page");
152
+ expect(builderSchema.pages.length).toBe(3);
153
+ const result = builderSchema.deletePage(p1);
154
+ expect(builderSchema.pages.length).toBe(2);
155
+ expect(result).toBe(true);
156
+ const result2 = builderSchema.deletePage(p2);
157
+ expect(result2).toBe(true);
158
+ expect(builderSchema.pages.length).toBe(1);
159
+ expect(builderSchema.pages[0]).toBe(p3);
160
+ const result3 = builderSchema.deletePage(p2);
161
+ expect(result3).toBe(false);
162
+ const result4 = builderSchema.deletePage(p3);
163
+ expect(result4).toBe(true);
164
+ });
162
165
 
163
- test("Can create Schema from dto", () => {
164
- const s = BuilderSchema.fromJson(schemaDto1);
165
- expect(s.id).toBe(schemaDto1.id);
166
- expect(s.prefix).toBe(schemaDto1.prefix);
167
- expect(s.baseHeight).toBe(schemaDto1.baseHeight);
168
- expect(s.baseWidth).toBe(schemaDto1.baseWidth);
169
- expect(s.backgroundColor).toBe(schemaDto1.backgroundColor);
170
- expect(s.pages.length).toBe(schemaDto1.pages.length);
171
- const p1Dto = schemaDto1.pages[0];
172
- expect(s.pages[0].id).toBe(p1Dto.id);
173
- const defaultQuestion = s.pages[0].defaultQuestion;
174
- expect(defaultQuestion).toBeDefined();
175
- expect(defaultQuestion.id).toBe(p1Dto.defaultQuestion.id);
176
- expect(defaultQuestion.options.length).toBe(p1Dto.defaultQuestion.options.length);
177
- const options = defaultQuestion.options;
178
- const nei = options[0];
179
- const ja = options[1];
180
- const vetIkke = options[2];
181
- expect(nei.label).toBe("Nei");
182
- expect(ja.label).toBe("Ja");
183
- expect(vetIkke.label).toBe("Vet ikke");
184
- expect(vetIkke.id).toBe(p1Dto.defaultQuestion.options[2].id);
185
- });
166
+ test("Can create Schema from dto", () => {
167
+ const s = BuilderSchema.fromJson(schemaDto1);
168
+ expect(s.id).toBe(schemaDto1.id);
169
+ expect(s.prefix).toBe(schemaDto1.prefix);
170
+ expect(s.baseHeight).toBe(schemaDto1.baseHeight);
171
+ expect(s.baseWidth).toBe(schemaDto1.baseWidth);
172
+ expect(s.backgroundColor).toBe(schemaDto1.backgroundColor);
173
+ expect(s.pages.length).toBe(schemaDto1.pages.length);
174
+ const p1Dto = schemaDto1.pages[0];
175
+ expect(s.pages[0].id).toBe(p1Dto.id);
176
+ const defaultQuestion = s.pages[0].defaultQuestion;
177
+ expect(defaultQuestion).toBeDefined();
178
+ expect(defaultQuestion.id).toBe(p1Dto.defaultQuestion.id);
179
+ expect(defaultQuestion.options.length).toBe(p1Dto.defaultQuestion.options.length);
180
+ const options = defaultQuestion.options;
181
+ const nei = options[0];
182
+ const ja = options[1];
183
+ const vetIkke = options[2];
184
+ expect(nei.label).toBe("Nei");
185
+ expect(ja.label).toBe("Ja");
186
+ expect(vetIkke.label).toBe("Vet ikke");
187
+ expect(vetIkke.id).toBe(p1Dto.defaultQuestion.options[2].id);
188
+ });
186
189
 
187
- test("fromJson === toJson", () => {
188
- const s = BuilderSchema.fromJson(schemaDto1);
189
- const json = s.toJson();
190
- expect(schemaDto1).toStrictEqual(json);
191
- });
192
- test("Can add page at concrete index", () => {
193
- const p1 = builderSchema.addPage("form");
194
- expect(p1.pageType).toBe("form");
195
- const p2 = builderSchema.addPage("multi-select", 0);
196
- expect(p2.pageType).toBe("multi-select");
197
- const pages = builderSchema.pages;
198
- expect(pages[0].id).toBe(p2.id);
199
- builderSchema.addPage("form");
200
- builderSchema.addPage("form");
201
- const last = builderSchema.addPage("form");
202
- expect(builderSchema.pages[builderSchema.pages.length - 1]).toBe(last);
203
- const p3 = builderSchema.addPage("info-page", 4);
204
- expect(pages[4].id).toBe(p3.id);
205
- });
206
- test("Can move page up and down", () => {
207
- const p1 = builderSchema.addPage("form");
208
- const p2 = builderSchema.addPage("form");
209
- const p3 = builderSchema.addPage("form");
210
- const p4 = builderSchema.addPage("multi-select");
211
- const last = builderSchema.addPage("form");
212
- const pages = builderSchema.pages;
213
- builderSchema.movePage(p2, 0);
214
- expect(pages[0]).toBe(p2);
215
- expect(pages[1]).toBe(p1);
216
- expect(builderSchema.movePage(p4, 4)).toBeTruthy();
217
- expect(builderSchema.movePage(p4, 5)).toBeFalsy();
218
- expect(builderSchema.movePage(p4, 10)).toBeFalsy();
190
+ test("fromJson === toJson", () => {
191
+ const s = BuilderSchema.fromJson(schemaDto1);
192
+ const json = s.toJson();
193
+ expect(schemaDto1).toStrictEqual(json);
194
+ });
195
+ test("Can add page at concrete index", () => {
196
+ const p1 = builderSchema.addPage("form");
197
+ expect(p1.pageType).toBe("form");
198
+ const p2 = builderSchema.addPage("multi-select", 0);
199
+ expect(p2.pageType).toBe("multi-select");
200
+ const pages = builderSchema.pages;
201
+ expect(pages[0].id).toBe(p2.id);
202
+ builderSchema.addPage("form");
203
+ builderSchema.addPage("form");
204
+ const last = builderSchema.addPage("form");
205
+ expect(builderSchema.pages[builderSchema.pages.length - 1]).toBe(last);
206
+ const p3 = builderSchema.addPage("info-page", 4);
207
+ expect(pages[4].id).toBe(p3.id);
208
+ });
209
+ test("Can move page up and down", () => {
210
+ const p1 = builderSchema.addPage("form");
211
+ const p2 = builderSchema.addPage("form");
212
+ const p3 = builderSchema.addPage("form");
213
+ const p4 = builderSchema.addPage("multi-select");
214
+ const last = builderSchema.addPage("form");
215
+ const pages = builderSchema.pages;
216
+ builderSchema.movePage(p2, 0);
217
+ expect(pages[0]).toBe(p2);
218
+ expect(pages[1]).toBe(p1);
219
+ expect(builderSchema.movePage(p4, 4)).toBeTruthy();
220
+ expect(builderSchema.movePage(p4, 5)).toBeFalsy();
221
+ expect(builderSchema.movePage(p4, 10)).toBeFalsy();
219
222
 
220
- // expect(pages[0].id).toBe(p4.id);
221
- });
222
- test("Can clone a page and insert at index", () => {
223
- const p1 = builderSchema.addPage("form");
224
- const p2 = builderSchema.addPage("form");
225
- const p3 = builderSchema.addPage("form");
226
- const mainTextContent = "Hello from test";
227
- const p4 = builderSchema.addPage("multi-select");
228
- p3.mainText.text = mainTextContent;
229
- const p1Clone = BuilderPage.fromJson(p1.clone());
230
- const beforeLen = builderSchema.pages.length;
231
- builderSchema.insertPage(p1Clone, 2);
232
- const pages = builderSchema.pages;
233
- expect(beforeLen + 1).toBe(pages.length);
234
- expect(pages[2]).toBe(p1Clone);
235
- });
236
- test("Will not insert a page that is already in array.", () => {
237
- const p1 = builderSchema.addPage("form");
238
- const p2 = builderSchema.addPage("form");
239
- const p3 = builderSchema.addPage("form");
240
- const beforeLen = builderSchema.pages.length;
241
- const result = builderSchema.insertPage(p1, 0);
242
- const pages = builderSchema.pages;
243
- expect(beforeLen).toBe(pages.length);
244
- expect(result).toBe(false);
245
- });
223
+ // expect(pages[0].id).toBe(p4.id);
224
+ });
225
+ test("Can clone a page and insert at index", () => {
226
+ const p1 = builderSchema.addPage("form");
227
+ const p2 = builderSchema.addPage("form");
228
+ const p3 = builderSchema.addPage("form");
229
+ const mainTextContent = "Hello from test";
230
+ const p4 = builderSchema.addPage("multi-select");
231
+ p3.mainText.text = mainTextContent;
232
+ const p1Clone = BuilderPage.fromJson(p1.clone());
233
+ const beforeLen = builderSchema.pages.length;
234
+ builderSchema.insertPage(p1Clone, 2);
235
+ const pages = builderSchema.pages;
236
+ expect(beforeLen + 1).toBe(pages.length);
237
+ expect(pages[2]).toBe(p1Clone);
238
+ });
239
+ test("Will not insert a page that is already in array.", () => {
240
+ const p1 = builderSchema.addPage("form");
241
+ const p2 = builderSchema.addPage("form");
242
+ const p3 = builderSchema.addPage("form");
243
+ const beforeLen = builderSchema.pages.length;
244
+ const result = builderSchema.insertPage(p1, 0);
245
+ const pages = builderSchema.pages;
246
+ expect(beforeLen).toBe(pages.length);
247
+ expect(result).toBe(false);
248
+ });
246
249
 
247
- test("Can generate a info-page", () => {
248
- const p1 = builderSchema.addPage("info-page");
249
- const p2 = builderSchema.addPage("question");
250
- p2.defaultQuestion.addOption("Ja", 1, 0);
251
- p2.defaultQuestion.addOption("Nei", 0);
252
- p1.nextButton.label = "Neste";
253
- builderSchema.backgroundColor = "red";
254
- builderSchema.baseHeight = 600;
255
- builderSchema.baseWidth = 500;
256
- builderSchema.prefix = "as";
257
- builderSchema.name = "depressed";
258
- const schema = builderSchema.compile().schema;
259
- expect(schema.backgroundColor).toBe("red");
260
- expect(schema.baseHeight).toBe(600);
261
- expect(schema.baseWidth).toBe(500);
262
- expect(schema.prefix).toBe("as");
263
- expect(schema.pages.length).toBe(2);
264
- const schemaP1 = schema.pages[0];
265
- const schemaP2 = schema.pages[1];
266
- expect(schemaP1.id).toBe(p1.id);
267
- expect(schemaP2.id).toBe(p2.id);
268
- expect(schemaP1.elements.length).toBe(2);
250
+ test("Can generate a info-page", () => {
251
+ const p1 = builderSchema.addPage("info-page");
252
+ const p2 = builderSchema.addPage("question");
253
+ p2.defaultQuestion.addOption("Ja", 1, 0);
254
+ p2.defaultQuestion.addOption("Nei", 0);
255
+ p1.nextButton.label = "Neste";
256
+ builderSchema.backgroundColor = "red";
257
+ builderSchema.baseHeight = 600;
258
+ builderSchema.baseWidth = 500;
259
+ // builderSchema.prefix = "as";
260
+ builderSchema.name = "depressed";
261
+ const schema = builderSchema.compile().schema;
262
+ expect(schema.backgroundColor).toBe("red");
263
+ expect(schema.baseHeight).toBe(600);
264
+ expect(schema.baseWidth).toBe(500);
265
+ expect(schema.pages.length).toBe(2);
266
+ const schemaP1 = schema.pages[0];
267
+ const schemaP2 = schema.pages[1];
268
+ expect(schemaP1.id).toBe(p1.id);
269
+ expect(schemaP2.id).toBe(p2.id);
270
+ expect(schemaP1.elements.length).toBe(2);
269
271
 
270
- // Has Buttons
271
- const options = p2.defaultQuestion.options;
272
- expect(schemaP2.elements.length).toBe(options.length + 1);
273
- });
274
- test("Can get ruleInput!", () => {
275
- const p0 = builderSchema.addPage("info-page");
276
- p0.prefix = "info_page_prefix_";
277
- const p1 = builderSchema.addPage("question");
278
- p1.prefix = "p1_prefix_";
279
- const p2 = builderSchema.addPage("question");
280
- p2.prefix = "p2_prefix_";
281
- p1.defaultQuestion.addOption("Ja", 1, 0);
282
- p1.defaultQuestion.addOption("Nei", 0, 0);
283
- p2.defaultQuestion.addOption("Ja", 1, 0);
284
- p2.defaultQuestion.addOption("Nei", 0);
285
- const ruleInput = builderSchema.getRuleInput();
286
- expect(ruleInput.questionVars.length).toBe(2);
287
- expect(ruleInput.jumpToPageActions.length).toBe(3);
288
- // TODO add TAGS!!
289
- expect(ruleInput.excludeByTagActions.length).toBe(0);
290
- expect(ruleInput.excludeByPageIdActions.length).toBe(3);
291
- const allPrefixes = new Set(ruleInput.jumpToPageActions.map((a) => a.pageId));
292
- expect(allPrefixes.has(p0.prefix)).toBe(true);
293
- expect(allPrefixes.has(p1.prefix)).toBe(true);
294
- expect(allPrefixes.has(p2.prefix)).toBe(true);
295
- ruleInput.questionVars.forEach((v) => {
296
- expect(allPrefixes.has(v.varId)).toBe(true);
297
- });
298
- ruleInput.jumpToPageActions.forEach((v) => {
299
- expect(allPrefixes.has(v.pageId)).toBe(true);
300
- });
272
+ // Has Buttons
273
+ const options = p2.defaultQuestion.options;
274
+ expect(schemaP2.elements.length).toBe(options.length + 1);
275
+ });
276
+ test("Can get ruleInput!", () => {
277
+ const p0 = builderSchema.addPage("info-page");
278
+ // p0.prefix = "info_page_prefix_";
279
+ const p1 = builderSchema.addPage("question");
280
+ // p1.prefix = "p1_prefix_";
281
+ const p2 = builderSchema.addPage("question");
282
+ // p2.prefix = "p2_prefix_";
283
+ p1.defaultQuestion.addOption("Ja", 1, 0);
284
+ p1.defaultQuestion.addOption("Nei", 0, 0);
285
+ p2.defaultQuestion.addOption("Ja", 1, 0);
286
+ p2.defaultQuestion.addOption("Nei", 0);
287
+ const ruleInput = builderSchema.getRuleInput();
288
+ expect(ruleInput.questionVars.length).toBe(2);
289
+ expect(ruleInput.jumpToPageActions.length).toBe(3);
290
+ // TODO add TAGS!!
291
+ expect(ruleInput.excludeByTagActions.length).toBe(0);
292
+ expect(ruleInput.excludeByPageIdActions.length).toBe(3);
293
+ const allPageIds = new Set(ruleInput.jumpToPageActions.map((a) => a.pageId));
294
+ expect(allPageIds.has(p0.id)).toBe(true);
295
+ expect(allPageIds.has(p1.id)).toBe(true);
296
+ expect(allPageIds.has(p2.id)).toBe(true);
297
+ // ruleInput.questionVars.forEach((v) => {
298
+ // expect(allPageIds.has(v.varId)).toBe(true);
299
+ // });
300
+ ruleInput.jumpToPageActions.forEach((v) => {
301
+ expect(allPageIds.has(v.pageId)).toBe(true);
301
302
  });
303
+ });
302
304
  });