Skip to content

Commit

Permalink
Update tests for new Time widget and removed Basics
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrandtbuffalo committed Oct 1, 2024
1 parent 6b8383d commit 7169e2e
Show file tree
Hide file tree
Showing 30 changed files with 256 additions and 170 deletions.
14 changes: 7 additions & 7 deletions t/customfields/access_via_queue.t
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ diag "check that we don't have the cf on create";
ok $tid, "created a ticket succesfully";
$m->content_lacks($cf_name, "don't see CF");

$m->follow_link( id => 'page-edit-basics');
$form = $m->form_name('TicketModify');
$m->follow_link( id => 'page-edit-jumbo');
$form = $m->form_name('TicketModifyAll');
$cf_field = "Object-RT::Ticket-$tid-CustomField-". $cf->id ."-Value";
ok !$form->find_input( $cf_field ), 'no form field on the page';
}
Expand All @@ -136,13 +136,13 @@ diag "check that owner can see and edit CF";
ok $m->goto_ticket( $tid ), "opened ticket";
$m->content_contains($cf_name, "see CF");

$m->follow_link( id => 'page-edit-basics');
my $form = $m->form_name('TicketModify');
$m->follow_link( id => 'page-edit-jumbo');
my $form = $m->form_name('TicketModifyAll');
my $cf_field = "Object-RT::Ticket-$tid-CustomField-". $cf->id ."-Value";
ok $form->find_input( $cf_field ), 'form field on the page';

$m->submit_form(
form_name => 'TicketModify',
form_name => 'TicketModifyAll',
fields => {
$cf_field => "changed cf",
},
Expand All @@ -165,8 +165,8 @@ note 'make sure CF is not reset to no value';
is $t->FirstCustomFieldValue($cf_name), '2012-02-12';

$m->goto_ticket($t->id);
$m->follow_link_ok({id => 'page-edit-basics'});
my $form = $m->form_name('TicketModify');
$m->follow_link_ok({id => 'page-edit-jumbo'});
my $form = $m->form_name('TicketModifyAll');
my $input = $form->find_input(
'Object-RT::Ticket-'. $t->id .'-CustomField-'. $cf->id .'-Value'
);
Expand Down
12 changes: 6 additions & 6 deletions t/customfields/ip.t
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ diag "create a ticket and edit IP field using Edit page"
ok( $id, "created ticket $id" );
my $cf_field = "Object-RT::Ticket-$id-CustomField-$cf_id-Values";

$agent->follow_link_ok( { text => 'Basics', n => "1" },
"Followed 'Basics' link" );
$agent->form_name('TicketModify');
$agent->follow_link_ok( { text => 'Jumbo', n => "1" },
"Followed 'Jumbo' link" );
$agent->form_name('TicketModifyAll');

is( $agent->value($cf_field), '', 'IP is empty' );
$agent->field( $cf_field => $val );
Expand All @@ -99,9 +99,9 @@ diag "create a ticket and edit IP field using Edit page"

diag "set IP with spaces around" if $ENV{'TEST_VERBOSE'};
$val = " 172.16.0.2 \n ";
$agent->follow_link_ok( { text => 'Basics', n => "1" },
"Followed 'Basics' link" );
$agent->form_name('TicketModify');
$agent->follow_link_ok( { text => 'Jumbo', n => "1" },
"Followed 'Jumbo' link" );
$agent->form_name('TicketModifyAll');
is( $agent->value($cf_field), '172.16.0.1', 'IP is in input box' );
$agent->field( $cf_field => $val );
$agent->click('SubmitTicket');
Expand Down
24 changes: 12 additions & 12 deletions t/customfields/iprange.t
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ diag "create a ticket and edit IP field using Edit page" if $ENV{'TEST_VERBOSE'}
ok( $id, "created ticket $id" );
my $cf_field = "Object-RT::Ticket-$id-CustomField-$cf_id-Values";

$agent->follow_link_ok( { text => 'Basics', n => "1" },
"Followed 'Basics' link" );
$agent->form_name('TicketModify');
$agent->follow_link_ok( { text => 'Jumbo', n => "1" },
"Followed 'Jumbo' link" );
$agent->form_name('TicketModifyAll');

like( $agent->value($cf_field), qr/^\s*$/, 'IP is empty' );
$agent->field( $cf_field => $val );
Expand All @@ -116,9 +116,9 @@ diag "create a ticket and edit IP field using Edit page" if $ENV{'TEST_VERBOSE'}

diag "set IP with spaces around" if $ENV{'TEST_VERBOSE'};
$val = " 172.16.0.2 \n ";
$agent->follow_link_ok( { text => 'Basics', n => "1" },
"Followed 'Basics' link" );
$agent->form_name('TicketModify');
$agent->follow_link_ok( { text => 'Jumbo', n => "1" },
"Followed 'Jumbo' link" );
$agent->form_name('TicketModifyAll');
like( $agent->value($cf_field),
qr/^\s*\Q172.16.0.1\E\s*$/, 'IP is in input box' );
$agent->field( $cf_field => $val );
Expand All @@ -133,9 +133,9 @@ diag "create a ticket and edit IP field using Edit page" if $ENV{'TEST_VERBOSE'}

diag "replace IP with a range" if $ENV{'TEST_VERBOSE'};
$val = '172.16.0.0-172.16.0.255';
$agent->follow_link_ok( { text => 'Basics', n => "1" },
"Followed 'Basics' link" );
$agent->form_name('TicketModify');
$agent->follow_link_ok( { text => 'Jumbo', n => "1" },
"Followed 'Jumbo' link" );
$agent->form_name('TicketModifyAll');
like( $agent->value($cf_field),
qr/^\s*\Q172.16.0.2\E\s*$/, 'IP is in input box' );
$agent->field( $cf_field => $val );
Expand All @@ -150,9 +150,9 @@ diag "create a ticket and edit IP field using Edit page" if $ENV{'TEST_VERBOSE'}

diag "delete range, add another range using CIDR" if $ENV{'TEST_VERBOSE'};
$val = '172.16/16';
$agent->follow_link_ok( { text => 'Basics', n => "1" },
"Followed 'Basics' link" );
$agent->form_name('TicketModify');
$agent->follow_link_ok( { text => 'Jumbo', n => "1" },
"Followed 'Jumbo' link" );
$agent->form_name('TicketModifyAll');
is( $agent->value($cf_field),
'172.16.0.0-172.16.0.255', 'IP is in input box' );
$agent->field( $cf_field => $val );
Expand Down
24 changes: 12 additions & 12 deletions t/customfields/iprangev6.t
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ diag "create a ticket and edit IP field using Edit page" if $ENV{'TEST_VERBOSE'}
ok( $id, "created ticket $id" );
my $cf_field = "Object-RT::Ticket-$id-CustomField-$cf_id-Values";

$agent->follow_link_ok( { text => 'Basics', n => "1" },
"Followed 'Basics' link" );
$agent->form_name('TicketModify');
$agent->follow_link_ok( { text => 'Jumbo', n => "1" },
"Followed 'Jumbo' link" );
$agent->form_name('TicketModifyAll');

is( $agent->value($cf_field), '', 'IP is empty' );
$agent->field( $cf_field => $val );
Expand All @@ -132,9 +132,9 @@ diag "create a ticket and edit IP field using Edit page" if $ENV{'TEST_VERBOSE'}
is( $ticket->FirstCustomFieldValue('IP'), $val, 'correct value' );

diag "set IP with spaces around" if $ENV{'TEST_VERBOSE'};
$agent->follow_link_ok( { text => 'Basics', n => "1" },
"Followed 'Basics' link" );
$agent->form_name('TicketModify');
$agent->follow_link_ok( { text => 'Jumbo', n => "1" },
"Followed 'Jumbo' link" );
$agent->form_name('TicketModifyAll');
is( $agent->value($cf_field), $val, 'IP is in input box' );
$val = 'bbcd' . ':abcd' x 7;
$agent->field( $cf_field => " $val " );
Expand All @@ -148,9 +148,9 @@ diag "create a ticket and edit IP field using Edit page" if $ENV{'TEST_VERBOSE'}
is( $ticket->FirstCustomFieldValue('IP'), $val, 'correct value' );

diag "replace IP with a range" if $ENV{'TEST_VERBOSE'};
$agent->follow_link_ok( { text => 'Basics', n => "1" },
"Followed 'Basics' link" );
$agent->form_name('TicketModify');
$agent->follow_link_ok( { text => 'Jumbo', n => "1" },
"Followed 'Jumbo' link" );
$agent->form_name('TicketModifyAll');
is( $agent->value($cf_field), $val, 'IP is in input box' );
$val = 'abcd::' . '-' . 'abcd' . ':ffff' x 7;
$agent->field( $cf_field => 'abcd::/16' );
Expand All @@ -164,9 +164,9 @@ diag "create a ticket and edit IP field using Edit page" if $ENV{'TEST_VERBOSE'}
is( $ticket->FirstCustomFieldValue('IP'), $val, 'correct value' );

diag "delete range, add another range using CIDR" if $ENV{'TEST_VERBOSE'};
$agent->follow_link_ok( { text => 'Basics', n => "1" },
"Followed 'Basics' link" );
$agent->form_name('TicketModify');
$agent->follow_link_ok( { text => 'Jumbo', n => "1" },
"Followed 'Jumbo' link" );
$agent->form_name('TicketModifyAll');
is( $agent->value($cf_field), $val, 'IP is in input box' );
$val = 'bb::' . '-' . 'bbff' . ':ffff' x 7;
$agent->field( $cf_field => $val );
Expand Down
12 changes: 6 additions & 6 deletions t/customfields/ipv6.t
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ diag "create a ticket and edit IP field using Edit page"
ok( $id, "created ticket $id" );
my $cf_field = "Object-RT::Ticket-$id-CustomField-$cf_id-Values";

$agent->follow_link_ok( { text => 'Basics', n => "1" },
"Followed 'Basics' link" );
$agent->form_name('TicketModify');
$agent->follow_link_ok( { text => 'Jumbo', n => "1" },
"Followed 'Jumbo' link" );
$agent->form_name('TicketModifyAll');

is( $agent->value($cf_field), '', 'IP is empty' );
$agent->field( $cf_field => $valid{$ip} );
Expand All @@ -121,9 +121,9 @@ diag "create a ticket and edit IP field using Edit page"
diag "set IP with spaces around" if $ENV{'TEST_VERBOSE'};
my $new_ip = '::3141';

$agent->follow_link_ok( { text => 'Basics', n => "1" },
"Followed 'Basics' link" );
$agent->form_name('TicketModify');
$agent->follow_link_ok( { text => 'Jumbo', n => "1" },
"Followed 'Jumbo' link" );
$agent->form_name('TicketModifyAll');
is( $agent->value($cf_field), $valid{$ip}, 'IP is in input box' );
$agent->field( $cf_field => $new_ip );
$agent->click('SubmitTicket');
Expand Down
2 changes: 1 addition & 1 deletion t/customfields/sort_order.t
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ diag "check ticket create, display and edit pages";
# Two groups here because inline-edit also adds corresponding labels
# The first group has just one label, the second doubled like above with "label for" + label
is_deeply(\@tmp, ['CF C', 'CF A', 'CF B', 'CF C', 'CF C', 'CF A', 'CF A', 'CF B', 'CF B']);
$m->follow_link_ok( {id => 'page-edit-basics'});
$m->follow_link_ok( {id => 'page-edit-jumbo'});

@tmp = ($m->content =~ /(CF [ABC])/g);
is_deeply(\@tmp, ['CF C', 'CF C', 'CF A', 'CF A', 'CF B', 'CF B']);
Expand Down
8 changes: 4 additions & 4 deletions t/lifecycles/basics.t
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ diag "open -> deleted, only via modify";
{
is $tstatus->($tid), 'open', 'ticket is open';

$m->get_ok( '/Ticket/Modify.html?id='. $tid );
my $form = $m->form_name('TicketModify');
$m->get_ok( '/Ticket/ModifyAll.html?id='. $tid );
my $form = $m->form_name('TicketModifyAll');
ok my $input = $form->find_input('Status'), 'found status selector';

my @form_values = $input->possible_values;
Expand All @@ -167,8 +167,8 @@ diag "deleted -> X via modify, only open is available";
{
is $tstatus->($tid), 'deleted', 'ticket is deleted';

$m->get_ok( '/Ticket/Modify.html?id='. $tid );
my $form = $m->form_name('TicketModify');
$m->get_ok( '/Ticket/ModifyAll.html?id='. $tid );
my $form = $m->form_name('TicketModifyAll');
ok my $input = $form->find_input('Status'), 'found status selector';

my @form_values = $input->possible_values;
Expand Down
22 changes: 14 additions & 8 deletions t/selenium/basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,20 @@ $s->login();

# Update time worked in hours
{
$s->follow_link_ok( { text => 'Basics', menu => '#page-edit' } );
$s->follow_link_ok( { text => 'Jumbo', menu => '#page-edit' } );

$s->submit_form_ok(
{
form_name => 'TicketModify',
form_name => 'TicketModifyAll',
fields => {
TimeWorked => 5,
'TimeWorked-TimeUnits' => 'hours',
},
button => 'SubmitTicket',
button => '[name=SubmitTicket].button',
},
'Update ticket TimeWorked'
);

sleep 3;
$s->text_contains( "5 hours", "5 hours is displayed" );
$s->text_contains( "300 min", "but minutes is also" );
}
Expand Down Expand Up @@ -123,11 +124,12 @@ diag "test custom field unique values";
is( $ticket->FirstCustomFieldValue($cf), 456, 'CF value is set' );
my $ticket_id = $ticket->Id;

$s->follow_link_ok( { text => 'Basics', menu => '#page-edit' } );
$s->follow_link_ok( { text => 'Jumbo', menu => '#page-edit' } );
$s->submit_form_ok(
{
form_name => 'TicketModify',
form_name => 'TicketModifyAll',
fields => { "Object-RT::Ticket-$ticket_id-CustomField-$cf_id-Value" => '123' },
button => '[name=SubmitTicket].button',
},
'Update ticket with cf value 123'

Expand All @@ -138,21 +140,25 @@ diag "test custom field unique values";
$s->submit_form_ok(
{

form_name => 'TicketModify',
form_name => 'TicketModifyAll',
fields => { "Object-RT::Ticket-$ticket_id-CustomField-$cf_id-Value" => '789' },
button => '[name=SubmitTicket].button',
},
'Update ticket with cf value 789'
);
sleep 1.5;
$s->text_contains( 'External ID 456 changed to 789', 'Changed cf to a new value' );

$s->submit_form_ok(
{

form_name => 'TicketModify',
form_name => 'TicketModifyAll',
fields => { "Object-RT::Ticket-$ticket_id-CustomField-$cf_id-Value" => '456' },
button => '[name=SubmitTicket].button',
},
'Update ticket with cf value 456'
);
sleep 1.5;
$s->text_contains( 'External ID 789 changed to 456', 'Changed cf back to old value' );
}

Expand Down
41 changes: 38 additions & 3 deletions t/selenium/ticket_inline_edit.t
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ diag "Testing basics inline edit";
fields => {
Subject => 'Test inline edit updated',
Status => 'open',
TimeWorked => 5,
RT::Interface::Web::GetCustomFieldInputName(
CustomField => $cf_basics,
Object => $ticket,
Expand All @@ -77,14 +76,12 @@ diag "Testing basics inline edit";
my $dom = $s->dom;
is( $dom->at('#header h1')->text, "#$ticket_id: Test inline edit updated", 'Got updated subject in header' );
is( $dom->at('div.status div.col div.rt-value .current-value')->text, 'open', 'Got updated status' );
like( $dom->at('div.time.worked div.col div.rt-value .current-value')->text, qr/^5 minutes\s*$/, 'Got updated timeworked' );
like( $dom->at('div.custom-field-basics div.col div.rt-value .current-value')->text, qr/^\s*b1\s*$/, 'Got updated cf basics' );
cmp_deeply(
$dom->find('.jGrowl-message')->map('text')->to_array,
bag(
qq{Ticket $ticket_id: Subject changed from 'Test inline edit' to 'Test inline edit updated'},
qq{Ticket $ticket_id: Status changed from 'new' to 'open'},
qq{Worked 5 minutes},
qq{basics b1 added},
),
'Got notification of changes'
Expand All @@ -93,6 +90,44 @@ diag "Testing basics inline edit";
$s->close_jgrowl;
}

diag "Testing time inline edit";
{
my $edit_button = $s->find_element( selector_to_xpath('div.ticket-info-times a.inline-edit-toggle') );
$edit_button->click;
$s->submit_form_ok(
{
form => 'div.ticket-info-times form.inline-edit',
fields => {
TimeEstimated => 10,
TimeWorked => 5,
TimeLeft => 15,
},
},
'Submit time inline edit'
);

sleep 1.5;
$s->title_is("#$ticket_id: Test inline edit updated");
my $dom = $s->dom;
like( $dom->at('div.time.estimated div.col div.rt-value .current-value')->text, qr/^10 minutes\s*$/, 'Got updated timeestimated' );
like( $dom->at('div.time.worked div.col div.rt-value .current-value')->text, qr/^5 minutes\s*$/, 'Got updated timeworked' );
like( $dom->at('div.time.left div.col div.rt-value .current-value')->text, qr/^15 minutes\s*$/, 'Got updated timeleft' );

my $test_date = RT::Date->new(RT->SystemUser);
$test_date->SetToNow;

cmp_deeply(
$dom->find('.jGrowl-message')->map('text')->to_array,
bag(
qq{Ticket 1: TimeEstimated changed from (no value) to '10'},
qq{Ticket 1: TimeLeft changed from (no value) to '15'},
'Worked 5 minutes on ' . $test_date->ISO(Date => 1, Time => 0),
),
'Got notification of changes'
);

$s->close_jgrowl;
}

diag "Testing people inline edit";
{
Expand Down
4 changes: 2 additions & 2 deletions t/sla/web.t
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ ok $m->login( 'user', 'password' ), 'logged in as user';
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->follow_link_ok( { text => 'Jumbo' }, 'Ticket -> Jumbo' );
$m->submit_form(
form_name => 'TicketModify',
form_name => 'TicketModifyAll',
fields => { SLA => 2 },
);
$ticket->Load( $id );
Expand Down
Loading

0 comments on commit 7169e2e

Please sign in to comment.