import rt 3.8.9
[freeside.git] / rt / lib / t / regression / 17custom_search.t
1 #!/usr/bin/perl -w
2 use strict;
3
4 use Test::More tests => 10;
5 BEGIN {
6     use RT;
7     RT::LoadConfig;
8     RT::Init;
9 }
10 use Test::WWW::Mechanize;
11
12 use constant BaseURL => $RT::WebURL;
13
14 # reset preferences for easier test?
15
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');
20
21 my $m = Test::WWW::Mechanize->new ( autocheck => 1 );
22 isa_ok($m, 'Test::WWW::Mechanize');
23
24 $m->get( BaseURL."?user=root;pass=password" );
25 $m->content_like(qr/Logout/, 'we did log in');
26
27 my $t_link = $m->find_link( text => "for custom search" );
28 like ($t_link->url, qr/$id/, 'link to the ticket we created');
29
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" );
34 $m->get ($cus_hp);
35 $m->content_like (qr'highest priority tickets');
36
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') ;
42
43 $m->form_name ('BuildQuery');
44 $m->click_button (name => 'Save');
45
46 $m->get( BaseURL );
47 $m->content_contains ('customsearch@localhost', 'requestor now displayed ');
48
49
50 # now remove Requestor from the fields
51 $m->get ($cus_hp);
52
53 $m->form_name ('BuildQuery');
54 $m->field (CurrentDisplayColumns => 'Requestors');
55 $m->click_button (name => 'RemoveCol') ;
56
57 $m->form_name ('BuildQuery');
58 $m->click_button (name => 'Save');
59
60 $m->get( BaseURL );
61 $m->content_lacks ('customsearch@localhost', 'requestor not displayed ');
62
63
64 # try to disable General from quick search
65
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" )};
70 warn $nlinks;
71 $m->get ($cus_qs);
72 $m->form_name ('Preferences');
73 $m->untick('Want-General', '1');
74 $m->click_button (name => 'Save');
75
76 $m->get( BaseURL );
77 is ($#{$m->find_all_links( text => "General" )}, $nlinks - 1,
78     'General gone from quicksearch list');
79
80 # get it back
81 $m->get ($cus_qs);
82 $m->form_name ('Preferences');
83 $m->tick('Want-General', '1');
84 $m->click_button (name => 'Save');
85
86 $m->get( BaseURL );
87 is ($#{$m->find_all_links( text => "General" )}, $nlinks,
88     'General back in quicksearch list');