@projectcaluma/ember-testing 11.0.0-beta.2 → 11.0.0-beta.5
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 +28 -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 +1 -1
- 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 +10 -5
- package/addon/mirage-graphql/register.js +20 -0
- package/addon/mirage-graphql/serialize.js +14 -0
- package/addon/scenarios/distribution.js +84 -27
- package/addon-mirage-support/factories/form.js +1 -0
- package/package.json +9 -8
- package/addon/mirage-graphql/handler.js +0 -60
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
# [@projectcaluma/ember-testing-v11.0.0-beta.5](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-testing-v11.0.0-beta.4...@projectcaluma/ember-testing-v11.0.0-beta.5) (2022-03-23)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **embroider:** add missing dependency on @ember/string ([3a6e6bb](https://github.com/projectcaluma/ember-caluma/commit/3a6e6bb39a8c1a40a2ae00b3d4ea00606a755e25))
|
|
7
|
+
* **embroider:** use factory function instead of dynamic importing ([91459e7](https://github.com/projectcaluma/ember-caluma/commit/91459e7add66139a1f268b6c74dbabd9fa486158))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **testing:** add handler for canceling work items ([51c8024](https://github.com/projectcaluma/ember-caluma/commit/51c80240234fffa36a44a68a695ee7dbf074f1a9))
|
|
13
|
+
* **testing:** extend distribution scenario with withdrawn inquiries ([a190f0f](https://github.com/projectcaluma/ember-caluma/commit/a190f0f7ccceeca2944b1647320c738d81d44733))
|
|
14
|
+
|
|
15
|
+
# [@projectcaluma/ember-testing-v11.0.0-beta.4](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-testing-v11.0.0-beta.3...@projectcaluma/ember-testing-v11.0.0-beta.4) (2022-03-11)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **form-builder:** add new categories published and unpublished ([52c1c1d](https://github.com/projectcaluma/ember-caluma/commit/52c1c1deaf15991e595e042f643889be64b425a0))
|
|
21
|
+
|
|
22
|
+
# [@projectcaluma/ember-testing-v11.0.0-beta.3](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-testing-v11.0.0-beta.2...@projectcaluma/ember-testing-v11.0.0-beta.3) (2022-02-16)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **distribution:** add index page when no inquiries exist ([689089c](https://github.com/projectcaluma/ember-caluma/commit/689089c8f28146a33346f382fe69e7ca1b588d97))
|
|
28
|
+
|
|
1
29
|
# [@projectcaluma/ember-testing-v11.0.0-beta.2](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-testing-v11.0.0-beta.1...@projectcaluma/ember-testing-v11.0.0-beta.2) (2022-02-07)
|
|
2
30
|
|
|
3
31
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default function deserialize(serialized) {
|
|
2
|
+
let decodedId = serialized.id;
|
|
3
|
+
|
|
4
|
+
try {
|
|
5
|
+
decodedId = atob(serialized.id).split(":")[1] || serialized.id;
|
|
6
|
+
} catch (e) {
|
|
7
|
+
// This will happen if the ID is not a relay ID (Type plus ID base64
|
|
8
|
+
// encoded) but just the raw ID. The deserialize function needs to be able
|
|
9
|
+
// to handle both
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return { ...serialized, ...(decodedId ? { id: decodedId } : {}) };
|
|
13
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseFilter from "@projectcaluma/ember-testing/mirage-graphql/filters/base";
|
|
2
2
|
|
|
3
|
-
export default class extends BaseFilter {
|
|
3
|
+
export default class AnswerFilter extends BaseFilter {
|
|
4
4
|
questions(records, value, { invert = false }) {
|
|
5
5
|
return records.filter(
|
|
6
6
|
(record) => invert !== value.includes(record.questionId)
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import BaseFilter from "@projectcaluma/ember-testing/mirage-graphql/filters/base";
|
|
2
2
|
|
|
3
|
-
export default class extends BaseFilter {
|
|
3
|
+
export default class FormFilter extends BaseFilter {
|
|
4
4
|
isArchived(records, value) {
|
|
5
5
|
return records.filter(({ isArchived }) => isArchived === value);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
isPublished(records, value) {
|
|
9
|
+
return records.filter(({ isPublished }) => isPublished === value);
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
search(records, value) {
|
|
9
13
|
const re = new RegExp(`.*${value}.*`, "i");
|
|
10
14
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import AnswerFilter from "@projectcaluma/ember-testing/mirage-graphql/filters/answer";
|
|
2
|
+
import BaseFilter from "@projectcaluma/ember-testing/mirage-graphql/filters/base";
|
|
3
|
+
import FormFilter from "@projectcaluma/ember-testing/mirage-graphql/filters/form";
|
|
4
|
+
import QuestionFilter from "@projectcaluma/ember-testing/mirage-graphql/filters/question";
|
|
5
|
+
import WorkItemFilter from "@projectcaluma/ember-testing/mirage-graphql/filters/work-item";
|
|
6
|
+
|
|
7
|
+
const FILTER_MAPPING = {
|
|
8
|
+
Answer: AnswerFilter,
|
|
9
|
+
Form: FormFilter,
|
|
10
|
+
Question: QuestionFilter,
|
|
11
|
+
WorkItem: WorkItemFilter,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default function createFilter(type, ...args) {
|
|
15
|
+
const FilterClass = FILTER_MAPPING[type] ?? BaseFilter;
|
|
16
|
+
return new FilterClass(type, ...args);
|
|
17
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseFilter from "@projectcaluma/ember-testing/mirage-graphql/filters/base";
|
|
2
2
|
|
|
3
|
-
export default class extends BaseFilter {
|
|
3
|
+
export default class QuestionFilter extends BaseFilter {
|
|
4
4
|
isArchived(records, value) {
|
|
5
5
|
return records.filter(({ isArchived }) => isArchived === value);
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseFilter from "@projectcaluma/ember-testing/mirage-graphql/filters/base";
|
|
2
2
|
|
|
3
|
-
export default class extends BaseFilter {
|
|
3
|
+
export default class WorkItemFilter extends BaseFilter {
|
|
4
4
|
status(records, value, { invert = false }) {
|
|
5
5
|
return records.filter(({ status }) => invert !== (status === value));
|
|
6
6
|
}
|
|
@@ -1,64 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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 createMock from "@projectcaluma/ember-testing/mirage-graphql/mocks";
|
|
11
|
+
import typeDefs from "@projectcaluma/ember-testing/mirage-graphql/schema.graphql";
|
|
12
|
+
|
|
13
|
+
export default function createGraphqlHandler(server) {
|
|
14
|
+
return function graphqlHandler({ db }, request) {
|
|
15
|
+
const mocks = db._collections.reduce((m, { name }) => {
|
|
16
|
+
const cls = classify(singularize(name));
|
|
17
|
+
const mock = createMock(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);
|
|
41
59
|
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const deserialize = (serialized) => {
|
|
45
|
-
let decodedId = serialized.id;
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
decodedId = atob(serialized.id).split(":")[1] || serialized.id;
|
|
49
|
-
} catch (e) {
|
|
50
|
-
// this is expected most times
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return { ...serialized, ...(decodedId ? { id: decodedId } : {}) };
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const Filter = function (type, ...args) {
|
|
57
|
-
return new (importTypeOrBase("./filters", type))(type, ...args);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const Mock = function (type, ...args) {
|
|
61
|
-
return new (importTypeOrBase("./mocks", type))(type, ...args);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export { default } from "./handler";
|
|
60
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DateTime } from "luxon";
|
|
2
2
|
|
|
3
|
-
import { register } from "@projectcaluma/ember-testing/mirage-graphql";
|
|
4
3
|
import BaseMock from "@projectcaluma/ember-testing/mirage-graphql/mocks/base";
|
|
4
|
+
import register from "@projectcaluma/ember-testing/mirage-graphql/register";
|
|
5
5
|
|
|
6
|
-
export default class extends BaseMock {
|
|
6
|
+
export default class AnswerMock extends BaseMock {
|
|
7
7
|
_handleSaveDocumentAnswer(
|
|
8
8
|
_,
|
|
9
9
|
{ question: questionId, document: documentId, value, type }
|
|
@@ -3,12 +3,10 @@ import { faker } from "@faker-js/faker";
|
|
|
3
3
|
import { singularize, pluralize } from "ember-inflector";
|
|
4
4
|
import { MockList } from "graphql-tools";
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
deserialize,
|
|
11
|
-
} from "@projectcaluma/ember-testing/mirage-graphql";
|
|
6
|
+
import deserialize from "@projectcaluma/ember-testing/mirage-graphql/deserialize";
|
|
7
|
+
import createFilter from "@projectcaluma/ember-testing/mirage-graphql/filters";
|
|
8
|
+
import register from "@projectcaluma/ember-testing/mirage-graphql/register";
|
|
9
|
+
import serialize from "@projectcaluma/ember-testing/mirage-graphql/serialize";
|
|
12
10
|
|
|
13
11
|
export const ANSWER_TYPES = [
|
|
14
12
|
"DATE",
|
|
@@ -50,13 +48,13 @@ export const TYPE_MAPPING = {
|
|
|
50
48
|
Task: TASK_TYPES,
|
|
51
49
|
};
|
|
52
50
|
|
|
53
|
-
export default class {
|
|
51
|
+
export default class BaseMock {
|
|
54
52
|
constructor(type, server) {
|
|
55
53
|
this.type = type;
|
|
56
54
|
this.server = server;
|
|
57
55
|
this.schema = server.schema;
|
|
58
56
|
|
|
59
|
-
this.filter =
|
|
57
|
+
this.filter = createFilter(type);
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
get collection() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { register } from "@projectcaluma/ember-testing/mirage-graphql";
|
|
2
1
|
import BaseMock from "@projectcaluma/ember-testing/mirage-graphql/mocks/base";
|
|
2
|
+
import register from "@projectcaluma/ember-testing/mirage-graphql/register";
|
|
3
3
|
|
|
4
|
-
export default class extends BaseMock {
|
|
4
|
+
export default class FormMock extends BaseMock {
|
|
5
5
|
@register("ReorderFormQuestionsPayload")
|
|
6
6
|
handleReorderFormQuestions(_, { input }) {
|
|
7
7
|
return this.handleSavePayload.fn.call(this, _, {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import AnswerMock from "@projectcaluma/ember-testing/mirage-graphql/mocks/answer";
|
|
2
|
+
import BaseMock from "@projectcaluma/ember-testing/mirage-graphql/mocks/base";
|
|
3
|
+
import FormMock from "@projectcaluma/ember-testing/mirage-graphql/mocks/form";
|
|
4
|
+
import QuestionMock from "@projectcaluma/ember-testing/mirage-graphql/mocks/question";
|
|
5
|
+
import WorkItemMock from "@projectcaluma/ember-testing/mirage-graphql/mocks/work-item";
|
|
6
|
+
|
|
7
|
+
const MOCK_MAPPING = {
|
|
8
|
+
Answer: AnswerMock,
|
|
9
|
+
Form: FormMock,
|
|
10
|
+
Question: QuestionMock,
|
|
11
|
+
WorkItem: WorkItemMock,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default function createMock(type, ...args) {
|
|
15
|
+
const MockClass = MOCK_MAPPING[type] ?? BaseMock;
|
|
16
|
+
return new MockClass(type, ...args);
|
|
17
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { register } from "@projectcaluma/ember-testing/mirage-graphql";
|
|
2
1
|
import BaseMock from "@projectcaluma/ember-testing/mirage-graphql/mocks/base";
|
|
2
|
+
import register from "@projectcaluma/ember-testing/mirage-graphql/register";
|
|
3
3
|
|
|
4
|
-
export default class extends BaseMock {
|
|
4
|
+
export default class QuestionMock extends BaseMock {
|
|
5
5
|
@register("SaveTextQuestionPayload")
|
|
6
6
|
handleSaveTextQuestion(_, { input }) {
|
|
7
7
|
return this.handleSavePayload.fn.call(this, _, {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { DateTime } from "luxon";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
register,
|
|
5
|
-
deserialize,
|
|
6
|
-
} from "@projectcaluma/ember-testing/mirage-graphql";
|
|
3
|
+
import deserialize from "@projectcaluma/ember-testing/mirage-graphql/deserialize";
|
|
7
4
|
import BaseMock from "@projectcaluma/ember-testing/mirage-graphql/mocks/base";
|
|
5
|
+
import register from "@projectcaluma/ember-testing/mirage-graphql/register";
|
|
8
6
|
import { createInquiry } from "@projectcaluma/ember-testing/scenarios/distribution";
|
|
9
7
|
|
|
10
|
-
export default class extends BaseMock {
|
|
8
|
+
export default class WorkItemMock extends BaseMock {
|
|
11
9
|
@register("ResumeWorkItemPayload")
|
|
12
10
|
handleResumeWorkItem(_, { input }) {
|
|
13
11
|
return this.handleSavePayload.fn.call(this, _, {
|
|
@@ -22,6 +20,13 @@ export default class extends BaseMock {
|
|
|
22
20
|
});
|
|
23
21
|
}
|
|
24
22
|
|
|
23
|
+
@register("CancelWorkItemPayload")
|
|
24
|
+
handleCancelWorkItem(_, { input }) {
|
|
25
|
+
return this.handleSavePayload.fn.call(this, _, {
|
|
26
|
+
input: { id: input.id, status: "CANCELED" },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
@register("CompleteWorkItemPayload")
|
|
26
31
|
handleCompleteWorkItem(_, { input }) {
|
|
27
32
|
const { id } = deserialize(input);
|
|
@@ -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
|
+
}
|
|
@@ -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",
|
|
@@ -192,6 +206,7 @@ export function reviseInquiry(server, { inquiry }) {
|
|
|
192
206
|
|
|
193
207
|
export function createCase(server, { group }) {
|
|
194
208
|
const distributionCase = server.create("case", {
|
|
209
|
+
id: "4222ab21-9c89-47de-98be-d62a8ed0ebeb",
|
|
195
210
|
status: "RUNNING",
|
|
196
211
|
workflowId: "distribution",
|
|
197
212
|
});
|
|
@@ -223,35 +238,42 @@ export default function (server, groups) {
|
|
|
223
238
|
const g4 = groups[4];
|
|
224
239
|
|
|
225
240
|
const create = (...args) => createInquiry(server, distributionCase, ...args);
|
|
241
|
+
const withdraw = (...args) => withdrawInquiry(server, ...args);
|
|
226
242
|
const send = (...args) => sendInquiry(server, ...args);
|
|
227
243
|
const answer = (...args) => answerInquiry(server, ...args);
|
|
228
244
|
const confirm = (...args) => confirmInquiry(...args);
|
|
229
245
|
const revise = (...args) => reviseInquiry(server, ...args);
|
|
230
246
|
|
|
231
|
-
const distributionCase = createCase(server, { group:
|
|
232
|
-
|
|
233
|
-
server.create("work-item", {
|
|
234
|
-
taskId: "create-inquiry",
|
|
235
|
-
status: "READY",
|
|
236
|
-
addressedGroups: [g.id],
|
|
237
|
-
});
|
|
247
|
+
const distributionCase = createCase(server, { group: g });
|
|
238
248
|
|
|
239
249
|
// controlling
|
|
240
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
|
+
});
|
|
241
257
|
send({
|
|
242
|
-
inquiry: create(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
258
|
+
inquiry: create(
|
|
259
|
+
{
|
|
260
|
+
from: g,
|
|
261
|
+
to: g2,
|
|
262
|
+
deadline: faker.date.past(),
|
|
263
|
+
},
|
|
264
|
+
{ id: "6bbdc36a-3174-4578-93d4-0cb84d3dab97" }
|
|
265
|
+
),
|
|
247
266
|
});
|
|
248
267
|
confirm({
|
|
249
268
|
inquiry: answer({
|
|
250
|
-
inquiry: create(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
269
|
+
inquiry: create(
|
|
270
|
+
{
|
|
271
|
+
from: g,
|
|
272
|
+
to: g3,
|
|
273
|
+
deadline: faker.date.past(),
|
|
274
|
+
},
|
|
275
|
+
{ id: "88999388-daf2-4a18-b7e2-50373d082331" }
|
|
276
|
+
),
|
|
255
277
|
status: "inquiry-answer-status-needs-interaction",
|
|
256
278
|
}),
|
|
257
279
|
});
|
|
@@ -259,15 +281,32 @@ export default function (server, groups) {
|
|
|
259
281
|
// "override" third controlling inquiry
|
|
260
282
|
confirm({
|
|
261
283
|
inquiry: answer({
|
|
262
|
-
inquiry: create(
|
|
284
|
+
inquiry: create(
|
|
285
|
+
{ from: g, to: g3 },
|
|
286
|
+
{
|
|
287
|
+
id: "75d56729-5518-469d-ae66-188a5c32d59d",
|
|
288
|
+
createdAt: faker.date.recent(),
|
|
289
|
+
}
|
|
290
|
+
),
|
|
263
291
|
status: "inquiry-answer-status-positive",
|
|
264
292
|
}),
|
|
265
293
|
});
|
|
266
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
|
+
|
|
267
303
|
// addressed
|
|
268
304
|
confirm({
|
|
269
305
|
inquiry: answer({
|
|
270
|
-
inquiry: create(
|
|
306
|
+
inquiry: create(
|
|
307
|
+
{ from: g2, to: g },
|
|
308
|
+
{ id: "e907584c-a38a-488e-80f7-bab6bb22f303" }
|
|
309
|
+
),
|
|
271
310
|
status: "inquiry-answer-status-needs-interaction",
|
|
272
311
|
}),
|
|
273
312
|
});
|
|
@@ -279,22 +318,34 @@ export default function (server, groups) {
|
|
|
279
318
|
to: g,
|
|
280
319
|
deadline: DateTime.now().plus({ days: 2 }).toJSDate(),
|
|
281
320
|
},
|
|
282
|
-
{
|
|
321
|
+
{
|
|
322
|
+
id: "4889435d-f310-472f-808b-7b20936c40fc",
|
|
323
|
+
createdAt: faker.date.recent(),
|
|
324
|
+
}
|
|
283
325
|
),
|
|
284
326
|
});
|
|
285
327
|
confirm({
|
|
286
328
|
inquiry: answer({
|
|
287
|
-
inquiry: create(
|
|
329
|
+
inquiry: create(
|
|
330
|
+
{ from: g4, to: g },
|
|
331
|
+
{ id: "4c5dbcc3-f42a-4c25-8d06-f85bd17edbf2" }
|
|
332
|
+
),
|
|
288
333
|
status: "inquiry-answer-status-negative",
|
|
289
334
|
}),
|
|
290
335
|
});
|
|
291
336
|
answer({
|
|
292
|
-
inquiry: create(
|
|
337
|
+
inquiry: create(
|
|
338
|
+
{ from: g3, to: g },
|
|
339
|
+
{ id: "3f7eea45-251d-4934-81fd-27c78bbca88c" }
|
|
340
|
+
),
|
|
293
341
|
status: "inquiry-answer-status-positive",
|
|
294
342
|
});
|
|
295
343
|
revise({
|
|
296
344
|
inquiry: answer({
|
|
297
|
-
inquiry: create(
|
|
345
|
+
inquiry: create(
|
|
346
|
+
{ from: g1, to: g },
|
|
347
|
+
{ id: "dd07b1a4-91e6-4411-a4ea-445637690577" }
|
|
348
|
+
),
|
|
298
349
|
status: "inquiry-answer-status-needs-interaction",
|
|
299
350
|
}),
|
|
300
351
|
});
|
|
@@ -302,13 +353,19 @@ export default function (server, groups) {
|
|
|
302
353
|
// more
|
|
303
354
|
confirm({
|
|
304
355
|
inquiry: answer({
|
|
305
|
-
inquiry: create(
|
|
356
|
+
inquiry: create(
|
|
357
|
+
{ from: g2, to: g3 },
|
|
358
|
+
{ id: "4f374860-28b3-465b-be5f-5e501a39fe8b" }
|
|
359
|
+
),
|
|
306
360
|
status: "inquiry-answer-status-needs-interaction",
|
|
307
361
|
}),
|
|
308
362
|
});
|
|
309
363
|
confirm({
|
|
310
364
|
inquiry: answer({
|
|
311
|
-
inquiry: create(
|
|
365
|
+
inquiry: create(
|
|
366
|
+
{ from: g3, to: g4 },
|
|
367
|
+
{ id: "16eebfae-55c5-4d31-ad48-7ed5578a22a2" }
|
|
368
|
+
),
|
|
312
369
|
status: "inquiry-answer-status-positive",
|
|
313
370
|
}),
|
|
314
371
|
});
|
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.5",
|
|
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.0.0",
|
|
18
19
|
"broccoli-funnel": "^3.0.8",
|
|
19
20
|
"broccoli-merge-trees": "^4.2.0",
|
|
20
|
-
"ember-apollo-client": "^
|
|
21
|
+
"ember-apollo-client": "^4.0.2",
|
|
21
22
|
"ember-auto-import": "^2.4.0",
|
|
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
36
|
"@ember/test-helpers": "2.6.0",
|
|
36
|
-
"@embroider/test-setup": "1.
|
|
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.0",
|
|
56
57
|
"qunit-dom": "2.0.0",
|
|
57
|
-
"webpack": "5.
|
|
58
|
+
"webpack": "5.70.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
|
-
}
|