[Rt-commit] rt branch, 4.6/search-selection-next, repushed
Blaine Motsinger
blaine at bestpractical.com
Thu Feb 13 21:23:06 EST 2020
The branch 4.6/search-selection-next was deleted and repushed:
was bd7c2e5011b8a093b89dfa9946d4c079dd57dd5d
now baffe69511891bf21496d89e8217aeb5edbaab5d
1: 2aab9ecde = 1: 2aab9ecde Add RT-Extension-DashboardSelectionUI to core
2: 6deca7f57 = 2: 6deca7f57 Upgrade jQuery ui sortable and add disableSelection
3: dd7e3e5e8 = 3: dd7e3e5e8 Update DashboardSelectionUI to elevator-light
4: 5d2fb31b1 = 4: 5d2fb31b1 Switch remove icon to fontawesome
5: f554b70cb = 5: f554b70cb Fix reset to defaults
6: 0cc961e47 = 6: 0cc961e47 Force redirect back to the current page on submit
7: e5ff16c4d = 7: e5ff16c4d Add name to forms for UpdateDashboard
8: bd7c2e501 ! 8: baffe6951 Update tests for MyRT Helper changes
@@ -207,3 +207,210 @@
}
+done_testing();
+
+diff --git a/t/web/dashboards-basics.t b/t/web/dashboards-basics.t
+--- a/t/web/dashboards-basics.t
++++ b/t/web/dashboards-basics.t
+@@
+ $m->follow_link_ok({text => "Basics"});
+ $m->content_contains("Modify the dashboard different dashboard");
+
++# add 'Unowned Tickets' to body of 'different dashboard' dashboard
+ $m->follow_link_ok({text => "Content"});
+ $m->content_contains("Modify the content of dashboard different dashboard");
+-my $form = $m->form_name('Dashboard-Searches-body');
+-my @input = $form->find_input('Searches-body-Available');
+-my ($unowned) =
+- map { ( $_->possible_values )[1] }
+- grep { ( $_->value_names )[1] =~ /Saved Search: Unowned Tickets/ } @input;
+-$form->value('Searches-body-Available' => $unowned );
+-$m->click_button(name => 'add');
+-$m->content_contains("Dashboard updated");
++
++my ( $dashboard_id ) = ( $m->uri =~ /id=(\d+)/ );
++ok( $dashboard_id, "got a dashboard ID, $dashboard_id" ); # 8
++
++my $payload = {
++ "dashboard_id" => $dashboard_id,
++ "panes" => {
++ "body" => [
++ {
++ "description" => "Unowned Tickets",
++ "name" => "Unowned Tickets",
++ "searchId" => "4",
++ "searchType" => "",
++ "type" => "system"
++ },
++ ],
++ "sidebar" => [
++ ]
++ }
++};
++
++my $json = JSON::to_json( $payload );
++my $res = $m->post(
++ $url . 'Helpers/UpdateDashboard',
++ [ content => $json ],
++);
++is( $res->code, 200, "add 'unowned tickets' to body" );
+
+ my $dashboard = RT::Dashboard->new($currentuser);
+-my ($id) = $m->content =~ /name="id" value="(\d+)"/;
+-ok($id, "got an ID, $id");
+-$dashboard->LoadById($id);
+-is($dashboard->Name, "different dashboard");
++$dashboard->LoadById($dashboard_id);
++is($dashboard->Name, 'different dashboard', "'different dashboard' name is correct");
+
+ is($dashboard->Privacy, 'RT::User-' . $user_obj->Id, "correct privacy");
+ is($dashboard->PossibleHiddenSearches, 0, "all searches are visible");
+@@
+ is(@searches, 1, "one saved search in the dashboard");
+ like($searches[0]->Name, qr/newest unowned tickets/, "correct search name");
+
+-$form = $m->form_name('Dashboard-Searches-body');
+- at input = $form->find_input('Searches-body-Available');
+-my ($my_tickets) =
+- map { ( $_->possible_values )[1] }
+- grep { ( $_->value_names )[1] =~ /Saved Search: My Tickets/ } @input;
+-$form->value('Searches-body-Available' => $my_tickets );
+-$m->click_button(name => 'add');
+-$m->content_contains("Dashboard updated");
++push(
++ @{$payload->{panes}->{body}},
++ {
++ "description" => "My Tickets",
++ "name" => "My Tickets",
++ "searchId" => "3",
++ "searchType" => "",
++ "type" => "system"
++ },
++);
+
+-$dashboard = RT::Dashboard->new($currentuser);
+-$dashboard->LoadById($id);
++$json = JSON::to_json( $payload );
++$res = $m->post(
++ $url . 'Helpers/UpdateDashboard',
++ [ content => $json ],
++);
++is( $res->code, 200, "add 'My Tickets' to body" );
+
++$dashboard->LoadById($dashboard_id);
+ @searches = $dashboard->Searches;
++
+ is(@searches, 2, "two saved searches in the dashboard");
+ like($searches[0]->Name, qr/newest unowned tickets/, "correct existing search name");
+ like($searches[1]->Name, qr/highest priority tickets I own/, "correct new search name");
+@@
+ Subject => 'dashboard test',
+ );
+
++$m->get_ok($url."Dashboards/index.html");
++$m->follow_link_ok({text => "different dashboard"});
+ $m->follow_link_ok({id => 'page-show'});
+ $m->content_contains("50 highest priority tickets I own");
+ $m->content_contains("50 newest unowned tickets");
+@@
+ 'only dashboard queries show up' );
+ $m->content_contains("dashboard test", "ticket subject");
+
+-$m->get_ok("/Dashboards/$id/This fragment left intentionally blank");
++$m->get_ok("/Dashboards/$dashboard_id/This fragment left intentionally blank");
+ $m->content_contains("50 highest priority tickets I own");
+ $m->content_contains("50 newest unowned tickets");
+ $m->content_unlike( qr/Bookmarked Tickets.*Bookmarked Tickets/s,
+ 'only dashboard queries show up' );
+ $m->content_contains("dashboard test", "ticket subject");
+
+-$m->get("/Dashboards/Modify.html?id=$id&Delete=1");
++$m->get("/Dashboards/Modify.html?id=$dashboard_id&Delete=1");
+ is($m->status, HTTP::Status::HTTP_FORBIDDEN);
+ $m->content_contains("Permission Denied", "unable to delete dashboard because we lack DeleteOwnDashboard");
+
+@@
+
+ $user_obj->PrincipalObj->GrantRight(Right => 'DeleteOwnDashboard', Object => $RT::System);
+
+-$m->get_ok("/Dashboards/Modify.html?id=$id");
++$m->get_ok("/Dashboards/Modify.html?id=$dashboard_id");
+ $m->content_contains('Delete', "Delete button shows because we have DeleteOwnDashboard");
+
+ $m->form_name('ModifyDashboard');
+ $m->click_button(name => 'Delete');
+ $m->content_contains("Deleted dashboard");
+
+-$m->get("/Dashboards/Modify.html?id=$id");
++$m->get("/Dashboards/Modify.html?id=$dashboard_id");
+ $m->content_lacks("different dashboard", "dashboard was deleted");
+-$m->content_contains("Could not load dashboard $id");
++$m->content_contains("Could not load dashboard $dashboard_id");
+
+ $m->next_warning_like(qr/Failed to load dashboard/, "the dashboard was deleted");
+ $m->next_warning_like(qr/Could not load dashboard/, "the dashboard was deleted");
+@@
+
+ $m->follow_link_ok({id => 'page-content'});
+
+-$form = $m->form_name('Dashboard-Searches-body');
+- at input = $form->find_input('Searches-body-Available');
+-my ($personal) =
+- map { ( $_->possible_values )[1] }
+- grep { ( $_->value_names )[1] =~ /Saved Search: personal search/ } @input;
+-$form->value('Searches-body-Available' => $personal );
+-$m->click_button(name => 'add');
+-$m->content_contains("Dashboard updated");
++my ( $system_dashboard_id ) = ( $m->uri =~ /id=(\d+)/ );
++ok( $system_dashboard_id, "got a dashboard ID for the system dashboard, $system_dashboard_id" ); # 10
++
++# get the saved search name from the content
++my ( $saved_search_name ) = ( $m->content =~ /(RT::User-\d+-SavedSearch-\d+)/ );
++ok( $saved_search_name, "got a saved search name, $saved_search_name" ); # RT::User-27-SavedSearch-9
++
++# add 'personal search' to 'system dashboard' dashboard
++$payload = {
++ "dashboard_id" => $system_dashboard_id,
++ "panes" => {
++ "body" => [
++ {
++ "description" => "personal search",
++ "name" => $saved_search_name,
++ "searchId" => "4",
++ "searchType" => "Ticket",
++ "type" => "saved"
++ },
++ ],
++ "sidebar" => [
++ ]
++ }
++};
++
++$json = JSON::to_json( $payload );
++$res = $m->post(
++ $url . 'Helpers/UpdateDashboard',
++ [ content => $json ],
++);
++is( $res->code, 200, "add 'personal search' to body" );
+
+-$m->content_contains("The following queries may not be visible to all users who can see this dashboard.");
++$m->get_ok($url."Dashboards/Queries.html?id=$system_dashboard_id");
++$m->content_contains("Warning: may not be visible to all viewers");
+
+ $m->follow_link_ok({id => 'page-show'});
+ $m->content_contains("personal search", "saved search shows up");
+@@
+
+ $omech->warning_like(qr/User .* tried to load container user /, "can't see other users' personal searches");
+
++done_testing();
++
++__END__
++
+ # make sure that navigating to dashboard pages with bad IDs throws an error
+ my ($bad_id) = $personal =~ /^search-(\d+)/;
+
+@@
+ $m->next_warning_like(qr/Could not load dashboard $bad_id/);
+ }
+
+-done_testing();
More information about the rt-commit
mailing list