4 use RT::Test tests => 30;
5 my ( $baseurl, $m ) = RT::Test->started_ok;
7 RT::Test->create_tickets(
8 { Queue => 'General' },
9 { Subject => 'ticket foo' },
10 { Subject => 'ticket bar' },
13 ok( $m->login, 'logged in' );
15 $m->get_ok('/Search/Simple.html');
16 $m->content_lacks( 'Show Results', 'no page menu' );
17 $m->get_ok('/Search/Simple.html?q=ticket foo');
18 $m->content_contains( 'Show Results', "has page menu" );
19 $m->title_is( 'Found 1 ticket', 'title' );
20 $m->content_contains( 'ticket foo', 'has ticket foo' );
22 # Test searches on custom fields
23 my $cf1 = RT::Test->load_or_create_custom_field(
26 Type => 'FreeformSingle', );
27 isa_ok( $cf1, 'RT::CustomField' );
29 my $cf2 = RT::Test->load_or_create_custom_field(
30 Name => 'Server-name',
32 Type => 'FreeformSingle', );
33 isa_ok( $cf2, 'RT::CustomField' );
35 my $t = RT::Ticket->new(RT->SystemUser);
38 my ($id,undef,$msg) = $t->Create(
40 Subject => 'Test searching CFs');
41 ok( $id, "Created ticket - $msg" );
45 my ($status, $msg) = $t->AddCustomFieldValue(
48 ok( $status, "Added CF value - $msg" );
52 my ($status, $msg) = $t->AddCustomFieldValue(
55 ok( $status, "Added CF value - $msg" );
59 my $search = 'cf.Location:Downtown';
60 $m->get_ok("/Search/Simple.html?q=$search");
61 $m->title_is( 'Found 1 ticket', 'Found 1 ticket' );
62 $m->text_contains( 'Test searching CFs', "Found test CF ticket with $search" );
65 $search = "cf.Location:downtown";
66 $m->get_ok("/Search/Simple.html?q=$search");
67 $m->title_is( 'Found 1 ticket', 'Found 1 ticket' );
68 $m->text_contains( 'Test searching CFs', "Found test CF ticket with $search" );
70 # With dash in CF name
71 $search = "cf.Server-name:Proxy";
72 $m->get_ok("/Search/Simple.html?q=$search");
73 $m->title_is( 'Found 1 ticket', 'Found 1 ticket' );
74 $m->text_contains( 'Test searching CFs', "Found test CF ticket with $search" );
76 # TODO more simple search tests