File: web.t

package info (click to toggle)
request-tracker5 5.0.3%2Bdfsg-3~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 77,648 kB
  • sloc: javascript: 187,930; perl: 79,061; sh: 1,302; makefile: 471; python: 37; php: 15
file content (107 lines) | stat: -rw-r--r-- 3,450 bytes parent folder | download | duplicates (4)
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
97
98
99
100
101
102
103
104
105
106
107
use strict;
use warnings;

BEGIN {
    use Test::MockTime 'set_fixed_time';
    use constant TIME => 1442455200;
    set_fixed_time(TIME);

    use RT::Test
        tests => undef,
        config => "use Test::MockTime 'set_fixed_time'; set_fixed_time(". TIME . q!);
            Set( %ServiceAgreements, (
            Default => '2',
            Levels  => {
                '2' => {
                    StartImmediately => 1,
                    Response => { RealMinutes => 60 * 2 },
                },
                '4' => {
                    StartImmediately => 1,
                    Response => { RealMinutes => 60 * 4 },
                },
            },
        ));!
    ;
}

my $now = TIME;

my $queue = RT::Test->load_or_create_queue( Name => 'General', SLADisabled => 0 );

my $user = RT::Test->load_or_create_user(
    Name         => 'user',
    Password     => 'password',
    EmailAddress => 'user@example.com',
);

my ( $baseurl, $m ) = RT::Test->started_ok;
ok(
    RT::Test->set_rights(
        { Principal => $user, Right => [ qw(SeeQueue CreateTicket ShowTicket ModifyTicket ShowConfigTab AdminQueue) ] },
    ),
    'set rights'
);

ok $m->login( 'user', 'password' ), 'logged in as user';

{

    $m->goto_create_ticket( $queue->id );
    my $form = $m->form_name( 'TicketCreate' );
    my $sla  = $form->find_input( 'SLA' );
    is_deeply( [$sla->possible_values], [ 2, 4 ], 'possible sla' );
    $m->submit_form( fields => { Subject => 'ticket foo with default sla' }, button => 'SubmitTicket' );

    my $ticket = RT::Test->last_ticket;
    ok( $ticket->id, 'ticket is created' );
    my $id = $ticket->id;
    is( $ticket->SLA,             2,                  'default SLA is 2' );
    is( $ticket->StartsObj->Unix, $now,               'Starts' );
    is( $ticket->DueObj->Unix,    $now + 60 * 60 * 2, 'Due' );
}

{
    $m->goto_create_ticket( $queue->id );
    my $form = $m->form_name( 'TicketCreate' );
    $m->submit_form( fields => { Subject => 'ticket foo with default sla', SLA => 4 }, button => 'SubmitTicket' );

    my $ticket = RT::Test->last_ticket;
    ok( $ticket->id, 'ticket is created' );
    my $id = $ticket->id;
    is( $ticket->SLA,             4,                  'SLA is set to 4' );
    is( $ticket->StartsObj->Unix, $now,               'Starts' );
    is( $ticket->DueObj->Unix,    $now + 60 * 60 * 4, 'Due' );
    $m->follow_link_ok( { text => 'Basics' }, 'Ticket -> Basics' );
    $m->submit_form(
        form_name => 'TicketModify',
        fields    => { SLA => 2 },
    );
    $ticket->Load( $id );
    is( $ticket->SLA, 2, 'SLA is set to 2' );
    is( $ticket->DueObj->Unix, $now + 60 * 60 * 2, 'Due is updated accordingly' );
}

{
    $m->get_ok( $baseurl . '/Admin/Queues/Modify.html?id=' . $queue->id );
    my $form = $m->form_name( 'ModifyQueue' );
    $m->untick( 'SLAEnabled', 1 );
    $m->submit;
    $m->text_contains( q{SLADisabled changed from (no value) to "1"} );
}

{

    $m->goto_create_ticket( $queue->id );
    my $form = $m->form_name( 'TicketCreate' );
    ok( !$form->find_input( 'SLA' ), 'no SLA input' );
    $m->submit_form( fields => { Subject => 'ticket foo without sla' }, button => 'SubmitTicket' );

    my $ticket = RT::Test->last_ticket;
    ok( $ticket->id,               'ticket is created' );
    ok( !$ticket->SLA,             'no SLA' );
    ok( !$ticket->StartsObj->Unix, 'no Starts' );
    ok( !$ticket->DueObj->Unix,    'no Due' );
}

done_testing;