This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / rt / lib / t / regression / 02basic_web.t
1 #!/usr/bin/perl
2
3 use strict;
4 use Test::More tests => 17;
5 use WWW::Mechanize;
6 use HTTP::Request::Common;
7 use HTTP::Cookies;
8 use LWP;
9 use Encode;
10
11 my $cookie_jar = HTTP::Cookies->new;
12 my $agent = WWW::Mechanize->new();
13
14 # give the agent a place to stash the cookies
15
16 $agent->cookie_jar($cookie_jar);
17
18 use RT;
19 RT::LoadConfig;
20
21 # get the top page
22 my $url = $RT::WebURL;
23 $agent->get($url);
24
25 is ($agent->{'status'}, 200, "Loaded a page");
26
27
28 # {{{ test a login
29
30 # follow the link marked "Login"
31
32 ok($agent->{form}->find_input('user'));
33
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
39 $agent->click(0);
40 is($agent->{'status'}, 200, "Fetched the page ok");
41 ok( $agent->{'content'} =~ /Logout/i, "Found a logout link");
42
43
44
45 $agent->get($url."Ticket/Create.html?Queue=1");
46 is ($agent->{'status'}, 200, "Loaded Create.html");
47 $agent->form(3);
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");
57 $agent->form(3);
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");
64
65 ok( $agent->{'content'} =~ qr{$string} , "Found the content");
66
67
68
69 # }}}
70
71 # {{{ Query Builder tests
72
73 my $response = $agent->get($url."Search/Build.html");
74 ok( $response->is_success, "Fetched " . $url."Search/Build.html" );
75
76 # Parsing TicketSQL
77 #
78 # Adding items
79
80 # set the first value
81 ok($agent->form_name('BuildQuery'));
82 $agent->field("AttachmentField", "Subject");
83 $agent->field("AttachmentOp", "LIKE");
84 $agent->field("ValueOfAttachment", "aaa");
85 $agent->submit();
86
87 # set the next value
88 ok($agent->form_name('BuildQuery'));
89 $agent->field("AttachmentField", "Subject");
90 $agent->field("AttachmentOp", "LIKE");
91 $agent->field("ValueOfAttachment", "bbb");
92 $agent->submit();
93
94 ok($agent->form_name('BuildQuery'));
95
96 # get the query
97 my $query = $agent->current_form->find_input("Query")->value;
98 # strip whitespace from ends
99 $query =~ s/^\s*//g;
100 $query =~ s/\s*$//g;
101
102 # collapse other whitespace
103 $query =~ s/\s+/ /g;
104
105 is ($query, "Subject LIKE 'aaa' AND Subject LIKE 'bbb'");
106
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
110 #
111 # move left
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
115 #
116 # move right
117 # - error if nothing selected
118 # - same item should be selected after move
119 # - can always move right (no max depth...should there be?)
120 #
121 # move up
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
125 #
126 # move down
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
130 #
131 # toggle
132 # - error if nothing selected
133 # - change all aggregators in the grouping
134 # - don't change any others
135 #
136 # delete
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?
142 #
143 # Clear
144 # - clears entire query
145 # - clears it from the session, too
146
147 # }}}
148
149
150 1;