7 use RT::Test tests => 21;
8 $RT::Test::SKIP_REQUEST_WORK_AROUND = 1;
10 my ($baseurl, $agent) = RT::Test->started_ok;
12 my $url = $agent->rt_base_url;
13 diag $url if $ENV{TEST_VERBOSE};
18 is ($agent->{'status'}, 200, "Loaded a page");
23 $agent->login('root' => 'password');
24 # the field isn't named, so we have to click link 0
25 is( $agent->{'status'}, 200, "Fetched the page ok");
26 ok( $agent->{'content'} =~ /Logout/i, "Found a logout link");
30 $agent->get($url."Ticket/Create.html?Queue=1");
31 is ($agent->{'status'}, 200, "Loaded Create.html");
32 $agent->form_number(3);
33 my $string = Encode::decode_utf8("I18N Web Testing æøå");
34 $agent->field('Subject' => "Ticket with utf8 body");
35 $agent->field('Content' => $string);
36 ok($agent->submit, "Created new ticket with $string as Content");
37 $agent->content_like( qr{$string} , "Found the content");
38 ok($agent->{redirected_uri}, "Did redirection");
41 my $ticket = RT::Test->last_ticket;
42 my $content = $ticket->Transactions->First->Content;
44 $content, qr{$string},
45 'content is there, API check'
51 $agent->get($url."Ticket/Create.html?Queue=1");
52 is ($agent->{'status'}, 200, "Loaded Create.html");
53 $agent->form_number(3);
55 my $string = Encode::decode_utf8("I18N Web Testing æøå");
56 $agent->field('Subject' => $string);
57 $agent->field('Content' => "Ticket with utf8 subject");
58 ok($agent->submit, "Created new ticket with $string as Content");
59 $agent->content_like( qr{$string} , "Found the content");
60 ok($agent->{redirected_uri}, "Did redirection");
63 my $ticket = RT::Test->last_ticket;
65 $ticket->Subject, $string,
66 'subject is correct, API check'
71 # Update time worked in hours
73 $agent->follow_link( text_regex => qr/Basics/ );
74 $agent->submit_form( form_number => 3,
75 fields => { TimeWorked => 5, 'TimeWorked-TimeUnits' => "hours" }
78 like ($agent->{'content'}, qr/to '300'/, "5 hours is 300 minutes");
84 todo_skip("Need to handle mason trying to compile images",1);
85 $agent->get( $url."NoAuth/images/test.png" );
86 my $file = RT::Test::get_relocatable_file(
88 qw(.. .. share html NoAuth images test.png)
92 length($agent->content),
94 "got a file of the correct size ($file)",
99 # {{{ Query Builder tests
101 # XXX: hey-ho, we have these tests in t/web/query-builder
102 # TODO: move everything about QB there
104 my $response = $agent->get($url."Search/Build.html");
105 ok( $response->is_success, "Fetched " . $url."Search/Build.html" );
111 # set the first value
112 ok($agent->form_name('BuildQuery'));
113 $agent->field("AttachmentField", "Subject");
114 $agent->field("AttachmentOp", "LIKE");
115 $agent->field("ValueOfAttachment", "aaa");
116 $agent->submit("AddClause");
119 ok($agent->form_name('BuildQuery'));
120 $agent->field("AttachmentField", "Subject");
121 $agent->field("AttachmentOp", "LIKE");
122 $agent->field("ValueOfAttachment", "bbb");
123 $agent->submit("AddClause");
125 ok($agent->form_name('BuildQuery'));
128 my $query = $agent->current_form->find_input("Query")->value;
129 # strip whitespace from ends
133 # collapse other whitespace
136 is ($query, "Subject LIKE 'aaa' AND Subject LIKE 'bbb'");