@datarailsshared/dr_renderer 1.5.133 → 1.5.147
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/.github/workflows/release.yml +12 -36
- package/package.json +1 -1
- package/src/charts/dr_gauge_chart.js +1 -1
- package/src/dr-renderer-helpers.js +0 -7
- package/src/highcharts_renderer.js +16 -54
- package/src/index.d.ts +6 -0
- package/src/options/builders.js +26 -27
- package/src/options/index.js +21 -25
- package/src/options/presets.js +22 -23
- package/src/types/options/builders.d.ts +3 -8
- package/src/types/options/index.d.ts +3 -8
- package/src/types/options/presets.d.ts +3 -8
- package/tests/__snapshots__/suboptions.test.js.snap +6 -6
- package/tests/dr_gauge_chart.test.js +9 -11
- package/tests/highcharts_renderer.test.js +34 -90
- package/tests/options-builder.test.js +77 -89
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Unit tests for the options builder module.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Tests the standalone options builder module components:
|
|
5
5
|
* - Constants
|
|
6
6
|
* - Element factories
|
|
@@ -26,7 +26,7 @@ const {
|
|
|
26
26
|
LABEL_DEFAULT_OPTIONS,
|
|
27
27
|
SUBOPTIONS_FONT_SIZE_VALUES,
|
|
28
28
|
DEFAULT_CATEGORY_CLASS,
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
// Element factories
|
|
31
31
|
createToggle,
|
|
32
32
|
createCheckbox,
|
|
@@ -40,7 +40,7 @@ const {
|
|
|
40
40
|
createFontStylingGroup,
|
|
41
41
|
createLabelStyleGroup,
|
|
42
42
|
createTooltipStyleGroup,
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
// Builders
|
|
45
45
|
withLabel,
|
|
46
46
|
withLabelPie,
|
|
@@ -76,7 +76,7 @@ const {
|
|
|
76
76
|
withGaugeGoal,
|
|
77
77
|
withGaugeSegments,
|
|
78
78
|
withGaugeIsAbsolute,
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
// Presets
|
|
81
81
|
CHART_PRESETS,
|
|
82
82
|
BUILDER_KEY_MAP,
|
|
@@ -86,16 +86,16 @@ const {
|
|
|
86
86
|
buildSuboptions,
|
|
87
87
|
getChartTypes,
|
|
88
88
|
hasPreset,
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
// Helpers
|
|
91
91
|
chartHasVerticalDataLabelsOption,
|
|
92
|
-
|
|
92
|
+
|
|
93
93
|
// Disabled conditions
|
|
94
94
|
LABEL_DISABLED_CONDITION,
|
|
95
95
|
LABEL_PIE_DISABLED_CONDITION,
|
|
96
96
|
TOOLTIP_DISABLED_CONDITION,
|
|
97
97
|
TOOLTIP_PIE_DISABLED_CONDITION,
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
// Reusable elements
|
|
100
100
|
LABEL_SHOW_TOGGLE,
|
|
101
101
|
LABEL_PIE_SHOW_TOGGLE,
|
|
@@ -103,17 +103,17 @@ const {
|
|
|
103
103
|
TOOLTIP_SHOW_TOGGLE,
|
|
104
104
|
TOOLTIP_PIE_SHOW_TOGGLE,
|
|
105
105
|
GAUGE_SHOW_TOGGLE,
|
|
106
|
-
|
|
106
|
+
|
|
107
107
|
// Factory
|
|
108
108
|
createDefaultSuboptions,
|
|
109
109
|
} = options;
|
|
110
110
|
|
|
111
111
|
describe('Options Builder Module', () => {
|
|
112
|
-
|
|
112
|
+
|
|
113
113
|
// =========================================================================
|
|
114
114
|
// Constants Tests
|
|
115
115
|
// =========================================================================
|
|
116
|
-
|
|
116
|
+
|
|
117
117
|
describe('Constants', () => {
|
|
118
118
|
describe('CHART_TYPES', () => {
|
|
119
119
|
it('should contain all expected chart types', () => {
|
|
@@ -440,12 +440,12 @@ describe('Options Builder Module', () => {
|
|
|
440
440
|
// =========================================================================
|
|
441
441
|
// Element Factory Tests
|
|
442
442
|
// =========================================================================
|
|
443
|
-
|
|
443
|
+
|
|
444
444
|
describe('Element Factories', () => {
|
|
445
445
|
describe('createToggle', () => {
|
|
446
446
|
it('should create a toggle element with required properties', () => {
|
|
447
447
|
const toggle = createToggle('show', 'Show', true);
|
|
448
|
-
|
|
448
|
+
|
|
449
449
|
expect(toggle).toEqual({
|
|
450
450
|
element_type: 'toggle',
|
|
451
451
|
element_label: 'Show',
|
|
@@ -462,7 +462,7 @@ describe('Options Builder Module', () => {
|
|
|
462
462
|
it('should merge additional options', () => {
|
|
463
463
|
const showFn = jest.fn();
|
|
464
464
|
const toggle = createToggle('show', 'Show', true, { showFn });
|
|
465
|
-
|
|
465
|
+
|
|
466
466
|
expect(toggle.showFn).toBe(showFn);
|
|
467
467
|
});
|
|
468
468
|
|
|
@@ -472,7 +472,7 @@ describe('Options Builder Module', () => {
|
|
|
472
472
|
disabled_str: '!{var}.other',
|
|
473
473
|
disabled_fn,
|
|
474
474
|
});
|
|
475
|
-
|
|
475
|
+
|
|
476
476
|
expect(toggle.disabled_str).toBe('!{var}.other');
|
|
477
477
|
expect(toggle.disabled_fn).toBe(disabled_fn);
|
|
478
478
|
});
|
|
@@ -481,7 +481,7 @@ describe('Options Builder Module', () => {
|
|
|
481
481
|
describe('createCheckbox', () => {
|
|
482
482
|
it('should create a checkbox element with required properties', () => {
|
|
483
483
|
const checkbox = createCheckbox('enabled', 'Enabled', true);
|
|
484
|
-
|
|
484
|
+
|
|
485
485
|
expect(checkbox).toEqual({
|
|
486
486
|
element_type: 'checkbox',
|
|
487
487
|
element_label: 'Enabled',
|
|
@@ -498,7 +498,7 @@ describe('Options Builder Module', () => {
|
|
|
498
498
|
it('should support clickFn option', () => {
|
|
499
499
|
const clickFn = jest.fn();
|
|
500
500
|
const checkbox = createCheckbox('value', 'Value', true, { clickFn });
|
|
501
|
-
|
|
501
|
+
|
|
502
502
|
expect(checkbox.clickFn).toBe(clickFn);
|
|
503
503
|
});
|
|
504
504
|
|
|
@@ -511,7 +511,7 @@ describe('Options Builder Module', () => {
|
|
|
511
511
|
describe('createInput', () => {
|
|
512
512
|
it('should create an input element with required properties', () => {
|
|
513
513
|
const input = createInput('name', 'Name', 'default');
|
|
514
|
-
|
|
514
|
+
|
|
515
515
|
expect(input).toEqual({
|
|
516
516
|
element_type: 'input',
|
|
517
517
|
element_label: 'Name',
|
|
@@ -554,7 +554,7 @@ describe('Options Builder Module', () => {
|
|
|
554
554
|
|
|
555
555
|
it('should create a select element with required properties', () => {
|
|
556
556
|
const select = createSelect('font', 'Font', fontOptions, 'Arial');
|
|
557
|
-
|
|
557
|
+
|
|
558
558
|
expect(select.element_type).toBe('select');
|
|
559
559
|
expect(select.element_label).toBe('Font');
|
|
560
560
|
expect(select.value_name).toBe('font');
|
|
@@ -565,7 +565,7 @@ describe('Options Builder Module', () => {
|
|
|
565
565
|
it('should support string array as options', () => {
|
|
566
566
|
const stringOptions = ['Arial', 'Poppins', 'Helvetica'];
|
|
567
567
|
const select = createSelect('font', 'Font', stringOptions, 'Arial');
|
|
568
|
-
|
|
568
|
+
|
|
569
569
|
expect(select.element_options).toEqual(stringOptions);
|
|
570
570
|
});
|
|
571
571
|
|
|
@@ -584,7 +584,7 @@ describe('Options Builder Module', () => {
|
|
|
584
584
|
|
|
585
585
|
it('should create a radio element with required properties', () => {
|
|
586
586
|
const radio = createRadio('align', 'Alignment', alignOptions, 'left');
|
|
587
|
-
|
|
587
|
+
|
|
588
588
|
expect(radio.element_type).toBe('radio');
|
|
589
589
|
expect(radio.element_label).toBe('Alignment');
|
|
590
590
|
expect(radio.value_name).toBe('align');
|
|
@@ -608,7 +608,7 @@ describe('Options Builder Module', () => {
|
|
|
608
608
|
describe('createColorPicker', () => {
|
|
609
609
|
it('should create a color picker element with required properties', () => {
|
|
610
610
|
const colorPicker = createColorPicker('color', 'Color', '#ff0000');
|
|
611
|
-
|
|
611
|
+
|
|
612
612
|
expect(colorPicker).toEqual({
|
|
613
613
|
element_type: 'color_picker',
|
|
614
614
|
element_label: 'Color',
|
|
@@ -626,14 +626,14 @@ describe('Options Builder Module', () => {
|
|
|
626
626
|
describe('createDivider', () => {
|
|
627
627
|
it('should create a divider element without label', () => {
|
|
628
628
|
const divider = createDivider();
|
|
629
|
-
|
|
629
|
+
|
|
630
630
|
expect(divider.element_type).toBe('devider');
|
|
631
631
|
expect(divider.element_label).toBeUndefined();
|
|
632
632
|
});
|
|
633
633
|
|
|
634
634
|
it('should create a divider element with label', () => {
|
|
635
635
|
const divider = createDivider('Section Title');
|
|
636
|
-
|
|
636
|
+
|
|
637
637
|
expect(divider.element_type).toBe('devider');
|
|
638
638
|
expect(divider.element_label).toBe('Section Title');
|
|
639
639
|
});
|
|
@@ -642,7 +642,7 @@ describe('Options Builder Module', () => {
|
|
|
642
642
|
describe('createTextarea', () => {
|
|
643
643
|
it('should create a textarea element with required properties', () => {
|
|
644
644
|
const textarea = createTextarea('description', 'Description', 'default text');
|
|
645
|
-
|
|
645
|
+
|
|
646
646
|
expect(textarea).toEqual({
|
|
647
647
|
element_type: 'textarea',
|
|
648
648
|
element_label: 'Description',
|
|
@@ -660,7 +660,7 @@ describe('Options Builder Module', () => {
|
|
|
660
660
|
describe('createTag', () => {
|
|
661
661
|
it('should create a tag element with required properties', () => {
|
|
662
662
|
const tag = createTag('tags', 'Tags', ['tag1', 'tag2']);
|
|
663
|
-
|
|
663
|
+
|
|
664
664
|
expect(tag.element_type).toBe('tag');
|
|
665
665
|
expect(tag.element_label).toBe('Tags');
|
|
666
666
|
expect(tag.value_name).toBe('tags');
|
|
@@ -674,7 +674,7 @@ describe('Options Builder Module', () => {
|
|
|
674
674
|
|
|
675
675
|
it('should set tag options with defaults', () => {
|
|
676
676
|
const tag = createTag('tags', 'Tags');
|
|
677
|
-
|
|
677
|
+
|
|
678
678
|
expect(tag.element_options).toEqual({
|
|
679
679
|
add_new_tag: true,
|
|
680
680
|
searchable: true,
|
|
@@ -688,7 +688,7 @@ describe('Options Builder Module', () => {
|
|
|
688
688
|
searchable: false,
|
|
689
689
|
multiple: false,
|
|
690
690
|
});
|
|
691
|
-
|
|
691
|
+
|
|
692
692
|
expect(tag.element_options).toEqual({
|
|
693
693
|
add_new_tag: false,
|
|
694
694
|
searchable: false,
|
|
@@ -705,20 +705,20 @@ describe('Options Builder Module', () => {
|
|
|
705
705
|
|
|
706
706
|
it('should contain font_style select, font_size select, and font_color picker', () => {
|
|
707
707
|
const group = createFontStylingGroup();
|
|
708
|
-
|
|
708
|
+
|
|
709
709
|
expect(group[0].value_name).toBe('font_style');
|
|
710
710
|
expect(group[0].element_type).toBe('select');
|
|
711
|
-
|
|
711
|
+
|
|
712
712
|
expect(group[1].value_name).toBe('font_size');
|
|
713
713
|
expect(group[1].element_type).toBe('select');
|
|
714
|
-
|
|
714
|
+
|
|
715
715
|
expect(group[2].value_name).toBe('font_color');
|
|
716
716
|
expect(group[2].element_type).toBe('color_picker');
|
|
717
717
|
});
|
|
718
718
|
|
|
719
719
|
it('should use label defaults when no custom defaults provided', () => {
|
|
720
720
|
const group = createFontStylingGroup();
|
|
721
|
-
|
|
721
|
+
|
|
722
722
|
expect(group[0].default_value).toBe(LABEL_DEFAULT_SETTINGS.FONT_FAMILY);
|
|
723
723
|
expect(group[1].default_value).toBe(LABEL_DEFAULT_SETTINGS.FONT_SIZE);
|
|
724
724
|
expect(group[2].default_value).toBe(LABEL_DEFAULT_SETTINGS.FONT_COLOR);
|
|
@@ -730,7 +730,7 @@ describe('Options Builder Module', () => {
|
|
|
730
730
|
fontSize: '14',
|
|
731
731
|
fontColor: '#000000',
|
|
732
732
|
});
|
|
733
|
-
|
|
733
|
+
|
|
734
734
|
expect(group[0].default_value).toBe('Arial');
|
|
735
735
|
expect(group[1].default_value).toBe('14');
|
|
736
736
|
expect(group[2].default_value).toBe('#000000');
|
|
@@ -740,7 +740,7 @@ describe('Options Builder Module', () => {
|
|
|
740
740
|
describe('createLabelStyleGroup', () => {
|
|
741
741
|
it('should return array with dividers and font styling', () => {
|
|
742
742
|
const group = createLabelStyleGroup();
|
|
743
|
-
|
|
743
|
+
|
|
744
744
|
// Should have 2 dividers + 3 font styling elements
|
|
745
745
|
expect(group).toHaveLength(5);
|
|
746
746
|
expect(group[0].element_type).toBe('devider');
|
|
@@ -752,7 +752,7 @@ describe('Options Builder Module', () => {
|
|
|
752
752
|
describe('createTooltipStyleGroup', () => {
|
|
753
753
|
it('should return array with dividers and font styling', () => {
|
|
754
754
|
const group = createTooltipStyleGroup();
|
|
755
|
-
|
|
755
|
+
|
|
756
756
|
// Should have 2 dividers + 3 font styling elements
|
|
757
757
|
expect(group).toHaveLength(5);
|
|
758
758
|
expect(group[0].element_type).toBe('devider');
|
|
@@ -762,7 +762,7 @@ describe('Options Builder Module', () => {
|
|
|
762
762
|
|
|
763
763
|
it('should use tooltip defaults', () => {
|
|
764
764
|
const group = createTooltipStyleGroup();
|
|
765
|
-
|
|
765
|
+
|
|
766
766
|
expect(group[2].default_value).toBe(TOOLTIP_DEFAULT_SETTINGS.FONT_FAMILY);
|
|
767
767
|
expect(group[3].default_value).toBe(TOOLTIP_DEFAULT_SETTINGS.FONT_SIZE);
|
|
768
768
|
expect(group[4].default_value).toBe(TOOLTIP_DEFAULT_SETTINGS.FONT_COLOR);
|
|
@@ -773,7 +773,7 @@ describe('Options Builder Module', () => {
|
|
|
773
773
|
// =========================================================================
|
|
774
774
|
// Builder Tests
|
|
775
775
|
// =========================================================================
|
|
776
|
-
|
|
776
|
+
|
|
777
777
|
describe('Builders', () => {
|
|
778
778
|
// Helper to validate SuboptionDefinition structure
|
|
779
779
|
const expectValidSuboptionDefinition = (def) => {
|
|
@@ -823,7 +823,7 @@ describe('Options Builder Module', () => {
|
|
|
823
823
|
const fontStyle = result.elements.find(e => e.value_name === 'font_style');
|
|
824
824
|
const fontSize = result.elements.find(e => e.value_name === 'font_size');
|
|
825
825
|
const fontColor = result.elements.find(e => e.value_name === 'font_color');
|
|
826
|
-
|
|
826
|
+
|
|
827
827
|
expect(fontStyle).toBeDefined();
|
|
828
828
|
expect(fontSize).toBeDefined();
|
|
829
829
|
expect(fontColor).toBeDefined();
|
|
@@ -845,7 +845,7 @@ describe('Options Builder Module', () => {
|
|
|
845
845
|
const result = withLabelPie();
|
|
846
846
|
const useAreaColor = result.elements.find(e => e.value_name === 'use_area_color');
|
|
847
847
|
const showPercentage = result.elements.find(e => e.value_name === 'show_percentage_in_labels');
|
|
848
|
-
|
|
848
|
+
|
|
849
849
|
expect(useAreaColor).toBeDefined();
|
|
850
850
|
expect(showPercentage).toBeDefined();
|
|
851
851
|
});
|
|
@@ -866,25 +866,19 @@ describe('Options Builder Module', () => {
|
|
|
866
866
|
const result = withLabelGauge();
|
|
867
867
|
const showPercentageInValue = result.elements.find(e => e.value_name === 'show_percentage_in_value');
|
|
868
868
|
const showGoalName = result.elements.find(e => e.value_name === 'show_goal_name');
|
|
869
|
-
|
|
869
|
+
|
|
870
870
|
expect(showPercentageInValue).toBeDefined();
|
|
871
871
|
expect(showGoalName).toBeDefined();
|
|
872
872
|
});
|
|
873
873
|
|
|
874
|
-
it('should use
|
|
875
|
-
const
|
|
876
|
-
|
|
877
|
-
hasFeature,
|
|
878
|
-
ENABLE_GAUGE_DYNAMIC_GOAL: 'test_feature',
|
|
879
|
-
});
|
|
880
|
-
|
|
874
|
+
it('should use enableGaugeDynamicGoal config for goal_name visibility', () => {
|
|
875
|
+
const result = withLabelGauge({ enableGaugeDynamicGoal: true });
|
|
876
|
+
|
|
881
877
|
const goalName = result.elements.find(e => e.value_name === 'goal_name');
|
|
882
878
|
expect(goalName).toBeDefined();
|
|
883
879
|
expect(goalName.showFn).toBeDefined();
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
goalName.showFn();
|
|
887
|
-
expect(hasFeature).toHaveBeenCalledWith('test_feature');
|
|
880
|
+
|
|
881
|
+
expect(goalName.showFn()).toBe(true);
|
|
888
882
|
});
|
|
889
883
|
});
|
|
890
884
|
|
|
@@ -898,7 +892,7 @@ describe('Options Builder Module', () => {
|
|
|
898
892
|
const result = withLabelWithPercentage();
|
|
899
893
|
const presentTotal = result.elements.find(e => e.value_name === 'present_total');
|
|
900
894
|
const showPercentage = result.elements.find(e => e.value_name === 'show_percentage');
|
|
901
|
-
|
|
895
|
+
|
|
902
896
|
expect(presentTotal).toBeDefined();
|
|
903
897
|
expect(showPercentage).toBeDefined();
|
|
904
898
|
});
|
|
@@ -929,7 +923,7 @@ describe('Options Builder Module', () => {
|
|
|
929
923
|
const result = withTooltip();
|
|
930
924
|
const show = result.elements.find(e => e.value_name === 'show');
|
|
931
925
|
const showValue = result.elements.find(e => e.value_name === 'show_value');
|
|
932
|
-
|
|
926
|
+
|
|
933
927
|
expect(show).toBeDefined();
|
|
934
928
|
expect(showValue).toBeDefined();
|
|
935
929
|
});
|
|
@@ -978,7 +972,7 @@ describe('Options Builder Module', () => {
|
|
|
978
972
|
const result = withAxisY();
|
|
979
973
|
const min = result.elements.find(e => e.value_name === 'min');
|
|
980
974
|
const max = result.elements.find(e => e.value_name === 'max');
|
|
981
|
-
|
|
975
|
+
|
|
982
976
|
expect(min).toBeDefined();
|
|
983
977
|
expect(max).toBeDefined();
|
|
984
978
|
});
|
|
@@ -994,7 +988,7 @@ describe('Options Builder Module', () => {
|
|
|
994
988
|
const result = withAxisYPercentStacked();
|
|
995
989
|
const min = result.elements.find(e => e.value_name === 'min');
|
|
996
990
|
const max = result.elements.find(e => e.value_name === 'max');
|
|
997
|
-
|
|
991
|
+
|
|
998
992
|
expect(min).toBeUndefined();
|
|
999
993
|
expect(max).toBeUndefined();
|
|
1000
994
|
});
|
|
@@ -1031,7 +1025,7 @@ describe('Options Builder Module', () => {
|
|
|
1031
1025
|
const result = withTableOptions();
|
|
1032
1026
|
const showColumnTotal = result.elements.find(e => e.value_name === 'show_column_total');
|
|
1033
1027
|
const showRowTotal = result.elements.find(e => e.value_name === 'show_row_total');
|
|
1034
|
-
|
|
1028
|
+
|
|
1035
1029
|
expect(showColumnTotal).toBeDefined();
|
|
1036
1030
|
expect(showRowTotal).toBeDefined();
|
|
1037
1031
|
});
|
|
@@ -1046,7 +1040,7 @@ describe('Options Builder Module', () => {
|
|
|
1046
1040
|
it('should have transpose disabled by default', () => {
|
|
1047
1041
|
const result = withTableOptionsTranspose();
|
|
1048
1042
|
const transpose = result.elements.find(e => e.value_name === 'transpose_table');
|
|
1049
|
-
|
|
1043
|
+
|
|
1050
1044
|
expect(transpose).toBeDefined();
|
|
1051
1045
|
expect(transpose.default_value).toBe(false);
|
|
1052
1046
|
});
|
|
@@ -1232,13 +1226,13 @@ describe('Options Builder Module', () => {
|
|
|
1232
1226
|
{ from: 0, to: 100, color: 'green', title: 'Good' },
|
|
1233
1227
|
];
|
|
1234
1228
|
const result = withGaugeSegments({ defaultSegments: customSegments });
|
|
1235
|
-
|
|
1229
|
+
|
|
1236
1230
|
expect(result.default_value).toEqual(customSegments);
|
|
1237
1231
|
});
|
|
1238
1232
|
|
|
1239
1233
|
it('should use fallback segments when not provided', () => {
|
|
1240
1234
|
const result = withGaugeSegments();
|
|
1241
|
-
|
|
1235
|
+
|
|
1242
1236
|
expect(result.default_value).toBeDefined();
|
|
1243
1237
|
expect(Array.isArray(result.default_value)).toBe(true);
|
|
1244
1238
|
expect(result.default_value.length).toBeGreaterThan(0);
|
|
@@ -1267,7 +1261,7 @@ describe('Options Builder Module', () => {
|
|
|
1267
1261
|
// =========================================================================
|
|
1268
1262
|
// Preset Tests
|
|
1269
1263
|
// =========================================================================
|
|
1270
|
-
|
|
1264
|
+
|
|
1271
1265
|
describe('Presets', () => {
|
|
1272
1266
|
describe('CHART_PRESETS', () => {
|
|
1273
1267
|
it('should be defined', () => {
|
|
@@ -1284,7 +1278,7 @@ describe('Options Builder Module', () => {
|
|
|
1284
1278
|
|
|
1285
1279
|
it('should have arrays of builder functions', () => {
|
|
1286
1280
|
const lineChartPreset = CHART_PRESETS[CHART_TYPES.LINE_CHART];
|
|
1287
|
-
|
|
1281
|
+
|
|
1288
1282
|
expect(Array.isArray(lineChartPreset)).toBe(true);
|
|
1289
1283
|
lineChartPreset.forEach(builder => {
|
|
1290
1284
|
expect(typeof builder).toBe('function');
|
|
@@ -1324,14 +1318,14 @@ describe('Options Builder Module', () => {
|
|
|
1324
1318
|
describe('getPresetForChart', () => {
|
|
1325
1319
|
it('should return preset for known chart type', () => {
|
|
1326
1320
|
const preset = getPresetForChart(CHART_TYPES.LINE_CHART);
|
|
1327
|
-
|
|
1321
|
+
|
|
1328
1322
|
expect(preset).toBeDefined();
|
|
1329
1323
|
expect(Array.isArray(preset)).toBe(true);
|
|
1330
1324
|
});
|
|
1331
1325
|
|
|
1332
1326
|
it('should include expected builders for line chart', () => {
|
|
1333
1327
|
const preset = getPresetForChart(CHART_TYPES.LINE_CHART);
|
|
1334
|
-
|
|
1328
|
+
|
|
1335
1329
|
expect(preset).toContain(withLabel);
|
|
1336
1330
|
expect(preset).toContain(withTooltip);
|
|
1337
1331
|
expect(preset).toContain(withAxisY);
|
|
@@ -1341,7 +1335,7 @@ describe('Options Builder Module', () => {
|
|
|
1341
1335
|
|
|
1342
1336
|
it('should include pie-specific builders for pie chart', () => {
|
|
1343
1337
|
const preset = getPresetForChart(CHART_TYPES.PIE_CHART);
|
|
1344
|
-
|
|
1338
|
+
|
|
1345
1339
|
expect(preset).toContain(withLabelPie);
|
|
1346
1340
|
expect(preset).toContain(withTooltipPie);
|
|
1347
1341
|
expect(preset).not.toContain(withLabel);
|
|
@@ -1350,7 +1344,7 @@ describe('Options Builder Module', () => {
|
|
|
1350
1344
|
|
|
1351
1345
|
it('should include gauge-specific builders for gauge chart', () => {
|
|
1352
1346
|
const preset = getPresetForChart(CHART_TYPES.GAUGE_CHART_ENHANCED);
|
|
1353
|
-
|
|
1347
|
+
|
|
1354
1348
|
expect(preset).toContain(withLabelGauge);
|
|
1355
1349
|
expect(preset).toContain(withTooltipGauge);
|
|
1356
1350
|
expect(preset).toContain(withGaugeGoal);
|
|
@@ -1366,14 +1360,14 @@ describe('Options Builder Module', () => {
|
|
|
1366
1360
|
describe('buildSuboptionsForChart', () => {
|
|
1367
1361
|
it('should build suboptions object for a chart type', () => {
|
|
1368
1362
|
const result = buildSuboptionsForChart(CHART_TYPES.LINE_CHART);
|
|
1369
|
-
|
|
1363
|
+
|
|
1370
1364
|
expect(result).toBeDefined();
|
|
1371
1365
|
expect(typeof result).toBe('object');
|
|
1372
1366
|
});
|
|
1373
1367
|
|
|
1374
1368
|
it('should include expected keys for line chart', () => {
|
|
1375
1369
|
const result = buildSuboptionsForChart(CHART_TYPES.LINE_CHART);
|
|
1376
|
-
|
|
1370
|
+
|
|
1377
1371
|
expect(result).toHaveProperty('label');
|
|
1378
1372
|
expect(result).toHaveProperty('tooltips');
|
|
1379
1373
|
expect(result).toHaveProperty('axisY');
|
|
@@ -1382,7 +1376,7 @@ describe('Options Builder Module', () => {
|
|
|
1382
1376
|
|
|
1383
1377
|
it('should include pie-specific keys for pie chart', () => {
|
|
1384
1378
|
const result = buildSuboptionsForChart(CHART_TYPES.PIE_CHART);
|
|
1385
|
-
|
|
1379
|
+
|
|
1386
1380
|
expect(result).toHaveProperty('label_pie');
|
|
1387
1381
|
expect(result).toHaveProperty('tooltips_pie');
|
|
1388
1382
|
expect(result).not.toHaveProperty('label');
|
|
@@ -1391,14 +1385,14 @@ describe('Options Builder Module', () => {
|
|
|
1391
1385
|
|
|
1392
1386
|
it('should return empty object for unknown chart type', () => {
|
|
1393
1387
|
const result = buildSuboptionsForChart('unknown-chart');
|
|
1394
|
-
|
|
1388
|
+
|
|
1395
1389
|
expect(result).toEqual({});
|
|
1396
1390
|
});
|
|
1397
1391
|
|
|
1398
1392
|
it('should pass config to builders', () => {
|
|
1399
1393
|
const config = { CHART_TYPES };
|
|
1400
1394
|
const result = buildSuboptionsForChart(CHART_TYPES.COLUMN_CHART, config);
|
|
1401
|
-
|
|
1395
|
+
|
|
1402
1396
|
// Should still work with config
|
|
1403
1397
|
expect(result).toHaveProperty('table_options');
|
|
1404
1398
|
});
|
|
@@ -1407,7 +1401,7 @@ describe('Options Builder Module', () => {
|
|
|
1407
1401
|
describe('buildSuboptions', () => {
|
|
1408
1402
|
it('should build suboptions from an array of builders', () => {
|
|
1409
1403
|
const result = buildSuboptions([withLabel, withTooltip]);
|
|
1410
|
-
|
|
1404
|
+
|
|
1411
1405
|
expect(Object.keys(result)).toHaveLength(2);
|
|
1412
1406
|
expect(result).toHaveProperty('label');
|
|
1413
1407
|
expect(result).toHaveProperty('tooltips');
|
|
@@ -1419,19 +1413,15 @@ describe('Options Builder Module', () => {
|
|
|
1419
1413
|
});
|
|
1420
1414
|
|
|
1421
1415
|
it('should pass config to builders', () => {
|
|
1422
|
-
const
|
|
1423
|
-
|
|
1424
|
-
hasFeature,
|
|
1425
|
-
ENABLE_GAUGE_DYNAMIC_GOAL: 'test',
|
|
1426
|
-
});
|
|
1427
|
-
|
|
1416
|
+
const result = buildSuboptions([withLabelGauge], { enableGaugeDynamicGoal: true });
|
|
1417
|
+
|
|
1428
1418
|
expect(result).toHaveProperty('label_gauge');
|
|
1429
1419
|
});
|
|
1430
1420
|
|
|
1431
1421
|
it('should skip unknown builders', () => {
|
|
1432
1422
|
const unknownBuilder = () => ({});
|
|
1433
1423
|
const result = buildSuboptions([withLabel, unknownBuilder, withTooltip]);
|
|
1434
|
-
|
|
1424
|
+
|
|
1435
1425
|
expect(Object.keys(result)).toHaveLength(2);
|
|
1436
1426
|
expect(result).toHaveProperty('label');
|
|
1437
1427
|
expect(result).toHaveProperty('tooltips');
|
|
@@ -1441,14 +1431,14 @@ describe('Options Builder Module', () => {
|
|
|
1441
1431
|
describe('getChartTypes', () => {
|
|
1442
1432
|
it('should return array of chart types', () => {
|
|
1443
1433
|
const result = getChartTypes();
|
|
1444
|
-
|
|
1434
|
+
|
|
1445
1435
|
expect(Array.isArray(result)).toBe(true);
|
|
1446
1436
|
expect(result.length).toBeGreaterThan(0);
|
|
1447
1437
|
});
|
|
1448
1438
|
|
|
1449
1439
|
it('should contain all expected chart types', () => {
|
|
1450
1440
|
const result = getChartTypes();
|
|
1451
|
-
|
|
1441
|
+
|
|
1452
1442
|
expect(result).toContain('line-chart');
|
|
1453
1443
|
expect(result).toContain('column-chart');
|
|
1454
1444
|
expect(result).toContain('bar-chart');
|
|
@@ -1474,7 +1464,7 @@ describe('Options Builder Module', () => {
|
|
|
1474
1464
|
// =========================================================================
|
|
1475
1465
|
// Helper Tests
|
|
1476
1466
|
// =========================================================================
|
|
1477
|
-
|
|
1467
|
+
|
|
1478
1468
|
describe('Helpers', () => {
|
|
1479
1469
|
describe('chartHasVerticalDataLabelsOption', () => {
|
|
1480
1470
|
it('should return true for charts that support vertical labels', () => {
|
|
@@ -1504,12 +1494,12 @@ describe('Options Builder Module', () => {
|
|
|
1504
1494
|
// =========================================================================
|
|
1505
1495
|
// Index/Factory Tests
|
|
1506
1496
|
// =========================================================================
|
|
1507
|
-
|
|
1497
|
+
|
|
1508
1498
|
describe('Index Exports and createDefaultSuboptions', () => {
|
|
1509
1499
|
describe('createDefaultSuboptions', () => {
|
|
1510
1500
|
it('should create a complete suboptions object', () => {
|
|
1511
1501
|
const result = createDefaultSuboptions();
|
|
1512
|
-
|
|
1502
|
+
|
|
1513
1503
|
expect(result).toBeDefined();
|
|
1514
1504
|
expect(typeof result).toBe('object');
|
|
1515
1505
|
});
|
|
@@ -1552,7 +1542,7 @@ describe('Options Builder Module', () => {
|
|
|
1552
1542
|
'gauge_segments',
|
|
1553
1543
|
'gauge_is_absolute',
|
|
1554
1544
|
];
|
|
1555
|
-
|
|
1545
|
+
|
|
1556
1546
|
expectedKeys.forEach(key => {
|
|
1557
1547
|
expect(result).toHaveProperty(key);
|
|
1558
1548
|
});
|
|
@@ -1564,23 +1554,21 @@ describe('Options Builder Module', () => {
|
|
|
1564
1554
|
});
|
|
1565
1555
|
|
|
1566
1556
|
it('should pass config to builders that need it', () => {
|
|
1567
|
-
const hasFeature = jest.fn().mockReturnValue(true);
|
|
1568
1557
|
const customSegments = [{ from: 0, to: 100, color: 'green', title: 'Good' }];
|
|
1569
|
-
|
|
1558
|
+
|
|
1570
1559
|
const result = createDefaultSuboptions({
|
|
1571
1560
|
CHART_TYPES,
|
|
1572
|
-
|
|
1573
|
-
ENABLE_GAUGE_DYNAMIC_GOAL: 'test_feature',
|
|
1561
|
+
enableGaugeDynamicGoal: true,
|
|
1574
1562
|
defaultGaugeSegments: customSegments,
|
|
1575
1563
|
});
|
|
1576
|
-
|
|
1564
|
+
|
|
1577
1565
|
// Gauge segments should use custom segments
|
|
1578
1566
|
expect(result.gauge_segments.default_value).toEqual(customSegments);
|
|
1579
1567
|
});
|
|
1580
1568
|
|
|
1581
1569
|
it('should create valid SuboptionDefinition for each suboption', () => {
|
|
1582
1570
|
const result = createDefaultSuboptions();
|
|
1583
|
-
|
|
1571
|
+
|
|
1584
1572
|
Object.values(result).forEach(suboption => {
|
|
1585
1573
|
expect(suboption).toHaveProperty('category_class');
|
|
1586
1574
|
expect(suboption).toHaveProperty('category_label');
|