1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#!/usr/bin/perl
use strict;
use warnings;
use RT::Test tests => 21;
my $queue = RT::Test->load_or_create_queue( Name => 'Regression' );
ok $queue && $queue->id, 'loaded or created queue';
my $user_a = RT::Test->load_or_create_user(
Name => 'user_a', Password => 'password',
);
ok $user_a && $user_a->id, 'loaded or created user';
my $user_b = RT::Test->load_or_create_user(
Name => 'user_b', Password => 'password',
);
ok $user_b && $user_b->id, 'loaded or created user';
ok( RT::Test->set_rights(
{ Principal => $user_a, Right => [qw(SeeQueue ShowTicket CreateTicket OwnTicket ModifyTicket)] },
{ Principal => $user_b, Right => [qw(SeeQueue ShowTicket ReplyToTicket)] },
), 'set rights');
RT::Test->started_ok;
my $agent_a = RT::Test::Web->new;
ok $agent_a->login('user_a', 'password'), 'logged in as user A';
my $agent_b = RT::Test::Web->new;
ok $agent_b->login('user_b', 'password'), 'logged in as user B';
diag "create a ticket for testing" if $ENV{TEST_VERBOSE};
my $tid;
{
my $ticket = RT::Ticket->new( $user_a );
my ($txn, $msg);
($tid, $txn, $msg) = $ticket->Create(
Queue => $queue->id,
Owner => $user_a->id,
Subject => 'test',
);
ok $tid, 'created a ticket #'. $tid or diag "error: $msg";
is $ticket->Owner, $user_a->id, 'correct owner';
}
diag "user B adds a message, we check that user A see notification and can clear it" if $ENV{TEST_VERBOSE};
{
my $ticket = RT::Ticket->new( $user_b );
$ticket->Load( $tid );
ok $ticket->id, 'loaded the ticket';
my ($status, $msg) = $ticket->Correspond( Content => 'bla-bla' );
ok $status, 'added reply' or diag "error: $msg";
my $txns = $ticket->Transactions;
$txns->Limit(
FIELD => 'Type',
VALUE => "Correspond",
);
my $txn = $txns->Last;
my $reply_id = $txn->id;
ok( $reply_id, 'got correspond txn id' );
$agent_a->goto_ticket($tid);
$agent_a->content_like(qr/bla-bla/ims, 'the message on the page');
$agent_a->content_like(
qr/unread message/ims,
'we have not seen something'
);
$agent_a->follow_link_ok(
{ text => 'jump to the first unread message' },
'try to jump to first unread message'
);
like( $agent_a->base, qr/#txn-$reply_id$/, 'contains anchor' );
$agent_a->follow_link_ok({text => 'jump to the first unread message and mark all messages as seen'}, 'try to mark all as seen');
$agent_a->content_like(
qr/Marked all messages as seen/ims,
'see success message'
);
like( $agent_a->base, qr/#txn-$reply_id$/, 'contains anchor' );
$agent_a->content_like(
qr/Marked all messages as seen/ims,
'see success message'
);
$agent_a->goto_ticket($tid);
$agent_a->content_unlike(
qr/unread message/ims,
'we have seen everything, so no messages'
);
}
|