fix ticketing system error on bootstrap of new install
[freeside.git] / rt / t / web / self_service.t
1 use strict;
2 use warnings;
3
4 use RT::Test
5   tests  => 17,
6   config => 'Set( $ShowUnreadMessageNotifications, 1 );'
7 ;
8
9 my ($url, $m) = RT::Test->started_ok;
10
11 my $user_a = RT::Test->load_or_create_user(
12     Name         => 'user_a',
13     Password     => 'password',
14     EmailAddress => 'user_a@example.com',
15     Privileged   => 0,
16 );
17 ok( $user_a && $user_a->id, 'loaded or created user' );
18 ok( ! $user_a->Privileged, 'user is not privileged' );
19
20 # Load Cc group
21 my $Cc = RT::System->RoleGroup( 'Cc' );
22 ok($Cc->id);
23 RT::Test->add_rights( { Principal => $Cc, Right => ['ShowTicket'] } );
24
25 my ($ticket) = RT::Test->create_ticket(
26     Queue   => 'General',
27     Subject => 'test subject',
28     Cc      => 'user_a@example.com',
29 );
30
31 my @results = $ticket->Correspond( Content => 'sample correspondence' );
32
33 ok( $m->login('user_a' => 'password'), 'unprivileged user logged in' );
34
35 $m->get_ok( '/SelfService/Display.html?id=' . $ticket->id,
36     'got selfservice display page' );
37
38 my $title = '#' . $ticket->id . ': test subject';
39 $m->title_is( $title );
40 $m->content_contains( "<h1>$title</h1>", "contains <h1>$title</h1>" );
41
42 # $ShowUnreadMessageNotifications tests:
43 $m->content_contains( "There are unread messages on this ticket." );
44
45 # mark the message as read
46 $m->follow_link_ok(
47     { text => 'jump to the first unread message and mark all messages as seen' },
48     'followed mark as seen link'
49 );
50
51 $m->content_contains( "<h1>$title</h1>", "contains <h1>$title</h1>" );
52 $m->content_lacks( "There are unread messages on this ticket." );
53
54 # TODO need more SelfService tests