1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
use strict;
use warnings;
use RT::Test tests => undef;
my ( $url, $m ) = RT::Test->started_ok;
ok( $m->login, 'logged in' );
# create a saved search
$m->get_ok( $url . "/Search/Build.html?Query=" . 'id=1' );
$m->submit_form(
form_name => 'BuildQuery',
fields => { SavedSearchDescription => 'foo', },
button => 'SavedSearchSave',
);
my ( $search_uri, $user_id, $search_id ) =
$m->content =~ /value="(RT::User-(\d+)-SavedSearch-(\d+))"/;
$m->submit_form(
form_name => 'BuildQuery',
fields => { SavedSearchLoad => $search_uri },
button => 'SavedSearchSave',
);
$m->content_like( qr/name="SavedSearchDelete"\s+value="Delete"/,
'found Delete button' );
$m->content_like(
qr/name="SavedSearchDescription"\s+value="foo"/,
'found Description input with the value filled'
);
# create a dashboard with the created search
$m->get_ok( $url . "/Dashboards/Modify.html?Create=1" );
$m->submit_form(
form_name => 'ModifyDashboard',
fields => { Name => 'bar' },
);
$m->content_contains('Saved dashboard bar', 'dashboard saved' );
my $dashboard_queries_link = $m->find_link( text_regex => qr/Content/ );
my ( $dashboard_id ) = $dashboard_queries_link->url =~ /id=(\d+)/;
$m->get_ok( $url . "/Dashboards/Queries.html?id=$dashboard_id" );
$m->content_lacks( 'value="Update"', 'no update button' );
# add foo saved search to the dashboard
my $args = {
"dashboard_id" => $dashboard_id,
"body" => "saved-" . "RT::User-" . $user_id . "-SavedSearch-" . $search_id,
};
$m->submit_form_ok({
form_name => 'UpdateSearches',
fields => $args,
button => 'UpdateSearches',
}, "added search foo to dashboard bar" );
like( $m->uri, qr/results=[A-Za-z0-9]{32}/, 'URL redirected for results' );
$m->content_contains( 'Dashboard updated' );
# delete the created search
$m->get_ok( $url . "/Search/Build.html?Query=" . 'id=1' );
$m->submit_form(
form_name => 'BuildQuery',
fields => { SavedSearchLoad => $search_uri },
);
$m->submit_form(
form_name => 'BuildQuery',
button => 'SavedSearchDelete',
);
$m->content_lacks( $search_uri, 'deleted search foo' );
# here is what we really want to test
$m->get_ok( $url . "/Dashboards/Queries.html?id=$dashboard_id" );
$m->content_contains('Unable to find search Saved Search: foo', 'found deleted message' );
$args = {
"dashboard_id" => $dashboard_id,
};
$m->submit_form_ok({
form_name => 'UpdateSearches',
fields => $args,
button => 'UpdateSearches',
}, "removed search foo from dashboard" );
like( $m->uri, qr/results=[A-Za-z0-9]{32}/, 'URL redirected for results' );
$m->content_contains( 'Dashboard updated' );
$m->get_ok( $url . "/Dashboards/Queries.html?id=$dashboard_id" );
$m->content_lacks('Unable to find search Saved Search: foo', 'deleted message is gone' );
done_testing;
|