@projectcaluma/ember-testing 11.0.0-beta.3 → 11.0.0-beta.6
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 +39 -0
- package/addon/mirage-graphql/deserialize.js +13 -0
- package/addon/mirage-graphql/filters/answer.js +1 -1
- package/addon/mirage-graphql/filters/base.js +3 -3
- 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 +1 -1
- package/addon/mirage-graphql/index.js +59 -63
- package/addon/mirage-graphql/mocks/answer.js +2 -2
- package/addon/mirage-graphql/mocks/base.js +6 -8
- 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 +2 -2
- package/addon/mirage-graphql/mocks/work-item.js +18 -5
- package/addon/mirage-graphql/register.js +20 -0
- package/addon/mirage-graphql/schema.graphql +1380 -882
- package/addon/mirage-graphql/serialize.js +14 -0
- package/addon/scenarios/distribution.js +31 -2
- package/addon-mirage-support/factories/form.js +1 -0
- package/package.json +11 -10
- package/addon/mirage-graphql/handler.js +0 -60
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { classify } from "@ember/string";
|
|
2
|
+
|
|
3
|
+
export default function serialize(deserialized = {}, type) {
|
|
4
|
+
const __typename = [deserialized.type?.toLowerCase(), type]
|
|
5
|
+
.filter(Boolean)
|
|
6
|
+
.map(classify)
|
|
7
|
+
.join("");
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
...deserialized,
|
|
11
|
+
id: btoa(`${__typename}:${deserialized.id}`),
|
|
12
|
+
__typename,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -2,8 +2,16 @@ import { faker } from "@faker-js/faker";
|
|
|
2
2
|
import { DateTime } from "luxon";
|
|
3
3
|
|
|
4
4
|
export function createBlueprint(server) {
|
|
5
|
-
const inquiryForm = server.create("form", {
|
|
6
|
-
|
|
5
|
+
const inquiryForm = server.create("form", {
|
|
6
|
+
name: "Inquiry",
|
|
7
|
+
slug: "inquiry",
|
|
8
|
+
isPublished: false,
|
|
9
|
+
});
|
|
10
|
+
const inquiryAnswerForm = server.create("form", {
|
|
11
|
+
name: "Inquiry answer",
|
|
12
|
+
slug: "inquiry-answer",
|
|
13
|
+
isPublished: false,
|
|
14
|
+
});
|
|
7
15
|
|
|
8
16
|
server.create("question", {
|
|
9
17
|
slug: "inquiry-remark",
|
|
@@ -102,6 +110,12 @@ export function createInquiry(
|
|
|
102
110
|
});
|
|
103
111
|
}
|
|
104
112
|
|
|
113
|
+
export function withdrawInquiry(server, { inquiry }) {
|
|
114
|
+
inquiry.update({ status: "CANCELED" });
|
|
115
|
+
|
|
116
|
+
return inquiry;
|
|
117
|
+
}
|
|
118
|
+
|
|
105
119
|
export function sendInquiry(server, { inquiry }) {
|
|
106
120
|
const childCase = server.create("case", {
|
|
107
121
|
status: "RUNNING",
|
|
@@ -224,6 +238,7 @@ export default function (server, groups) {
|
|
|
224
238
|
const g4 = groups[4];
|
|
225
239
|
|
|
226
240
|
const create = (...args) => createInquiry(server, distributionCase, ...args);
|
|
241
|
+
const withdraw = (...args) => withdrawInquiry(server, ...args);
|
|
227
242
|
const send = (...args) => sendInquiry(server, ...args);
|
|
228
243
|
const answer = (...args) => answerInquiry(server, ...args);
|
|
229
244
|
const confirm = (...args) => confirmInquiry(...args);
|
|
@@ -233,6 +248,12 @@ export default function (server, groups) {
|
|
|
233
248
|
|
|
234
249
|
// controlling
|
|
235
250
|
create({ from: g, to: g1 });
|
|
251
|
+
withdraw({
|
|
252
|
+
inquiry: create(
|
|
253
|
+
{ from: g, to: g2 },
|
|
254
|
+
{ id: "4afed640-07a6-4eb9-82a7-b5e961391370" }
|
|
255
|
+
),
|
|
256
|
+
});
|
|
236
257
|
send({
|
|
237
258
|
inquiry: create(
|
|
238
259
|
{
|
|
@@ -271,6 +292,14 @@ export default function (server, groups) {
|
|
|
271
292
|
}),
|
|
272
293
|
});
|
|
273
294
|
|
|
295
|
+
// withdrawn inquiry, should not be visible anywhere
|
|
296
|
+
withdraw({
|
|
297
|
+
inquiry: create(
|
|
298
|
+
{ from: g, to: g4 },
|
|
299
|
+
{ id: "7360fa66-83d2-4f6a-b489-5db46f6fd670" }
|
|
300
|
+
),
|
|
301
|
+
});
|
|
302
|
+
|
|
274
303
|
// addressed
|
|
275
304
|
confirm({
|
|
276
305
|
inquiry: answer({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-testing",
|
|
3
|
-
"version": "11.0.0-beta.
|
|
3
|
+
"version": "11.0.0-beta.6",
|
|
4
4
|
"description": "Ember addon for testing with Caluma addons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -14,26 +14,27 @@
|
|
|
14
14
|
"test:ember-compatibility": "ember try:each"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
17
|
+
"@ember/string": "^3.0.0",
|
|
18
|
+
"@faker-js/faker": "^6.1.2",
|
|
18
19
|
"broccoli-funnel": "^3.0.8",
|
|
19
20
|
"broccoli-merge-trees": "^4.2.0",
|
|
20
|
-
"ember-apollo-client": "^
|
|
21
|
-
"ember-auto-import": "^2.4.
|
|
21
|
+
"ember-apollo-client": "^4.0.2",
|
|
22
|
+
"ember-auto-import": "^2.4.1",
|
|
22
23
|
"ember-cli-babel": "^7.26.11",
|
|
23
24
|
"ember-cli-htmlbars": "^6.0.1",
|
|
24
|
-
"ember-cli-mirage": "^
|
|
25
|
+
"ember-cli-mirage": "^3.0.0-alpha.2",
|
|
25
26
|
"ember-fetch": "^8.1.1",
|
|
26
27
|
"ember-inflector": "^4.0.2",
|
|
27
28
|
"graphql": "^15.8.0",
|
|
28
29
|
"graphql-iso-date": "^3.6.1",
|
|
29
30
|
"graphql-tools": "^4.0.8",
|
|
30
|
-
"luxon": "^2.3.
|
|
31
|
+
"luxon": "^2.3.1",
|
|
31
32
|
"miragejs": "^0.1.43"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@ember/optional-features": "2.0.0",
|
|
35
|
-
"@ember/test-helpers": "2.
|
|
36
|
-
"@embroider/test-setup": "1.
|
|
36
|
+
"@ember/test-helpers": "2.7.0",
|
|
37
|
+
"@embroider/test-setup": "1.5.0",
|
|
37
38
|
"broccoli-asset-rev": "3.0.0",
|
|
38
39
|
"ember-cli": "3.28.5",
|
|
39
40
|
"ember-cli-code-coverage": "1.0.3",
|
|
@@ -52,9 +53,9 @@
|
|
|
52
53
|
"ember-try": "2.0.0",
|
|
53
54
|
"graphql-tag": "2.12.6",
|
|
54
55
|
"loader.js": "4.7.0",
|
|
55
|
-
"qunit": "2.
|
|
56
|
+
"qunit": "2.18.1",
|
|
56
57
|
"qunit-dom": "2.0.0",
|
|
57
|
-
"webpack": "5.
|
|
58
|
+
"webpack": "5.71.0"
|
|
58
59
|
},
|
|
59
60
|
"engines": {
|
|
60
61
|
"node": "12.* || 14.* || >= 16"
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { classify } from "@ember/string";
|
|
2
|
-
import { singularize } from "ember-inflector";
|
|
3
|
-
import { graphql } from "graphql";
|
|
4
|
-
import {
|
|
5
|
-
GraphQLDate as Date,
|
|
6
|
-
GraphQLDateTime as DateTime,
|
|
7
|
-
} from "graphql-iso-date";
|
|
8
|
-
import { addMockFunctionsToSchema, makeExecutableSchema } from "graphql-tools";
|
|
9
|
-
|
|
10
|
-
import { Mock } from "@projectcaluma/ember-testing/mirage-graphql";
|
|
11
|
-
import typeDefs from "@projectcaluma/ember-testing/mirage-graphql/schema.graphql";
|
|
12
|
-
|
|
13
|
-
export default function (server) {
|
|
14
|
-
return function ({ db }, request) {
|
|
15
|
-
const mocks = db._collections.reduce((m, { name }) => {
|
|
16
|
-
const cls = classify(singularize(name));
|
|
17
|
-
const mock = new Mock(cls, server);
|
|
18
|
-
|
|
19
|
-
return { ...m, ...mock.getHandlers() };
|
|
20
|
-
}, {});
|
|
21
|
-
|
|
22
|
-
const schema = makeExecutableSchema({
|
|
23
|
-
typeDefs,
|
|
24
|
-
resolvers: {
|
|
25
|
-
Date,
|
|
26
|
-
DateTime,
|
|
27
|
-
GenericScalar: {
|
|
28
|
-
serialize(value) {
|
|
29
|
-
return typeof value === "string" ? JSON.parse(value) : value;
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
resolverValidationOptions: { requireResolversForResolveType: false },
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const { query, variables } = JSON.parse(request.requestBody);
|
|
37
|
-
|
|
38
|
-
addMockFunctionsToSchema({
|
|
39
|
-
schema,
|
|
40
|
-
mocks: {
|
|
41
|
-
...mocks,
|
|
42
|
-
JSONString: () => JSON.stringify({}),
|
|
43
|
-
GenericScalar: () => ({}),
|
|
44
|
-
Node: (_, { id }) => ({ __typename: atob(id).split(":")[0] }),
|
|
45
|
-
SelectedOption: ({ value }) => {
|
|
46
|
-
const option = server.schema.options.findBy({ slug: value });
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
slug: value,
|
|
50
|
-
label: option.label,
|
|
51
|
-
__typename: "SelectedOption",
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
preserveResolvers: false,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return graphql(schema, query, null, null, variables);
|
|
59
|
-
};
|
|
60
|
-
}
|