#!/usr/bin/perl
use strict;
-use Test::More tests => 17;
+use Test::More tests => 19;
use WWW::Mechanize;
use HTTP::Request::Common;
use HTTP::Cookies;
$agent->cookie_jar($cookie_jar);
use RT;
-RT::LoadConfig;
-
+RT::LoadConfig();
# get the top page
my $url = $RT::WebURL;
+diag $url;
$agent->get($url);
is ($agent->{'status'}, 200, "Loaded a page");
$agent->get($url."Ticket/Create.html?Queue=1");
is ($agent->{'status'}, 200, "Loaded Create.html");
-$agent->form(3);
+$agent->form_number(3);
# Start with a string containing characters in latin1
my $string = "I18N Web Testing æøå";
Encode::from_to($string, 'iso-8859-1', 'utf8');
$agent->field('Subject' => "Ticket with utf8 body");
$agent->field('Content' => $string);
ok($agent->submit(), "Created new ticket with $string as Content");
-ok( $agent->{'content'} =~ qr{$string} , "Found the content");
+like( $agent->{'content'}, qr{$string} , "Found the content");
+ok($agent->{redirected_uri}, "Did redirection");
+
+
$agent->get($url."Ticket/Create.html?Queue=1");
is ($agent->{'status'}, 200, "Loaded Create.html");
-$agent->form(3);
+$agent->form_number(3);
# Start with a string containing characters in latin1
my $string = "I18N Web Testing æøå";
Encode::from_to($string, 'iso-8859-1', 'utf8');
$agent->field('Content' => "Ticket with utf8 subject");
ok($agent->submit(), "Created new ticket with $string as Subject");
-ok( $agent->{'content'} =~ qr{$string} , "Found the content");
+like( $agent->{'content'}, qr{$string} , "Found the content");
+# Update time worked in hours
+$agent->follow_link( text_regex => qr/Basics/ );
+$agent->submit_form( form_number => 3,
+ fields => { TimeWorked => 5, 'TimeWorked-TimeUnits' => "hours" }
+);
+like ($agent->{'content'}, qr/to '300'/, "5 hours is 300 minutes");
# }}}
$agent->field("AttachmentField", "Subject");
$agent->field("AttachmentOp", "LIKE");
$agent->field("ValueOfAttachment", "aaa");
-$agent->submit();
+$agent->submit("AddClause");
# set the next value
ok($agent->form_name('BuildQuery'));
$agent->field("AttachmentField", "Subject");
$agent->field("AttachmentOp", "LIKE");
$agent->field("ValueOfAttachment", "bbb");
-$agent->submit();
+$agent->submit("AddClause");
ok($agent->form_name('BuildQuery'));