@powersync/service-core-tests 0.12.8 → 0.12.10
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 +21 -0
- package/dist/tests/register-report-tests.d.ts +78 -0
- package/dist/tests/register-report-tests.js +119 -0
- package/dist/tests/register-report-tests.js.map +1 -0
- package/dist/tests/tests-index.d.ts +1 -0
- package/dist/tests/tests-index.js +1 -0
- package/dist/tests/tests-index.js.map +1 -1
- package/package.json +4 -4
- package/src/tests/register-report-tests.ts +136 -0
- package/src/tests/tests-index.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @powersync/service-core-tests
|
|
2
2
|
|
|
3
|
+
## 0.12.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [c6bdb4f]
|
|
8
|
+
- @powersync/service-core@1.16.1
|
|
9
|
+
|
|
10
|
+
## 0.12.9
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 88982d9: Migrate to trusted publishing
|
|
15
|
+
- Updated dependencies [b4fa979]
|
|
16
|
+
- Updated dependencies [80fd68b]
|
|
17
|
+
- Updated dependencies [c2bd0b0]
|
|
18
|
+
- Updated dependencies [0268858]
|
|
19
|
+
- Updated dependencies [88982d9]
|
|
20
|
+
- @powersync/service-sync-rules@0.29.6
|
|
21
|
+
- @powersync/service-core@1.16.0
|
|
22
|
+
- @powersync/service-jsonbig@0.17.12
|
|
23
|
+
|
|
3
24
|
## 0.12.8
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { storage } from '@powersync/service-core';
|
|
2
|
+
export declare const REPORT_TEST_DATES: {
|
|
3
|
+
now: Date;
|
|
4
|
+
nowAdd5minutes: Date;
|
|
5
|
+
nowLess5minutes: Date;
|
|
6
|
+
dayAgo: Date;
|
|
7
|
+
yesterday: Date;
|
|
8
|
+
weekAgo: Date;
|
|
9
|
+
monthAgo: Date;
|
|
10
|
+
};
|
|
11
|
+
export declare const REPORT_TEST_USERS: {
|
|
12
|
+
user_one: {
|
|
13
|
+
user_id: string;
|
|
14
|
+
client_id: string;
|
|
15
|
+
connected_at: Date;
|
|
16
|
+
sdk: string;
|
|
17
|
+
user_agent: string;
|
|
18
|
+
jwt_exp: Date;
|
|
19
|
+
};
|
|
20
|
+
user_two: {
|
|
21
|
+
user_id: string;
|
|
22
|
+
client_id: string;
|
|
23
|
+
connected_at: Date;
|
|
24
|
+
sdk: string;
|
|
25
|
+
user_agent: string;
|
|
26
|
+
jwt_exp: Date;
|
|
27
|
+
};
|
|
28
|
+
user_three: {
|
|
29
|
+
user_id: string;
|
|
30
|
+
client_id: string;
|
|
31
|
+
connected_at: Date;
|
|
32
|
+
sdk: string;
|
|
33
|
+
user_agent: string;
|
|
34
|
+
disconnected_at: Date;
|
|
35
|
+
};
|
|
36
|
+
user_four: {
|
|
37
|
+
user_id: string;
|
|
38
|
+
client_id: string;
|
|
39
|
+
connected_at: Date;
|
|
40
|
+
sdk: string;
|
|
41
|
+
user_agent: string;
|
|
42
|
+
jwt_exp: Date;
|
|
43
|
+
};
|
|
44
|
+
user_old: {
|
|
45
|
+
user_id: string;
|
|
46
|
+
client_id: string;
|
|
47
|
+
connected_at: Date;
|
|
48
|
+
sdk: string;
|
|
49
|
+
user_agent: string;
|
|
50
|
+
jwt_exp: Date;
|
|
51
|
+
};
|
|
52
|
+
user_week: {
|
|
53
|
+
user_id: string;
|
|
54
|
+
client_id: string;
|
|
55
|
+
connected_at: Date;
|
|
56
|
+
sdk: string;
|
|
57
|
+
user_agent: string;
|
|
58
|
+
disconnected_at: Date;
|
|
59
|
+
};
|
|
60
|
+
user_month: {
|
|
61
|
+
user_id: string;
|
|
62
|
+
client_id: string;
|
|
63
|
+
connected_at: Date;
|
|
64
|
+
sdk: string;
|
|
65
|
+
user_agent: string;
|
|
66
|
+
disconnected_at: Date;
|
|
67
|
+
};
|
|
68
|
+
user_expired: {
|
|
69
|
+
user_id: string;
|
|
70
|
+
client_id: string;
|
|
71
|
+
connected_at: Date;
|
|
72
|
+
sdk: string;
|
|
73
|
+
user_agent: string;
|
|
74
|
+
jwt_exp: Date;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export type ReportUserData = typeof REPORT_TEST_USERS;
|
|
78
|
+
export declare function registerReportTests(factory: storage.ReportStorage): Promise<void>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { expect, it } from 'vitest';
|
|
2
|
+
const now = new Date();
|
|
3
|
+
const nowAdd5minutes = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes() + 5);
|
|
4
|
+
const nowLess5minutes = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes() - 5);
|
|
5
|
+
const dayAgo = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, now.getHours());
|
|
6
|
+
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
|
|
7
|
+
const weekAgo = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7);
|
|
8
|
+
const monthAgo = new Date(now.getFullYear(), now.getMonth() - 1, now.getDate());
|
|
9
|
+
export const REPORT_TEST_DATES = {
|
|
10
|
+
now,
|
|
11
|
+
nowAdd5minutes,
|
|
12
|
+
nowLess5minutes,
|
|
13
|
+
dayAgo,
|
|
14
|
+
yesterday,
|
|
15
|
+
weekAgo,
|
|
16
|
+
monthAgo
|
|
17
|
+
};
|
|
18
|
+
const user_one = {
|
|
19
|
+
user_id: 'user_one',
|
|
20
|
+
client_id: 'client_one',
|
|
21
|
+
connected_at: now,
|
|
22
|
+
sdk: 'powersync-dart/1.6.4',
|
|
23
|
+
user_agent: 'powersync-dart/1.6.4 Dart (flutter-web) Chrome/128 android',
|
|
24
|
+
jwt_exp: nowAdd5minutes
|
|
25
|
+
};
|
|
26
|
+
const user_two = {
|
|
27
|
+
user_id: 'user_two',
|
|
28
|
+
client_id: 'client_two',
|
|
29
|
+
connected_at: nowLess5minutes,
|
|
30
|
+
sdk: 'powersync-js/1.21.1',
|
|
31
|
+
user_agent: 'powersync-js/1.21.0 powersync-web Chromium/138 linux',
|
|
32
|
+
jwt_exp: nowAdd5minutes
|
|
33
|
+
};
|
|
34
|
+
const user_three = {
|
|
35
|
+
user_id: 'user_three',
|
|
36
|
+
client_id: 'client_three',
|
|
37
|
+
connected_at: yesterday,
|
|
38
|
+
sdk: 'powersync-js/1.21.2',
|
|
39
|
+
user_agent: 'powersync-js/1.21.0 powersync-web Firefox/141 linux',
|
|
40
|
+
disconnected_at: yesterday
|
|
41
|
+
};
|
|
42
|
+
const user_four = {
|
|
43
|
+
user_id: 'user_four',
|
|
44
|
+
client_id: 'client_four',
|
|
45
|
+
connected_at: now,
|
|
46
|
+
sdk: 'powersync-js/1.21.4',
|
|
47
|
+
user_agent: 'powersync-js/1.21.0 powersync-web Firefox/141 linux',
|
|
48
|
+
jwt_exp: nowLess5minutes
|
|
49
|
+
};
|
|
50
|
+
const user_old = {
|
|
51
|
+
user_id: 'user_one',
|
|
52
|
+
client_id: '',
|
|
53
|
+
connected_at: now,
|
|
54
|
+
sdk: 'unknown',
|
|
55
|
+
user_agent: 'Dart (flutter-web) Chrome/128 android',
|
|
56
|
+
jwt_exp: nowAdd5minutes
|
|
57
|
+
};
|
|
58
|
+
const user_week = {
|
|
59
|
+
user_id: 'user_week',
|
|
60
|
+
client_id: 'client_week',
|
|
61
|
+
connected_at: weekAgo,
|
|
62
|
+
sdk: 'powersync-js/1.24.5',
|
|
63
|
+
user_agent: 'powersync-js/1.21.0 powersync-web Firefox/141 linux',
|
|
64
|
+
disconnected_at: weekAgo
|
|
65
|
+
};
|
|
66
|
+
const user_month = {
|
|
67
|
+
user_id: 'user_month',
|
|
68
|
+
client_id: 'client_month',
|
|
69
|
+
connected_at: monthAgo,
|
|
70
|
+
sdk: 'powersync-js/1.23.6',
|
|
71
|
+
user_agent: 'powersync-js/1.23.0 powersync-web Firefox/141 linux',
|
|
72
|
+
disconnected_at: monthAgo
|
|
73
|
+
};
|
|
74
|
+
const user_expired = {
|
|
75
|
+
user_id: 'user_expired',
|
|
76
|
+
client_id: 'client_expired',
|
|
77
|
+
connected_at: monthAgo,
|
|
78
|
+
sdk: 'powersync-js/1.23.7',
|
|
79
|
+
user_agent: 'powersync-js/1.23.0 powersync-web Firefox/141 linux',
|
|
80
|
+
jwt_exp: monthAgo
|
|
81
|
+
};
|
|
82
|
+
export const REPORT_TEST_USERS = {
|
|
83
|
+
user_one,
|
|
84
|
+
user_two,
|
|
85
|
+
user_three,
|
|
86
|
+
user_four,
|
|
87
|
+
user_old,
|
|
88
|
+
user_week,
|
|
89
|
+
user_month,
|
|
90
|
+
user_expired
|
|
91
|
+
};
|
|
92
|
+
export async function registerReportTests(factory) {
|
|
93
|
+
it('Should show currently connected users', async () => {
|
|
94
|
+
const current = await factory.getConnectedClients();
|
|
95
|
+
expect(current).toMatchSnapshot();
|
|
96
|
+
});
|
|
97
|
+
it('Should show connection report data for user over the past month', async () => {
|
|
98
|
+
const sdk = await factory.getClientConnectionReports({
|
|
99
|
+
start: monthAgo,
|
|
100
|
+
end: now
|
|
101
|
+
});
|
|
102
|
+
expect(sdk).toMatchSnapshot();
|
|
103
|
+
});
|
|
104
|
+
it('Should show connection report data for user over the past week', async () => {
|
|
105
|
+
const sdk = await factory.getClientConnectionReports({
|
|
106
|
+
start: weekAgo,
|
|
107
|
+
end: now
|
|
108
|
+
});
|
|
109
|
+
expect(sdk).toMatchSnapshot();
|
|
110
|
+
});
|
|
111
|
+
it('Should show connection report data for user over the past day', async () => {
|
|
112
|
+
const sdk = await factory.getClientConnectionReports({
|
|
113
|
+
start: dayAgo,
|
|
114
|
+
end: now
|
|
115
|
+
});
|
|
116
|
+
expect(sdk).toMatchSnapshot();
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=register-report-tests.js.map
|
|
@@ -0,0 +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,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC9F,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;AACjF,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;AAC/E,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,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YACnD,KAAK,EAAE,OAAO;YACd,GAAG,EAAE,GAAG;SACT,CAAC,CAAC;QACH,MAAM,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,+DAA+D,EAAE,KAAK,IAAI,EAAE;QAC7E,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,0BAA0B,CAAC;YACnD,KAAK,EAAE,MAAM;YACb,GAAG,EAAE,GAAG;SACT,CAAC,CAAC;QACH,MAAM,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -6,4 +6,5 @@ export * from './register-data-storage-data-tests.js';
|
|
|
6
6
|
export * from './register-data-storage-checkpoint-tests.js';
|
|
7
7
|
export * from './register-migration-tests.js';
|
|
8
8
|
export * from './register-sync-tests.js';
|
|
9
|
+
export * from './register-report-tests.js';
|
|
9
10
|
export * from './util.js';
|
|
@@ -6,5 +6,6 @@ export * from './register-data-storage-data-tests.js';
|
|
|
6
6
|
export * from './register-data-storage-checkpoint-tests.js';
|
|
7
7
|
export * from './register-migration-tests.js';
|
|
8
8
|
export * from './register-sync-tests.js';
|
|
9
|
+
export * from './register-report-tests.js';
|
|
9
10
|
export * from './util.js';
|
|
10
11
|
//# sourceMappingURL=tests-index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tests-index.js","sourceRoot":"","sources":["../../src/tests/tests-index.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC;AACtD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,uCAAuC,CAAC;AACtD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"tests-index.js","sourceRoot":"","sources":["../../src/tests/tests-index.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC;AACtD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,uCAAuC,CAAC;AACtD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,WAAW,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.10",
|
|
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.
|
|
14
|
-
"@powersync/service-jsonbig": "^0.17.
|
|
15
|
-
"@powersync/service-sync-rules": "^0.29.
|
|
13
|
+
"@powersync/service-core": "^1.16.1",
|
|
14
|
+
"@powersync/service-jsonbig": "^0.17.12",
|
|
15
|
+
"@powersync/service-sync-rules": "^0.29.6"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"vite-tsconfig-paths": "^5.1.4",
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { storage } from '@powersync/service-core';
|
|
2
|
+
import { expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
const now = new Date();
|
|
5
|
+
const nowAdd5minutes = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes() + 5);
|
|
6
|
+
const nowLess5minutes = new Date(
|
|
7
|
+
now.getFullYear(),
|
|
8
|
+
now.getMonth(),
|
|
9
|
+
now.getDate(),
|
|
10
|
+
now.getHours(),
|
|
11
|
+
now.getMinutes() - 5
|
|
12
|
+
);
|
|
13
|
+
const dayAgo = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, now.getHours());
|
|
14
|
+
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
|
|
15
|
+
const weekAgo = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7);
|
|
16
|
+
const monthAgo = new Date(now.getFullYear(), now.getMonth() - 1, now.getDate());
|
|
17
|
+
|
|
18
|
+
export const REPORT_TEST_DATES = {
|
|
19
|
+
now,
|
|
20
|
+
nowAdd5minutes,
|
|
21
|
+
nowLess5minutes,
|
|
22
|
+
dayAgo,
|
|
23
|
+
yesterday,
|
|
24
|
+
weekAgo,
|
|
25
|
+
monthAgo
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const user_one = {
|
|
29
|
+
user_id: 'user_one',
|
|
30
|
+
client_id: 'client_one',
|
|
31
|
+
connected_at: now,
|
|
32
|
+
sdk: 'powersync-dart/1.6.4',
|
|
33
|
+
user_agent: 'powersync-dart/1.6.4 Dart (flutter-web) Chrome/128 android',
|
|
34
|
+
jwt_exp: nowAdd5minutes
|
|
35
|
+
};
|
|
36
|
+
const user_two = {
|
|
37
|
+
user_id: 'user_two',
|
|
38
|
+
client_id: 'client_two',
|
|
39
|
+
connected_at: nowLess5minutes,
|
|
40
|
+
sdk: 'powersync-js/1.21.1',
|
|
41
|
+
user_agent: 'powersync-js/1.21.0 powersync-web Chromium/138 linux',
|
|
42
|
+
jwt_exp: nowAdd5minutes
|
|
43
|
+
};
|
|
44
|
+
const user_three = {
|
|
45
|
+
user_id: 'user_three',
|
|
46
|
+
client_id: 'client_three',
|
|
47
|
+
connected_at: yesterday,
|
|
48
|
+
sdk: 'powersync-js/1.21.2',
|
|
49
|
+
user_agent: 'powersync-js/1.21.0 powersync-web Firefox/141 linux',
|
|
50
|
+
disconnected_at: yesterday
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const user_four = {
|
|
54
|
+
user_id: 'user_four',
|
|
55
|
+
client_id: 'client_four',
|
|
56
|
+
connected_at: now,
|
|
57
|
+
sdk: 'powersync-js/1.21.4',
|
|
58
|
+
user_agent: 'powersync-js/1.21.0 powersync-web Firefox/141 linux',
|
|
59
|
+
jwt_exp: nowLess5minutes
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const user_old = {
|
|
63
|
+
user_id: 'user_one',
|
|
64
|
+
client_id: '',
|
|
65
|
+
connected_at: now,
|
|
66
|
+
sdk: 'unknown',
|
|
67
|
+
user_agent: 'Dart (flutter-web) Chrome/128 android',
|
|
68
|
+
jwt_exp: nowAdd5minutes
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const user_week = {
|
|
72
|
+
user_id: 'user_week',
|
|
73
|
+
client_id: 'client_week',
|
|
74
|
+
connected_at: weekAgo,
|
|
75
|
+
sdk: 'powersync-js/1.24.5',
|
|
76
|
+
user_agent: 'powersync-js/1.21.0 powersync-web Firefox/141 linux',
|
|
77
|
+
disconnected_at: weekAgo
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const user_month = {
|
|
81
|
+
user_id: 'user_month',
|
|
82
|
+
client_id: 'client_month',
|
|
83
|
+
connected_at: monthAgo,
|
|
84
|
+
sdk: 'powersync-js/1.23.6',
|
|
85
|
+
user_agent: 'powersync-js/1.23.0 powersync-web Firefox/141 linux',
|
|
86
|
+
disconnected_at: monthAgo
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const user_expired = {
|
|
90
|
+
user_id: 'user_expired',
|
|
91
|
+
client_id: 'client_expired',
|
|
92
|
+
connected_at: monthAgo,
|
|
93
|
+
sdk: 'powersync-js/1.23.7',
|
|
94
|
+
user_agent: 'powersync-js/1.23.0 powersync-web Firefox/141 linux',
|
|
95
|
+
jwt_exp: monthAgo
|
|
96
|
+
};
|
|
97
|
+
export const REPORT_TEST_USERS = {
|
|
98
|
+
user_one,
|
|
99
|
+
user_two,
|
|
100
|
+
user_three,
|
|
101
|
+
user_four,
|
|
102
|
+
user_old,
|
|
103
|
+
user_week,
|
|
104
|
+
user_month,
|
|
105
|
+
user_expired
|
|
106
|
+
};
|
|
107
|
+
export type ReportUserData = typeof REPORT_TEST_USERS;
|
|
108
|
+
|
|
109
|
+
export async function registerReportTests(factory: storage.ReportStorage) {
|
|
110
|
+
it('Should show currently connected users', async () => {
|
|
111
|
+
const current = await factory.getConnectedClients();
|
|
112
|
+
expect(current).toMatchSnapshot();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('Should show connection report data for user over the past month', async () => {
|
|
116
|
+
const sdk = await factory.getClientConnectionReports({
|
|
117
|
+
start: monthAgo,
|
|
118
|
+
end: now
|
|
119
|
+
});
|
|
120
|
+
expect(sdk).toMatchSnapshot();
|
|
121
|
+
});
|
|
122
|
+
it('Should show connection report data for user over the past week', async () => {
|
|
123
|
+
const sdk = await factory.getClientConnectionReports({
|
|
124
|
+
start: weekAgo,
|
|
125
|
+
end: now
|
|
126
|
+
});
|
|
127
|
+
expect(sdk).toMatchSnapshot();
|
|
128
|
+
});
|
|
129
|
+
it('Should show connection report data for user over the past day', async () => {
|
|
130
|
+
const sdk = await factory.getClientConnectionReports({
|
|
131
|
+
start: dayAgo,
|
|
132
|
+
end: now
|
|
133
|
+
});
|
|
134
|
+
expect(sdk).toMatchSnapshot();
|
|
135
|
+
});
|
|
136
|
+
}
|
package/src/tests/tests-index.ts
CHANGED
|
@@ -6,4 +6,5 @@ export * from './register-data-storage-data-tests.js';
|
|
|
6
6
|
export * from './register-data-storage-checkpoint-tests.js';
|
|
7
7
|
export * from './register-migration-tests.js';
|
|
8
8
|
export * from './register-sync-tests.js';
|
|
9
|
+
export * from './register-report-tests.js';
|
|
9
10
|
export * from './util.js';
|