Merge branch 'master' of https://github.com/jgoodman/Freeside
[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::Group->new( RT->SystemUser );
22 my($ok, $msg) = $Cc->LoadSystemRoleGroup( 'Cc' );
23 ok($ok, $msg);
24 RT::Test->add_rights( { Principal => $Cc, Right => ['ShowTicket'] } );
25
26 my ($ticket) = RT::Test->create_ticket(
27     Queue   => 'General',
28     Subject => 'test subject',
29     Cc      => 'user_a@example.com',
30 );
31
32 my @results = $ticket->Correspond( Content => 'sample correspondence' );
33
34 ok( $m->login('user_a' => 'password'), 'unprivileged user logged in' );
35
36 $m->get_ok( '/SelfService/Display.html?id=' . $ticket->id,
37     'got selfservice display page' );
38
39 my $title = '#' . $ticket->id . ': test subject';
40 $m->title_is( $title );
41 $m->content_contains( "<h1>$title</h1>", "contains <h1>$title</h1>" );
42
43 # $ShowUnreadMessageNotifications tests:
44 $m->content_contains( "There are unread messages on this ticket." );
45
46 # mark the message as read
47 $m->follow_link_ok(
48     { text => 'jump to the first unread message and mark all messages as seen' },
49     'followed mark as seen link'
50 );
51
52 $m->content_contains( "<h1>$title</h1>", "contains <h1>$title</h1>" );
53 $m->content_lacks( "There are unread messages on this ticket." );
54
55 # TODO need more SelfService tests