@projectcaluma/ember-testing 12.1.0 → 12.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/addon/mirage-graphql/filters/base.js +2 -2
- package/addon/mirage-graphql/filters/question.js +1 -1
- package/addon/mirage-graphql/filters/work-item.js +2 -2
- package/addon/mirage-graphql/mocks/answer.js +1 -1
- package/addon/mirage-graphql/mocks/base.js +7 -7
- package/addon/mirage-graphql/mocks/work-item.js +1 -1
- package/addon/mirage-graphql/schema.graphql +24 -5
- package/addon/scenarios/distribution.js +14 -14
- package/addon-mirage-support/factories/question.js +1 -1
- package/package.json +4 -4
|
@@ -53,7 +53,7 @@ export default class BaseFilter {
|
|
|
53
53
|
filter(records, filters) {
|
|
54
54
|
return this._getFilterFns(filters?.filter ?? []).reduce(
|
|
55
55
|
(recs, fn) => fn(recs),
|
|
56
|
-
this.sort(records, filters?.order)
|
|
56
|
+
this.sort(records, filters?.order),
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -95,7 +95,7 @@ export default class BaseFilter {
|
|
|
95
95
|
id === value ||
|
|
96
96
|
slug === value ||
|
|
97
97
|
btoa(`${this.type}:${id}`) === value ||
|
|
98
|
-
btoa(`${this.type}:${slug}`) === value
|
|
98
|
+
btoa(`${this.type}:${slug}`) === value,
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -13,7 +13,7 @@ export default class QuestionFilter extends BaseFilter {
|
|
|
13
13
|
|
|
14
14
|
excludeForms(records, value) {
|
|
15
15
|
return records.filter(
|
|
16
|
-
({ formIds }) => !value.some((id) => (formIds || []).includes(id))
|
|
16
|
+
({ formIds }) => !value.some((id) => (formIds || []).includes(id)),
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -15,13 +15,13 @@ export default class WorkItemFilter extends BaseFilter {
|
|
|
15
15
|
|
|
16
16
|
controllingGroups(records, value) {
|
|
17
17
|
return records.filter((record) =>
|
|
18
|
-
value.every((g) => record.controllingGroups?.includes(g))
|
|
18
|
+
value.every((g) => record.controllingGroups?.includes(g)),
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
addressedGroups(records, value) {
|
|
23
23
|
return records.filter((record) =>
|
|
24
|
-
value.every((g) => record.addressedGroups?.includes(g))
|
|
24
|
+
value.every((g) => record.addressedGroups?.includes(g)),
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -6,7 +6,7 @@ import register from "@projectcaluma/ember-testing/mirage-graphql/register";
|
|
|
6
6
|
export default class AnswerMock extends BaseMock {
|
|
7
7
|
_handleSaveDocumentAnswer(
|
|
8
8
|
_,
|
|
9
|
-
{ question: questionId, document: documentId, value, type }
|
|
9
|
+
{ question: questionId, document: documentId, value, type },
|
|
10
10
|
) {
|
|
11
11
|
const answer = this.collection.findBy({ questionId, documentId });
|
|
12
12
|
|
|
@@ -69,7 +69,7 @@ export default class BaseMock {
|
|
|
69
69
|
|
|
70
70
|
return Object.prototype.isPrototypeOf.call(
|
|
71
71
|
Reflect.getPrototypeOf(proto),
|
|
72
|
-
Object
|
|
72
|
+
Object,
|
|
73
73
|
)
|
|
74
74
|
? res
|
|
75
75
|
: [...handlers(proto), ...res];
|
|
@@ -91,10 +91,10 @@ export default class BaseMock {
|
|
|
91
91
|
...typeHandlers,
|
|
92
92
|
[handlerName.replace(
|
|
93
93
|
/\{subtype\}/,
|
|
94
|
-
classify(type.toLowerCase())
|
|
94
|
+
classify(type.toLowerCase()),
|
|
95
95
|
)]: fn,
|
|
96
96
|
}),
|
|
97
|
-
{}
|
|
97
|
+
{},
|
|
98
98
|
)
|
|
99
99
|
: { [baseHandlerName]: fn };
|
|
100
100
|
|
|
@@ -114,7 +114,7 @@ export default class BaseMock {
|
|
|
114
114
|
handleConnection(root, vars, _, { fieldName }) {
|
|
115
115
|
let records = this.filter.filter(
|
|
116
116
|
this.collection.all().models,
|
|
117
|
-
deserialize(vars)
|
|
117
|
+
deserialize(vars),
|
|
118
118
|
);
|
|
119
119
|
|
|
120
120
|
const relKey = `${singularize(fieldName)}Ids`;
|
|
@@ -189,7 +189,7 @@ export default class BaseMock {
|
|
|
189
189
|
@register("Save{subtype}{type}Payload")
|
|
190
190
|
handleSavePayload(
|
|
191
191
|
_,
|
|
192
|
-
{ input: { clientMutationId = faker.string.uuid(), slug, id, ...args } }
|
|
192
|
+
{ input: { clientMutationId = faker.string.uuid(), slug, id, ...args } },
|
|
193
193
|
) {
|
|
194
194
|
// Sometimes we pass the identifier as property `slug` (e.g in `saveForm`),
|
|
195
195
|
// sometimes as `id` (e.g. in `saveDocument`) and sometimes as the camelized
|
|
@@ -219,8 +219,8 @@ export default class BaseMock {
|
|
|
219
219
|
deserialize({
|
|
220
220
|
...identifier,
|
|
221
221
|
...parsedArgs,
|
|
222
|
-
})
|
|
223
|
-
)
|
|
222
|
+
}),
|
|
223
|
+
),
|
|
224
224
|
);
|
|
225
225
|
|
|
226
226
|
return {
|
|
@@ -2424,19 +2424,38 @@ input QuestionFilterSetType {
|
|
|
2424
2424
|
"""
|
|
2425
2425
|
Question jexl expression returning boolean.
|
|
2426
2426
|
|
|
2427
|
-
Following
|
|
2428
|
-
* answer
|
|
2429
|
-
* mapby
|
|
2427
|
+
Following transforms can be used:
|
|
2428
|
+
* `answer`: get answer of document by question slug
|
|
2429
|
+
* `mapby`: map list by key. Helpful to work with table answers
|
|
2430
2430
|
whereas an answer is a list of dicts.
|
|
2431
|
+
* `stringify`: JSON stringify
|
|
2432
|
+
* `flatten`: flatten list values
|
|
2433
|
+
* `min`: get min value in a list
|
|
2434
|
+
* `max`: get max value in a list
|
|
2435
|
+
* `sum`: sum of a list
|
|
2436
|
+
* `round`: round the value
|
|
2437
|
+
* `ceil`: round value up
|
|
2438
|
+
* `floor`: round value down
|
|
2439
|
+
* `debug`: debug output
|
|
2440
|
+
|
|
2441
|
+
Following binary operators can be used:
|
|
2442
|
+
* `intersects`: list intersection operator
|
|
2431
2443
|
|
|
2432
2444
|
Following context is available:
|
|
2433
|
-
* form
|
|
2445
|
+
* `form`: legacy property pointing to the root form (this should not be used anymore)
|
|
2446
|
+
* `info.form`: slug of the form this question is attached to
|
|
2447
|
+
* `info.formMeta`: meta property of the form this question is attached to
|
|
2448
|
+
* `info.parent.form`: parent form slug
|
|
2449
|
+
* `info.parent.formMeta`: parent form meta property
|
|
2450
|
+
* `info.root.form`: top level form slug
|
|
2451
|
+
* `info.root.formMeta`: top level form meta property
|
|
2434
2452
|
|
|
2435
2453
|
Examples:
|
|
2436
2454
|
* 'answer' == 'question-slug'|answer
|
|
2437
2455
|
* 'answer' in 'list-question-slug'|answer
|
|
2438
2456
|
* 'answer' in 'table-question-slug'|answer|mapby('column-question')
|
|
2439
|
-
* '
|
|
2457
|
+
* 'answer' in 'table-question-slug'|answer|mapby('multiple-choice-question')|flatten
|
|
2458
|
+
* 'form-slug' == info.form
|
|
2440
2459
|
"""
|
|
2441
2460
|
scalar QuestionJexl
|
|
2442
2461
|
|
|
@@ -98,7 +98,7 @@ export function createInquiry(
|
|
|
98
98
|
server,
|
|
99
99
|
distributionCase,
|
|
100
100
|
{ from, to, remark, deadline },
|
|
101
|
-
workItemAttrs = {}
|
|
101
|
+
workItemAttrs = {},
|
|
102
102
|
) {
|
|
103
103
|
const document = server.create("document", { formId: "inquiry" });
|
|
104
104
|
|
|
@@ -211,7 +211,7 @@ export function confirmInquiry(server, { inquiry }) {
|
|
|
211
211
|
!inquiry.case.workItems.filter(
|
|
212
212
|
(workItem) =>
|
|
213
213
|
workItem.taskId === "check-inquiries" &&
|
|
214
|
-
String(workItem.addressedGroups) === String(inquiry.addressedGroups)
|
|
214
|
+
String(workItem.addressedGroups) === String(inquiry.addressedGroups),
|
|
215
215
|
).length
|
|
216
216
|
) {
|
|
217
217
|
server.create("work-item", {
|
|
@@ -296,7 +296,7 @@ export default function (server, groups) {
|
|
|
296
296
|
withdraw({
|
|
297
297
|
inquiry: create(
|
|
298
298
|
{ from: g, to: g2 },
|
|
299
|
-
{ id: "4afed640-07a6-4eb9-82a7-b5e961391370" }
|
|
299
|
+
{ id: "4afed640-07a6-4eb9-82a7-b5e961391370" },
|
|
300
300
|
),
|
|
301
301
|
});
|
|
302
302
|
send({
|
|
@@ -306,7 +306,7 @@ export default function (server, groups) {
|
|
|
306
306
|
to: g2,
|
|
307
307
|
deadline: faker.date.past(),
|
|
308
308
|
},
|
|
309
|
-
{ id: "6bbdc36a-3174-4578-93d4-0cb84d3dab97", meta: {} }
|
|
309
|
+
{ id: "6bbdc36a-3174-4578-93d4-0cb84d3dab97", meta: {} },
|
|
310
310
|
),
|
|
311
311
|
});
|
|
312
312
|
confirm({
|
|
@@ -317,7 +317,7 @@ export default function (server, groups) {
|
|
|
317
317
|
to: g3,
|
|
318
318
|
deadline: faker.date.past(),
|
|
319
319
|
},
|
|
320
|
-
{ id: "88999388-daf2-4a18-b7e2-50373d082331" }
|
|
320
|
+
{ id: "88999388-daf2-4a18-b7e2-50373d082331" },
|
|
321
321
|
),
|
|
322
322
|
status: "inquiry-answer-status-needs-interaction",
|
|
323
323
|
}),
|
|
@@ -331,7 +331,7 @@ export default function (server, groups) {
|
|
|
331
331
|
{
|
|
332
332
|
id: "75d56729-5518-469d-ae66-188a5c32d59d",
|
|
333
333
|
createdAt: faker.date.recent(),
|
|
334
|
-
}
|
|
334
|
+
},
|
|
335
335
|
),
|
|
336
336
|
status: "inquiry-answer-status-positive",
|
|
337
337
|
}),
|
|
@@ -341,7 +341,7 @@ export default function (server, groups) {
|
|
|
341
341
|
withdraw({
|
|
342
342
|
inquiry: create(
|
|
343
343
|
{ from: g, to: g4 },
|
|
344
|
-
{ id: "7360fa66-83d2-4f6a-b489-5db46f6fd670" }
|
|
344
|
+
{ id: "7360fa66-83d2-4f6a-b489-5db46f6fd670" },
|
|
345
345
|
),
|
|
346
346
|
});
|
|
347
347
|
|
|
@@ -350,7 +350,7 @@ export default function (server, groups) {
|
|
|
350
350
|
inquiry: answer({
|
|
351
351
|
inquiry: create(
|
|
352
352
|
{ from: g2, to: g },
|
|
353
|
-
{ id: "e907584c-a38a-488e-80f7-bab6bb22f303" }
|
|
353
|
+
{ id: "e907584c-a38a-488e-80f7-bab6bb22f303" },
|
|
354
354
|
),
|
|
355
355
|
status: "inquiry-answer-status-needs-interaction",
|
|
356
356
|
}),
|
|
@@ -366,14 +366,14 @@ export default function (server, groups) {
|
|
|
366
366
|
{
|
|
367
367
|
id: "4889435d-f310-472f-808b-7b20936c40fc",
|
|
368
368
|
createdAt: faker.date.recent(),
|
|
369
|
-
}
|
|
369
|
+
},
|
|
370
370
|
),
|
|
371
371
|
});
|
|
372
372
|
confirm({
|
|
373
373
|
inquiry: answer({
|
|
374
374
|
inquiry: create(
|
|
375
375
|
{ from: g4, to: g },
|
|
376
|
-
{ id: "4c5dbcc3-f42a-4c25-8d06-f85bd17edbf2" }
|
|
376
|
+
{ id: "4c5dbcc3-f42a-4c25-8d06-f85bd17edbf2" },
|
|
377
377
|
),
|
|
378
378
|
status: "inquiry-answer-status-negative",
|
|
379
379
|
}),
|
|
@@ -381,7 +381,7 @@ export default function (server, groups) {
|
|
|
381
381
|
answer({
|
|
382
382
|
inquiry: create(
|
|
383
383
|
{ from: g3, to: g },
|
|
384
|
-
{ id: "3f7eea45-251d-4934-81fd-27c78bbca88c" }
|
|
384
|
+
{ id: "3f7eea45-251d-4934-81fd-27c78bbca88c" },
|
|
385
385
|
),
|
|
386
386
|
status: "inquiry-answer-status-positive",
|
|
387
387
|
});
|
|
@@ -389,7 +389,7 @@ export default function (server, groups) {
|
|
|
389
389
|
inquiry: answer({
|
|
390
390
|
inquiry: create(
|
|
391
391
|
{ from: g1, to: g },
|
|
392
|
-
{ id: "dd07b1a4-91e6-4411-a4ea-445637690577" }
|
|
392
|
+
{ id: "dd07b1a4-91e6-4411-a4ea-445637690577" },
|
|
393
393
|
),
|
|
394
394
|
status: "inquiry-answer-status-needs-interaction",
|
|
395
395
|
}),
|
|
@@ -400,7 +400,7 @@ export default function (server, groups) {
|
|
|
400
400
|
inquiry: answer({
|
|
401
401
|
inquiry: create(
|
|
402
402
|
{ from: g2, to: g3 },
|
|
403
|
-
{ id: "4f374860-28b3-465b-be5f-5e501a39fe8b" }
|
|
403
|
+
{ id: "4f374860-28b3-465b-be5f-5e501a39fe8b" },
|
|
404
404
|
),
|
|
405
405
|
status: "inquiry-answer-status-needs-interaction",
|
|
406
406
|
}),
|
|
@@ -409,7 +409,7 @@ export default function (server, groups) {
|
|
|
409
409
|
inquiry: answer({
|
|
410
410
|
inquiry: create(
|
|
411
411
|
{ from: g3, to: g4 },
|
|
412
|
-
{ id: "16eebfae-55c5-4d31-ad48-7ed5578a22a2" }
|
|
412
|
+
{ id: "16eebfae-55c5-4d31-ad48-7ed5578a22a2" },
|
|
413
413
|
),
|
|
414
414
|
status: "inquiry-answer-status-positive",
|
|
415
415
|
}),
|
|
@@ -47,7 +47,7 @@ export default Factory.extend({
|
|
|
47
47
|
const options = server.createList("option", 3);
|
|
48
48
|
|
|
49
49
|
options.forEach((option) =>
|
|
50
|
-
option.update({ slug: `${question.slug}-${option.slug}` })
|
|
50
|
+
option.update({ slug: `${question.slug}-${option.slug}` }),
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
question.update({ optionIds: options.map(({ id }) => id) });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-testing",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.2.0",
|
|
4
4
|
"description": "Ember addon for testing with Caluma addons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@ember/optional-features": "2.0.0",
|
|
31
|
-
"@ember/test-helpers": "3.
|
|
31
|
+
"@ember/test-helpers": "3.2.0",
|
|
32
32
|
"@embroider/test-setup": "3.0.1",
|
|
33
33
|
"@glimmer/component": "1.1.2",
|
|
34
34
|
"broccoli-asset-rev": "3.0.0",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"ember-load-initializers": "2.1.2",
|
|
42
42
|
"ember-qunit": "7.0.0",
|
|
43
43
|
"ember-resolver": "10.1.1",
|
|
44
|
-
"ember-source": "4.12.
|
|
44
|
+
"ember-source": "4.12.3",
|
|
45
45
|
"ember-source-channel-url": "3.0.0",
|
|
46
46
|
"ember-try": "2.0.0",
|
|
47
47
|
"graphql-tag": "2.12.6",
|
|
48
48
|
"loader.js": "4.7.0",
|
|
49
49
|
"qunit": "2.19.4",
|
|
50
50
|
"qunit-dom": "2.0.0",
|
|
51
|
-
"webpack": "5.
|
|
51
|
+
"webpack": "5.88.2"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"ember-source": "^4.0.0"
|