4 use RT::Test tests => 20;
5 my ( $url, $m ) = RT::Test->started_ok;
6 ok( $m->login, 'logged in' );
8 # create a saved search
9 $m->get_ok( $url . "/Search/Build.html?Query=" . 'id=1' );
12 form_name => 'BuildQuery',
13 fields => { SavedSearchDescription => 'foo', },
14 button => 'SavedSearchSave',
17 my ( $search_uri, $user_id, $search_id ) =
18 $m->content =~ /value="(RT::User-(\d+)-SavedSearch-(\d+))"/;
20 form_name => 'BuildQuery',
21 fields => { SavedSearchLoad => $search_uri },
22 button => 'SavedSearchSave',
25 $m->content_like( qr/name="SavedSearchDelete"\s+value="Delete"/,
26 'found Delete button' );
28 qr/name="SavedSearchDescription"\s+value="foo"/,
29 'found Description input with the value filled'
32 # create a dashboard with the created search
34 $m->get_ok( $url . "/Dashboards/Modify.html?Create=1" );
36 form_name => 'ModifyDashboard',
37 fields => { Name => 'bar' },
40 $m->content_contains('Saved dashboard bar', 'dashboard saved' );
41 my $dashboard_queries_link = $m->find_link( text_regex => qr/Content/ );
42 my ( $dashboard_id ) = $dashboard_queries_link->url =~ /id=(\d+)/;
44 $m->get_ok( $url . "/Dashboards/Queries.html?id=$dashboard_id" );
46 $m->content_lacks( 'value="Update"', 'no update button' );
49 form_name => 'Dashboard-Searches-body',
51 { 'Searches-body-Available' => "search-$search_id-RT::User-$user_id" },
55 $m->content_contains('Dashboard updated', 'added search foo to dashboard bar' );
57 # delete the created search
59 $m->get_ok( $url . "/Search/Build.html?Query=" . 'id=1' );
61 form_name => 'BuildQuery',
62 fields => { SavedSearchLoad => $search_uri },
65 form_name => 'BuildQuery',
66 button => 'SavedSearchDelete',
69 $m->content_lacks( $search_uri, 'deleted search foo' );
71 # here is what we really want to test
73 $m->get_ok( $url . "/Dashboards/Queries.html?id=$dashboard_id" );
74 $m->content_contains('Deleted queries', 'found deleted message' );
76 # Update button shows so we can update the deleted search easily
77 $m->content_contains( 'value="Update"', 'found update button' );
80 form_name => 'Dashboard-Searches-body',
84 $m->content_lacks('Deleted queries', 'deleted message is gone' );
85 $m->content_lacks( 'value="Update"', 'update button is gone too' );
87 $m->get_warnings; # we'll get a lot of warnings because the deleted search