@powersync/service-core-tests 0.12.11 → 0.12.13
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
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @powersync/service-core-tests
|
|
2
2
|
|
|
3
|
+
## 0.12.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 57f7660: General client connections analytics added
|
|
8
|
+
- Updated dependencies [57f7660]
|
|
9
|
+
- Updated dependencies [c050acd]
|
|
10
|
+
- Updated dependencies [0156d10]
|
|
11
|
+
- Updated dependencies [6eee0b3]
|
|
12
|
+
- @powersync/service-core@1.17.0
|
|
13
|
+
- @powersync/service-sync-rules@0.29.8
|
|
14
|
+
|
|
15
|
+
## 0.12.12
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [fff0024]
|
|
20
|
+
- @powersync/service-sync-rules@0.29.7
|
|
21
|
+
- @powersync/service-core@1.16.3
|
|
22
|
+
|
|
3
23
|
## 0.12.11
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -50,14 +50,14 @@ const user_four = {
|
|
|
50
50
|
const user_old = {
|
|
51
51
|
user_id: 'user_one',
|
|
52
52
|
client_id: '',
|
|
53
|
-
connected_at:
|
|
53
|
+
connected_at: nowLess5minutes,
|
|
54
54
|
sdk: 'unknown',
|
|
55
55
|
user_agent: 'Dart (flutter-web) Chrome/128 android',
|
|
56
56
|
jwt_exp: nowAdd5minutes
|
|
57
57
|
};
|
|
58
58
|
const user_week = {
|
|
59
59
|
user_id: 'user_week',
|
|
60
|
-
client_id: '
|
|
60
|
+
client_id: 'client_one',
|
|
61
61
|
connected_at: weekAgo,
|
|
62
62
|
sdk: 'powersync-js/1.24.5',
|
|
63
63
|
user_agent: 'powersync-js/1.21.0 powersync-web Firefox/141 linux',
|
|
@@ -89,6 +89,14 @@ export const REPORT_TEST_USERS = {
|
|
|
89
89
|
user_month,
|
|
90
90
|
user_expired
|
|
91
91
|
};
|
|
92
|
+
const removeVolatileFields = (connections) => {
|
|
93
|
+
return connections.map((sdk) => {
|
|
94
|
+
const { _id, disconnected_at, connected_at, jwt_exp, ...rest } = sdk;
|
|
95
|
+
return {
|
|
96
|
+
...rest
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
};
|
|
92
100
|
export async function registerReportTests(factory) {
|
|
93
101
|
it('Should show currently connected users', async () => {
|
|
94
102
|
const current = await factory.getConnectedClients();
|
|
@@ -115,5 +123,101 @@ export async function registerReportTests(factory) {
|
|
|
115
123
|
});
|
|
116
124
|
expect(sdk).toMatchSnapshot();
|
|
117
125
|
});
|
|
126
|
+
it('Should show paginated response of all connections of specified client_id', async () => {
|
|
127
|
+
const connections = await factory.getGeneralClientConnectionAnalytics({
|
|
128
|
+
client_id: user_two.client_id
|
|
129
|
+
});
|
|
130
|
+
const cleaned = {
|
|
131
|
+
...connections,
|
|
132
|
+
items: removeVolatileFields(connections.items)
|
|
133
|
+
};
|
|
134
|
+
expect(cleaned).toMatchSnapshot();
|
|
135
|
+
});
|
|
136
|
+
it('Should show paginated response of connections of specified user_id', async () => {
|
|
137
|
+
const connections = await factory.getGeneralClientConnectionAnalytics({
|
|
138
|
+
user_id: user_one.user_id
|
|
139
|
+
});
|
|
140
|
+
const cleaned = {
|
|
141
|
+
...connections,
|
|
142
|
+
items: removeVolatileFields(connections.items)
|
|
143
|
+
};
|
|
144
|
+
expect(cleaned).toMatchSnapshot();
|
|
145
|
+
});
|
|
146
|
+
it('Should show paginated response of connections over a date range', async () => {
|
|
147
|
+
const connections = await factory.getGeneralClientConnectionAnalytics({
|
|
148
|
+
date_range: {
|
|
149
|
+
start: weekAgo,
|
|
150
|
+
end: now
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
const cleaned = {
|
|
154
|
+
...connections,
|
|
155
|
+
items: removeVolatileFields(connections.items)
|
|
156
|
+
};
|
|
157
|
+
expect(cleaned).toMatchSnapshot();
|
|
158
|
+
});
|
|
159
|
+
it('Should show paginated response of connections over a date range of specified client_id and user_id', async () => {
|
|
160
|
+
const connections = await factory.getGeneralClientConnectionAnalytics({
|
|
161
|
+
client_id: user_one.client_id,
|
|
162
|
+
user_id: user_one.user_id,
|
|
163
|
+
date_range: {
|
|
164
|
+
start: weekAgo,
|
|
165
|
+
end: now
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
const cleaned = {
|
|
169
|
+
...connections,
|
|
170
|
+
items: removeVolatileFields(connections.items)
|
|
171
|
+
};
|
|
172
|
+
expect(cleaned).toMatchSnapshot();
|
|
173
|
+
});
|
|
174
|
+
it('Should show paginated response of all connections with a limit', async () => {
|
|
175
|
+
const initial = await factory.getGeneralClientConnectionAnalytics({
|
|
176
|
+
limit: 4
|
|
177
|
+
});
|
|
178
|
+
const cursor = initial.cursor;
|
|
179
|
+
expect(cursor).toBeDefined();
|
|
180
|
+
const cleanedInitial = {
|
|
181
|
+
...initial,
|
|
182
|
+
cursor: '<removed-for-snapshot>',
|
|
183
|
+
items: removeVolatileFields(initial.items)
|
|
184
|
+
};
|
|
185
|
+
expect(cleanedInitial).toMatchSnapshot();
|
|
186
|
+
const connections = await factory.getGeneralClientConnectionAnalytics({
|
|
187
|
+
cursor
|
|
188
|
+
});
|
|
189
|
+
const cleaned = {
|
|
190
|
+
...connections,
|
|
191
|
+
items: removeVolatileFields(connections.items)
|
|
192
|
+
};
|
|
193
|
+
expect(cleaned).toMatchSnapshot();
|
|
194
|
+
});
|
|
195
|
+
it('Should show paginated response of all connections with a limit with date range', async () => {
|
|
196
|
+
const date_range = {
|
|
197
|
+
start: monthAgo,
|
|
198
|
+
end: nowLess5minutes
|
|
199
|
+
};
|
|
200
|
+
const initial = await factory.getGeneralClientConnectionAnalytics({
|
|
201
|
+
limit: 4,
|
|
202
|
+
date_range
|
|
203
|
+
});
|
|
204
|
+
const cursor = initial.cursor;
|
|
205
|
+
expect(cursor).toBeDefined();
|
|
206
|
+
const cleanedInitial = {
|
|
207
|
+
...initial,
|
|
208
|
+
cursor: '<removed-for-snapshot>',
|
|
209
|
+
items: removeVolatileFields(initial.items)
|
|
210
|
+
};
|
|
211
|
+
expect(cleanedInitial).toMatchSnapshot();
|
|
212
|
+
const connections = await factory.getGeneralClientConnectionAnalytics({
|
|
213
|
+
cursor,
|
|
214
|
+
date_range
|
|
215
|
+
});
|
|
216
|
+
const cleaned = {
|
|
217
|
+
...connections,
|
|
218
|
+
items: removeVolatileFields(initial.items)
|
|
219
|
+
};
|
|
220
|
+
expect(cleaned).toMatchSnapshot();
|
|
221
|
+
});
|
|
118
222
|
}
|
|
119
223
|
//# sourceMappingURL=register-report-tests.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-report-tests.js","sourceRoot":"","sources":["../../src/tests/register-report-tests.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;AACvB,MAAM,cAAc,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;AACxH,MAAM,eAAe,GAAG,IAAI,IAAI,CAC9B,GAAG,CAAC,WAAW,EAAE,EACjB,GAAG,CAAC,QAAQ,EAAE,EACd,GAAG,CAAC,OAAO,EAAE,EACb,GAAG,CAAC,QAAQ,EAAE,EACd,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CACrB,CAAC;AACF,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,OAAO,EA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AC,mCAAmC,CAAC;YACpE,MAAM;YACN,UAAU;SACX,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG;YACd,GAAG,WAAW;YACd,KAAK,EAAE,oBAAoB,CAAC,OAAO,CAAC,KAAK,CAAC;SAC3C,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.12.
|
|
8
|
+
"version": "0.12.13",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"license": "FSL-1.1-ALv2",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@powersync/service-core": "^1.
|
|
13
|
+
"@powersync/service-core": "^1.17.0",
|
|
14
14
|
"@powersync/service-jsonbig": "^0.17.12",
|
|
15
|
-
"@powersync/service-sync-rules": "^0.29.
|
|
15
|
+
"@powersync/service-sync-rules": "^0.29.8"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"vite-tsconfig-paths": "^5.1.4",
|
|
@@ -62,7 +62,7 @@ const user_four = {
|
|
|
62
62
|
const user_old = {
|
|
63
63
|
user_id: 'user_one',
|
|
64
64
|
client_id: '',
|
|
65
|
-
connected_at:
|
|
65
|
+
connected_at: nowLess5minutes,
|
|
66
66
|
sdk: 'unknown',
|
|
67
67
|
user_agent: 'Dart (flutter-web) Chrome/128 android',
|
|
68
68
|
jwt_exp: nowAdd5minutes
|
|
@@ -70,7 +70,7 @@ const user_old = {
|
|
|
70
70
|
|
|
71
71
|
const user_week = {
|
|
72
72
|
user_id: 'user_week',
|
|
73
|
-
client_id: '
|
|
73
|
+
client_id: 'client_one',
|
|
74
74
|
connected_at: weekAgo,
|
|
75
75
|
sdk: 'powersync-js/1.24.5',
|
|
76
76
|
user_agent: 'powersync-js/1.21.0 powersync-web Firefox/141 linux',
|
|
@@ -106,6 +106,16 @@ export const REPORT_TEST_USERS = {
|
|
|
106
106
|
};
|
|
107
107
|
export type ReportUserData = typeof REPORT_TEST_USERS;
|
|
108
108
|
|
|
109
|
+
type LocalConnection = Partial<typeof user_expired>;
|
|
110
|
+
const removeVolatileFields = <T>(connections: LocalConnection[]) => {
|
|
111
|
+
return connections.map((sdk: Partial<LocalConnection & { _id: string; disconnected_at?: Date }>) => {
|
|
112
|
+
const { _id, disconnected_at, connected_at, jwt_exp, ...rest } = sdk;
|
|
113
|
+
return {
|
|
114
|
+
...rest
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
109
119
|
export async function registerReportTests(factory: storage.ReportStorage) {
|
|
110
120
|
it('Should show currently connected users', async () => {
|
|
111
121
|
const current = await factory.getConnectedClients();
|
|
@@ -133,4 +143,113 @@ export async function registerReportTests(factory: storage.ReportStorage) {
|
|
|
133
143
|
});
|
|
134
144
|
expect(sdk).toMatchSnapshot();
|
|
135
145
|
});
|
|
146
|
+
|
|
147
|
+
it('Should show paginated response of all connections of specified client_id', async () => {
|
|
148
|
+
const connections = await factory.getGeneralClientConnectionAnalytics({
|
|
149
|
+
client_id: user_two.client_id
|
|
150
|
+
});
|
|
151
|
+
const cleaned = {
|
|
152
|
+
...connections,
|
|
153
|
+
items: removeVolatileFields(connections.items)
|
|
154
|
+
};
|
|
155
|
+
expect(cleaned).toMatchSnapshot();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('Should show paginated response of connections of specified user_id', async () => {
|
|
159
|
+
const connections = await factory.getGeneralClientConnectionAnalytics({
|
|
160
|
+
user_id: user_one.user_id
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const cleaned = {
|
|
164
|
+
...connections,
|
|
165
|
+
items: removeVolatileFields(connections.items)
|
|
166
|
+
};
|
|
167
|
+
expect(cleaned).toMatchSnapshot();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('Should show paginated response of connections over a date range', async () => {
|
|
171
|
+
const connections = await factory.getGeneralClientConnectionAnalytics({
|
|
172
|
+
date_range: {
|
|
173
|
+
start: weekAgo,
|
|
174
|
+
end: now
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
const cleaned = {
|
|
179
|
+
...connections,
|
|
180
|
+
items: removeVolatileFields(connections.items)
|
|
181
|
+
};
|
|
182
|
+
expect(cleaned).toMatchSnapshot();
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('Should show paginated response of connections over a date range of specified client_id and user_id', async () => {
|
|
186
|
+
const connections = await factory.getGeneralClientConnectionAnalytics({
|
|
187
|
+
client_id: user_one.client_id,
|
|
188
|
+
user_id: user_one.user_id,
|
|
189
|
+
date_range: {
|
|
190
|
+
start: weekAgo,
|
|
191
|
+
end: now
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const cleaned = {
|
|
196
|
+
...connections,
|
|
197
|
+
items: removeVolatileFields(connections.items)
|
|
198
|
+
};
|
|
199
|
+
expect(cleaned).toMatchSnapshot();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('Should show paginated response of all connections with a limit', async () => {
|
|
203
|
+
const initial = await factory.getGeneralClientConnectionAnalytics({
|
|
204
|
+
limit: 4
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const cursor = initial.cursor;
|
|
208
|
+
expect(cursor).toBeDefined();
|
|
209
|
+
const cleanedInitial = {
|
|
210
|
+
...initial,
|
|
211
|
+
cursor: '<removed-for-snapshot>',
|
|
212
|
+
items: removeVolatileFields(initial.items)
|
|
213
|
+
};
|
|
214
|
+
expect(cleanedInitial).toMatchSnapshot();
|
|
215
|
+
const connections = await factory.getGeneralClientConnectionAnalytics({
|
|
216
|
+
cursor
|
|
217
|
+
});
|
|
218
|
+
const cleaned = {
|
|
219
|
+
...connections,
|
|
220
|
+
items: removeVolatileFields(connections.items)
|
|
221
|
+
};
|
|
222
|
+
expect(cleaned).toMatchSnapshot();
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('Should show paginated response of all connections with a limit with date range', async () => {
|
|
226
|
+
const date_range = {
|
|
227
|
+
start: monthAgo,
|
|
228
|
+
end: nowLess5minutes
|
|
229
|
+
};
|
|
230
|
+
const initial = await factory.getGeneralClientConnectionAnalytics({
|
|
231
|
+
limit: 4,
|
|
232
|
+
date_range
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
const cursor = initial.cursor;
|
|
236
|
+
expect(cursor).toBeDefined();
|
|
237
|
+
|
|
238
|
+
const cleanedInitial = {
|
|
239
|
+
...initial,
|
|
240
|
+
cursor: '<removed-for-snapshot>',
|
|
241
|
+
items: removeVolatileFields(initial.items)
|
|
242
|
+
};
|
|
243
|
+
expect(cleanedInitial).toMatchSnapshot();
|
|
244
|
+
const connections = await factory.getGeneralClientConnectionAnalytics({
|
|
245
|
+
cursor,
|
|
246
|
+
date_range
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
const cleaned = {
|
|
250
|
+
...connections,
|
|
251
|
+
items: removeVolatileFields(initial.items)
|
|
252
|
+
};
|
|
253
|
+
expect(cleaned).toMatchSnapshot();
|
|
254
|
+
});
|
|
136
255
|
}
|