import rt 3.6.4
[freeside.git] / rt / lib / t / regression / 18custom_frontpage.t
1 #!/usr/bin/perl -w
2 use strict;
3
4 use Test::More tests => 7;
5 BEGIN {
6     use RT;
7     RT::LoadConfig;
8     RT::Init;
9 }
10 use Test::WWW::Mechanize;
11
12 use constant BaseURL => $RT::WebURL;
13
14
15 my $user_obj = RT::User->new($RT::SystemUser);
16 my ($ret, $msg) = $user_obj->LoadOrCreateByEmail('customer@example.com');
17 ok($ret, 'ACL test user creation');
18 $user_obj->SetName('customer');
19 $user_obj->SetPrivileged(1);
20 ($ret, $msg) = $user_obj->SetPassword('customer');
21 $user_obj->PrincipalObj->GrantRight(Right => 'LoadSavedSearch');
22 $user_obj->PrincipalObj->GrantRight(Right => 'EditSavedSearch');
23 $user_obj->PrincipalObj->GrantRight(Right => 'CreateSavedSearch');
24 $user_obj->PrincipalObj->GrantRight(Right => 'ModifySelf');
25
26 my $m = Test::WWW::Mechanize->new ( autocheck => 1 );
27 isa_ok($m, 'Test::WWW::Mechanize');
28
29 $m->get( BaseURL."?user=customer;pass=customer" );
30
31 $m->content_like(qr/Logout/, 'we did log in');
32
33 $m->get ( BaseURL."Search/Build.html");
34
35 #create a saved search
36 $m->form_name ('BuildQuery');
37
38 $m->field ( "ValueOfAttachment" => 'stupid');
39 $m->field ( "Description" => 'stupid tickets');
40 $m->click_button (name => 'Save');
41
42 $m->get ( BaseURL.'Prefs/MyRT.html' );
43 $m->content_like (qr/stupid tickets/, 'saved search listed in rt at a glance items');
44
45 $m->follow_link (text => 'Logout');
46
47 $m->get( BaseURL."?user=root;pass=password" );
48 $m->content_like(qr/Logout/, 'we did log in');
49
50 $m->get ( BaseURL.'Prefs/MyRT.html' );
51 $m->form_name ('SelectionBox-body');
52 # can't use submit form for mutli-valued select as it uses set_fields
53 $m->field ('body-Selected' => ['component-QuickCreate', 'system-Unowned Tickets', 'system-My Tickets']);
54 $m->click_button (name => 'remove');
55 $m->form_name ('SelectionBox-body');
56 #$m->click_button (name => 'body-Save');
57 $m->get ( BaseURL );
58 $m->content_lacks ('highest priority tickets', 'remove everything from body pane');
59
60 $m->get ( BaseURL.'Prefs/MyRT.html' );
61 $m->form_name ('SelectionBox-body');
62 $m->field ('body-Available' => ['component-QuickCreate', 'system-Unowned Tickets', 'system-My Tickets']);
63 $m->click_button (name => 'add');
64
65 $m->form_name ('SelectionBox-body');
66 $m->field ('body-Selected' => ['component-QuickCreate']);
67 $m->click_button (name => 'movedown');
68
69 $m->form_name ('SelectionBox-body');
70 $m->click_button (name => 'movedown');
71
72 $m->form_name ('SelectionBox-body');
73 #$m->click_button (name => 'body-Save');
74 $m->get ( BaseURL );
75 $m->content_like (qr'highest priority tickets', 'adds them back');