5 use HTTP::Request::Common;
10 my $cookie_jar = HTTP::Cookies->new;
11 my $agent = WWW::Mechanize->new();
13 # give the agent a place to stash the cookies
15 $agent->cookie_jar($cookie_jar);
19 my $url = "http://localhost".$RT::WebPath."/";
22 is ($agent->{'status'}, 200, "Loaded a page");
27 # follow the link marked "Login"
29 ok($agent->{form}->find_input('user'));
31 ok($agent->{form}->find_input('pass'));
32 ok ($agent->{'content'} =~ /username:/i);
33 $agent->field( 'user' => 'root' );
34 $agent->field( 'pass' => 'password' );
35 # the field isn't named, so we have to click link 0
37 is($agent->{'status'}, 200, "Fetched the page ok");
38 ok( $agent->{'content'} =~ /Logout/i, "Found a logout link");
42 $agent->get($url."Ticket/Create.html?Queue=1");
43 is ($agent->{'status'}, 200, "Loaded Create.html");
45 # Start with a string containing characters in latin1
46 my $string = "I18N Web Testing æøå";
47 Encode::from_to($string, 'iso-8859-1', 'utf8');
48 $agent->field('Subject' => "Foo");
49 $agent->field('Content' => $string);
50 ok($agent->submit(), "Created new ticket with $string");
52 ok( $agent->{'content'} =~ qr{$string} , "Found the content");
54 $agent->get($url."Ticket/Create.html?Queue=1");
55 is ($agent->{'status'}, 200, "Loaded Create.html");
57 # Start with a string containing characters in latin1
58 my $string = "I18N Web Testing æøå";
59 Encode::from_to($string, 'iso-8859-1', 'utf8');
60 $agent->field('Subject' => $string);
61 $agent->field('Content' => "BAR");
62 ok($agent->submit(), "Created new ticket with $string");
64 ok( $agent->{'content'} =~ qr{$string} , "Found the content");
70 # {{{ Query Builder tests
72 my $response = $agent->get($url."Search/Build.html");
73 ok( $response->is_success, "Fetched " . $url."Search/Build.html" );
80 ok($agent->form_name('BuildQuery'));
81 $agent->field("AttachmentField", "Subject");
82 $agent->field("AttachmentOp", "LIKE");
83 $agent->field("ValueOfAttachment", "aaa");
87 ok($agent->form_name('BuildQuery'));
88 $agent->field("AttachmentField", "Subject");
89 $agent->field("AttachmentOp", "LIKE");
90 $agent->field("ValueOfAttachment", "bbb");
93 ok($agent->form_name('BuildQuery'));
96 my $query = $agent->current_form->find_input("Query")->value;
97 # strip whitespace from ends
101 # collapse other whitespace
104 is ($query, "Subject LIKE 'aaa' AND Subject LIKE 'bbb'");
106 # - new items go one level down
107 # - add items at currently selected level
108 # - if nothing is selected, add at end, one level down
111 # - error if nothing selected
112 # - same item should be selected after move
113 # - can't move left if you're at the top level
116 # - error if nothing selected
117 # - same item should be selected after move
118 # - can always move right (no max depth...should there be?)
121 # - error if nothing selected
122 # - same item should be selected after move
123 # - can't move up if you're first in the list
126 # - error if nothing selected
127 # - same item should be selected after move
128 # - can't move down if you're last in the list
131 # - error if nothing selected
132 # - change all aggregators in the grouping
133 # - don't change any others
136 # - error if nothing selected
137 # - delete currently selected item
138 # - delete all children of a grouping
139 # - if delete leaves a node with no children, delete that, too
140 # - what should be selected?
143 # - clears entire query
144 # - clears it from the session, too
149 find ( \&wanted , 'html/');
152 -f && /\.html$/ && $_ !~ /Logout.html$/ && test_get($File::Find::name);
160 ok ($agent->get("$url/$file", "GET $url/$file"));
161 is ($agent->{'status'}, 200, "Loaded $file");
162 # ok( $agent->{'content'} =~ /Logout/i, "Found a logout link on $file ");
163 ok( $agent->{'content'} !~ /Not logged in/i, "Still logged in for $file");
164 ok( $agent->{'content'} !~ /System error/i, "Didn't get a Mason compilation error on $file");