3 use RT::Test tests => 170;
5 my ( $url, $m ) = RT::Test->started_ok;
6 my $root = RT::Test->load_or_create_user( Name => 'root' );
8 diag "create another queue";
9 my $test_queue = RT::Queue->new( $RT::SystemUser );
10 ok( $test_queue->Create( Name => 'foo' ) );
12 diag "create cf cfbar";
13 my $cfbar = RT::CustomField->new( $RT::SystemUser );
18 LookupType => 'RT::Queue-RT::Ticket'
22 $cfbar->AddToObject( $test_queue );
24 diag "create some tickets to link";
25 # yep, create 3 tickets for DependsOn
26 my @tickets = map { { Subject => "link of $_" } }
27 qw/DependsOn DependsOn DependsOn DependedOnBy HasMember HasMember
28 MemberOf RefersTo RefersTo ReferredToBy/;
29 RT::Test->create_tickets( { Status => 'resolved' }, @tickets );
31 diag "test different mobile agents";
33 'hiptop', 'Blazer', 'Novarra', 'Vagabond',
34 'SonyEricsson', 'Symbian', 'NetFront', 'UP.Browser',
35 'UP.Link', 'Windows CE', 'MIDP', 'J2ME',
36 'DoCoMo', 'J-PHONE', 'PalmOS', 'PalmSource',
37 'iPhone', 'iPod', 'AvantGo', 'Nokia',
38 'Android', 'WebOS', 'S60'
41 for my $agent (@agents) {
44 $m->content_contains( 'Not using a mobile browser',
45 "mobile login page for agent $agent" );
48 $m->submit_form( fields => { user => 'root', pass => 'password' } );
49 is( $m->uri, $url . '/m/', 'logged in via mobile ui' );
50 ok( $m->find_link( text => 'Home' ), 'has homepage link, so really logged in' );
52 diag "create some tickets";
53 $m->follow_link_ok( { text => 'New ticket' } );
54 like( $m->uri, qr'/m/ticket/select_create_queue', 'queue select page' );
55 $m->follow_link_ok( { text => 'General' } );
56 like( $m->uri, qr'/m/ticket/create', 'ticket create page' );
60 Content => 'content 1',
62 Cc => 'cc@example.com',
63 AdminCc => 'admincc@example.com',
64 InitialPriority => 13,
67 'TimeEstimated-TimeUnits' => 'hours',
70 Starts => '2011-01-11 11:11:11',
71 Due => '2011-02-12 12:12:12',
72 'new-DependsOn' => '1 2 3',
73 'DependsOn-new' => '4',
74 'new-MemberOf' => '5 6',
75 'MemberOf-new' => '7',
76 'new-RefersTo' => '8 9',
77 'RefersTo-new' => '10',
80 like( $m->uri, qr'/m/ticket/show', 'ticket show page' );
81 $m->content_contains( 'ticket1', 'subject' );
82 $m->content_contains( 'open', 'status' );
83 $m->content_contains( 'cc@example.com', 'cc' );
84 $m->content_contains( 'admincc@example.com', 'admincc' );
85 $m->content_contains( '13/93', 'priority' );
86 $m->content_contains( '2 hour', 'time estimates' );
87 $m->content_contains( '30 min', 'time worked' );
88 $m->content_contains( '60 min', 'time left' );
89 $m->content_contains( 'Tue Jan 11 11:11:11', 'starts' );
90 $m->content_contains( 'Sat Feb 12 12:12:12', 'due' );
91 $m->content_like( qr/(link of DependsOn).*\1.*\1/s, 'depends on' );
92 $m->content_contains( 'link of DependedOnBy', 'depended on by' );
93 $m->content_like( qr/(link of HasMember).*\1/s, 'has member' );
94 $m->content_contains( 'link of MemberOf', 'member of' );
95 $m->content_like( qr/(link of RefersTo).*\1/s, 'refers to' );
96 $m->content_contains( 'link of ReferredToBy', 'referred to by' );
98 diag "test ticket reply";
99 $m->follow_link_ok( { text => 'Reply' } );
100 like( $m->uri, qr'/m/ticket/reply', 'ticket reply page' );
103 UpdateContent => 'reply 1',
104 UpdateTimeWorked => '30',
105 UpdateStatus => 'resolved',
106 UpdateType => 'response',
108 button => 'SubmitTicket',
110 like( $m->uri, qr'/m/ticket/show', 'back to ticket show page' );
111 $m->content_contains( '1 hour', 'time worked' );
112 $m->content_contains( 'resolved', 'status' );
113 $m->follow_link_ok( { text => 'Reply' } );
114 like( $m->uri, qr'/m/ticket/reply', 'ticket reply page' );
117 UpdateContent => 'reply 2',
118 UpdateSubject => 'ticket1',
119 UpdateStatus => 'open',
120 UpdateType => 'private',
122 button => 'SubmitTicket',
125 $m->content_contains( 'ticket1', 'subject' );
126 $m->content_contains( 'open', 'status' );
128 like( $m->uri, qr'/m/ticket/show', 'back to ticket show page' );
130 diag "test ticket history";
131 $m->follow_link_ok( { text => 'History' } );
132 like( $m->uri, qr'/m/ticket/history', 'ticket history page' );
133 $m->content_contains( 'content 1', 'has main content' );
134 $m->content_contains( 'reply 1', 'has replied content' );
135 $m->content_contains( 'reply 2', 'has replied content' );
137 diag "create another ticket in queue foo";
138 $m->follow_link_ok( { text => 'Home' } );
139 is( $m->uri, "$url/m/", 'main mobile page' );
140 $m->follow_link_ok( { text => 'New ticket' } );
141 like( $m->uri, qr'/m/ticket/select_create_queue', 'queue select page' );
142 $m->follow_link_ok( { text => 'foo' } );
143 like( $m->uri, qr'/m/ticket/create', 'ticket create page' );
144 $m->content_contains( 'cfbar', 'has cf name' );
145 $m->content_contains( 'Object-RT::Ticket--CustomField-' . $cfbar->id . '-Value', 'has cf input name' );
148 Subject => 'ticket2',
149 Content => 'content 2',
151 'Object-RT::Ticket--CustomField-' . $cfbar->id . '-Value' => 'cfvalue',
155 like( $m->uri, qr'/m/ticket/show', 'ticket show page' );
156 $m->content_contains( 'cfbar', 'has cf name' );
157 $m->content_contains( 'cfvalue', 'has cf value' );
159 $m->follow_link_ok( { text => 'Home' } );
160 is( $m->uri, "$url/m/", 'main mobile page' );
162 diag "test unowned tickets link";
163 $m->follow_link_ok( { text => 'Unowned tickets' } );
164 $m->content_contains( 'Found 1 ticket', 'found 1 ticket' );
165 $m->content_contains( 'ticket1', 'has ticket1' );
166 $m->content_lacks( 'ticket2', 'no ticket2' );
169 diag "test tickets I own link";
170 $m->follow_link_ok( { text => 'Tickets I own' } );
171 $m->content_contains( 'Found 1 ticket', 'found 1 ticket' );
172 $m->content_lacks( 'ticket1', 'no ticket1' );
173 ok( $m->find_link( text_regex => qr/ticket2/ ), 'has ticket2 link' );
176 diag "test all tickets link";
177 $m->follow_link_ok( { text => 'All tickets' } );
178 $m->content_contains( 'Found 12 tickets', 'found 12 tickets' );
179 ok( $m->find_link( text_regex => qr/ticket1/ ), 'has ticket1 link' );
180 ok( $m->find_link( text_regex => qr/ticket2/ ), 'has ticket2 link' );
183 diag "test bookmarked tickets link";
184 my $ticket = RT::Ticket->new(RT::CurrentUser->new('root'));
186 $root->ToggleBookmark($ticket);
188 $m->follow_link_ok( { text => 'Bookmarked tickets' } );
189 $m->content_contains( 'Found 1 ticket', 'found 1 ticket' );
190 ok( $m->find_link( text_regex => qr/ticket1/ ), 'has ticket1 link' );
191 $m->content_lacks( 'ticket2', 'no ticket2' );
194 diag "test tickets search";
195 $m->submit_form( fields => { q => 'ticket2' } );
196 $m->content_contains( 'Found 1 ticket', 'found 1 ticket' );
197 $m->content_lacks( 'ticket1', 'no ticket1' );
198 ok( $m->find_link( text_regex => qr/ticket2/ ), 'has ticket2 link' );
201 diag "test logout link";
202 $m->follow_link_ok( { text => 'Logout' } );
203 is( $m->uri, "$url/m/", 'still in mobile' );
204 $m->submit_form( fields => { user => 'root', pass => 'password' } );
206 diag "test notmobile link";
207 $m->follow_link_ok( { text => 'Home' } );
208 $m->follow_link_ok( { text => 'Not using a mobile browser?' } );
209 is( $m->uri, $url . '/', 'got full ui' );