@webresto/graphql 1.3.7 → 1.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. package/.gitattributes +2 -0
  2. package/.gitlab-ci.yml +18 -0
  3. package/.vscode/extensions.json +5 -0
  4. package/docs/actions.md +25 -0
  5. package/docs/authorization.md +215 -0
  6. package/docs/captcha.md +71 -0
  7. package/docs/device-id.md +30 -0
  8. package/docs/messages.md +10 -0
  9. package/docs/user.md +54 -0
  10. package/index.d.ts +0 -1
  11. package/index.js +6 -2
  12. package/index.ts +2 -2
  13. package/lib/afterHook.js +8 -0
  14. package/lib/afterHook.ts +9 -0
  15. package/lib/bindTranslations.d.ts +1 -0
  16. package/lib/bindTranslations.js +40 -0
  17. package/lib/bindTranslations.ts +39 -0
  18. package/lib/defaults.d.ts +1 -0
  19. package/lib/defaults.js +49 -10
  20. package/lib/defaults.ts +55 -0
  21. package/lib/eventHelper.d.ts +14 -5
  22. package/lib/eventHelper.js +28 -9
  23. package/lib/eventHelper.ts +41 -8
  24. package/lib/getRecomended.d.ts +1 -0
  25. package/lib/getRecomended.js +29 -0
  26. package/lib/getRecomended.ts +31 -0
  27. package/lib/graphqlHelper.d.ts +3 -4
  28. package/lib/graphqlHelper.js +184 -72
  29. package/lib/graphqlHelper.ts +329 -185
  30. package/lib/jwt.d.ts +10 -0
  31. package/lib/jwt.js +43 -0
  32. package/lib/jwt.ts +61 -0
  33. package/package.json +13 -6
  34. package/src/additionalResolvers.d.ts +72 -9
  35. package/src/additionalResolvers.js +93 -24
  36. package/src/additionalResolvers.ts +105 -34
  37. package/src/graphql.d.ts +5 -3
  38. package/src/graphql.js +170 -37
  39. package/src/graphql.ts +210 -60
  40. package/src/resolvers/bonusProgram.d.ts +32 -0
  41. package/src/resolvers/bonusProgram.js +65 -0
  42. package/src/resolvers/bonusProgram.ts +79 -0
  43. package/src/resolvers/captcha.d.ts +11 -0
  44. package/src/resolvers/captcha.js +19 -0
  45. package/src/resolvers/captcha.ts +16 -0
  46. package/src/resolvers/checkout.d.ts +35 -16
  47. package/src/resolvers/checkout.js +171 -94
  48. package/src/resolvers/checkout.ts +214 -104
  49. package/src/resolvers/dishAndModifier.js +8 -4
  50. package/src/resolvers/dishAndModifier.ts +4 -0
  51. package/src/resolvers/error.d.ts +9 -0
  52. package/src/resolvers/error.js +21 -0
  53. package/src/resolvers/error.ts +21 -0
  54. package/src/resolvers/menu.d.ts +9 -0
  55. package/src/resolvers/menu.js +12 -0
  56. package/src/resolvers/menu.ts +10 -0
  57. package/src/resolvers/order.d.ts +527 -0
  58. package/src/resolvers/order.js +349 -0
  59. package/src/resolvers/order.ts +435 -0
  60. package/src/resolvers/paymentMethod.js +7 -3
  61. package/src/resolvers/paymentMethod.ts +9 -5
  62. package/src/resolvers/pickupPoint.d.ts +1 -0
  63. package/src/resolvers/pickupPoint.js +24 -0
  64. package/src/resolvers/pickupPoint.ts +23 -0
  65. package/src/resolvers/recomended.d.ts +13 -0
  66. package/src/resolvers/recomended.js +80 -0
  67. package/src/resolvers/recomended.ts +86 -0
  68. package/src/resolvers/restrictions.d.ts +37 -1
  69. package/src/resolvers/restrictions.js +100 -15
  70. package/src/resolvers/restrictions.ts +106 -14
  71. package/src/resolvers/streets.d.ts +1 -1
  72. package/src/resolvers/streets.js +1 -4
  73. package/src/resolvers/streets.ts +1 -3
  74. package/src/resolvers/subscriptions.d.ts +4 -4
  75. package/src/resolvers/subscriptions.js +49 -12
  76. package/src/resolvers/subscriptions.ts +59 -14
  77. package/src/resolvers/telemetry.d.ts +14 -0
  78. package/src/resolvers/telemetry.js +25 -0
  79. package/src/resolvers/telemetry.ts +24 -0
  80. package/src/resolvers/user.d.ts +82 -0
  81. package/src/resolvers/user.js +416 -0
  82. package/src/resolvers/user.ts +621 -0
  83. package/src/resolvers/userLocation.d.ts +53 -0
  84. package/src/resolvers/userLocation.js +74 -0
  85. package/src/resolvers/userLocation.ts +125 -0
  86. package/src/resolvers/userOTPrequest.d.ts +21 -0
  87. package/src/resolvers/userOTPrequest.js +57 -0
  88. package/src/resolvers/userOTPrequest.ts +75 -0
  89. package/test/e2e_helper.js +157 -0
  90. package/test/e2e_helper.ts +212 -0
  91. package/test/fixture/config/i18n.js +7 -20
  92. package/test/fixture/config/locales/de.json +1 -0
  93. package/test/fixture/config/locales/en.json +10 -0
  94. package/test/fixture/config/locales/es.json +3 -0
  95. package/test/fixture/config/locales/fr.json +1 -0
  96. package/test/fixture/config/log.js +1 -1
  97. package/test/fixture/package.json +5 -6
  98. package/test/fixture/patches/rttc+10.0.1.patch +17 -0
  99. package/test/integration/captcha.test.js +20 -0
  100. package/test/integration/captcha.test.ts +25 -0
  101. package/test/integration/dish.test.js +35 -0
  102. package/test/integration/dish.test.ts +43 -0
  103. package/test/integration/graphql.test.js +5 -2
  104. package/test/integration/graphql.test.ts +2 -4
  105. package/test/integration/images.test.js +35 -0
  106. package/test/integration/images.test.ts +40 -0
  107. package/test/integration/locale.test.js +26 -0
  108. package/test/integration/locale.test.ts +32 -0
  109. package/test/integration/order.test.js +56 -43
  110. package/test/integration/order.test.ts +59 -59
  111. package/test/integration/subscriptions.test.js +136 -0
  112. package/test/integration/subscriptions.test.ts +162 -0
  113. package/test/integration/user.test.js +249 -0
  114. package/test/integration/user.test.ts +299 -0
  115. package/test/unit/first.test.js +4 -2
  116. package/test/unit/first.test.ts +1 -1
  117. package/test/unit/get-recomended.test.js +56 -0
  118. package/test/unit/get-recomended.test.ts +63 -0
  119. package/translations/de.json +2 -0
  120. package/translations/en.json +3 -0
  121. package/translations/es.json +3 -0
  122. package/translations/fr.json +2 -0
  123. package/translations/ru.json +36 -0
  124. package/tsconfig.json +20 -5
  125. package/types/global.d.ts +30 -0
  126. package/types/global.js +2 -0
  127. package/types/global.ts +31 -0
  128. package/types/primitives.d.ts +19 -0
  129. package/types/references.d.ts +1 -0
  130. package/types/restoGraphQLConfig.d.ts +13 -0
  131. package/lib/afterHook.ts___graphql-transport-ws +0 -138
  132. package/lib/afterHook.ts___graphql-ws +0 -133
  133. package/lib/errorWrapper.d.ts +0 -4
  134. package/lib/errorWrapper.js +0 -13
  135. package/lib/errorWrapper.ts +0 -12
  136. package/notes.md +0 -1976
  137. package/src/resolvers/cart.d.ts +0 -343
  138. package/src/resolvers/cart.js +0 -196
  139. package/src/resolvers/cart.ts +0 -278
  140. package/test/fixture/config/connections.js +0 -9
  141. package/test/integration/sails_not_crash.test.js +0 -3
  142. package/test/integration/sails_not_crash.test.ts +0 -3
@@ -0,0 +1,212 @@
1
+ //
2
+ // E2E Test Setup
3
+ // e2e_helpers.js
4
+ //
5
+
6
+ import { getMainDefinition } from "@apollo/client/utilities";
7
+ import { WebSocketLink } from "@apollo/client/link/ws";
8
+ import fetch from "cross-fetch";
9
+ import * as ws from "ws";
10
+ import axios from "axios";
11
+
12
+ import {
13
+ split,
14
+ HttpLink,
15
+ ApolloClient,
16
+ InMemoryCache,
17
+ DocumentNode,
18
+ SubscriptionOptions,
19
+ } from "@apollo/client";
20
+
21
+ const host = "127.0.0.1";
22
+ const port = process.env.PORT === undefined ? "42772" : process.env.PORT;
23
+
24
+ export type TestServerInfo = {
25
+ port: string;
26
+ host: string;
27
+ };
28
+
29
+
30
+ /**
31
+ * Our test apollo client <3
32
+ *
33
+ * @export
34
+ * @class TestApolloClient
35
+ * @extends {ApolloClient<any>}
36
+ */
37
+ export class TestApolloClient extends ApolloClient<any> {
38
+ private wsLink: WebSocketLink;
39
+
40
+ constructor(serverInfo: TestServerInfo) {
41
+ const { host } = serverInfo;
42
+
43
+ const wsLink = new WebSocketLink({
44
+ // @TODO: Update WS url
45
+ uri: `ws://${host}:${port}/graphql`,
46
+ webSocketImpl: ws,
47
+ options: {
48
+ reconnect: false,
49
+ connectionParams: {
50
+ Authorization: "Bearer dummy",
51
+ },
52
+ },
53
+ });
54
+
55
+ const httpLink = new HttpLink({
56
+ // @TODO: update HTTP url
57
+ uri: `http://${host}:${port}/graphql`,
58
+ fetch: fetch,
59
+ });
60
+
61
+ const splitLink = split(
62
+ ({ query }) => {
63
+ const definition = getMainDefinition(query);
64
+ return (
65
+ definition.kind === "OperationDefinition" &&
66
+ definition.operation === "subscription"
67
+ );
68
+ },
69
+ wsLink,
70
+ httpLink
71
+ );
72
+
73
+ super({
74
+ link: splitLink,
75
+ cache: new InMemoryCache(),
76
+ });
77
+
78
+ this.wsLink = wsLink;
79
+ }
80
+
81
+ stop() {
82
+ super.stop();
83
+ //
84
+ // This is important, or else your test session will never close.
85
+ // Also the reason it inherits from ApolloClient instead of just creating it
86
+ // That way we can sneak in that WS closing
87
+ //
88
+ (this.wsLink as any).subscriptionClient.close();
89
+ }
90
+ }
91
+
92
+ //
93
+ //
94
+ // A very rough helper for testing subscription
95
+ //
96
+ // @TODO: look into finding better alternatives
97
+ //
98
+ //
99
+
100
+ type SubscriptionTestParams = {
101
+ client: TestApolloClient;
102
+ query: DocumentNode;
103
+ variables?: SubscriptionOptions;
104
+ };
105
+
106
+ type WaitCondition = () => boolean;
107
+
108
+ /**
109
+ * Helper to create a subscription with a bunch of handy methods
110
+ *
111
+ * @export
112
+ * @param {SubscriptionTestParams} params
113
+ * @returns
114
+ */
115
+ export function createSubscription(params: SubscriptionTestParams) {
116
+ const results: any[] = [];
117
+
118
+ let error: any;
119
+
120
+ let observer = params.client
121
+ .subscribe({
122
+ errorPolicy: "all",
123
+ query: params.query,
124
+ variables: params.variables || {},
125
+ })
126
+ .subscribe({
127
+ next(data) {
128
+ results.push(data);
129
+ },
130
+ error: (err) => {
131
+ error = err;
132
+ },
133
+ });
134
+
135
+ return {
136
+ results,
137
+ observer,
138
+
139
+ disconnect() {
140
+ observer.unsubscribe();
141
+ },
142
+
143
+ wait(ms: number = 100) {
144
+ return new Promise((done) => {
145
+ setTimeout(() => {
146
+ done(null);
147
+ }, ms);
148
+ });
149
+ },
150
+
151
+ waitForResults(opts: { len?: number; timeout?: number } = {}) {
152
+ return new Promise((done, fail) => {
153
+ let step = 50;
154
+ let sum = 0;
155
+ let timeout = opts.timeout ?? 3000;
156
+ let len = opts.len ?? 1;
157
+
158
+ const interval = setInterval(() => {
159
+ if (!error && results.length >= len) {
160
+ clearInterval(interval);
161
+ return done(results);
162
+ }
163
+ if (error || sum >= timeout) {
164
+ error =
165
+ error ||
166
+ new Error(
167
+ `Timeout: subscription did not receive the expected results after ${timeout}ms`
168
+ );
169
+ clearInterval(interval);
170
+ return fail(error);
171
+ }
172
+ sum += step;
173
+ }, step);
174
+ });
175
+ },
176
+
177
+ get triggerCount() {
178
+ return results.length;
179
+ },
180
+
181
+ get error() {
182
+ return error;
183
+ },
184
+ };
185
+ }
186
+
187
+ export async function runGQL(query: string, headersOrToken?: string | any, variables?: string ): Promise<{[key: string]: any}> {
188
+ return new Promise((resolve, reject) => {
189
+ let headers = headersOrToken;
190
+ // Except stringToken
191
+ if (typeof headersOrToken === "string") {
192
+ headers = {
193
+ Authorization: `${headersOrToken}`,
194
+ };
195
+ }
196
+
197
+ axios
198
+ .post(`http://${host}:${port}/graphql`, { query, variables }, { headers })
199
+ .then((response) => {
200
+ if(response.data.errors) {
201
+ console.log(response.data.errors)
202
+ return resolve(response.data)
203
+ }
204
+ return resolve(response.data);
205
+ })
206
+
207
+ .catch((error) => {
208
+ console.log(error.response.data.errors)
209
+ return resolve(error.response.data);
210
+ });
211
+ });
212
+ }
@@ -5,14 +5,11 @@
5
5
  * If your app will touch people from all over the world, i18n (or internationalization)
6
6
  * may be an important part of your international strategy.
7
7
  *
8
+ * For a complete list of options for Sails' built-in i18n support, see:
9
+ * https://sailsjs.com/config/i-18-n
8
10
  *
9
- * For more informationom i18n in Sails, check out:
10
- * http://sailsjs.org/#!/documentation/concepts/Internationalization
11
- *
12
- * For a complete list of i18n options, see:
13
- * https://github.com/mashpie/i18n-node#list-of-configuration-options
14
- *
15
- *
11
+ * For more info on i18n in Sails in general, check out:
12
+ * https://sailsjs.com/docs/concepts/internationalization
16
13
  */
17
14
 
18
15
  module.exports.i18n = {
@@ -23,7 +20,7 @@ module.exports.i18n = {
23
20
  * *
24
21
  ***************************************************************************/
25
22
 
26
- // locales: ['en', 'es', 'fr', 'de'],
23
+ locales: ['en', 'es', 'fr', 'de'],
27
24
 
28
25
  /****************************************************************************
29
26
  * *
@@ -34,16 +31,7 @@ module.exports.i18n = {
34
31
  * *
35
32
  ****************************************************************************/
36
33
 
37
- // defaultLocale: 'en',
38
-
39
- /****************************************************************************
40
- * *
41
- * Automatically add new keys to locale (translation) files when they are *
42
- * encountered during a request? *
43
- * *
44
- ****************************************************************************/
45
-
46
- // updateFiles: false,
34
+ defaultLocale: 'en',
47
35
 
48
36
  /****************************************************************************
49
37
  * *
@@ -52,6 +40,5 @@ module.exports.i18n = {
52
40
  * *
53
41
  ****************************************************************************/
54
42
 
55
- // localesDirectory: '/config/locales'
56
-
43
+ localesDirectory: 'config/locales'
57
44
  };
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1,10 @@
1
+ {
2
+ "Status here": "Status here",
3
+ "Attention": "Attention",
4
+ "Ready for order": "Ready for order",
5
+ "Successfully": "Successfully",
6
+ "Your order is accepted for processing": "Your order is accepted for processing",
7
+ "Success": "Success",
8
+ "OTP sended": "OTP sended",
9
+ "Authorization": "Authorization"
10
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "Status here": "Estado aquí"
3
+ }
@@ -0,0 +1 @@
1
+ {}
@@ -24,6 +24,6 @@ module.exports.log = {
24
24
  * *
25
25
  ***************************************************************************/
26
26
 
27
- level: 'debug'
27
+ level: 'error'
28
28
 
29
29
  };
@@ -7,21 +7,20 @@
7
7
  "dependencies": {
8
8
  "@webresto/core": "file:../../node_modules/@webresto/core",
9
9
  "@webresto/graphql": "file:../..",
10
- "@webresto/worktime": "file:../../node_modules/@webresto/worktime",
11
- "replace-in-file": "^6.3.2",
12
10
  "include-all": "^1.0.8",
13
11
  "rc": "^1.0.1",
14
12
  "request": "^2.88.2",
15
- "sails": "^1.5.0",
16
- "sails-hook-orm": "^2.1.1",
13
+ "sails": "^1.5.3",
14
+ "sails-hook-orm": "^4.0.0",
17
15
  "sails-hook-stateflow": "^1.0.6",
18
- "connect-flash": "^0.1.1",
16
+ "muddy-water": "^1.0.6",
17
+ "patch-package": "^6.4.7",
19
18
  "sails-memory": "^0.10.7"
20
19
  },
21
20
  "scripts": {
22
21
  "debug": "node debug app.js",
23
22
  "start": "node app.js",
24
- "postinstall": "node ./hacks/waterline.js"
23
+ "postinstall": "patch-package --patch-dir=node_modules/muddy-water"
25
24
  },
26
25
  "main": "app.js",
27
26
  "repository": {
@@ -0,0 +1,17 @@
1
+ diff --git a/node_modules/rttc/lib/helpers/types.js b/node_modules/rttc/lib/helpers/types.js
2
+ index a11279d..1181562 100644
3
+ --- a/node_modules/rttc/lib/helpers/types.js
4
+ +++ b/node_modules/rttc/lib/helpers/types.js
5
+ @@ -460,9 +460,11 @@ var TYPES = {
6
+ }
7
+ // Reject RttcRefPlaceholders
8
+ // (this is a special case so there is a placeholder value that ONLY validates against the "ref" type)
9
+ - if (_.isObject(v) && v.constructor.name === 'RttcRefPlaceholder') {
10
+ +
11
+ + if (_.isObject(v) && v.constructor && v.constructor.name === 'RttcRefPlaceholder') {
12
+ return false;
13
+ }
14
+ +
15
+ if (_.isString(v) || _.isNumber(v) || _.isBoolean(v) || _.isPlainObject(v) || _.isArray(v) || _.isNull(v)) {
16
+ return true;
17
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ const e2e_helper_1 = require("../e2e_helper");
5
+ let headers = {
6
+ 'x-device-id': '123testDeviceId',
7
+ };
8
+ describe('Captcha', function () {
9
+ it('get new job', async () => {
10
+ const query = `
11
+ {captchaGetJob(label: "test:123") {
12
+ id
13
+ task
14
+ }}`;
15
+ const result = await (0, e2e_helper_1.runGQL)(query, headers);
16
+ (0, chai_1.expect)(typeof result.data.captchaGetJob.id).to.equal("string");
17
+ (0, chai_1.expect)(typeof result.data.captchaGetJob.task).to.equal("string");
18
+ (0, chai_1.expect)(result.errors).to.be.undefined;
19
+ });
20
+ });
@@ -0,0 +1,25 @@
1
+ import {expect} from "chai"
2
+
3
+ import { runGQL } from "../e2e_helper";
4
+
5
+ let headers = {
6
+ 'x-device-id': '123testDeviceId',
7
+ }
8
+
9
+ describe('Captcha', function () {
10
+ it('get new job', async () => {
11
+ const query = `
12
+ {captchaGetJob(label: "test:123") {
13
+ id
14
+ task
15
+ }}`;
16
+
17
+ const result = await runGQL(query, headers);
18
+
19
+ expect(typeof result.data.captchaGetJob.id).to.equal("string");
20
+ expect(typeof result.data.captchaGetJob.task).to.equal("string");
21
+ expect(result.errors).to.be.undefined;
22
+ });
23
+ });
24
+
25
+
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ const e2e_helper_1 = require("../e2e_helper");
5
+ let headers = {
6
+ 'x-device-id': '123testDeviceId',
7
+ };
8
+ describe('Dishes', function () {
9
+ it('Get by parentGroup list', async () => {
10
+ const query = `#graphql
11
+ {dish (criteria: {parentGroup: [
12
+ "3e43dde8-1bc5-450e-aeb6-8cf2ac1759b2",
13
+ "582fc73f-ebb7-4153-8923-d1fd4a772e96",
14
+ "b6d7ce4b-b604-423d-bdb8-715cc65c5468",
15
+ "3658e9a7-a4ee-4a0f-971b-50b221fba1c5"
16
+ ]}){
17
+ id
18
+ name
19
+ parentGroup
20
+ {
21
+ id
22
+ name
23
+ }
24
+ }}`;
25
+ const result = await (0, e2e_helper_1.runGQL)(query, headers);
26
+ let dishesSeed = require('../fixture/seeds/dish.json');
27
+ let dishesData = {};
28
+ dishesSeed.forEach(function (raw_dish) {
29
+ dishesData[raw_dish.id] = raw_dish;
30
+ });
31
+ result.data.dish.forEach(function (dish) {
32
+ (0, chai_1.expect)(dish.parentGroup.id).to.equal(dishesData[dish.id].parentGroup);
33
+ });
34
+ });
35
+ });
@@ -0,0 +1,43 @@
1
+ import {expect} from "chai"
2
+
3
+ import { runGQL } from "../e2e_helper";
4
+
5
+ let headers = {
6
+ 'x-device-id': '123testDeviceId',
7
+ }
8
+
9
+ describe('Dishes', function () {
10
+ it('Get by parentGroup list', async () => {
11
+ const query = `#graphql
12
+ {dish (criteria: {parentGroup: [
13
+ "3e43dde8-1bc5-450e-aeb6-8cf2ac1759b2",
14
+ "582fc73f-ebb7-4153-8923-d1fd4a772e96",
15
+ "b6d7ce4b-b604-423d-bdb8-715cc65c5468",
16
+ "3658e9a7-a4ee-4a0f-971b-50b221fba1c5"
17
+ ]}){
18
+ id
19
+ name
20
+ parentGroup
21
+ {
22
+ id
23
+ name
24
+ }
25
+ }}`;
26
+
27
+ const result = await runGQL(query, headers);
28
+
29
+ let dishesSeed = require('../fixture/seeds/dish.json');
30
+ let dishesData = {};
31
+
32
+ dishesSeed.forEach(function (raw_dish) {
33
+ dishesData[raw_dish.id] = raw_dish;
34
+ });
35
+
36
+ result.data.dish.forEach(function (dish) {
37
+ expect(dish.parentGroup.id).to.equal(dishesData[dish.id].parentGroup);
38
+ });
39
+ });
40
+ });
41
+
42
+
43
+
@@ -1,10 +1,13 @@
1
- const expect = require("chai").expect;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // const expect = require("chai").expect;
4
+ const chai_1 = require("chai");
2
5
  describe('GraphQl', function () {
3
6
  it('Added fields exist in schema', async () => {
4
7
  const graphql = require('./../fixture/node_modules/@webresto/graphql/src/graphql').default;
5
8
  const result = await graphql.getServer().executeOperation({
6
9
  query: '{dish { id } \n group { id }}'
7
10
  });
8
- expect(result.errors).to.be.undefined;
11
+ (0, chai_1.expect)(result.errors).to.be.undefined;
9
12
  });
10
13
  });
@@ -1,5 +1,5 @@
1
- const expect = require("chai").expect;
2
-
1
+ // const expect = require("chai").expect;
2
+ import {expect} from "chai"
3
3
  describe('GraphQl', function () {
4
4
  it('Added fields exist in schema', async () => {
5
5
 
@@ -10,5 +10,3 @@ describe('GraphQl', function () {
10
10
  expect(result.errors).to.be.undefined;
11
11
  });
12
12
  });
13
-
14
-
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ describe('Images', function () {
5
+ it('Get by parentGroup list', async () => {
6
+ const graphql = require('./../fixture/node_modules/@webresto/graphql/src/graphql').default;
7
+ const result = await graphql.getServer().executeOperation({
8
+ query: `
9
+ {dish (criteria: {parentGroup: [
10
+ "3e43dde8-1bc5-450e-aeb6-8cf2ac1759b2",
11
+ "582fc73f-ebb7-4153-8923-d1fd4a772e96",
12
+ "b6d7ce4b-b604-423d-bdb8-715cc65c5468",
13
+ "3658e9a7-a4ee-4a0f-971b-50b221fba1c5"
14
+ ]}){
15
+ id
16
+ name
17
+ parentGroup
18
+ {
19
+ id
20
+ name
21
+ }
22
+ }}
23
+ `
24
+ });
25
+ let dishesSeed = require('../fixture/seeds/dish.json');
26
+ let dishesData = {};
27
+ dishesSeed.forEach(function (raw_dish) {
28
+ dishesData[raw_dish.id] = raw_dish;
29
+ // console.log(2222,dishesData[raw_dish.id])
30
+ });
31
+ result.data.dish.forEach(function (dish) {
32
+ (0, chai_1.expect)(dish.parentGroup.id).to.equal(dishesData[dish.id].parentGroup);
33
+ });
34
+ });
35
+ });
@@ -0,0 +1,40 @@
1
+ import {expect} from "chai"
2
+
3
+ describe('Images', function () {
4
+ it('Get by parentGroup list', async () => {
5
+
6
+ const graphql = require('./../fixture/node_modules/@webresto/graphql/src/graphql').default;
7
+ const result = await graphql.getServer().executeOperation({
8
+ query: `
9
+ {dish (criteria: {parentGroup: [
10
+ "3e43dde8-1bc5-450e-aeb6-8cf2ac1759b2",
11
+ "582fc73f-ebb7-4153-8923-d1fd4a772e96",
12
+ "b6d7ce4b-b604-423d-bdb8-715cc65c5468",
13
+ "3658e9a7-a4ee-4a0f-971b-50b221fba1c5"
14
+ ]}){
15
+ id
16
+ name
17
+ parentGroup
18
+ {
19
+ id
20
+ name
21
+ }
22
+ }}
23
+ `
24
+ });
25
+ let dishesSeed = require('../fixture/seeds/dish.json')
26
+ let dishesData = {}
27
+
28
+ dishesSeed.forEach(function(raw_dish){
29
+ dishesData[raw_dish.id] = raw_dish
30
+ // console.log(2222,dishesData[raw_dish.id])
31
+ })
32
+
33
+
34
+ result.data.dish.forEach( function(dish){
35
+ expect(dish.parentGroup.id).to.equal(dishesData[dish.id].parentGroup);
36
+ });
37
+ });
38
+ });
39
+
40
+
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ const e2e_helper_1 = require("../e2e_helper");
5
+ let headers = {
6
+ 'x-device-id': '123testDeviceId',
7
+ };
8
+ describe('Locale', function () {
9
+ it('Check change locale', async () => {
10
+ const query = `
11
+ {telemetry {
12
+ i18n
13
+ locale
14
+ }}`;
15
+ const result = await (0, e2e_helper_1.runGQL)(query, headers);
16
+ (0, chai_1.expect)(result.data.telemetry.i18n).to.equal("Status here");
17
+ (0, chai_1.expect)(result.data.telemetry.locale).to.equal("en");
18
+ (0, chai_1.expect)(result.errors).to.be.undefined;
19
+ // Español
20
+ headers['accept-language'] = 'es';
21
+ const result_es = await (0, e2e_helper_1.runGQL)(query, headers);
22
+ (0, chai_1.expect)(result_es.data.telemetry.i18n).to.equal("Estado aquí");
23
+ (0, chai_1.expect)(result_es.data.telemetry.locale).to.equal("es");
24
+ (0, chai_1.expect)(result_es.errors).to.be.undefined;
25
+ });
26
+ });
@@ -0,0 +1,32 @@
1
+ import { expect } from "chai";
2
+ import { runGQL } from "../e2e_helper";
3
+
4
+ let headers = {
5
+ 'x-device-id': '123testDeviceId',
6
+ }
7
+
8
+ describe('Locale', function () {
9
+ it('Check change locale', async () => {
10
+ const query = `
11
+ {telemetry {
12
+ i18n
13
+ locale
14
+ }}`;
15
+
16
+ const result = await runGQL(query, headers);
17
+
18
+ expect(result.data.telemetry.i18n).to.equal("Status here");
19
+ expect(result.data.telemetry.locale).to.equal("en");
20
+ expect(result.errors).to.be.undefined;
21
+
22
+ // Español
23
+ headers['accept-language'] = 'es';
24
+ const result_es = await runGQL(query, headers);
25
+ expect(result_es.data.telemetry.i18n).to.equal("Estado aquí");
26
+ expect(result_es.data.telemetry.locale).to.equal("es");
27
+ expect(result_es.errors).to.be.undefined;
28
+
29
+ });
30
+ });
31
+
32
+