summaryrefslogtreecommitdiff
path: root/rt/lib/t/regression/17custom_search.t
blob: 8e53f44866fb9b60bdda5e9f852d85c834b9aa63 (plain)
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
#!/usr/bin/perl -w
use strict;

use Test::More tests => 10;
BEGIN {
    use RT;
    RT::LoadConfig;
    RT::Init;
}
use Test::WWW::Mechanize;

use constant BaseURL => $RT::WebURL;

# reset preferences for easier test?

my $t = RT::Ticket->new($RT::SystemUser);
$t->Create(Subject => 'for custom search', Queue => 'general',
	   Owner => 'root', Requestor => 'customsearch@localhost');
ok(my $id = $t->id, 'created ticket for custom search');

my $m = Test::WWW::Mechanize->new ( autocheck => 1 );
isa_ok($m, 'Test::WWW::Mechanize');

$m->get( BaseURL."?user=root;pass=password" );
$m->content_like(qr/Logout/, 'we did log in');

my $t_link = $m->find_link( text => "for custom search" );
like ($t_link->url, qr/$id/, 'link to the ticket we created');

$m->content_lacks ('customsearch@localhost', 'requestor not displayed ');
$m->get ( BaseURL.'Prefs/MyRT.html' );
my $cus_hp = $m->find_link( text => "My Tickets" );
my $cus_qs = $m->find_link( text => "Quick search" );
$m->get ($cus_hp);
$m->content_like (qr'highest priority tickets');

# add Requestor to the fields
$m->form_name ('BuildQuery');
# can't use submit form for mutli-valued select as it uses set_fields
$m->field (SelectDisplayColumns => ['Requestors']);
$m->click_button (name => 'AddCol') ;

$m->form_name ('BuildQuery');
$m->click_button (name => 'Save');

$m->get( BaseURL );
$m->content_contains ('customsearch@localhost', 'requestor now displayed ');


# now remove Requestor from the fields
$m->get ($cus_hp);

$m->form_name ('BuildQuery');
$m->field (CurrentDisplayColumns => 'Requestors');
$m->click_button (name => 'RemoveCol') ;

$m->form_name ('BuildQuery');
$m->click_button (name => 'Save');

$m->get( BaseURL );
$m->content_lacks ('customsearch@localhost', 'requestor not displayed ');


# try to disable General from quick search

# Note that there's a small problem in the current implementation,
# since ticked quese are wanted, we do the invesrsion.  So any
# queue added during the quicksearch setting will be unticked.
my $nlinks = $#{$m->find_all_links( text => "General" )};
warn $nlinks;
$m->get ($cus_qs);
$m->form_name ('Preferences');
$m->untick('Want-General', '1');
$m->click_button (name => 'Save');

$m->get( BaseURL );
is ($#{$m->find_all_links( text => "General" )}, $nlinks - 1,
    'General gone from quicksearch list');

# get it back
$m->get ($cus_qs);
$m->form_name ('Preferences');
$m->tick('Want-General', '1');
$m->click_button (name => 'Save');

$m->get( BaseURL );
is ($#{$m->find_all_links( text => "General" )}, $nlinks,
    'General back in quicksearch list');