7 use RT::Test tests => 24;
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 ok($agent->{form}->find_input('user'));
24 ok($agent->{form}->find_input('pass'));
26 ok($agent->{'content'} =~ /username:/i);
27 $agent->field( 'user' => 'root' );
28 $agent->field( 'pass' => 'password' );
30 # the field isn't named, so we have to click link 0
32 is( $agent->{'status'}, 200, "Fetched the page ok");
33 ok( $agent->{'content'} =~ /Logout/i, "Found a logout link");
37 $agent->get($url."Ticket/Create.html?Queue=1");
38 is ($agent->{'status'}, 200, "Loaded Create.html");
39 $agent->form_number(3);
40 my $string = Encode::decode_utf8("I18N Web Testing æøå");
41 $agent->field('Subject' => "Ticket with utf8 body");
42 $agent->field('Content' => $string);
43 ok($agent->submit, "Created new ticket with $string as Content");
44 $agent->content_like( qr{$string} , "Found the content");
45 ok($agent->{redirected_uri}, "Did redirection");
48 my $ticket = RT::Test->last_ticket;
49 my $content = $ticket->Transactions->First->Content;
51 $content, qr{$string},
52 'content is there, API check'
58 $agent->get($url."Ticket/Create.html?Queue=1");
59 is ($agent->{'status'}, 200, "Loaded Create.html");
60 $agent->form_number(3);
62 my $string = Encode::decode_utf8("I18N Web Testing æøå");
63 $agent->field('Subject' => $string);
64 $agent->field('Content' => "Ticket with utf8 subject");
65 ok($agent->submit, "Created new ticket with $string as Content");
66 $agent->content_like( qr{$string} , "Found the content");
67 ok($agent->{redirected_uri}, "Did redirection");
70 my $ticket = RT::Test->last_ticket;
72 $ticket->Subject, $string,
73 'subject is correct, API check'
78 # Update time worked in hours
80 $agent->follow_link( text_regex => qr/Basics/ );
81 $agent->submit_form( form_number => 3,
82 fields => { TimeWorked => 5, 'TimeWorked-TimeUnits' => "hours" }
85 like ($agent->{'content'}, qr/to '300'/, "5 hours is 300 minutes");
91 todo_skip("Need to handle mason trying to compile images",1);
92 $agent->get( $url."NoAuth/images/test.png" );
93 my $file = RT::Test::get_relocatable_file(
95 qw(.. .. share html NoAuth images test.png)
99 length($agent->content),
101 "got a file of the correct size ($file)",
106 # {{{ Query Builder tests
108 # XXX: hey-ho, we have these tests in t/web/query-builder
109 # TODO: move everything about QB there
111 my $response = $agent->get($url."Search/Build.html");
112 ok( $response->is_success, "Fetched " . $url."Search/Build.html" );
118 # set the first value
119 ok($agent->form_name('BuildQuery'));
120 $agent->field("AttachmentField", "Subject");
121 $agent->field("AttachmentOp", "LIKE");
122 $agent->field("ValueOfAttachment", "aaa");
123 $agent->submit("AddClause");
126 ok($agent->form_name('BuildQuery'));
127 $agent->field("AttachmentField", "Subject");
128 $agent->field("AttachmentOp", "LIKE");
129 $agent->field("ValueOfAttachment", "bbb");
130 $agent->submit("AddClause");
132 ok($agent->form_name('BuildQuery'));
135 my $query = $agent->current_form->find_input("Query")->value;
136 # strip whitespace from ends
140 # collapse other whitespace
143 is ($query, "Subject LIKE 'aaa' AND Subject LIKE 'bbb'");