@@ -641,7 +641,58 @@ describe('MultiQueryModeContent', function () {
641
641
] ) ;
642
642
} ) ;
643
643
644
- it ( 'updates query at the correct index' , async function ( ) {
644
+ it ( 'allows changing a query' , async function ( ) {
645
+ let queries : any ;
646
+ function Component ( ) {
647
+ queries = useReadQueriesFromLocation ( ) ;
648
+ return < MultiQueryModeContent /> ;
649
+ }
650
+
651
+ render (
652
+ < PageParamsProvider >
653
+ < SpanTagsProvider dataset = { DiscoverDatasets . SPANS_EAP } enabled >
654
+ < Component />
655
+ </ SpanTagsProvider >
656
+ </ PageParamsProvider >
657
+ ) ;
658
+
659
+ expect ( queries ) . toEqual ( [
660
+ {
661
+ yAxes : [ 'count(span.duration)' ] ,
662
+ sortBys : [
663
+ {
664
+ field : 'timestamp' ,
665
+ kind : 'desc' ,
666
+ } ,
667
+ ] ,
668
+ fields : [ 'id' , 'span.duration' , 'timestamp' ] ,
669
+ groupBys : [ ] ,
670
+ query : '' ,
671
+ } ,
672
+ ] ) ;
673
+
674
+ const section = screen . getByTestId ( 'section-visualize-0' ) ;
675
+ await userEvent . click ( within ( section ) . getByRole ( 'button' , { name : 'count' } ) ) ;
676
+ await userEvent . click ( within ( section ) . getByRole ( 'option' , { name : 'avg' } ) ) ;
677
+ await userEvent . click ( within ( section ) . getByRole ( 'button' , { name : 'span.duration' } ) ) ;
678
+ await userEvent . click ( within ( section ) . getByRole ( 'option' , { name : 'span.self_time' } ) ) ;
679
+ expect ( queries ) . toEqual ( [
680
+ {
681
+ yAxes : [ 'avg(span.self_time)' ] ,
682
+ sortBys : [
683
+ {
684
+ field : 'timestamp' ,
685
+ kind : 'desc' ,
686
+ } ,
687
+ ] ,
688
+ fields : [ 'id' , 'span.self_time' , 'timestamp' ] ,
689
+ groupBys : [ ] ,
690
+ query : '' ,
691
+ } ,
692
+ ] ) ;
693
+ } ) ;
694
+
695
+ it ( 'allows adding a query' , async function ( ) {
645
696
let queries : any ;
646
697
function Component ( ) {
647
698
queries = useReadQueriesFromLocation ( ) ;
@@ -699,12 +750,47 @@ describe('MultiQueryModeContent', function () {
699
750
query : '' ,
700
751
} ,
701
752
] ) ;
753
+ } ) ;
754
+
755
+ it ( 'allows duplicating a query' , async function ( ) {
756
+ let queries : any ;
757
+ function Component ( ) {
758
+ queries = useReadQueriesFromLocation ( ) ;
759
+ return < MultiQueryModeContent /> ;
760
+ }
761
+
762
+ render (
763
+ < PageParamsProvider >
764
+ < SpanTagsProvider dataset = { DiscoverDatasets . SPANS_EAP } enabled >
765
+ < Component />
766
+ </ SpanTagsProvider >
767
+ </ PageParamsProvider >
768
+ ) ;
769
+
770
+ expect ( queries ) . toEqual ( [
771
+ {
772
+ yAxes : [ 'count(span.duration)' ] ,
773
+ sortBys : [
774
+ {
775
+ field : 'timestamp' ,
776
+ kind : 'desc' ,
777
+ } ,
778
+ ] ,
779
+ fields : [ 'id' , 'span.duration' , 'timestamp' ] ,
780
+ groupBys : [ ] ,
781
+ query : '' ,
782
+ } ,
783
+ ] ) ;
702
784
703
785
const section = screen . getByTestId ( 'section-visualize-0' ) ;
704
786
await userEvent . click ( within ( section ) . getByRole ( 'button' , { name : 'count' } ) ) ;
705
787
await userEvent . click ( within ( section ) . getByRole ( 'option' , { name : 'avg' } ) ) ;
706
788
await userEvent . click ( within ( section ) . getByRole ( 'button' , { name : 'span.duration' } ) ) ;
707
789
await userEvent . click ( within ( section ) . getByRole ( 'option' , { name : 'span.self_time' } ) ) ;
790
+
791
+ // Duplicate chart
792
+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'More options' } ) ) ;
793
+ await userEvent . click ( screen . getByRole ( 'menuitemradio' , { name : 'Duplicate Query' } ) ) ;
708
794
expect ( queries ) . toEqual ( [
709
795
{
710
796
yAxes : [ 'avg(span.self_time)' ] ,
@@ -718,6 +804,37 @@ describe('MultiQueryModeContent', function () {
718
804
groupBys : [ ] ,
719
805
query : '' ,
720
806
} ,
807
+ {
808
+ yAxes : [ 'avg(span.self_time)' ] ,
809
+ sortBys : [
810
+ {
811
+ field : 'timestamp' ,
812
+ kind : 'desc' ,
813
+ } ,
814
+ ] ,
815
+ fields : [ 'id' , 'span.self_time' , 'timestamp' ] ,
816
+ groupBys : [ ] ,
817
+ query : '' ,
818
+ } ,
819
+ ] ) ;
820
+ } ) ;
821
+
822
+ it ( 'allows deleting a query' , async function ( ) {
823
+ let queries : any ;
824
+ function Component ( ) {
825
+ queries = useReadQueriesFromLocation ( ) ;
826
+ return < MultiQueryModeContent /> ;
827
+ }
828
+
829
+ render (
830
+ < PageParamsProvider >
831
+ < SpanTagsProvider dataset = { DiscoverDatasets . SPANS_EAP } enabled >
832
+ < Component />
833
+ </ SpanTagsProvider >
834
+ </ PageParamsProvider >
835
+ ) ;
836
+
837
+ expect ( queries ) . toEqual ( [
721
838
{
722
839
yAxes : [ 'count(span.duration)' ] ,
723
840
sortBys : [
@@ -731,7 +848,71 @@ describe('MultiQueryModeContent', function () {
731
848
query : '' ,
732
849
} ,
733
850
] ) ;
734
- await userEvent . click ( screen . getAllByLabelText ( 'Delete Query' ) [ 0 ] ! ) ;
851
+
852
+ // Add chart
853
+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Add Query' } ) ) ;
854
+ expect ( queries ) . toEqual ( [
855
+ {
856
+ yAxes : [ 'count(span.duration)' ] ,
857
+ sortBys : [
858
+ {
859
+ field : 'timestamp' ,
860
+ kind : 'desc' ,
861
+ } ,
862
+ ] ,
863
+ fields : [ 'id' , 'span.duration' , 'timestamp' ] ,
864
+ groupBys : [ ] ,
865
+ query : '' ,
866
+ } ,
867
+ {
868
+ yAxes : [ 'count(span.duration)' ] ,
869
+ sortBys : [
870
+ {
871
+ field : 'timestamp' ,
872
+ kind : 'desc' ,
873
+ } ,
874
+ ] ,
875
+ fields : [ 'id' , 'span.duration' , 'timestamp' ] ,
876
+ groupBys : [ ] ,
877
+ query : '' ,
878
+ } ,
879
+ ] ) ;
880
+
881
+ const section = screen . getByTestId ( 'section-visualize-0' ) ;
882
+ await userEvent . click ( within ( section ) . getByRole ( 'button' , { name : 'count' } ) ) ;
883
+ await userEvent . click ( within ( section ) . getByRole ( 'option' , { name : 'avg' } ) ) ;
884
+ await userEvent . click ( within ( section ) . getByRole ( 'button' , { name : 'span.duration' } ) ) ;
885
+ await userEvent . click ( within ( section ) . getByRole ( 'option' , { name : 'span.self_time' } ) ) ;
886
+ expect ( queries ) . toEqual ( [
887
+ {
888
+ yAxes : [ 'avg(span.self_time)' ] ,
889
+ sortBys : [
890
+ {
891
+ field : 'timestamp' ,
892
+ kind : 'desc' ,
893
+ } ,
894
+ ] ,
895
+ fields : [ 'id' , 'span.self_time' , 'timestamp' ] ,
896
+ groupBys : [ ] ,
897
+ query : '' ,
898
+ } ,
899
+ {
900
+ yAxes : [ 'count(span.duration)' ] ,
901
+ sortBys : [
902
+ {
903
+ field : 'timestamp' ,
904
+ kind : 'desc' ,
905
+ } ,
906
+ ] ,
907
+ fields : [ 'id' , 'span.duration' , 'timestamp' ] ,
908
+ groupBys : [ ] ,
909
+ query : '' ,
910
+ } ,
911
+ ] ) ;
912
+
913
+ await userEvent . click ( screen . getAllByRole ( 'button' , { name : 'More options' } ) [ 0 ] ! ) ;
914
+ await userEvent . click ( screen . getByRole ( 'menuitemradio' , { name : 'Delete Query' } ) ) ;
915
+
735
916
expect ( queries ) . toEqual ( [
736
917
{
737
918
yAxes : [ 'count(span.duration)' ] ,
@@ -960,14 +1141,11 @@ describe('MultiQueryModeContent', function () {
960
1141
} ,
961
1142
} ,
962
1143
} ) ;
963
- function Component ( ) {
964
- return < MultiQueryModeContent /> ;
965
- }
966
1144
967
1145
render (
968
1146
< PageParamsProvider >
969
1147
< SpanTagsProvider dataset = { DiscoverDatasets . SPANS_EAP } enabled >
970
- < Component />
1148
+ < MultiQueryModeContent />
971
1149
</ SpanTagsProvider >
972
1150
</ PageParamsProvider > ,
973
1151
{
@@ -1046,14 +1224,10 @@ describe('MultiQueryModeContent', function () {
1046
1224
} ,
1047
1225
} ) ;
1048
1226
1049
- function Component ( ) {
1050
- return < MultiQueryModeContent /> ;
1051
- }
1052
-
1053
1227
render (
1054
1228
< PageParamsProvider >
1055
1229
< SpanTagsProvider dataset = { DiscoverDatasets . SPANS_EAP } enabled >
1056
- < Component />
1230
+ < MultiQueryModeContent />
1057
1231
</ SpanTagsProvider >
1058
1232
</ PageParamsProvider > ,
1059
1233
{
0 commit comments