4 use RT::Test tests => 34;
6 my $lifecycles = RT->Config->Get('Lifecycles');
8 initial => ['initial'],
10 inactive => ['resolved'],
14 RT::Lifecycle->FillCache();
16 my $general = RT::Test->load_or_create_queue( Name => 'General' );
17 my $foo = RT::Test->load_or_create_queue( Name => 'foo', Lifecycle => 'foo' );
19 my $global_cf = RT::Test->load_or_create_custom_field(
22 Type => 'FreeformSingle',
25 my $general_cf = RT::Test->load_or_create_custom_field(
28 Type => 'FreeformSingle',
31 my $foo_cf = RT::Test->load_or_create_custom_field(
34 Type => 'FreeformSingle'
37 my $root = RT::Test->load_or_create_user( Name => 'root', );
38 my $user_a = RT::Test->load_or_create_user(
40 Password => 'password',
42 my $user_b = RT::Test->load_or_create_user(
44 Password => 'password',
52 Right => ['OwnTicket'],
57 Right => ['OwnTicket'],
60 'granted OwnTicket right for user_a and user_b'
63 my ( $url, $m ) = RT::Test->started_ok;
64 ok( $m->login, 'logged in' );
66 $m->get_ok( $url . '/Search/Build.html' );
68 diag "check default statuses, cf and owners";
69 my $form = $m->form_name('BuildQuery');
70 ok( $form, 'found BuildQuery form' );
71 ok( $form->find_input("ValueOf'CF.{global_cf}'"), 'found global_cf by default' );
72 ok( !$form->find_input("ValueOf'CF.{general_cf}'"), 'no general_cf by default' );
73 ok( !$form->find_input("ValueOf'CF.{foo_cf}'"), 'no foo_cf by default' );
75 my $status_input = $form->find_input('ValueOfStatus');
76 my @statuses = sort $status_input->possible_values;
78 \@statuses, [ '', qw/initial new open rejected resolved stalled/], 'found all statuses'
81 my $owner_input = $form->find_input('ValueOfActor');
82 my @owners = sort $owner_input->possible_values;
84 \@owners, [ '', qw/Nobody root user_a user_b/], 'found all users'
87 diag "limit queue to foo";
89 fields => { ValueOfQueue => 'foo' },
90 button => 'AddClause',
93 $form = $m->form_name('BuildQuery');
94 ok( $form->find_input("ValueOf'CF.{foo_cf}'"), 'found foo_cf' );
95 ok( $form->find_input("ValueOf'CF.{global_cf}'"), 'found global_cf' );
96 ok( !$form->find_input("ValueOf'CF.{general_cf}'"), 'still no general_cf' );
97 $status_input = $form->find_input('ValueOfStatus');
98 @statuses = sort $status_input->possible_values;
101 [ '', qw/initial open resolved/ ],
102 'found statuses from foo only'
105 $owner_input = $form->find_input('ValueOfActor');
106 @owners = sort $owner_input->possible_values;
108 \@owners, [ '', qw/Nobody root user_b/], 'no user_a'
111 diag "limit queue to general too";
114 fields => { ValueOfQueue => 'General' },
115 button => 'AddClause',
118 $form = $m->form_name('BuildQuery');
119 ok( $form->find_input("ValueOf'CF.{general_cf}'"), 'found general_cf' );
120 ok( $form->find_input("ValueOf'CF.{foo_cf}'"), 'found foo_cf' );
121 ok( $form->find_input("ValueOf'CF.{global_cf}'"), 'found global_cf' );
122 $status_input = $form->find_input('ValueOfStatus');
123 @statuses = sort $status_input->possible_values;
126 [ '', qw/initial new open rejected resolved stalled/ ],
127 'found all statuses again'
129 $owner_input = $form->find_input('ValueOfActor');
130 @owners = sort $owner_input->possible_values;
132 \@owners, [ '', qw/Nobody root user_a user_b/], 'found all users again'
135 diag "limit queue to != foo";
136 $m->get_ok( $url . '/Search/Build.html?NewQuery=1' );
138 form_name => 'BuildQuery',
139 fields => { ValueOfQueue => 'foo', QueueOp => '!=' },
140 button => 'AddClause',
143 $form = $m->form_name('BuildQuery');
144 ok( $form->find_input("ValueOf'CF.{global_cf}'"), 'found global_cf' );
145 ok( !$form->find_input("ValueOf'CF.{foo_cf}'"), 'no foo_cf' );
146 ok( !$form->find_input("ValueOf'CF.{general_cf}'"), 'no general_cf' );
147 $status_input = $form->find_input('ValueOfStatus');
148 @statuses = sort $status_input->possible_values;
150 \@statuses, [ '', qw/initial new open rejected resolved stalled/],
153 $owner_input = $form->find_input('ValueOfActor');
154 @owners = sort $owner_input->possible_values;
156 \@owners, [ '', qw/Nobody root user_a user_b/], 'found all users'
159 diag "limit queue to General OR foo";
160 $m->get_ok( $url . '/Search/Edit.html' );
162 form_name => 'BuildQueryAdvanced',
163 fields => { Query => q{Queue = 'General' OR Queue = 'foo'} },
165 $form = $m->form_name('BuildQuery');
166 ok( $form->find_input("ValueOf'CF.{general_cf}'"), 'found general_cf' );
167 ok( $form->find_input("ValueOf'CF.{foo_cf}'"), 'found foo_cf' );
168 ok( $form->find_input("ValueOf'CF.{global_cf}'"), 'found global_cf' );
169 $status_input = $form->find_input('ValueOfStatus');
170 @statuses = sort $status_input->possible_values;
173 [ '', qw/initial new open rejected resolved stalled/ ],
176 $owner_input = $form->find_input('ValueOfActor');
177 @owners = sort $owner_input->possible_values;
179 \@owners, [ '', qw/Nobody root user_a user_b/], 'found all users'