5 use RT::Test nodata => 1, tests => 23, config => 'Set($ShowUnreadMessageNotifications, 1);';
7 my $queue = RT::Test->load_or_create_queue( Name => 'Regression' );
8 ok $queue && $queue->id, 'loaded or created queue';
10 my $user_a = RT::Test->load_or_create_user(
11 Name => 'user_a', Password => 'password',
13 ok $user_a && $user_a->id, 'loaded or created user';
15 my $user_b = RT::Test->load_or_create_user(
16 Name => 'user_b', Password => 'password',
18 ok $user_b && $user_b->id, 'loaded or created user';
20 ok( RT::Test->set_rights(
21 { Principal => $user_a, Right => [qw(SeeQueue ShowTicket CreateTicket OwnTicket ModifyTicket)] },
22 { Principal => $user_b, Right => [qw(SeeQueue ShowTicket ReplyToTicket)] },
26 my $agent_a = RT::Test::Web->new;
27 ok $agent_a->login('user_a', 'password'), 'logged in as user A';
29 my $agent_b = RT::Test::Web->new;
30 ok $agent_b->login('user_b', 'password'), 'logged in as user B';
32 diag "create a ticket for testing";
35 my $ticket = RT::Ticket->new( $user_a );
37 ($tid, $txn, $msg) = $ticket->Create(
42 ok $tid, 'created a ticket #'. $tid or diag "error: $msg";
43 is $ticket->Owner, $user_a->id, 'correct owner';
46 diag "user B adds a message, we check that user A see notification and can clear it";
48 my $ticket = RT::Ticket->new( $user_b );
49 $ticket->Load( $tid );
50 ok $ticket->id, 'loaded the ticket';
52 my ($status, $msg) = $ticket->Correspond( Content => 'bla-bla' );
53 ok $status, 'added reply' or diag "error: $msg";
54 my $txns = $ticket->Transactions;
57 VALUE => "Correspond",
59 my $txn = $txns->Last;
60 my $reply_id = $txn->id;
61 ok( $reply_id, 'got correspond txn id' );
63 $agent_a->goto_ticket($tid);
64 $agent_a->content_contains('bla-bla', 'the message on the page');
66 $agent_a->content_contains(
68 'we have not seen something'
71 $agent_a->follow_link_ok(
72 { text => 'jump to the first unread message' },
73 'try to jump to first unread message'
75 like( $agent_a->base, qr/#txn-$reply_id$/, 'contains anchor' );
77 $agent_a->follow_link_ok({text => 'jump to the first unread message and mark all messages as seen'}, 'try to mark all as seen');
78 $agent_a->content_contains(
79 'Marked all messages as seen',
82 like( $agent_a->base, qr/#txn-$reply_id$/, 'contains anchor' );
84 $agent_a->content_contains(
85 'Marked all messages as seen',
89 $agent_a->goto_ticket($tid);
90 $agent_a->content_lacks(
92 'we have seen everything, so no messages'