4 use Test::More tests => 10;
10 use Test::WWW::Mechanize;
12 use constant BaseURL => $RT::WebURL;
14 # reset preferences for easier test?
16 my $t = RT::Ticket->new($RT::SystemUser);
17 $t->Create(Subject => 'for custom search', Queue => 'general',
18 Owner => 'root', Requestor => 'customsearch@localhost');
19 ok(my $id = $t->id, 'created ticket for custom search');
21 my $m = Test::WWW::Mechanize->new ( autocheck => 1 );
22 isa_ok($m, 'Test::WWW::Mechanize');
24 $m->get( BaseURL."?user=root;pass=password" );
25 $m->content_like(qr/Logout/, 'we did log in');
27 my $t_link = $m->find_link( text => "for custom search" );
28 like ($t_link->url, qr/$id/, 'link to the ticket we created');
30 $m->content_lacks ('customsearch@localhost', 'requestor not displayed ');
31 $m->get ( BaseURL.'Prefs/MyRT.html' );
32 my $cus_hp = $m->find_link( text => "My Tickets" );
33 my $cus_qs = $m->find_link( text => "Quick search" );
35 $m->content_like (qr'highest priority tickets');
37 # add Requestor to the fields
38 $m->form_name ('BuildQuery');
39 # can't use submit form for mutli-valued select as it uses set_fields
40 $m->field (SelectDisplayColumns => ['Requestors']);
41 $m->click_button (name => 'AddCol') ;
43 $m->form_name ('BuildQuery');
44 $m->click_button (name => 'Save');
47 $m->content_contains ('customsearch@localhost', 'requestor now displayed ');
50 # now remove Requestor from the fields
53 $m->form_name ('BuildQuery');
54 $m->field (CurrentDisplayColumns => 'Requestors');
55 $m->click_button (name => 'RemoveCol') ;
57 $m->form_name ('BuildQuery');
58 $m->click_button (name => 'Save');
61 $m->content_lacks ('customsearch@localhost', 'requestor not displayed ');
64 # try to disable General from quick search
66 # Note that there's a small problem in the current implementation,
67 # since ticked quese are wanted, we do the invesrsion. So any
68 # queue added during the quicksearch setting will be unticked.
69 my $nlinks = $#{$m->find_all_links( text => "General" )};
72 $m->form_name ('Preferences');
73 $m->untick('Want-General', '1');
74 $m->click_button (name => 'Save');
77 is ($#{$m->find_all_links( text => "General" )}, $nlinks - 1,
78 'General gone from quicksearch list');
82 $m->form_name ('Preferences');
83 $m->tick('Want-General', '1');
84 $m->click_button (name => 'Save');
87 is ($#{$m->find_all_links( text => "General" )}, $nlinks,
88 'General back in quicksearch list');