@projectcaluma/ember-testing 10.2.0-beta.1 → 11.0.0-beta.3
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 +1023 -0
- package/addon/mirage-graphql/mocks/answer.js +2 -8
- package/addon/mirage-graphql/mocks/base.js +1 -1
- package/addon/mirage-graphql/mocks/work-item.js +33 -0
- package/addon/scenarios/distribution.js +80 -24
- package/addon-mirage-support/factories/answer.js +4 -10
- package/addon-mirage-support/factories/case.js +2 -2
- package/addon-mirage-support/factories/document.js +2 -2
- package/addon-mirage-support/factories/file.js +2 -2
- package/addon-mirage-support/factories/form.js +2 -2
- package/addon-mirage-support/factories/format-validator.js +2 -2
- package/addon-mirage-support/factories/option.js +1 -1
- package/addon-mirage-support/factories/question.js +2 -2
- package/addon-mirage-support/factories/task.js +2 -2
- package/addon-mirage-support/factories/work-item.js +2 -2
- package/addon-mirage-support/factories/workflow.js +1 -1
- package/addon-mirage-support/models/answer.js +1 -1
- package/addon-mirage-support/models/case.js +1 -1
- package/addon-mirage-support/models/document.js +1 -1
- package/addon-mirage-support/models/file.js +1 -1
- package/addon-mirage-support/models/form.js +1 -1
- package/addon-mirage-support/models/format-validator.js +1 -1
- package/addon-mirage-support/models/option.js +1 -1
- package/addon-mirage-support/models/question.js +2 -1
- package/addon-mirage-support/models/task.js +1 -1
- package/addon-mirage-support/models/work-item.js +1 -1
- package/addon-mirage-support/models/workflow.js +1 -1
- package/blueprints/@projectcaluma/ember-testing/index.js +1 -4
- package/package.json +9 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DateTime } from "luxon";
|
|
2
2
|
|
|
3
3
|
import { register } from "@projectcaluma/ember-testing/mirage-graphql";
|
|
4
4
|
import BaseMock from "@projectcaluma/ember-testing/mirage-graphql/mocks/base";
|
|
@@ -74,13 +74,7 @@ export default class extends BaseMock {
|
|
|
74
74
|
@register("SaveDefaultDateAnswerPayload")
|
|
75
75
|
handleSaveDateAnswer(_, { input }) {
|
|
76
76
|
const date = input.value;
|
|
77
|
-
const value = date
|
|
78
|
-
? moment({
|
|
79
|
-
day: date.getUTCDate(),
|
|
80
|
-
month: date.getUTCMonth(),
|
|
81
|
-
year: date.getUTCFullYear(),
|
|
82
|
-
}).format(moment.HTML5_FMT.DATE)
|
|
83
|
-
: null;
|
|
77
|
+
const value = date ? DateTime.fromJSDate(date).toISODate() : null;
|
|
84
78
|
|
|
85
79
|
return this._handleSaveDocumentAnswer(_, {
|
|
86
80
|
...input,
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { DateTime } from "luxon";
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
register,
|
|
3
5
|
deserialize,
|
|
4
6
|
} from "@projectcaluma/ember-testing/mirage-graphql";
|
|
5
7
|
import BaseMock from "@projectcaluma/ember-testing/mirage-graphql/mocks/base";
|
|
8
|
+
import { createInquiry } from "@projectcaluma/ember-testing/scenarios/distribution";
|
|
6
9
|
|
|
7
10
|
export default class extends BaseMock {
|
|
8
11
|
@register("ResumeWorkItemPayload")
|
|
@@ -63,6 +66,36 @@ export default class extends BaseMock {
|
|
|
63
66
|
status: "READY",
|
|
64
67
|
taskId: "adjust-inquiry-answer",
|
|
65
68
|
});
|
|
69
|
+
} else if (taskId === "create-inquiry") {
|
|
70
|
+
const { addressed_groups: groups } = JSON.parse(input.context);
|
|
71
|
+
|
|
72
|
+
groups.forEach((group) => {
|
|
73
|
+
createInquiry(
|
|
74
|
+
this.server,
|
|
75
|
+
workItem.case,
|
|
76
|
+
{
|
|
77
|
+
to: { id: group },
|
|
78
|
+
from: { id: workItem.addressedGroups[0] },
|
|
79
|
+
remark: "",
|
|
80
|
+
deadline: DateTime.now().plus({ days: 30 }).toJSDate(),
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
createdAt: new Date(),
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
this.server.create("work-item", {
|
|
88
|
+
taskId: "create-inquiry",
|
|
89
|
+
status: "READY",
|
|
90
|
+
addressedGroups: [group],
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
this.server.create("work-item", {
|
|
95
|
+
taskId: "create-inquiry",
|
|
96
|
+
status: "READY",
|
|
97
|
+
addressedGroups: workItem.addressedGroups,
|
|
98
|
+
});
|
|
66
99
|
}
|
|
67
100
|
|
|
68
101
|
return this.handleSavePayload.fn.call(this, _, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import faker from "faker";
|
|
2
|
-
import
|
|
1
|
+
import { faker } from "@faker-js/faker";
|
|
2
|
+
import { DateTime } from "luxon";
|
|
3
3
|
|
|
4
4
|
export function createBlueprint(server) {
|
|
5
5
|
const inquiryForm = server.create("form", { slug: "inquiry" });
|
|
@@ -56,6 +56,8 @@ export function createBlueprint(server) {
|
|
|
56
56
|
server.create("workflow", { slug: "distribution" });
|
|
57
57
|
server.create("workflow", { slug: "inquiry" });
|
|
58
58
|
|
|
59
|
+
server.create("task", { slug: "create-inquiry" });
|
|
60
|
+
server.create("task", { slug: "complete-distribution" });
|
|
59
61
|
server.create("task", { slug: "inquiry" });
|
|
60
62
|
server.create("task", {
|
|
61
63
|
slug: "compose-inquiry-answer",
|
|
@@ -188,14 +190,33 @@ export function reviseInquiry(server, { inquiry }) {
|
|
|
188
190
|
return inquiry;
|
|
189
191
|
}
|
|
190
192
|
|
|
191
|
-
export
|
|
192
|
-
createBlueprint(server);
|
|
193
|
-
|
|
193
|
+
export function createCase(server, { group }) {
|
|
194
194
|
const distributionCase = server.create("case", {
|
|
195
|
+
id: "4222ab21-9c89-47de-98be-d62a8ed0ebeb",
|
|
195
196
|
status: "RUNNING",
|
|
196
197
|
workflowId: "distribution",
|
|
197
198
|
});
|
|
198
199
|
|
|
200
|
+
server.create("work-item", {
|
|
201
|
+
case: distributionCase,
|
|
202
|
+
taskId: "create-inquiry",
|
|
203
|
+
status: "READY",
|
|
204
|
+
addressedGroups: [group.id],
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
server.create("work-item", {
|
|
208
|
+
case: distributionCase,
|
|
209
|
+
taskId: "complete-distribution",
|
|
210
|
+
status: "READY",
|
|
211
|
+
addressedGroups: [group.id],
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
return distributionCase;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export default function (server, groups) {
|
|
218
|
+
createBlueprint(server);
|
|
219
|
+
|
|
199
220
|
const g = groups[0];
|
|
200
221
|
const g1 = groups[1];
|
|
201
222
|
const g2 = groups[2];
|
|
@@ -208,22 +229,30 @@ export default function (server, groups) {
|
|
|
208
229
|
const confirm = (...args) => confirmInquiry(...args);
|
|
209
230
|
const revise = (...args) => reviseInquiry(server, ...args);
|
|
210
231
|
|
|
232
|
+
const distributionCase = createCase(server, { group: g });
|
|
233
|
+
|
|
211
234
|
// controlling
|
|
212
235
|
create({ from: g, to: g1 });
|
|
213
236
|
send({
|
|
214
|
-
inquiry: create(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
237
|
+
inquiry: create(
|
|
238
|
+
{
|
|
239
|
+
from: g,
|
|
240
|
+
to: g2,
|
|
241
|
+
deadline: faker.date.past(),
|
|
242
|
+
},
|
|
243
|
+
{ id: "6bbdc36a-3174-4578-93d4-0cb84d3dab97" }
|
|
244
|
+
),
|
|
219
245
|
});
|
|
220
246
|
confirm({
|
|
221
247
|
inquiry: answer({
|
|
222
|
-
inquiry: create(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
248
|
+
inquiry: create(
|
|
249
|
+
{
|
|
250
|
+
from: g,
|
|
251
|
+
to: g3,
|
|
252
|
+
deadline: faker.date.past(),
|
|
253
|
+
},
|
|
254
|
+
{ id: "88999388-daf2-4a18-b7e2-50373d082331" }
|
|
255
|
+
),
|
|
227
256
|
status: "inquiry-answer-status-needs-interaction",
|
|
228
257
|
}),
|
|
229
258
|
});
|
|
@@ -231,7 +260,13 @@ export default function (server, groups) {
|
|
|
231
260
|
// "override" third controlling inquiry
|
|
232
261
|
confirm({
|
|
233
262
|
inquiry: answer({
|
|
234
|
-
inquiry: create(
|
|
263
|
+
inquiry: create(
|
|
264
|
+
{ from: g, to: g3 },
|
|
265
|
+
{
|
|
266
|
+
id: "75d56729-5518-469d-ae66-188a5c32d59d",
|
|
267
|
+
createdAt: faker.date.recent(),
|
|
268
|
+
}
|
|
269
|
+
),
|
|
235
270
|
status: "inquiry-answer-status-positive",
|
|
236
271
|
}),
|
|
237
272
|
});
|
|
@@ -239,7 +274,10 @@ export default function (server, groups) {
|
|
|
239
274
|
// addressed
|
|
240
275
|
confirm({
|
|
241
276
|
inquiry: answer({
|
|
242
|
-
inquiry: create(
|
|
277
|
+
inquiry: create(
|
|
278
|
+
{ from: g2, to: g },
|
|
279
|
+
{ id: "e907584c-a38a-488e-80f7-bab6bb22f303" }
|
|
280
|
+
),
|
|
243
281
|
status: "inquiry-answer-status-needs-interaction",
|
|
244
282
|
}),
|
|
245
283
|
});
|
|
@@ -249,24 +287,36 @@ export default function (server, groups) {
|
|
|
249
287
|
{
|
|
250
288
|
from: g2,
|
|
251
289
|
to: g,
|
|
252
|
-
deadline:
|
|
290
|
+
deadline: DateTime.now().plus({ days: 2 }).toJSDate(),
|
|
253
291
|
},
|
|
254
|
-
{
|
|
292
|
+
{
|
|
293
|
+
id: "4889435d-f310-472f-808b-7b20936c40fc",
|
|
294
|
+
createdAt: faker.date.recent(),
|
|
295
|
+
}
|
|
255
296
|
),
|
|
256
297
|
});
|
|
257
298
|
confirm({
|
|
258
299
|
inquiry: answer({
|
|
259
|
-
inquiry: create(
|
|
300
|
+
inquiry: create(
|
|
301
|
+
{ from: g4, to: g },
|
|
302
|
+
{ id: "4c5dbcc3-f42a-4c25-8d06-f85bd17edbf2" }
|
|
303
|
+
),
|
|
260
304
|
status: "inquiry-answer-status-negative",
|
|
261
305
|
}),
|
|
262
306
|
});
|
|
263
307
|
answer({
|
|
264
|
-
inquiry: create(
|
|
308
|
+
inquiry: create(
|
|
309
|
+
{ from: g3, to: g },
|
|
310
|
+
{ id: "3f7eea45-251d-4934-81fd-27c78bbca88c" }
|
|
311
|
+
),
|
|
265
312
|
status: "inquiry-answer-status-positive",
|
|
266
313
|
});
|
|
267
314
|
revise({
|
|
268
315
|
inquiry: answer({
|
|
269
|
-
inquiry: create(
|
|
316
|
+
inquiry: create(
|
|
317
|
+
{ from: g1, to: g },
|
|
318
|
+
{ id: "dd07b1a4-91e6-4411-a4ea-445637690577" }
|
|
319
|
+
),
|
|
270
320
|
status: "inquiry-answer-status-needs-interaction",
|
|
271
321
|
}),
|
|
272
322
|
});
|
|
@@ -274,13 +324,19 @@ export default function (server, groups) {
|
|
|
274
324
|
// more
|
|
275
325
|
confirm({
|
|
276
326
|
inquiry: answer({
|
|
277
|
-
inquiry: create(
|
|
327
|
+
inquiry: create(
|
|
328
|
+
{ from: g2, to: g3 },
|
|
329
|
+
{ id: "4f374860-28b3-465b-be5f-5e501a39fe8b" }
|
|
330
|
+
),
|
|
278
331
|
status: "inquiry-answer-status-needs-interaction",
|
|
279
332
|
}),
|
|
280
333
|
});
|
|
281
334
|
confirm({
|
|
282
335
|
inquiry: answer({
|
|
283
|
-
inquiry: create(
|
|
336
|
+
inquiry: create(
|
|
337
|
+
{ from: g3, to: g4 },
|
|
338
|
+
{ id: "16eebfae-55c5-4d31-ad48-7ed5578a22a2" }
|
|
339
|
+
),
|
|
284
340
|
status: "inquiry-answer-status-positive",
|
|
285
341
|
}),
|
|
286
342
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { faker } from "@faker-js/faker";
|
|
2
|
+
import { DateTime } from "luxon";
|
|
3
|
+
import { Factory } from "miragejs";
|
|
4
4
|
|
|
5
5
|
export default Factory.extend({
|
|
6
6
|
id: () => faker.datatype.uuid(),
|
|
@@ -73,13 +73,7 @@ export default Factory.extend({
|
|
|
73
73
|
|
|
74
74
|
if (answer.value === undefined) {
|
|
75
75
|
const date = faker.date.future();
|
|
76
|
-
answer.update({
|
|
77
|
-
value: moment({
|
|
78
|
-
day: date.getUTCDate(),
|
|
79
|
-
month: date.getUTCMonth(),
|
|
80
|
-
year: date.getUTCFullYear(),
|
|
81
|
-
}).format(moment.HTML5_FMT.DATE),
|
|
82
|
-
});
|
|
76
|
+
answer.update({ value: DateTime.fromJSDate(date).toISODate() });
|
|
83
77
|
}
|
|
84
78
|
} else if (answer.question.type === "TABLE") {
|
|
85
79
|
answer.update({ type: "TABLE" });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model, hasMany, belongsTo } from "
|
|
1
|
+
import { Model, hasMany, belongsTo } from "miragejs";
|
|
2
2
|
|
|
3
3
|
export default Model.extend({
|
|
4
4
|
forms: hasMany({ inverse: "questions" }),
|
|
@@ -6,4 +6,5 @@ export default Model.extend({
|
|
|
6
6
|
subForm: belongsTo("form", { inverse: null }),
|
|
7
7
|
rowForm: belongsTo("form", { inverse: null }),
|
|
8
8
|
defaultAnswer: belongsTo("answer", { inverse: null }),
|
|
9
|
+
formatValidators: hasMany(),
|
|
9
10
|
});
|
|
@@ -5,10 +5,7 @@ module.exports = {
|
|
|
5
5
|
|
|
6
6
|
afterInstall() {
|
|
7
7
|
return this.addAddonsToProject({
|
|
8
|
-
packages: [
|
|
9
|
-
{ name: "@projectcaluma/ember-core" },
|
|
10
|
-
{ name: "ember-cli-mirage" },
|
|
11
|
-
],
|
|
8
|
+
packages: [{ name: "ember-cli-mirage" }],
|
|
12
9
|
}).then(() => this.addPackagesToProject([{ name: "faker" }]));
|
|
13
10
|
},
|
|
14
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-testing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0-beta.3",
|
|
4
4
|
"description": "Ember addon for testing with Caluma addons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -14,25 +14,26 @@
|
|
|
14
14
|
"test:ember-compatibility": "ember try:each"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
+
"@faker-js/faker": "^6.0.0-alpha.6",
|
|
17
18
|
"broccoli-funnel": "^3.0.8",
|
|
18
19
|
"broccoli-merge-trees": "^4.2.0",
|
|
19
20
|
"ember-apollo-client": "^3.2.0",
|
|
20
|
-
"ember-auto-import": "^2.
|
|
21
|
+
"ember-auto-import": "^2.4.0",
|
|
21
22
|
"ember-cli-babel": "^7.26.11",
|
|
22
23
|
"ember-cli-htmlbars": "^6.0.1",
|
|
23
|
-
"ember-cli-mirage": "^2.
|
|
24
|
-
"ember-fetch": "^8.
|
|
24
|
+
"ember-cli-mirage": "^2.4.0",
|
|
25
|
+
"ember-fetch": "^8.1.1",
|
|
25
26
|
"ember-inflector": "^4.0.2",
|
|
26
|
-
"faker": "^5.5.3",
|
|
27
27
|
"graphql": "^15.8.0",
|
|
28
28
|
"graphql-iso-date": "^3.6.1",
|
|
29
29
|
"graphql-tools": "^4.0.8",
|
|
30
|
-
"
|
|
30
|
+
"luxon": "^2.3.0",
|
|
31
|
+
"miragejs": "^0.1.43"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@ember/optional-features": "2.0.0",
|
|
34
35
|
"@ember/test-helpers": "2.6.0",
|
|
35
|
-
"@embroider/test-setup": "
|
|
36
|
+
"@embroider/test-setup": "1.2.0",
|
|
36
37
|
"broccoli-asset-rev": "3.0.0",
|
|
37
38
|
"ember-cli": "3.28.5",
|
|
38
39
|
"ember-cli-code-coverage": "1.0.3",
|
|
@@ -49,12 +50,11 @@
|
|
|
49
50
|
"ember-source": "3.28.8",
|
|
50
51
|
"ember-source-channel-url": "3.0.0",
|
|
51
52
|
"ember-try": "2.0.0",
|
|
52
|
-
"get-graphql-schema": "2.1.2",
|
|
53
53
|
"graphql-tag": "2.12.6",
|
|
54
54
|
"loader.js": "4.7.0",
|
|
55
55
|
"qunit": "2.17.2",
|
|
56
56
|
"qunit-dom": "2.0.0",
|
|
57
|
-
"webpack": "5.
|
|
57
|
+
"webpack": "5.69.0"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": "12.* || 14.* || >= 16"
|