5 use RT::Test tests => 18;
6 my ( $url, $m ) = RT::Test->started_ok;
7 ok( $m->login, 'logged in' );
9 # create a saved search
10 $m->get_ok( $url . "/Search/Build.html?Query=" . 'id=1' );
13 form_name => 'BuildQuery',
14 fields => { SavedSearchDescription => 'foo', },
15 button => 'SavedSearchSave',
18 my ( $search_uri, $user_id, $search_id ) =
19 $m->content =~ /value="(RT::User-(\d+)-SavedSearch-(\d+))"/;
21 form_name => 'BuildQuery',
22 fields => { SavedSearchLoad => $search_uri },
23 button => 'SavedSearchSave',
26 $m->content_like( qr/name="SavedSearchDelete"\s+value="Delete"/,
27 'found Delete button' );
29 qr/name="SavedSearchDescription"\s+value="foo"/,
30 'found Description input with the value filled'
33 # create a dashboard with the created search
35 $m->get_ok( $url . "/Dashboards/Modify.html?Create=1" );
37 form_name => 'ModifyDashboard',
38 fields => { Name => 'bar' },
41 $m->content_like( qr/Saved dashboard bar/i, 'dashboard saved' );
42 my $dashboard_queries_link = $m->find_link( text_regex => qr/Queries/ );
43 my ( $dashboard_id ) = $dashboard_queries_link->url =~ /id=(\d+)/;
45 $m->get_ok( $url . "/Dashboards/Queries.html?id=$dashboard_id" );
47 $m->content_lacks( 'value="Update"', 'no update button' );
50 form_name => 'Dashboard-Searches-body',
52 { 'Searches-body-Available' => "search-$search_id-RT::User-$user_id" },
56 $m->content_like( qr/Dashboard updated/i, 'added search foo to dashboard bar' );
58 # delete the created search
60 $m->get_ok( $url . "/Search/Build.html?Query=" . 'id=1' );
62 form_name => 'BuildQuery',
63 fields => { SavedSearchLoad => $search_uri },
66 form_name => 'BuildQuery',
67 button => 'SavedSearchDelete',
70 $m->content_lacks( $search_uri, 'deleted search foo' );
72 # here is what we really want to test
74 $m->get_ok( $url . "/Dashboards/Queries.html?id=$dashboard_id" );
75 $m->content_like( qr/Deleted queries/i, 'found deleted message' );
77 # Update button shows so we can update the deleted search easily
78 $m->content_contains( 'value="Update"', 'found update button' );
81 form_name => 'Dashboard-Searches-body',
85 $m->content_unlike( qr/Deleted queries/i, 'deleted message is gone' );
86 $m->content_lacks( 'value="Update"', 'update button is gone too' );
88 $m->get_warnings; # we'll get a lot of warnings because the deleted search