first pass RT4 merge, RT#13852
[freeside.git] / rt / t / web / custom_search.t
1 #!/usr/bin/perl -w
2 use strict;
3
4 use RT::Test tests => 13;
5 my ($baseurl, $m) = RT::Test->started_ok;
6 my $url = $m->rt_base_url;
7
8 # reset preferences for easier test?
9
10
11
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');
16
17 ok $m->login, 'logged in';
18
19 my $t_link = $m->find_link( text => "for custom search".$$ );
20 like ($t_link->url, qr/$id/, 'link to the ticket we created');
21
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" );
26 $m->get ($cus_hp);
27 $m->content_contains('highest priority tickets');
28
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') ;
34
35 $m->form_name ('BuildQuery');
36 $m->click_button (name => 'Save');
37
38 $m->get( $url );
39 $m->content_contains ('customsearch@localhost', 'requestor now displayed ');
40
41
42 # now remove Requestor from the fields
43 $m->get ($cus_hp);
44
45 $m->form_name ('BuildQuery');
46
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");
50
51 $m->field (CurrentDisplayColumns => $requestor_value);
52 $m->click_button (name => 'RemoveCol') ;
53
54 $m->form_name ('BuildQuery');
55 $m->click_button (name => 'Save');
56
57 $m->get( $url );
58 $m->content_lacks ('customsearch@localhost', 'requestor not displayed ');
59
60
61 # try to disable General from quick search
62
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" )};
67 $m->get ($cus_qs);
68 $m->form_name ('Preferences');
69 $m->untick('Want-General', '1');
70 $m->click_button (name => 'Save');
71
72 $m->get( $url );
73 is ($#{$m->find_all_links( text => "General" )}, $nlinks - 1,
74     'General gone from quicksearch list');
75
76 # get it back
77 $m->get ($cus_qs);
78 $m->form_name ('Preferences');
79 $m->tick('Want-General', '1');
80 $m->click_button (name => 'Save');
81
82 $m->get( $url );
83 is ($#{$m->find_all_links( text => "General" )}, $nlinks,
84     'General back in quicksearch list');