4 use Test::More tests => 17;
6 use HTTP::Request::Common;
11 my $cookie_jar = HTTP::Cookies->new;
12 my $agent = WWW::Mechanize->new();
14 # give the agent a place to stash the cookies
16 $agent->cookie_jar($cookie_jar);
22 my $url = $RT::WebURL;
25 is ($agent->{'status'}, 200, "Loaded a page");
30 # follow the link marked "Login"
32 ok($agent->{form}->find_input('user'));
34 ok($agent->{form}->find_input('pass'));
35 ok ($agent->{'content'} =~ /username:/i);
36 $agent->field( 'user' => 'root' );
37 $agent->field( 'pass' => 'password' );
38 # the field isn't named, so we have to click link 0
40 is($agent->{'status'}, 200, "Fetched the page ok");
41 ok( $agent->{'content'} =~ /Logout/i, "Found a logout link");
45 $agent->get($url."Ticket/Create.html?Queue=1");
46 is ($agent->{'status'}, 200, "Loaded Create.html");
48 # Start with a string containing characters in latin1
49 my $string = "I18N Web Testing æøå";
50 Encode::from_to($string, 'iso-8859-1', 'utf8');
51 $agent->field('Subject' => "Ticket with utf8 body");
52 $agent->field('Content' => $string);
53 ok($agent->submit(), "Created new ticket with $string as Content");
54 ok( $agent->{'content'} =~ qr{$string} , "Found the content");
55 $agent->get($url."Ticket/Create.html?Queue=1");
56 is ($agent->{'status'}, 200, "Loaded Create.html");
58 # Start with a string containing characters in latin1
59 my $string = "I18N Web Testing æøå";
60 Encode::from_to($string, 'iso-8859-1', 'utf8');
61 $agent->field('Subject' => $string);
62 $agent->field('Content' => "Ticket with utf8 subject");
63 ok($agent->submit(), "Created new ticket with $string as Subject");
65 ok( $agent->{'content'} =~ qr{$string} , "Found the content");
71 # {{{ Query Builder tests
73 my $response = $agent->get($url."Search/Build.html");
74 ok( $response->is_success, "Fetched " . $url."Search/Build.html" );
81 ok($agent->form_name('BuildQuery'));
82 $agent->field("AttachmentField", "Subject");
83 $agent->field("AttachmentOp", "LIKE");
84 $agent->field("ValueOfAttachment", "aaa");
88 ok($agent->form_name('BuildQuery'));
89 $agent->field("AttachmentField", "Subject");
90 $agent->field("AttachmentOp", "LIKE");
91 $agent->field("ValueOfAttachment", "bbb");
94 ok($agent->form_name('BuildQuery'));
97 my $query = $agent->current_form->find_input("Query")->value;
98 # strip whitespace from ends
102 # collapse other whitespace
105 is ($query, "Subject LIKE 'aaa' AND Subject LIKE 'bbb'");
107 # - new items go one level down
108 # - add items at currently selected level
109 # - if nothing is selected, add at end, one level down
112 # - error if nothing selected
113 # - same item should be selected after move
114 # - can't move left if you're at the top level
117 # - error if nothing selected
118 # - same item should be selected after move
119 # - can always move right (no max depth...should there be?)
122 # - error if nothing selected
123 # - same item should be selected after move
124 # - can't move up if you're first in the list
127 # - error if nothing selected
128 # - same item should be selected after move
129 # - can't move down if you're last in the list
132 # - error if nothing selected
133 # - change all aggregators in the grouping
134 # - don't change any others
137 # - error if nothing selected
138 # - delete currently selected item
139 # - delete all children of a grouping
140 # - if delete leaves a node with no children, delete that, too
141 # - what should be selected?
144 # - clears entire query
145 # - clears it from the session, too