1
- import type { TrafficUsageDataSegmentedCombinedSchema } from 'openapi' ;
1
+ import type {
2
+ MeteredConnectionsSchema ,
3
+ TrafficUsageDataSegmentedCombinedSchema ,
4
+ } from 'openapi' ;
2
5
import {
3
6
toConnectionChartData ,
4
7
toTrafficUsageChartData ,
@@ -152,9 +155,9 @@ describe('toTrafficUsageChartData', () => {
152
155
} ) ;
153
156
154
157
describe ( 'toConnectionChartData' , ( ) => {
155
- const dataPoint = ( period : string , count : number ) => ( {
158
+ const dataPoint = ( period : string , connections : number ) => ( {
156
159
period,
157
- trafficTypes : [ { count , group : 'successful-requests' } ] ,
160
+ connections ,
158
161
} ) ;
159
162
160
163
const fromEndpointInfo = ( endpoint : keyof typeof endpointsInfo ) => {
@@ -167,24 +170,20 @@ describe('toConnectionChartData', () => {
167
170
} ;
168
171
169
172
test ( 'monthly data conversion' , ( ) => {
170
- const input : TrafficUsageDataSegmentedCombinedSchema = {
173
+ const input : MeteredConnectionsSchema = {
171
174
grouping : 'monthly' ,
172
175
dateRange : {
173
176
from : '2025-01-01' ,
174
177
to : '2025-06-30' ,
175
178
} ,
176
179
apiData : [
177
180
{
178
- apiPath : '/api/admin' , // filter out
179
- dataPoints : [ dataPoint ( '2025-06' , 5 ) ] ,
180
- } ,
181
- {
182
- apiPath : '/api/client' ,
181
+ meteredGroup : 'default' ,
183
182
dataPoints : [
184
- dataPoint ( '2025-06' , 10 * 5 * 60 * 24 * 30 ) ,
185
- dataPoint ( '2025-01' , 7 * 5 * 60 * 24 * 31 ) ,
186
- dataPoint ( '2025-03' , 11 * 5 * 60 * 24 * 31 ) ,
187
- dataPoint ( '2025-04' , 13 * 5 * 60 * 24 * 30 ) ,
183
+ dataPoint ( '2025-06' , 10 ) ,
184
+ dataPoint ( '2025-01' , 7 ) ,
185
+ dataPoint ( '2025-03' , 11 ) ,
186
+ dataPoint ( '2025-04' , 13 ) ,
188
187
] ,
189
188
} ,
190
189
] ,
@@ -194,7 +193,9 @@ describe('toConnectionChartData', () => {
194
193
datasets : [
195
194
{
196
195
data : [ 7 , 0 , 11 , 13 , 0 , 10 ] ,
197
- ...fromEndpointInfo ( '/api/client' ) ,
196
+ hoverBackgroundColor : '#6D66D9' ,
197
+ label : 'Connections' ,
198
+ backgroundColor : '#6D66D9' ,
198
199
} ,
199
200
] ,
200
201
labels : [
@@ -211,24 +212,20 @@ describe('toConnectionChartData', () => {
211
212
} ) ;
212
213
213
214
test ( 'daily data conversion' , ( ) => {
214
- const input : TrafficUsageDataSegmentedCombinedSchema = {
215
+ const input : MeteredConnectionsSchema = {
215
216
grouping : 'daily' ,
216
217
dateRange : {
217
218
from : '2025-01-01' ,
218
219
to : '2025-01-31' ,
219
220
} ,
220
221
apiData : [
221
222
{
222
- apiPath : '/api/admin' , // filter out
223
- dataPoints : [ dataPoint ( '2025-01-01' , 5 ) ] ,
224
- } ,
225
- {
226
- apiPath : '/api/client' ,
223
+ meteredGroup : 'default' ,
227
224
dataPoints : [
228
- dataPoint ( '2025-01-02' , 2 * 5 * 60 * 24 ) ,
229
- dataPoint ( '2025-01-17' , 6 * 5 * 60 * 24 ) ,
230
- dataPoint ( '2025-01-19' , 4 * 5 * 60 * 24 ) ,
231
- dataPoint ( '2025-01-06' , 8 * 5 * 60 * 24 ) ,
225
+ dataPoint ( '2025-01-02' , 2 ) ,
226
+ dataPoint ( '2025-01-17' , 6 ) ,
227
+ dataPoint ( '2025-01-19' , 4 ) ,
228
+ dataPoint ( '2025-01-06' , 8 ) ,
232
229
] ,
233
230
} ,
234
231
] ,
@@ -241,7 +238,9 @@ describe('toConnectionChartData', () => {
241
238
0 , 2 , 0 , 0 , 0 , 8 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 6 , 0 , 4 ,
242
239
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
243
240
] ,
244
- ...fromEndpointInfo ( '/api/client' ) ,
241
+ hoverBackgroundColor : '#6D66D9' ,
242
+ label : 'Connections' ,
243
+ backgroundColor : '#6D66D9' ,
245
244
} ,
246
245
] ,
247
246
labels : Array . from ( { length : 31 } ) . map ( ( _ , index ) =>
0 commit comments