6 use RT::Test nodata => 1, tests => 23, config => 'Set($ShowUnreadMessageNotifications, 1);';
8 my $queue = RT::Test->load_or_create_queue( Name => 'Regression' );
9 ok $queue && $queue->id, 'loaded or created queue';
11 my $user_a = RT::Test->load_or_create_user(
12 Name => 'user_a', Password => 'password',
14 ok $user_a && $user_a->id, 'loaded or created user';
16 my $user_b = RT::Test->load_or_create_user(
17 Name => 'user_b', Password => 'password',
19 ok $user_b && $user_b->id, 'loaded or created user';
21 ok( RT::Test->set_rights(
22 { Principal => $user_a, Right => [qw(SeeQueue ShowTicket CreateTicket OwnTicket ModifyTicket)] },
23 { Principal => $user_b, Right => [qw(SeeQueue ShowTicket ReplyToTicket)] },
27 my $agent_a = RT::Test::Web->new;
28 ok $agent_a->login('user_a', 'password'), 'logged in as user A';
30 my $agent_b = RT::Test::Web->new;
31 ok $agent_b->login('user_b', 'password'), 'logged in as user B';
33 diag "create a ticket for testing";
36 my $ticket = RT::Ticket->new( $user_a );
38 ($tid, $txn, $msg) = $ticket->Create(
43 ok $tid, 'created a ticket #'. $tid or diag "error: $msg";
44 is $ticket->Owner, $user_a->id, 'correct owner';
47 diag "user B adds a message, we check that user A see notification and can clear it";
49 my $ticket = RT::Ticket->new( $user_b );
50 $ticket->Load( $tid );
51 ok $ticket->id, 'loaded the ticket';
53 my ($status, $msg) = $ticket->Correspond( Content => 'bla-bla' );
54 ok $status, 'added reply' or diag "error: $msg";
55 my $txns = $ticket->Transactions;
58 VALUE => "Correspond",
60 my $txn = $txns->Last;
61 my $reply_id = $txn->id;
62 ok( $reply_id, 'got correspond txn id' );
64 $agent_a->goto_ticket($tid);
65 $agent_a->content_contains('bla-bla', 'the message on the page');
67 $agent_a->content_contains(
69 'we have not seen something'
72 $agent_a->follow_link_ok(
73 { text => 'jump to the first unread message' },
74 'try to jump to first unread message'
76 like( $agent_a->base, qr/#txn-$reply_id$/, 'contains anchor' );
78 $agent_a->follow_link_ok({text => 'jump to the first unread message and mark all messages as seen'}, 'try to mark all as seen');
79 $agent_a->content_contains(
80 'Marked all messages as seen',
83 like( $agent_a->base, qr/#txn-$reply_id$/, 'contains anchor' );
85 $agent_a->content_contains(
86 'Marked all messages as seen',
90 $agent_a->goto_ticket($tid);
91 $agent_a->content_lacks(
93 'we have seen everything, so no messages'