Skip to content

Commit

Permalink
Update tests for label/value changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrandtbuffalo committed Jul 1, 2024
1 parent 85e28bd commit c5debee
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 56 deletions.
11 changes: 6 additions & 5 deletions t/customfields/sort_order.t
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ diag "check ticket create, display and edit pages";
$m->get_ok( '/Ticket/Create.html?Queue=' . $queue->id, 'go to ticket create page with queue id' );

my @tmp = ($m->content =~ /(CF [ABC])/g);
is_deeply(\@tmp, ['CF C', 'CF A', 'CF B']);
# Names appear twice, one "label for" attribute and one actual label
is_deeply(\@tmp, ['CF C', 'CF C', 'CF A', 'CF A', 'CF B', 'CF B']);

$m->submit_form(
form_name => "TicketCreate",
Expand All @@ -78,13 +79,13 @@ diag "check ticket create, display and edit pages";
ok $tid, "created a ticket succesfully";

@tmp = ($m->content =~ /(CF [ABC])/g);

# x2 here because inline-edit also adds corresponding labels
is_deeply(\@tmp, [('CF C', 'CF A', 'CF B')x2]);
# 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-basics'});

@tmp = ($m->content =~ /(CF [ABC])/g);
is_deeply(\@tmp, ['CF C', 'CF A', 'CF B']);
is_deeply(\@tmp, ['CF C', 'CF C', 'CF A', 'CF A', 'CF B', 'CF B']);
}

done_testing;
5 changes: 3 additions & 2 deletions t/externalauth/ldap.t
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ diag "test admin user create";
$m->logout;
ok( $m->login );
$m->get_ok( $baseurl . '/Admin/Users/Modify.html?Create=1', 'user create page' );
$m->text_contains( 'Employee Type: Set from external source' );
$m->text_contains( 'Employee ID: Set from external source' );
$m->text_contains( 'Employee Type' );
$m->text_contains( 'Employee ID' );
$m->text_contains( 'Set from external source' );

my $username = 'testuser2';
$m->submit_form(
Expand Down
22 changes: 11 additions & 11 deletions t/selenium/ticket_inline_edit.t
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ diag "Testing basics inline edit";
$s->title_is("#$ticket_id: Test inline edit updated");
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.value .current-value')->text, 'open', 'Got updated status' );
like( $dom->at('div.time.worked div.value .current-value')->text, qr/^5 minutes\s*$/, 'Got updated timeworked' );
like( $dom->at('div.custom-field-basics div.value .current-value')->text, qr/^\s*b1\s*$/, 'Got updated cf basics' );
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(
Expand Down Expand Up @@ -120,10 +120,10 @@ diag "Testing people inline edit";

sleep 1.5;
my $dom = $s->dom;
is( $dom->at('div.owner div.value .current-value span.user a')->text, $root->Format, 'Got updated owner' );
is( $dom->at('div.requestors div.value .current-value span.user a')->text,
is( $dom->at('div.owner div.col div.rt-value .current-value span.user a')->text, $root->Format, 'Got updated owner' );
is( $dom->at('div.requestors div.col div.rt-value .current-value span.user a')->text,
'<bob@example.com>', 'Got updated requestor' );
is( $dom->at('div.cc div.value .current-value span.user a')->text, '<alice@example.com>', 'Got updated cc' );
is( $dom->at('div.cc div.col div.rt-value .current-value span.user a')->text, '<alice@example.com>', 'Got updated cc' );

cmp_deeply(
$dom->find('.jGrowl-message')->map('text')->to_array,
Expand Down Expand Up @@ -295,8 +295,8 @@ diag "Testing custom fields grouping inline edit";

sleep 1;
my $dom = $s->dom;
like( $dom->at('div.custom-field-bar1 div.value .current-value')->text, qr/^\s*B\s*$/, 'Got updated cf bar1' );
like( $dom->at('div.custom-field-bar2 div.value .current-value')->text, qr/^\s*C\s*$/, 'Got updated cf bar2' );
like( $dom->at('div.custom-field-bar1 div.col div.rt-value .current-value')->text, qr/^\s*B\s*$/, 'Got updated cf bar1' );
like( $dom->at('div.custom-field-bar2 div.col div.rt-value .current-value')->text, qr/^\s*C\s*$/, 'Got updated cf bar2' );
cmp_deeply(
$dom->find('.jGrowl-message')->map('text')->to_array,
bag( qq{bar1 B added}, qq{bar2 C added}, ),
Expand Down Expand Up @@ -326,7 +326,7 @@ diag "Testing custom fields inline edit";

sleep 1;
my $dom = $s->dom;
like( $dom->at('div.custom-field-baz div.value .current-value')->text, qr/^\s*E\s*$/, 'Got updated cf baz' );
like( $dom->at('div.custom-field-baz div.col div.rt-value .current-value')->text, qr/^\s*E\s*$/, 'Got updated cf baz' );
is_deeply(
$dom->find('.jGrowl-message')->map('text')->to_array,
[ qq{E added as a value for baz}, ],
Expand All @@ -349,7 +349,7 @@ diag "Testing custom fields inline edit";
);
sleep 1;
$dom = $s->dom;
like( $dom->at('div.custom-field-baz div.value .current-value')->text, qr/^\s*F\s*$/, 'Got updated cf baz' );
like( $dom->at('div.custom-field-baz div.col div.rt-value .current-value')->text, qr/^\s*F\s*$/, 'Got updated cf baz' );
cmp_deeply(
$dom->find('.jGrowl-message')->map('text')->to_array,
bag( qq{E is no longer a value for custom field baz}, qq{F added as a value for baz}, ),
Expand All @@ -375,7 +375,7 @@ diag "Testing basics inline edit";

sleep 1;
my $dom = $s->dom;
is( $dom->at('div.queue div.value .current-value a')->text, 'Foo', 'Got updated queue' );
is( $dom->at('div.queue div.col div.rt-value .current-value a')->text, 'Foo', 'Got updated queue' );
is_deeply(
$dom->find('.jGrowl-message')->map('text')->to_array,
[ qq{Ticket $ticket_id: Queue changed from General to Foo}, ],
Expand Down
4 changes: 2 additions & 2 deletions t/web/cf_date.t
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ diag 'check valid inputs with various timezones in ticket create page';
is( $ticket->CustomFieldValues($cfid)->First->Content,
'2010-05-04', 'date in db' );

$m->content_contains('test cf date:', 'has no cf date field on the page' );
$m->content_contains('test cf date', 'has no cf date field on the page' );
$m->content_contains('Tue May 04 2010',
'has cf date value on the page' );
}
Expand Down Expand Up @@ -178,7 +178,7 @@ diag 'check invalid inputs';
$m->content_like( qr/Ticket \d+ created/,
"a ticket is created succesfully" );

$m->content_contains('test cf date:', 'has no cf date field on the page' );
$m->content_contains('test cf date', 'has no cf date field on the page' );
$m->content_lacks('foodate', 'invalid dates not set' );

my @warnings = $m->get_warnings;
Expand Down
6 changes: 3 additions & 3 deletions t/web/cf_datetime.t
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ diag 'check valid inputs with various timezones in ticket create page';
);
}

$m->content_contains('test cf datetime:', 'has cf datetime field on the page');
$m->content_contains('test cf datetime', 'has cf datetime field on the page');
$m->content_contains('Tue May 04 13:00:01 2010', 'has cf datetime value on the page');

$root->SetTimezone( 'Asia/Shanghai' );
Expand Down Expand Up @@ -124,7 +124,7 @@ diag 'check valid inputs with various timezones in ticket create page';
);
}

$m->content_contains('test cf datetime:', 'has cf datetime field on the page');
$m->content_contains('test cf datetime', 'has cf datetime field on the page');
$m->content_contains( 'Thu May 06 07:00:01 2010',
'cf datetime input respects user timezone' );
$root->SetTimezone( 'EST5EDT' ); # back to -04:00
Expand Down Expand Up @@ -248,7 +248,7 @@ diag 'check invalid inputs';
);
$m->content_like(qr/Ticket \d+ created/, "a ticket is created succesfully");

$m->content_contains('test cf datetime:', 'has cf datetime field on the page');
$m->content_contains('test cf datetime', 'has cf datetime field on the page');
$m->content_lacks('foodate', 'invalid dates not set');

my @warnings = $m->get_warnings;
Expand Down
2 changes: 1 addition & 1 deletion t/web/cf_groupings.t
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ my $id = $m->get_ticket_id;
foreach my $grouping (@groupings) {
my $row_id = "CF-$CF{$grouping}-ShowRow";
is $dom->find(qq{#$row_id})->size, 1, "CF on the page";
like $dom->at(qq{#$row_id})->all_text, qr/Test$grouping:\s*Test${grouping}Value/, "value is set";
like $dom->at(qq{#$row_id})->all_text, qr/Test$grouping\s*Test${grouping}Value/, "value is set";
ok $dom->at(qq{$location{$grouping} #$row_id}), "CF is in the right place";
}
}
Expand Down
2 changes: 1 addition & 1 deletion t/web/cf_groupings_per_queue.t
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ for my $queue ( $general, $foo ) {
foreach my $grouping (@groupings) {
my $row_id = "CF-$CF{$grouping}-ShowRow";
is $dom->find(qq{#$row_id})->size, 1, "CF on the page";
like $dom->at(qq{#$row_id})->all_text, qr/Test$grouping:\s*Test${grouping}Value/, "value is set";
like $dom->at(qq{#$row_id})->all_text, qr/Test$grouping\s*Test${grouping}Value/, "value is set";
ok $dom->at(qq{$location{$grouping} #$row_id}), "CF is in the right place";
}
if ( $queue == $general ) {
Expand Down
2 changes: 1 addition & 1 deletion t/web/cf_textarea.t
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ while ( my( $label, $data ) = each %$cfs ) {

# open ticket "Basics" page
$m->get_ok($EditUrl, "Fetched $EditUrl");
$m->content_contains($_->{name} . ':') for ( values %$cfs );
$m->content_contains($_->{name}) for ( values %$cfs );

$m->submit_form_ok({
with_fields => {
Expand Down
2 changes: 1 addition & 1 deletion t/web/mobile.t
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ $m->content_contains( 'ticket1', 'subject' );
$m->content_contains( 'open', 'status' );
$m->content_contains( 'cc@example.com', 'cc' );
$m->content_contains( 'admincc@example.com', 'admincc' );
$m->text_contains( 'Low/Medium', 'priority' );
$m->content_contains( qq{<span class="FinalPriority ticket-info-final-priority-medium">Medium</span>}, 'Priority on display' );
$m->content_contains( '2 hour', 'time estimates' );
$m->content_contains( '30 min', 'time worked' );
$m->content_contains( '60 min', 'time left' );
Expand Down
4 changes: 3 additions & 1 deletion t/web/priority.t
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ for my $field (qw/InitialPriority FinalPriority/) {
}

$m->submit_form_ok( { fields => { Subject => 'Test PriorityAsString', InitialPriority => 50 }, button => 'SubmitTicket' }, 'Create ticket' );
$m->text_like( qr{Priority:\s*Medium/Low}, 'Priority/FinalPriority on display' );
# The label and value are separated by markup, so use content_contains to
# confirm this is the "Medium" associated with Priority.
$m->content_contains( qq{<span class="Priority ticket-info-priority-medium">Medium</span>}, 'Priority on display' );

$m->follow_link_ok( { text => 'Basics' } );
$form = $m->form_name('TicketModify');
Expand Down
12 changes: 6 additions & 6 deletions t/web/redirect-after-login.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ diag $url if $ENV{TEST_VERBOSE};
ok($agent->current_form->find_input('pass'));
like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct");

ok($agent->content =~ /username:/i);
ok($agent->content =~ /username/i);
$agent->field( 'user' => 'root' );
$agent->field( 'pass' => 'password' );

Expand All @@ -40,7 +40,7 @@ diag $url if $ENV{TEST_VERBOSE};
ok($agent->current_form->find_input('pass'));
like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct");

ok($agent->content =~ /username:/i);
ok($agent->content =~ /username/i);
$agent->field( 'user' => 'root' );
$agent->field( 'pass' => 'wrongpass' );

Expand Down Expand Up @@ -69,7 +69,7 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) {
like($agent->value('next'), qr/^[a-z0-9]{32}$/i, "next page argument is a hash");
like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct");

ok($agent->content =~ /username:/i);
ok($agent->content =~ /username/i);
$agent->field( 'user' => 'root' );
$agent->field( 'pass' => 'password' );

Expand Down Expand Up @@ -103,7 +103,7 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) {
like($agent->value('next'), qr/^[a-z0-9]{32}$/i, "next page argument is a hash");
like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct");

ok($agent->content =~ /username:/i);
ok($agent->content =~ /username/i);
$agent->field( 'user' => 'root' );
$agent->field( 'pass' => 'wrongpass' );

Expand All @@ -122,7 +122,7 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) {
like($agent->value('next'), qr/^[a-z0-9]{32}$/i, "next page argument is a hash");
like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct");

ok($agent->content =~ /username:/i);
ok($agent->content =~ /username/i);
$agent->field( 'user' => 'root' );
$agent->field( 'pass' => 'password' );

Expand Down Expand Up @@ -177,7 +177,7 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) {
$agent->warning_like(qr/FAILED LOGIN for root/, "got failed login warning");

# Try to login again
ok($agent->content =~ /username:/i);
ok($agent->content =~ /username/i);
$agent->field( 'user' => 'root' );
$agent->field( 'pass' => 'password' );

Expand Down
10 changes: 5 additions & 5 deletions t/web/reminder-permissions.t
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ my ( $root_reminder_id, $user_a_reminder_id );
diag "create two reminders, with owner root and user_a, respectively";
{
$m->goto_ticket( $ticket->id );
$m->text_contains( 'New reminder:', 'can create a new reminder' );
$m->text_contains( 'New reminder', 'can create a new reminder' );
$m->form_name('UpdateReminders');
$m->field( 'NewReminder-Subject' => "root reminder" );
$m->submit;
Expand Down Expand Up @@ -74,7 +74,7 @@ my $m_a = RT::Test::Web->new;
{
ok( $m_a->login( user_a => 'password' ), 'logged in as user_a' );
$m_a->goto_ticket( $ticket->id );
$m_a->content_lacks( 'New reminder:', 'can not create a new reminder' );
$m_a->content_lacks( 'New reminder', 'can not create a new reminder' );
$m_a->content_contains( 'root reminder', 'can see root reminder' );
$m_a->content_contains( 'user_a reminder', 'can see user_a reminder' );
$m_a->content_like(
Expand All @@ -93,7 +93,7 @@ qr!<input[^/]+name="Complete-Reminder-$root_reminder_id"[^/]+disabled="disabled"
$m_a->title_is("Reminders for ticket #" . $ticket->id . ": " . $ticket->Subject);
$m_a->content_contains( 'root reminder', 'can see root reminder' );
$m_a->content_contains( 'user_a reminder', 'can see user_a reminder' );
$m_a->content_lacks( 'New reminder:', 'can not create a new reminder' );
$m_a->content_lacks( 'New reminder', 'can not create a new reminder' );
$m_a->content_like(
qr!<input[^/]+name="Complete-Reminder-$root_reminder_id"[^/]+disabled="disabled"!,
"root reminder checkbox is disabled"
Expand All @@ -114,7 +114,7 @@ diag "set ticket owner to user_a to let user_a grant modify ticket right";
$ticket->SetOwner( $user_a->id );

$m_a->goto_ticket( $ticket->id );
$m_a->content_contains( 'New reminder:', 'can create a new reminder' );
$m_a->content_contains( 'New reminder', 'can create a new reminder' );
$m_a->content_like(
qr!<input[^/]+name="Complete-Reminder-$root_reminder_id"[^/]+disabled="disabled"!,
"root reminder checkbox is still disabled"
Expand All @@ -127,7 +127,7 @@ qr!<input[^/]+name="Complete-Reminder-$root_reminder_id"[^/]+disabled="disabled"

$m_a->follow_link_ok( { id => 'page-reminders' } );
$m_a->title_is("Reminders for ticket #" . $ticket->id . ": " . $ticket->Subject);
$m_a->content_contains( 'New reminder:', 'can create a new reminder' );
$m_a->content_contains( 'New reminder', 'can create a new reminder' );
$m_a->content_like(
qr!<input[^/]+name="Complete-Reminder-$root_reminder_id"[^/]+disabled="disabled"!,
"root reminder checkbox is still disabled"
Expand Down
12 changes: 6 additions & 6 deletions t/web/reminders.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ $ticket->Create(Subject => 'testing reminders!', Queue => 'General');
ok($ticket->id, 'created a ticket');

$m->goto_ticket($ticket->id);
$m->text_contains('New reminder:', 'can create a new reminder');
$m->text_contains('New reminder', 'can create a new reminder');
$m->content_unlike(qr{Check box to complete}, "we don't display this text when there are no reminders");
$m->content_unlike(qr{<div[^>]*>Reminders</div>}, "no reminder titlebar");

$m->follow_link_ok({id => 'page-reminders'});
$m->title_is("Reminders for ticket #" . $ticket->id . ": " . $ticket->Subject);
$m->text_contains('New reminder:', 'can create a new reminder');
$m->text_contains('New reminder', 'can create a new reminder');
$m->content_unlike(qr{Check box to complete}, "we don't display this text when there are no reminders");
$m->content_unlike(qr{<div[^>]*>Reminders?</div>}, "no reminder titlebar");

Expand All @@ -39,7 +39,7 @@ $m->content_contains( "baby&#39;s first reminder",
'got the reminder even the ticket is deleted' );

$m->goto_ticket( $ticket->id );
$m->content_lacks('New reminder:', "can't create a new reminder");
$m->content_lacks('New reminder', "can't create a new reminder");
$m->text_contains('Check box to complete', "we DO display this text when there are reminders");
$m->content_like(qr{Reminders}, "now we have a reminder titlebar");
$m->text_contains("baby's first reminder", "display the reminder's subject");
Expand All @@ -57,7 +57,7 @@ $ticket->SetStatus('open');
is( $ticket->Status, 'open', 'changed back to new' );

$m->goto_ticket($ticket->id);
$m->text_contains('New reminder:', "can create a new reminder");
$m->text_contains('New reminder', "can create a new reminder");
$m->text_contains('Check box to complete', "we DO display this text when there are reminders");
$m->content_like(qr{Reminders}, "now we have a reminder titlebar");
$m->text_contains("baby's first reminder", "display the reminder's subject");
Expand All @@ -82,14 +82,14 @@ $reminder = RT::Ticket->new($user);
$reminder->Load($reminder_id);
is($reminder->Status, 'resolved');

$m->text_contains('New reminder:', 'can create a new reminder');
$m->text_contains('New reminder', 'can create a new reminder');
$m->content_unlike(qr{Check box to complete}, "we don't display this text when there are open reminders");
$m->content_unlike(qr{<div[^>]*>Reminders?</div>}, "no reminder titlebar");
$m->content_unlike(qr{baby's first reminder}, "we don't display resolved reminders");

$m->follow_link_ok({id => 'page-reminders'});
$m->title_is("Reminders for ticket #" . $ticket->id . ": " . $ticket->Subject);
$m->text_contains('New reminder:', 'can create a new reminder');
$m->text_contains('New reminder', 'can create a new reminder');
$m->text_contains('Check box to complete', "we DO display this text when there are reminders");
$m->content_contains("changed the subject", "display the resolved reminder's subject");

Expand Down
4 changes: 2 additions & 2 deletions t/web/self_service.t
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ diag 'Test $SelfServiceUserPrefs config';
$m->content_contains( '<input type="password" class="form-control" name="CurrentPass"', "'Edit-Prefs' option contains default user info" );
} elsif ( $config eq 'view-info' ) {
$m->content_lacks( 'name="NickName" value=""', "'View-Info' option contains no input fields for full user info" );
$m->content_contains( "Nickname:", "'View-Info' option contains full user info" );
$m->content_contains( "Nickname", "'View-Info' option contains full user info" );
} elsif ( $config eq 'edit-prefs-view-info' ) {
$m->content_contains( '<input type="password" class="form-control" name="CurrentPass"', "'Edit-Prefs-View-Info' option contains default user info" );
$m->content_contains( 'Nickname:', "'Edit-Prefs-View-Info' option contains full user info" );
$m->content_contains( 'Nickname', "'Edit-Prefs-View-Info' option contains full user info" );
$m->content_lacks( 'name="NickName" value=""', "'Edit-Prefs-View-Info' option contains no input fields for full user info" );
} else {
RT::Test->add_rights( { Principal => $user_a, Right => ['ModifySelf'] } );
Expand Down
2 changes: 1 addition & 1 deletion t/web/ticket_display_unset_fields.t
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ diag "Test unset custom fields";
# open ticket "Basics" page
my $EditUrl = "/Ticket/Modify.html?id=" . $foo->id;
$m->get_ok($EditUrl, "Fetched $EditUrl");
$m->content_contains('TextArea:');
$m->content_contains('TextArea');

my $cf_input = RT::Interface::Web::GetCustomFieldInputName(
Object => $foo,
Expand Down
Loading

0 comments on commit c5debee

Please sign in to comment.