@projectcaluma/ember-testing 11.0.0-beta.9 → 11.0.1
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/CHANGELOG.md +19 -0
- package/addon/mirage-graphql/filters/answer.js +4 -6
- package/addon/mirage-graphql/filters/base.js +22 -1
- package/addon/mirage-graphql/filters/work-item.js +10 -10
- package/addon/mirage-graphql/mocks/answer.js +4 -4
- package/addon/mirage-graphql/mocks/base.js +8 -3
- package/addon/mirage-graphql/mocks/question.js +3 -3
- package/addon/mirage-graphql/mocks/work-item.js +40 -5
- package/addon/mirage-graphql/schema.graphql +425 -351
- package/addon/scenarios/distribution.js +37 -10
- package/addon-mirage-support/factories/answer.js +10 -6
- package/addon-mirage-support/factories/document.js +0 -2
- package/addon-mirage-support/factories/file.js +1 -1
- package/addon-mirage-support/factories/form.js +4 -0
- package/addon-mirage-support/factories/work-item.js +2 -0
- package/addon-mirage-support/models/task.js +1 -0
- package/package.json +24 -23
- package/config/environment.js +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [@projectcaluma/ember-testing-v11.0.0-beta.11](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-testing-v11.0.0-beta.10...@projectcaluma/ember-testing-v11.0.0-beta.11) (2022-08-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **testing:** add createdBy and modifiedBy filters ([c6ace21](https://github.com/projectcaluma/ember-caluma/commit/c6ace21c573d45da6f99c0bc2de076c507f4f056))
|
|
7
|
+
* **testing:** allow inverting of filters ([88ab05d](https://github.com/projectcaluma/ember-caluma/commit/88ab05d4c01275e835d79c22451592666cec4db2))
|
|
8
|
+
|
|
9
|
+
# [@projectcaluma/ember-testing-v11.0.0-beta.10](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-testing-v11.0.0-beta.9...@projectcaluma/ember-testing-v11.0.0-beta.10) (2022-08-05)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* feat!: add multi file upload (#2040) ([c4fd004](https://github.com/projectcaluma/ember-caluma/commit/c4fd0049654b2d2e5ea62e5909a45d89cb888b40)), closes [#2040](https://github.com/projectcaluma/ember-caluma/issues/2040)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### BREAKING CHANGES
|
|
16
|
+
|
|
17
|
+
* This requires the caluma backend version v8.0.0-beta.12
|
|
18
|
+
or later.
|
|
19
|
+
|
|
1
20
|
# [@projectcaluma/ember-testing-v11.0.0-beta.9](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-testing-v11.0.0-beta.8...@projectcaluma/ember-testing-v11.0.0-beta.9) (2022-06-09)
|
|
2
21
|
|
|
3
22
|
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import BaseFilter from "@projectcaluma/ember-testing/mirage-graphql/filters/base";
|
|
2
2
|
|
|
3
3
|
export default class AnswerFilter extends BaseFilter {
|
|
4
|
-
questions(records, value
|
|
5
|
-
return records.filter(
|
|
6
|
-
(record) => invert !== value.includes(record.questionId)
|
|
7
|
-
);
|
|
4
|
+
questions(records, value) {
|
|
5
|
+
return records.filter((record) => value.includes(record.questionId));
|
|
8
6
|
}
|
|
9
7
|
|
|
10
|
-
question(records, value
|
|
11
|
-
return this.questions(records, [value]
|
|
8
|
+
question(records, value) {
|
|
9
|
+
return this.questions(records, [value]);
|
|
12
10
|
}
|
|
13
11
|
}
|
|
@@ -23,7 +23,12 @@ export default class BaseFilter {
|
|
|
23
23
|
const fn = this[key];
|
|
24
24
|
|
|
25
25
|
return typeof fn === "function" && ![null, undefined].includes(value)
|
|
26
|
-
? (records) =>
|
|
26
|
+
? (records) => {
|
|
27
|
+
const filteredRecords = fn.call(this, records, value, options);
|
|
28
|
+
return options?.invert
|
|
29
|
+
? records.filter((record) => !filteredRecords.includes(record))
|
|
30
|
+
: filteredRecords;
|
|
31
|
+
}
|
|
27
32
|
: (records) => records;
|
|
28
33
|
});
|
|
29
34
|
}
|
|
@@ -64,6 +69,22 @@ export default class BaseFilter {
|
|
|
64
69
|
return records.filter(({ slug }) => values.includes(slug));
|
|
65
70
|
}
|
|
66
71
|
|
|
72
|
+
createdByUser(records, value) {
|
|
73
|
+
return records.filter(({ createdByUser }) => createdByUser === value);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
createdByGroup(records, value) {
|
|
77
|
+
return records.filter(({ createdByGroup }) => createdByGroup === value);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
modifiedByUser(records, value) {
|
|
81
|
+
return records.filter(({ modifiedByUser }) => modifiedByUser === value);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
modifiedByGroup(records, value) {
|
|
85
|
+
return records.filter(({ modifiedByGroup }) => modifiedByGroup === value);
|
|
86
|
+
}
|
|
87
|
+
|
|
67
88
|
id(records, value) {
|
|
68
89
|
if (value === undefined || value === null) {
|
|
69
90
|
return [];
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import BaseFilter from "@projectcaluma/ember-testing/mirage-graphql/filters/base";
|
|
2
2
|
|
|
3
3
|
export default class WorkItemFilter extends BaseFilter {
|
|
4
|
-
status(records, value
|
|
5
|
-
return records.filter(({ status }) =>
|
|
4
|
+
status(records, value) {
|
|
5
|
+
return records.filter(({ status }) => status === value);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
tasks(records, value
|
|
9
|
-
return records.filter((record) =>
|
|
8
|
+
tasks(records, value) {
|
|
9
|
+
return records.filter((record) => value.includes(record.taskId));
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
task(records, value
|
|
13
|
-
return this.tasks(records, [value]
|
|
12
|
+
task(records, value) {
|
|
13
|
+
return this.tasks(records, [value]);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
controllingGroups(records, value
|
|
16
|
+
controllingGroups(records, value) {
|
|
17
17
|
return records.filter((record) =>
|
|
18
|
-
value.every((g) =>
|
|
18
|
+
value.every((g) => record.controllingGroups?.includes(g))
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
addressedGroups(records, value
|
|
22
|
+
addressedGroups(records, value) {
|
|
23
23
|
return records.filter((record) =>
|
|
24
|
-
value.every((g) =>
|
|
24
|
+
value.every((g) => record.addressedGroups?.includes(g))
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -61,12 +61,12 @@ export default class AnswerMock extends BaseMock {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
@register("
|
|
65
|
-
|
|
64
|
+
@register("SaveDocumentFilesAnswerPayload")
|
|
65
|
+
handleSaveFilesAnswer(_, { input }) {
|
|
66
66
|
return this._handleSaveDocumentAnswer(_, {
|
|
67
67
|
...input,
|
|
68
|
-
value: input.value ?
|
|
69
|
-
type: "
|
|
68
|
+
value: input.value ? [...input.value] : [],
|
|
69
|
+
type: "FILES",
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -10,7 +10,7 @@ import serialize from "@projectcaluma/ember-testing/mirage-graphql/serialize";
|
|
|
10
10
|
|
|
11
11
|
export const ANSWER_TYPES = [
|
|
12
12
|
"DATE",
|
|
13
|
-
"
|
|
13
|
+
"FILES",
|
|
14
14
|
"FLOAT",
|
|
15
15
|
"INTEGER",
|
|
16
16
|
"LIST",
|
|
@@ -25,7 +25,7 @@ export const QUESTION_TYPES = [
|
|
|
25
25
|
"DATE",
|
|
26
26
|
"DYNAMIC_CHOICE",
|
|
27
27
|
"DYNAMIC_MULTIPLE_CHOICE",
|
|
28
|
-
"
|
|
28
|
+
"FILES",
|
|
29
29
|
"FLOAT",
|
|
30
30
|
"FORM",
|
|
31
31
|
"INTEGER",
|
|
@@ -191,7 +191,12 @@ export default class BaseMock {
|
|
|
191
191
|
_,
|
|
192
192
|
{ input: { clientMutationId = faker.datatype.uuid(), slug, id, ...args } }
|
|
193
193
|
) {
|
|
194
|
-
|
|
194
|
+
// Sometimes we pass the identifier as property `slug` (e.g in `saveForm`),
|
|
195
|
+
// sometimes as `id` (e.g. in `saveDocument`) and sometimes as the camelized
|
|
196
|
+
// name of the type (e.g in `saveWorkItem`).
|
|
197
|
+
const identifier = slug
|
|
198
|
+
? { slug }
|
|
199
|
+
: { id: id ?? args[camelize(this.type)] };
|
|
195
200
|
|
|
196
201
|
const relKeys = this.schema.modelFor(camelize(this.type)).foreignKeys;
|
|
197
202
|
|
|
@@ -92,10 +92,10 @@ export default class QuestionMock extends BaseMock {
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
@register("
|
|
96
|
-
|
|
95
|
+
@register("SaveFilesQuestionPayload")
|
|
96
|
+
handleSaveFilesQuestion(_, { input }) {
|
|
97
97
|
return this.handleSavePayload.fn.call(this, _, {
|
|
98
|
-
input: { ...input, type: "
|
|
98
|
+
input: { ...input, type: "FILES" },
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -27,6 +27,32 @@ export default class WorkItemMock extends BaseMock {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
@register("RedoWorkItemPayload")
|
|
31
|
+
handleRedoWorkItem(_, { input }) {
|
|
32
|
+
const { id } = deserialize(input);
|
|
33
|
+
const workItem = this.collection.find(id);
|
|
34
|
+
const caseId = workItem?.childCaseId;
|
|
35
|
+
|
|
36
|
+
if (workItem.taskId === "distribution") {
|
|
37
|
+
this.collection
|
|
38
|
+
.where({ caseId, taskId: "complete-distribution" })
|
|
39
|
+
.update({ status: "READY" });
|
|
40
|
+
this.collection
|
|
41
|
+
.where({ caseId, taskId: "create-inquiry" })
|
|
42
|
+
.update({ status: "READY" });
|
|
43
|
+
} else if (workItem.taskId === "inquiry") {
|
|
44
|
+
this.server.create("work-item", {
|
|
45
|
+
caseId,
|
|
46
|
+
status: "READY",
|
|
47
|
+
taskId: "adjust-inquiry-answer",
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return this.handleSavePayload.fn.call(this, _, {
|
|
52
|
+
input: { id, isRedoable: false, status: "READY" },
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
30
56
|
@register("CompleteWorkItemPayload")
|
|
31
57
|
handleCompleteWorkItem(_, { input }) {
|
|
32
58
|
const { id } = deserialize(input);
|
|
@@ -60,7 +86,7 @@ export default class WorkItemMock extends BaseMock {
|
|
|
60
86
|
.update({ status: "CANCELED" });
|
|
61
87
|
this.collection
|
|
62
88
|
.findBy({ childCaseId: caseId })
|
|
63
|
-
.update({ status: "COMPLETED" });
|
|
89
|
+
.update({ status: "COMPLETED", isRedoable: true });
|
|
64
90
|
this.schema.cases.find(caseId).update({ status: "COMPLETED" });
|
|
65
91
|
} else if (taskId === "revise-inquiry-answer") {
|
|
66
92
|
this.collection
|
|
@@ -72,7 +98,12 @@ export default class WorkItemMock extends BaseMock {
|
|
|
72
98
|
taskId: "adjust-inquiry-answer",
|
|
73
99
|
});
|
|
74
100
|
} else if (taskId === "create-inquiry") {
|
|
75
|
-
const { addressed_groups: groups } = JSON.parse(input.context);
|
|
101
|
+
const { addressed_groups: groups, answers } = JSON.parse(input.context);
|
|
102
|
+
|
|
103
|
+
const remark = answers?.["inquiry-remark"] ?? "";
|
|
104
|
+
const deadline =
|
|
105
|
+
answers?.["inquiry-deadline"] ??
|
|
106
|
+
DateTime.now().plus({ days: 30 }).toISODate();
|
|
76
107
|
|
|
77
108
|
groups.forEach((group) => {
|
|
78
109
|
createInquiry(
|
|
@@ -81,8 +112,8 @@ export default class WorkItemMock extends BaseMock {
|
|
|
81
112
|
{
|
|
82
113
|
to: { id: group },
|
|
83
114
|
from: { id: workItem.addressedGroups[0] },
|
|
84
|
-
remark
|
|
85
|
-
deadline
|
|
115
|
+
remark,
|
|
116
|
+
deadline,
|
|
86
117
|
},
|
|
87
118
|
{
|
|
88
119
|
createdAt: new Date(),
|
|
@@ -102,6 +133,10 @@ export default class WorkItemMock extends BaseMock {
|
|
|
102
133
|
addressedGroups: workItem.addressedGroups,
|
|
103
134
|
});
|
|
104
135
|
} else if (taskId === "complete-distribution") {
|
|
136
|
+
this.collection
|
|
137
|
+
.where({ childCaseId: caseId, status: "READY", taskId: "distribution" })
|
|
138
|
+
.update({ status: "COMPLETED", isRedoable: true });
|
|
139
|
+
|
|
105
140
|
this.collection
|
|
106
141
|
.where({ caseId, status: "READY", taskId: "inquiry" })
|
|
107
142
|
.update({ status: "SKIPPED" });
|
|
@@ -116,7 +151,7 @@ export default class WorkItemMock extends BaseMock {
|
|
|
116
151
|
}
|
|
117
152
|
|
|
118
153
|
return this.handleSavePayload.fn.call(this, _, {
|
|
119
|
-
input: { id
|
|
154
|
+
input: { id, status: "COMPLETED" },
|
|
120
155
|
});
|
|
121
156
|
}
|
|
122
157
|
}
|