@projectcaluma/ember-testing 11.0.0-beta.4 → 11.0.0-beta.7

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.
@@ -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
+ }
@@ -60,6 +60,15 @@ export function createBlueprint(server) {
60
60
  type: "TEXTAREA",
61
61
  formIds: [inquiryAnswerForm.id],
62
62
  });
63
+ server.create("question", {
64
+ slug: "inquiry-answer-hint",
65
+ isRequired: "false",
66
+ maxLength: 9999,
67
+ minLength: 0,
68
+ label: "Hint",
69
+ type: "TEXTAREA",
70
+ formIds: [inquiryAnswerForm.id],
71
+ });
63
72
 
64
73
  server.create("workflow", { slug: "distribution" });
65
74
  server.create("workflow", { slug: "inquiry" });
@@ -85,7 +94,10 @@ export function createInquiry(
85
94
  { from, to, remark, deadline },
86
95
  workItemAttrs = {}
87
96
  ) {
88
- const document = server.create("document", { formId: "inquiry" });
97
+ const document = server.create("document", {
98
+ formId: "inquiry",
99
+ modifiedContentByUser: "1",
100
+ });
89
101
 
90
102
  server.create("answer", {
91
103
  document,
@@ -110,11 +122,20 @@ export function createInquiry(
110
122
  });
111
123
  }
112
124
 
125
+ export function withdrawInquiry(server, { inquiry }) {
126
+ inquiry.update({ status: "CANCELED" });
127
+
128
+ return inquiry;
129
+ }
130
+
113
131
  export function sendInquiry(server, { inquiry }) {
114
132
  const childCase = server.create("case", {
115
133
  status: "RUNNING",
116
134
  workflowId: "inquiry",
117
- document: server.create("document", { formId: "inquiry-answer" }),
135
+ document: server.create("document", {
136
+ formId: "inquiry-answer",
137
+ modifiedContentByUser: "1",
138
+ }),
118
139
  });
119
140
 
120
141
  server.create("work-item", {
@@ -129,7 +150,7 @@ export function sendInquiry(server, { inquiry }) {
129
150
  return inquiry;
130
151
  }
131
152
 
132
- export function answerInquiry(server, { inquiry, status, reason }) {
153
+ export function answerInquiry(server, { inquiry, status, reason, hint }) {
133
154
  if (inquiry.status !== "READY") {
134
155
  inquiry = sendInquiry(server, { inquiry });
135
156
  }
@@ -143,7 +164,12 @@ export function answerInquiry(server, { inquiry, status, reason }) {
143
164
  server.create("answer", {
144
165
  document: inquiry.childCase.document,
145
166
  questionId: "inquiry-answer-reason",
146
- value: reason ?? faker.lorem.paragraph(),
167
+ value: reason ?? faker.lorem.paragraphs(3, "\n\n"),
168
+ });
169
+ server.create("answer", {
170
+ document: inquiry.childCase.document,
171
+ questionId: "inquiry-answer-hint",
172
+ value: hint ?? faker.lorem.paragraph(),
147
173
  });
148
174
 
149
175
  inquiry.childCase.workItems
@@ -232,6 +258,7 @@ export default function (server, groups) {
232
258
  const g4 = groups[4];
233
259
 
234
260
  const create = (...args) => createInquiry(server, distributionCase, ...args);
261
+ const withdraw = (...args) => withdrawInquiry(server, ...args);
235
262
  const send = (...args) => sendInquiry(server, ...args);
236
263
  const answer = (...args) => answerInquiry(server, ...args);
237
264
  const confirm = (...args) => confirmInquiry(...args);
@@ -241,6 +268,12 @@ export default function (server, groups) {
241
268
 
242
269
  // controlling
243
270
  create({ from: g, to: g1 });
271
+ withdraw({
272
+ inquiry: create(
273
+ { from: g, to: g2 },
274
+ { id: "4afed640-07a6-4eb9-82a7-b5e961391370" }
275
+ ),
276
+ });
244
277
  send({
245
278
  inquiry: create(
246
279
  {
@@ -279,6 +312,14 @@ export default function (server, groups) {
279
312
  }),
280
313
  });
281
314
 
315
+ // withdrawn inquiry, should not be visible anywhere
316
+ withdraw({
317
+ inquiry: create(
318
+ { from: g, to: g4 },
319
+ { id: "7360fa66-83d2-4f6a-b489-5db46f6fd670" }
320
+ ),
321
+ });
322
+
282
323
  // addressed
283
324
  confirm({
284
325
  inquiry: answer({
@@ -45,7 +45,7 @@ export default Factory.extend({
45
45
  if (answer.value === undefined) {
46
46
  answer.update({
47
47
  value: [
48
- faker.random.arrayElement(answer.question.options.models).slug,
48
+ faker.helpers.arrayElement(answer.question.options.models).slug,
49
49
  ],
50
50
  });
51
51
  }
@@ -54,7 +54,8 @@ export default Factory.extend({
54
54
 
55
55
  if (answer.value === undefined) {
56
56
  answer.update({
57
- value: faker.random.arrayElement(answer.question.options.models).slug,
57
+ value: faker.helpers.arrayElement(answer.question.options.models)
58
+ .slug,
58
59
  });
59
60
  }
60
61
  } else if (answer.question.type === "FILE") {
@@ -8,5 +8,5 @@ export default Factory.extend({
8
8
  createdByUser: () => faker.datatype.uuid(),
9
9
  createdAt: () => faker.date.past(),
10
10
  modifiedAt: () => faker.date.past(),
11
- status: () => faker.random.arrayElement(STATUS),
11
+ status: () => faker.helpers.arrayElement(STATUS),
12
12
  });
@@ -3,4 +3,6 @@ import { Factory } from "miragejs";
3
3
 
4
4
  export default Factory.extend({
5
5
  id: () => faker.datatype.uuid(),
6
+ modifiedContentByUser: () => faker.datatype.uuid(),
7
+ modifiedContentAt: () => faker.date.past(),
6
8
  });
@@ -9,7 +9,7 @@ export default Factory.extend({
9
9
  createdByUser: () => faker.datatype.uuid(),
10
10
  createdAt: () => faker.date.past(),
11
11
  deadline: () => faker.date.future(),
12
- status: () => faker.random.arrayElement(STATUS),
12
+ status: () => faker.helpers.arrayElement(STATUS),
13
13
  addressedGroups: () => ["group1", "group2"],
14
14
  closedAt() {
15
15
  return STATUS.filter((s) => s !== "READY").includes(this.status)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-testing",
3
- "version": "11.0.0-beta.4",
3
+ "version": "11.0.0-beta.7",
4
4
  "description": "Ember addon for testing with Caluma addons.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -14,30 +14,31 @@
14
14
  "test:ember-compatibility": "ember try:each"
15
15
  },
16
16
  "dependencies": {
17
- "@faker-js/faker": "^6.0.0-beta.0",
17
+ "@ember/string": "^3.0.0",
18
+ "@faker-js/faker": "^6.3.1",
18
19
  "broccoli-funnel": "^3.0.8",
19
20
  "broccoli-merge-trees": "^4.2.0",
20
- "ember-apollo-client": "^3.2.0",
21
- "ember-auto-import": "^2.4.0",
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": "^3.0.0-alpha.2",
25
+ "ember-cli-mirage": "^3.0.0-alpha.3",
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.1",
31
+ "luxon": "^2.4.0",
31
32
  "miragejs": "^0.1.43"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@ember/optional-features": "2.0.0",
35
- "@ember/test-helpers": "2.6.0",
36
- "@embroider/test-setup": "1.5.0",
36
+ "@ember/test-helpers": "2.7.0",
37
+ "@embroider/test-setup": "1.6.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",
40
- "ember-cli-dependency-checker": "3.2.0",
41
+ "ember-cli-dependency-checker": "3.3.1",
41
42
  "ember-cli-inject-live-reload": "2.1.0",
42
43
  "ember-cli-sri": "2.1.1",
43
44
  "ember-cli-terser": "4.0.2",
@@ -47,14 +48,14 @@
47
48
  "ember-maybe-import-regenerator": "1.0.0",
48
49
  "ember-qunit": "5.1.5",
49
50
  "ember-resolver": "8.0.3",
50
- "ember-source": "3.28.8",
51
+ "ember-source": "3.28.9",
51
52
  "ember-source-channel-url": "3.0.0",
52
53
  "ember-try": "2.0.0",
53
54
  "graphql-tag": "2.12.6",
54
55
  "loader.js": "4.7.0",
55
- "qunit": "2.18.0",
56
+ "qunit": "2.19.1",
56
57
  "qunit-dom": "2.0.0",
57
- "webpack": "5.70.0"
58
+ "webpack": "5.72.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
- }