@projectcaluma/ember-testing 11.0.0-beta.3 → 11.0.0-beta.30
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 +86 -0
- package/addon/mirage-graphql/deserialize.js +13 -0
- package/addon/mirage-graphql/filters/answer.js +5 -7
- package/addon/mirage-graphql/filters/base.js +42 -24
- package/addon/mirage-graphql/filters/form.js +5 -1
- package/addon/mirage-graphql/filters/index.js +17 -0
- package/addon/mirage-graphql/filters/question.js +1 -1
- package/addon/mirage-graphql/filters/work-item.js +11 -11
- package/addon/mirage-graphql/index.js +59 -63
- package/addon/mirage-graphql/mocks/answer.js +6 -6
- package/addon/mirage-graphql/mocks/base.js +14 -11
- package/addon/mirage-graphql/mocks/form.js +2 -2
- package/addon/mirage-graphql/mocks/index.js +17 -0
- package/addon/mirage-graphql/mocks/question.js +5 -5
- package/addon/mirage-graphql/mocks/work-item.js +57 -12
- package/addon/mirage-graphql/register.js +20 -0
- package/addon/mirage-graphql/schema.graphql +763 -1889
- package/addon/mirage-graphql/serialize.js +14 -0
- package/addon/scenarios/distribution.js +91 -12
- package/addon-mirage-support/factories/answer.js +13 -8
- package/addon-mirage-support/factories/case.js +1 -1
- package/addon-mirage-support/factories/document.js +2 -0
- package/addon-mirage-support/factories/file.js +1 -1
- package/addon-mirage-support/factories/form.js +5 -0
- package/addon-mirage-support/factories/work-item.js +2 -1
- package/addon-mirage-support/models/task.js +1 -0
- package/package.json +19 -20
- package/addon/mirage-graphql/handler.js +0 -60
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
register,
|
|
5
|
-
deserialize,
|
|
6
|
-
} from "@projectcaluma/ember-testing/mirage-graphql";
|
|
1
|
+
import deserialize from "@projectcaluma/ember-testing/mirage-graphql/deserialize";
|
|
7
2
|
import BaseMock from "@projectcaluma/ember-testing/mirage-graphql/mocks/base";
|
|
3
|
+
import register from "@projectcaluma/ember-testing/mirage-graphql/register";
|
|
8
4
|
import { createInquiry } from "@projectcaluma/ember-testing/scenarios/distribution";
|
|
9
5
|
|
|
10
|
-
export default class extends BaseMock {
|
|
6
|
+
export default class WorkItemMock extends BaseMock {
|
|
11
7
|
@register("ResumeWorkItemPayload")
|
|
12
8
|
handleResumeWorkItem(_, { input }) {
|
|
13
9
|
return this.handleSavePayload.fn.call(this, _, {
|
|
@@ -22,6 +18,39 @@ export default class extends BaseMock {
|
|
|
22
18
|
});
|
|
23
19
|
}
|
|
24
20
|
|
|
21
|
+
@register("CancelWorkItemPayload")
|
|
22
|
+
handleCancelWorkItem(_, { input }) {
|
|
23
|
+
return this.handleSavePayload.fn.call(this, _, {
|
|
24
|
+
input: { id: input.id, status: "CANCELED" },
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@register("RedoWorkItemPayload")
|
|
29
|
+
handleRedoWorkItem(_, { input }) {
|
|
30
|
+
const { id } = deserialize(input);
|
|
31
|
+
const workItem = this.collection.find(id);
|
|
32
|
+
const caseId = workItem?.childCaseId;
|
|
33
|
+
|
|
34
|
+
if (workItem.taskId === "distribution") {
|
|
35
|
+
this.collection
|
|
36
|
+
.where({ caseId, taskId: "complete-distribution" })
|
|
37
|
+
.update({ status: "READY" });
|
|
38
|
+
this.collection
|
|
39
|
+
.where({ caseId, taskId: "create-inquiry" })
|
|
40
|
+
.update({ status: "READY" });
|
|
41
|
+
} else if (workItem.taskId === "inquiry") {
|
|
42
|
+
this.server.create("work-item", {
|
|
43
|
+
caseId,
|
|
44
|
+
status: "READY",
|
|
45
|
+
taskId: "adjust-inquiry-answer",
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return this.handleSavePayload.fn.call(this, _, {
|
|
50
|
+
input: { id, isRedoable: false, status: "READY" },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
25
54
|
@register("CompleteWorkItemPayload")
|
|
26
55
|
handleCompleteWorkItem(_, { input }) {
|
|
27
56
|
const { id } = deserialize(input);
|
|
@@ -55,7 +84,7 @@ export default class extends BaseMock {
|
|
|
55
84
|
.update({ status: "CANCELED" });
|
|
56
85
|
this.collection
|
|
57
86
|
.findBy({ childCaseId: caseId })
|
|
58
|
-
.update({ status: "COMPLETED" });
|
|
87
|
+
.update({ status: "COMPLETED", isRedoable: true });
|
|
59
88
|
this.schema.cases.find(caseId).update({ status: "COMPLETED" });
|
|
60
89
|
} else if (taskId === "revise-inquiry-answer") {
|
|
61
90
|
this.collection
|
|
@@ -67,7 +96,7 @@ export default class extends BaseMock {
|
|
|
67
96
|
taskId: "adjust-inquiry-answer",
|
|
68
97
|
});
|
|
69
98
|
} else if (taskId === "create-inquiry") {
|
|
70
|
-
const { addressed_groups: groups } = JSON.parse(input.context);
|
|
99
|
+
const { addressed_groups: groups, answers } = JSON.parse(input.context);
|
|
71
100
|
|
|
72
101
|
groups.forEach((group) => {
|
|
73
102
|
createInquiry(
|
|
@@ -76,8 +105,8 @@ export default class extends BaseMock {
|
|
|
76
105
|
{
|
|
77
106
|
to: { id: group },
|
|
78
107
|
from: { id: workItem.addressedGroups[0] },
|
|
79
|
-
remark: "",
|
|
80
|
-
deadline:
|
|
108
|
+
remark: answers["inquiry-remark"],
|
|
109
|
+
deadline: answers["inquiry-deadline"],
|
|
81
110
|
},
|
|
82
111
|
{
|
|
83
112
|
createdAt: new Date(),
|
|
@@ -96,10 +125,26 @@ export default class extends BaseMock {
|
|
|
96
125
|
status: "READY",
|
|
97
126
|
addressedGroups: workItem.addressedGroups,
|
|
98
127
|
});
|
|
128
|
+
} else if (taskId === "complete-distribution") {
|
|
129
|
+
this.collection
|
|
130
|
+
.where({ childCaseId: caseId, status: "READY", taskId: "distribution" })
|
|
131
|
+
.update({ status: "COMPLETED", isRedoable: true });
|
|
132
|
+
|
|
133
|
+
this.collection
|
|
134
|
+
.where({ caseId, status: "READY", taskId: "inquiry" })
|
|
135
|
+
.update({ status: "SKIPPED" });
|
|
136
|
+
|
|
137
|
+
this.collection
|
|
138
|
+
.where({ caseId, status: "READY" })
|
|
139
|
+
.update({ status: "CANCELED" });
|
|
140
|
+
|
|
141
|
+
this.collection
|
|
142
|
+
.where({ caseId, status: "SUSPENDED" })
|
|
143
|
+
.update({ status: "CANCELED" });
|
|
99
144
|
}
|
|
100
145
|
|
|
101
146
|
return this.handleSavePayload.fn.call(this, _, {
|
|
102
|
-
input: { id
|
|
147
|
+
input: { id, status: "COMPLETED" },
|
|
103
148
|
});
|
|
104
149
|
}
|
|
105
150
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default function register(tpl) {
|
|
2
|
+
return function decorate(target, name, descriptor) {
|
|
3
|
+
if (descriptor.value.__isHandler) {
|
|
4
|
+
descriptor.value.__handlerFor.push(tpl);
|
|
5
|
+
return descriptor;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
descriptor.writable = false;
|
|
9
|
+
descriptor.enumerable = true;
|
|
10
|
+
|
|
11
|
+
descriptor.value = {
|
|
12
|
+
__isHandler: true,
|
|
13
|
+
// Mocks can have multiple handlers per type.
|
|
14
|
+
__handlerFor: [tpl],
|
|
15
|
+
fn: descriptor.value,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return descriptor;
|
|
19
|
+
};
|
|
20
|
+
}
|