@datarailsshared/dr_renderer 1.2.396 → 1.2.397
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/package.json
CHANGED
@@ -6174,4 +6174,250 @@ describe('highcharts_renderer', () => {
|
|
6174
6174
|
expect(tooltipHtml).toEqual('row 1: 10.99%');
|
6175
6175
|
});
|
6176
6176
|
});
|
6177
|
+
|
6178
|
+
describe("Function updateFiltersShowNames", () => {
|
6179
|
+
|
6180
|
+
it("should receive array or object", () => {
|
6181
|
+
|
6182
|
+
const filters = [{
|
6183
|
+
field: 4030578,
|
6184
|
+
name: "Month",
|
6185
|
+
values: [1682812800, 1680220800, "[null]"],
|
6186
|
+
is_excluded: false,
|
6187
|
+
allow_nulls: false,
|
6188
|
+
show_in_graph: true,
|
6189
|
+
type: "Date",
|
6190
|
+
override_global_filter: false,
|
6191
|
+
},
|
6192
|
+
{
|
6193
|
+
field: 4030223,
|
6194
|
+
name: "AccountCode",
|
6195
|
+
values: null,
|
6196
|
+
is_excluded: false,
|
6197
|
+
allow_nulls: false,
|
6198
|
+
show_in_graph: true,
|
6199
|
+
type: "Text",
|
6200
|
+
override_global_filter: false,
|
6201
|
+
},
|
6202
|
+
];
|
6203
|
+
|
6204
|
+
highchartsRenderer.updateFiltersShowNames(filters);
|
6205
|
+
|
6206
|
+
expect(filters[0].value_to_show).toEqual("04/30/2023, 03/31/2023, [null]");
|
6207
|
+
expect(filters[1].value_to_show).toEqual("All");
|
6208
|
+
});
|
6209
|
+
|
6210
|
+
it("should receive array or object", () => {
|
6211
|
+
const filters = [{
|
6212
|
+
field: 934090,
|
6213
|
+
name: "Data Type",
|
6214
|
+
values: ["Activity"],
|
6215
|
+
is_excluded: false,
|
6216
|
+
allow_nulls: false,
|
6217
|
+
show_in_graph: false,
|
6218
|
+
type: "Text",
|
6219
|
+
override_global_filter: false,
|
6220
|
+
},
|
6221
|
+
{
|
6222
|
+
field: 934093,
|
6223
|
+
name: "Scenario",
|
6224
|
+
values: {
|
6225
|
+
type: "advanced",
|
6226
|
+
val: [{
|
6227
|
+
operator: null,
|
6228
|
+
condition: "equals",
|
6229
|
+
value: "Actuals",
|
6230
|
+
}, ],
|
6231
|
+
},
|
6232
|
+
is_excluded: false,
|
6233
|
+
allow_nulls: false,
|
6234
|
+
show_in_graph: false,
|
6235
|
+
type: "Text",
|
6236
|
+
override_global_filter: false,
|
6237
|
+
},
|
6238
|
+
];
|
6239
|
+
|
6240
|
+
highchartsRenderer.updateFiltersShowNames(filters);
|
6241
|
+
|
6242
|
+
expect(filters[0].value_to_show).toEqual("Activity");
|
6243
|
+
expect(filters[1].value_to_show).toEqual("All");
|
6244
|
+
});
|
6245
|
+
});
|
6246
|
+
|
6247
|
+
describe("Function returnRawDataValue", () => {
|
6248
|
+
const testCases = [{
|
6249
|
+
name: "Date",
|
6250
|
+
filter: {
|
6251
|
+
field: 4030578,
|
6252
|
+
name: "Month",
|
6253
|
+
values: [1682812800, 1680220800, "[null]", null, 0, "", 1680220800],
|
6254
|
+
is_excluded: false,
|
6255
|
+
allow_nulls: false,
|
6256
|
+
show_in_graph: true,
|
6257
|
+
type: "Date",
|
6258
|
+
override_global_filter: false,
|
6259
|
+
},
|
6260
|
+
expectedResults: [
|
6261
|
+
"04/30/2023", "03/31/2023", "[null]", "[null]", "Untagged", "[blank]", "03/31/2023",
|
6262
|
+
],
|
6263
|
+
},
|
6264
|
+
{
|
6265
|
+
name: "Date with VT_Month",
|
6266
|
+
filter: {
|
6267
|
+
field: 4030578,
|
6268
|
+
name: "VT_Month",
|
6269
|
+
values: [1682812800, 1680220800, "[null]", null, 0, "", 1680220800],
|
6270
|
+
is_excluded: false,
|
6271
|
+
allow_nulls: false,
|
6272
|
+
show_in_graph: true,
|
6273
|
+
type: "Date",
|
6274
|
+
override_global_filter: false,
|
6275
|
+
},
|
6276
|
+
expectedResults: [
|
6277
|
+
"Apr 2023", "Mar 2023", "[null]", "[null]", "Untagged", "[blank]", "Mar 2023",
|
6278
|
+
],
|
6279
|
+
},
|
6280
|
+
{
|
6281
|
+
name: "Number",
|
6282
|
+
filter: {
|
6283
|
+
field: 4030578,
|
6284
|
+
name: "Month",
|
6285
|
+
values: [100, 200, "[null]", null, "Text", 0],
|
6286
|
+
is_excluded: false,
|
6287
|
+
allow_nulls: false,
|
6288
|
+
show_in_graph: true,
|
6289
|
+
type: "Number",
|
6290
|
+
override_global_filter: false,
|
6291
|
+
},
|
6292
|
+
expectedResults: [100, 200, "[null]", "[null]", "Text", 0],
|
6293
|
+
},
|
6294
|
+
];
|
6295
|
+
|
6296
|
+
testCases.forEach((testCase) => {
|
6297
|
+
describe(`Scenario: ${testCase.name}`, () => {
|
6298
|
+
testCase.filter.values.forEach((value, index) => {
|
6299
|
+
it(`should return the expected result with value ${value}`, () => {
|
6300
|
+
const result = highchartsRenderer.returnRawDataValue(testCase.filter.type, value, testCase.filter.format, testCase.filter.name);
|
6301
|
+
expect(result).toEqual(testCase.expectedResults[index]);
|
6302
|
+
});
|
6303
|
+
});
|
6304
|
+
});
|
6305
|
+
});
|
6306
|
+
});
|
6307
|
+
|
6308
|
+
describe("Function check_values_not_for_convert", () => {
|
6309
|
+
const testCases = [{
|
6310
|
+
name: "should return a array when field is series row name equal to field name",
|
6311
|
+
currentgraph: {
|
6312
|
+
rows: [{
|
6313
|
+
name: "Month",
|
6314
|
+
}, ],
|
6315
|
+
cols: [{
|
6316
|
+
name: "Grouping",
|
6317
|
+
}, ],
|
6318
|
+
options: {
|
6319
|
+
chartOptions: {
|
6320
|
+
delta_column: {
|
6321
|
+
field: "series",
|
6322
|
+
name: "Month",
|
6323
|
+
},
|
6324
|
+
},
|
6325
|
+
},
|
6326
|
+
},
|
6327
|
+
field_name: "Month",
|
6328
|
+
expected: ["Month"],
|
6329
|
+
},
|
6330
|
+
{
|
6331
|
+
name: "should return an empty array when field is category and col name does not equal to field name",
|
6332
|
+
currentgraph: {
|
6333
|
+
rows: [{
|
6334
|
+
name: "Month",
|
6335
|
+
}, ],
|
6336
|
+
cols: [{
|
6337
|
+
name: "Grouping",
|
6338
|
+
}, ],
|
6339
|
+
options: {
|
6340
|
+
chartOptions: {
|
6341
|
+
delta_column: {
|
6342
|
+
field: "category",
|
6343
|
+
name: "Month",
|
6344
|
+
},
|
6345
|
+
},
|
6346
|
+
},
|
6347
|
+
},
|
6348
|
+
field_name: "Month",
|
6349
|
+
expected: [],
|
6350
|
+
},
|
6351
|
+
{
|
6352
|
+
name: "should return an empty array when field is category and col name does not equal to field name",
|
6353
|
+
currentgraph: {
|
6354
|
+
rows: [{
|
6355
|
+
name: "Grouping",
|
6356
|
+
}, ],
|
6357
|
+
cols: [{
|
6358
|
+
name: "Month",
|
6359
|
+
}, ],
|
6360
|
+
options: {
|
6361
|
+
chartOptions: {
|
6362
|
+
delta_column: {
|
6363
|
+
field: "category",
|
6364
|
+
name: "Month",
|
6365
|
+
},
|
6366
|
+
},
|
6367
|
+
},
|
6368
|
+
},
|
6369
|
+
field_name: "Month",
|
6370
|
+
expected: ["Month"],
|
6371
|
+
},
|
6372
|
+
{
|
6373
|
+
name: 'should return an array with keys with trend "total" from walkthrough_options.values.walkthrough',
|
6374
|
+
currentgraph: {
|
6375
|
+
chart_type: "waterfall-chart-walkthrough",
|
6376
|
+
options: {
|
6377
|
+
walkthrough_options: {
|
6378
|
+
values: {
|
6379
|
+
walkthrough: [{
|
6380
|
+
trend: "total",
|
6381
|
+
key: ["Total"]
|
6382
|
+
},
|
6383
|
+
{
|
6384
|
+
trend: "other",
|
6385
|
+
key: ["Value2"]
|
6386
|
+
},
|
6387
|
+
],
|
6388
|
+
},
|
6389
|
+
},
|
6390
|
+
},
|
6391
|
+
},
|
6392
|
+
field_name: "SampleName",
|
6393
|
+
expected: ["Total"],
|
6394
|
+
},
|
6395
|
+
{
|
6396
|
+
name: "should return an empty array when no conditions are met",
|
6397
|
+
currentgraph: {
|
6398
|
+
options: {
|
6399
|
+
chartOptions: {}
|
6400
|
+
},
|
6401
|
+
chart_type: "column-chart",
|
6402
|
+
},
|
6403
|
+
field_name: "Month",
|
6404
|
+
expected: [],
|
6405
|
+
},
|
6406
|
+
];
|
6407
|
+
|
6408
|
+
testCases.forEach(({
|
6409
|
+
name,
|
6410
|
+
currentgraph,
|
6411
|
+
field_name,
|
6412
|
+
expected
|
6413
|
+
}) => {
|
6414
|
+
it(name, () => {
|
6415
|
+
const result = highchartsRenderer.check_values_not_for_convert(
|
6416
|
+
currentgraph,
|
6417
|
+
field_name
|
6418
|
+
);
|
6419
|
+
expect(result).toEqual(expected);
|
6420
|
+
});
|
6421
|
+
});
|
6422
|
+
});
|
6177
6423
|
});
|