[Rt-commit] rt branch 5.0/saved-chart-content-avoid-empty-key created. rt-5.0.2-116-g5e60826064

BPS Git Server git at git.bestpractical.com
Fri Apr 8 15:05:14 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/saved-chart-content-avoid-empty-key has been created
        at  5e60826064e84a25c88711a630c73187eadeac3b (commit)

- Log -----------------------------------------------------------------
commit 5e60826064e84a25c88711a630c73187eadeac3b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Apr 8 22:36:08 2022 +0800

    Test empty keys in saved chart content

diff --git a/t/web/saved_search_chart.t b/t/web/saved_search_chart.t
index 24c492e558..8b3317b95a 100644
--- a/t/web/saved_search_chart.t
+++ b/t/web/saved_search_chart.t
@@ -198,4 +198,38 @@ diag "saving a chart without changing its config shows up on dashboards (I#31557
     is_deeply($search->GetParameter('ChartFunction'), ['COUNT'], 'chart correctly initialized with default ChartFunction');
 }
 
+diag "test chart content with default parameters";
+{
+    $m->get_ok( $url . "/Search/Chart.html?Query=" . 'id!=-1' );
+    $m->follow_link_ok( { text => 'Chart' } );    # Get all the default parameters
+    $m->submit_form(
+        form_name => 'SaveSearch',
+        fields    => {
+            SavedSearchDescription => 'chart with default parameters',
+            SavedSearchOwner       => $owner,
+        },
+        button => 'SavedSearchSave',
+    );
+
+    $m->form_name('SaveSearch');
+    my $load_select = $m->current_form->find_input('SavedSearchLoad');
+    my @labels      = $load_select->value_names;
+    my @values      = $load_select->possible_values;
+    require List::MoreUtils;
+    my %label_value = List::MoreUtils::mesh( @labels, @values );
+
+    my $chart_id = $label_value{'chart with default parameters'};
+    ok( $chart_id, 'got a saved chart id' );
+
+    my ( $privacy, $user_id, $search_id ) = $chart_id =~ /^(RT::User-(\d+))-SavedSearch-(\d+)$/;
+    my $user = RT::User->new( RT->SystemUser );
+    $user->Load($user_id);
+    is( $user->Name, 'root', 'loaded user' );
+    my $currentuser = RT::CurrentUser->new($user);
+
+    my $search = RT::SavedSearch->new($currentuser);
+    $search->Load( $privacy, $search_id );
+    ok( !exists $search->{Attribute}->Content->{''}, 'No empty key' );
+}
+
 done_testing;

commit 89774e117e8ef56392c4b4d1ed627c136798356f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Apr 8 21:55:32 2022 +0800

    Exclude empty keys from search fields for saved charts
    
    This is to avoid adding " '' => undef " to content of saved charts when
    an empty ExtraQueryParams param is passed in, which is the default
    behavior.

diff --git a/share/html/Search/Chart.html b/share/html/Search/Chart.html
index 6adc8356ab..c7f1eb44f1 100644
--- a/share/html/Search/Chart.html
+++ b/share/html/Search/Chart.html
@@ -57,7 +57,7 @@ $m->callback( ARGSRef => \%ARGS, CallbackName => 'Initial' );
 
 my $title = loc( "Grouped search results");
 
-my @search_fields = ( qw(Query GroupBy StackedGroupBy ChartStyle ChartFunction Width Height ExtraQueryParams), @ExtraQueryParams );
+my @search_fields = ( qw(Query GroupBy StackedGroupBy ChartStyle ChartFunction Width Height ExtraQueryParams), grep $_, @ExtraQueryParams );
 my $saved_search = $m->comp( '/Widgets/SavedSearch:new',
     SearchType   => 'Chart',
     SearchFields => [@search_fields],

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list