4 use RT::Test tests => 11;
5 my ($baseurl, $m) = RT::Test->started_ok;
6 my $url = $m->rt_base_url;
8 # reset preferences for easier test?
12 my $t = RT::Ticket->new($RT::SystemUser);
13 $t->Create(Subject => 'for custom search'.$$, Queue => 'general',
14 Owner => 'root', Requestor => 'customsearch@localhost');
15 ok(my $id = $t->id, 'created ticket for custom search');
17 ok $m->login, 'logged in';
19 my $t_link = $m->find_link( text => "for custom search".$$ );
20 like ($t_link->url, qr/$id/, 'link to the ticket we created');
22 $m->content_lacks ('customsearch@localhost', 'requestor not displayed ');
23 $m->get ( $url.'Prefs/MyRT.html' );
24 my $cus_hp = $m->find_link( text => "My Tickets" );
25 my $cus_qs = $m->find_link( text => "Quick search" );
27 $m->content_like (qr'highest priority tickets');
29 # add Requestor to the fields
30 $m->form_name ('BuildQuery');
31 # can't use submit form for mutli-valued select as it uses set_fields
32 $m->field (SelectDisplayColumns => ['Requestors']);
33 $m->click_button (name => 'AddCol') ;
35 $m->form_name ('BuildQuery');
36 $m->click_button (name => 'Save');
39 $m->content_contains ('customsearch@localhost', 'requestor now displayed ');
42 # now remove Requestor from the fields
45 $m->form_name ('BuildQuery');
47 my $cdc = $m->current_form->find_input('CurrentDisplayColumns');
48 my ($requestor_value) = grep { /Requestor/ } $cdc->possible_values;
49 ok($requestor_value, "got the requestor value");
51 $m->field (CurrentDisplayColumns => $requestor_value);
52 $m->click_button (name => 'RemoveCol') ;
54 $m->form_name ('BuildQuery');
55 $m->click_button (name => 'Save');
58 $m->content_lacks ('customsearch@localhost', 'requestor not displayed ');
61 # try to disable General from quick search
63 # Note that there's a small problem in the current implementation,
64 # since ticked quese are wanted, we do the invesrsion. So any
65 # queue added during the quicksearch setting will be unticked.
66 my $nlinks = $#{$m->find_all_links( text => "General" )};
68 $m->form_name ('Preferences');
69 $m->untick('Want-General', '1');
70 $m->click_button (name => 'Save');
73 is ($#{$m->find_all_links( text => "General" )}, $nlinks - 1,
74 'General gone from quicksearch list');
78 $m->form_name ('Preferences');
79 $m->tick('Want-General', '1');
80 $m->click_button (name => 'Save');
83 is ($#{$m->find_all_links( text => "General" )}, $nlinks,
84 'General back in quicksearch list');