fix ticketing system error on bootstrap of new install
[freeside.git] / rt / t / web / dashboards-deleted-saved-search.t
1 use strict;
2 use warnings;
3
4 use RT::Test tests => 20;
5 my ( $url, $m ) = RT::Test->started_ok;
6 ok( $m->login, 'logged in' );
7
8 # create a saved search
9 $m->get_ok( $url . "/Search/Build.html?Query=" . 'id=1' );
10
11 $m->submit_form(
12     form_name => 'BuildQuery',
13     fields    => { SavedSearchDescription => 'foo', },
14     button    => 'SavedSearchSave',
15 );
16
17 my ( $search_uri, $user_id, $search_id ) =
18   $m->content =~ /value="(RT::User-(\d+)-SavedSearch-(\d+))"/;
19 $m->submit_form(
20     form_name => 'BuildQuery',
21     fields    => { SavedSearchLoad => $search_uri },
22     button    => 'SavedSearchSave',
23 );
24
25 $m->content_like( qr/name="SavedSearchDelete"\s+value="Delete"/,
26     'found Delete button' );
27 $m->content_like(
28     qr/name="SavedSearchDescription"\s+value="foo"/,
29     'found Description input with the value filled'
30 );
31
32 # create a dashboard with the created search
33
34 $m->get_ok( $url . "/Dashboards/Modify.html?Create=1" );
35 $m->submit_form(
36     form_name => 'ModifyDashboard',
37     fields    => { Name => 'bar' },
38 );
39
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+)/;
43
44 $m->get_ok( $url . "/Dashboards/Queries.html?id=$dashboard_id" );
45
46 $m->content_lacks( 'value="Update"', 'no update button' );
47
48 $m->submit_form(
49     form_name => 'Dashboard-Searches-body',
50     fields =>
51       { 'Searches-body-Available' => "search-$search_id-RT::User-$user_id" },
52     button => 'add',
53 );
54
55 $m->content_contains('Dashboard updated', 'added search foo to dashboard bar' );
56
57 # delete the created search
58
59 $m->get_ok( $url . "/Search/Build.html?Query=" . 'id=1' );
60 $m->submit_form(
61     form_name => 'BuildQuery',
62     fields    => { SavedSearchLoad => $search_uri },
63 );
64 $m->submit_form(
65     form_name => 'BuildQuery',
66     button    => 'SavedSearchDelete',
67 );
68
69 $m->content_lacks( $search_uri, 'deleted search foo' );
70
71 # here is what we really want to test
72
73 $m->get_ok( $url . "/Dashboards/Queries.html?id=$dashboard_id" );
74 $m->content_contains('Deleted queries', 'found deleted message' );
75
76 # Update button shows so we can update the deleted search easily
77 $m->content_contains( 'value="Update"', 'found update button' );
78
79 $m->submit_form(
80     form_name => 'Dashboard-Searches-body',
81     button    => 'update',
82 );
83
84 $m->content_lacks('Deleted queries', 'deleted message is gone' );
85 $m->content_lacks( 'value="Update"', 'update button is gone too' );
86
87 $m->get_warnings; # we'll get a lot of warnings because the deleted search
88