@messenger-box/platform-client 0.0.1-alpha.338 → 0.0.1-alpha.346
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
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.0.1-alpha.346](https://github.com/CDEBase/messenger-box/compare/v0.0.1-alpha.345...v0.0.1-alpha.346) (2023-05-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
9
|
+
|
|
6
10
|
## [0.0.1-alpha.338](https://github.com/CDEBase/messenger-box/compare/v0.0.1-alpha.337...v0.0.1-alpha.338) (2023-04-19)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @messenger-box/platform-client
|
package/jest.config.js
CHANGED
|
@@ -4,17 +4,18 @@ const baseConfig = require('../../../jest.config.base');
|
|
|
4
4
|
const mergeData = merge.recursive(
|
|
5
5
|
baseConfig,
|
|
6
6
|
{
|
|
7
|
-
testEnvironment: 'jsdom',
|
|
7
|
+
// testEnvironment: 'jsdom',
|
|
8
8
|
transform: {
|
|
9
9
|
'\\.(js|jsx)?$': '../../../transform.js',
|
|
10
10
|
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
//transformIgnorePatterns: ['<rootDir>/node_modules/(?!(@react-native|react-native|@expo/vector-icons)/).*/'],
|
|
12
|
+
// moduleNameMapper: {
|
|
13
|
+
// '^__mocks__/(.*)$': '<rootDir>/../../__mocks__/$1',
|
|
14
|
+
// // we'll use commonjs version of lodash for tests 👌
|
|
15
|
+
// // because we don't need to use any kind of tree shaking right?!
|
|
16
|
+
// '^lodash-es$': '<rootDir>/../../../node_modules/lodash/index.js',
|
|
17
|
+
// },
|
|
18
|
+
roots: ['src/tests'],
|
|
18
19
|
},
|
|
19
20
|
{
|
|
20
21
|
globals: {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@messenger-box/platform-client",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.346",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"build:lib:watch": "yarn build:lib -- --watch",
|
|
14
14
|
"jest": "./node_modules/.bin/jest",
|
|
15
15
|
"prepublish": "yarn build",
|
|
16
|
-
"test": "jest",
|
|
16
|
+
"test": "jest --updateSnapshot",
|
|
17
17
|
"test:debug": "npm test -- --runInBand",
|
|
18
18
|
"test:watch": "npm test -- --watch",
|
|
19
19
|
"watch": "yarn build:lib:watch"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"typescript": {
|
|
35
35
|
"definition": "lib/index.d.ts"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "54d5cc6da6ef71b82d9a858a7d08754e0879e364"
|
|
38
38
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Set expo token test Set expo token 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"getDeviceToken": {
|
|
6
|
+
"tokens": [
|
|
7
|
+
{
|
|
8
|
+
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRhcnVudXBhZGh5YXlkZXYyMDIyQGdtYWlsLmNvbSIsImlhdCI6MTY3MTE4MTQ1NSwiZXhwIjoxNjcxMjY3ODU1fQ.XQTWTuUW3HUo4pviGgK2bEvd79e4BIYPgLKfItx5OEo",
|
|
9
|
+
"type": "EMAIL_VERIFICATION",
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"token": "ExponentPushToken[_RzGb5J887HIJpVzH9_07h]",
|
|
13
|
+
"type": "EXPO_NOTIFICATION_TOKEN",
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import fetch from 'node-fetch';
|
|
2
|
+
|
|
3
|
+
describe('Set expo token test', () => {
|
|
4
|
+
const API = 'http://localhost:8091/graphql';
|
|
5
|
+
const bearerToken =
|
|
6
|
+
'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlJFRkdOalEzTlRJNFJUY3dNRVV5TXpRNVJFTTNORE0wUkVWRU56VTJOemd6TkRVME16RXpSUSJ9.eyJpc3MiOiJodHRwczovL2Rldi1jZGViYXNlLmF1dGgwLmNvbS8iLCJzdWIiOiJnb29nbGUtb2F1dGgyfDExMzQ4ODQ2MzgxMTAwODMyNDMxNiIsImF1ZCI6WyJodHRwczovL2Rldi1jZGViYXNlLmF1dGgwLmNvbS9hcGkvdjIvIiwiaHR0cHM6Ly9kZXYtY2RlYmFzZS5hdXRoMC5jb20vdXNlcmluZm8iXSwiaWF0IjoxNjgzNzkwNTM4LCJleHAiOjE2ODM4NzY5MzgsImF6cCI6IlQ5WE0yOTJsMzNYYjEyUlZQdlJJZnJiNWhZVFpzUm1lIiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBlbWFpbCByZWFkOmN1cnJlbnRfdXNlciB1cGRhdGU6Y3VycmVudF91c2VyX2lkZW50aXRpZXMgb2ZmbGluZV9hY2Nlc3MifQ.Ft_sRo0f3J0vGCckes0r2AuJpr21KZPgkCow9kRxyCpuoffKNu34o9XebFWNX_fP4GQlT68Nj71EDsQA7AMlvCwv5IvZVeYdTeCYNcDa7FwmXhRsGUxH-lOlqp-KZjKI3BB_AwVUFNh9w5EaEcAXOgqK-00DKbuUniXygH2fckMXevMB1s6q9De167G-YwTmyKbVQUDCNA6pemsgB6CiaZkf2MF_7LETGcSl3TgY-WN6AP9gjZh8HayK3la4sbrfdJ05gIF32yFrSm5kiM84F3y2f-2m6FT6AzbrlBGr3nBaL1vYOYpxrRHOIq3y_HvBGxr4yJGPrZdLcC5VjEoGsg';
|
|
7
|
+
const expoToken = 'ExponentPushToken[_RzGb5J887HIJpVzH9_07h]';
|
|
8
|
+
|
|
9
|
+
it('Set expo token', async () => {
|
|
10
|
+
const tokensquery: any = `
|
|
11
|
+
getDeviceToken
|
|
12
|
+
{
|
|
13
|
+
tokens
|
|
14
|
+
{
|
|
15
|
+
token
|
|
16
|
+
type
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
const query = `
|
|
22
|
+
mutation SetDeviceToken($deviceToken: String) {
|
|
23
|
+
setDeviceToken(deviceToken: $deviceToken) {
|
|
24
|
+
tokens {
|
|
25
|
+
token
|
|
26
|
+
type
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
let getTokens = await fetch(API, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
headers: {
|
|
35
|
+
'Content-Type': 'application/json',
|
|
36
|
+
Authorization: bearerToken,
|
|
37
|
+
},
|
|
38
|
+
body: JSON.stringify({
|
|
39
|
+
query: `{${tokensquery}}`,
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
let tokensResponse = await getTokens.json();
|
|
44
|
+
if (tokensResponse) {
|
|
45
|
+
const checkExpoTokens: any =
|
|
46
|
+
tokensResponse?.data?.getDeviceToken?.tokens?.filter(
|
|
47
|
+
(t: any) => t?.type === 'EXPO_NOTIFICATION_TOKEN' && t?.token == expoToken,
|
|
48
|
+
) ?? null;
|
|
49
|
+
|
|
50
|
+
if (checkExpoTokens && checkExpoTokens?.length == 0) {
|
|
51
|
+
let response = await fetch(API, {
|
|
52
|
+
method: 'POST',
|
|
53
|
+
headers: {
|
|
54
|
+
'Content-Type': 'application/json',
|
|
55
|
+
Authorization: bearerToken,
|
|
56
|
+
},
|
|
57
|
+
body: JSON.stringify({
|
|
58
|
+
query,
|
|
59
|
+
variables: {
|
|
60
|
+
deviceToken: expoToken,
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
let result = await response.json();
|
|
65
|
+
if (result) expect(result?.data).toMatchSnapshot();
|
|
66
|
+
} else expect(tokensResponse?.data).toMatchSnapshot();
|
|
67
|
+
} else {
|
|
68
|
+
let response = await fetch(API, {
|
|
69
|
+
method: 'POST',
|
|
70
|
+
headers: {
|
|
71
|
+
'Content-Type': 'application/json',
|
|
72
|
+
Authorization: bearerToken,
|
|
73
|
+
},
|
|
74
|
+
body: JSON.stringify({
|
|
75
|
+
query,
|
|
76
|
+
variables: {
|
|
77
|
+
deviceToken: expoToken,
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
});
|
|
81
|
+
let result = await response.json();
|
|
82
|
+
expect(result?.data).toMatchSnapshot();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|