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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825
|
# --
# Copyright (C) 2001-2021 OTRS AG, https://otrs.com/
# Copyright (C) 2021 Znuny GmbH, https://znuny.org/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
use strict;
use warnings;
use utf8;
use vars (qw($Self));
use Kernel::Language;
my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
$Selenium->RunTest(
sub {
my $HelperObject = $Kernel::OM->Get('Kernel::System::UnitTest::Helper');
my $DynamicFieldObject = $Kernel::OM->Get('Kernel::System::DynamicField');
my $DynamicFieldBackendObject = $Kernel::OM->Get('Kernel::System::DynamicField::Backend');
my $StandardTemplateObject = $Kernel::OM->Get('Kernel::System::StandardTemplate');
my $CustomerUserObject = $Kernel::OM->Get('Kernel::System::CustomerUser');
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
# Disable check email addresses.
$HelperObject->ConfigSettingChange(
Key => 'CheckEmailAddresses',
Value => 0,
);
# Do not check RichText.
$HelperObject->ConfigSettingChange(
Valid => 1,
Key => 'Frontend::RichText',
Value => 0
);
# Do not check service and type.
$HelperObject->ConfigSettingChange(
Valid => 1,
Key => 'Ticket::Service',
Value => 0
);
$HelperObject->ConfigSettingChange(
Valid => 1,
Key => 'Ticket::Type',
Value => 0
);
# Disable RequiredLock for AgentTicketCompose.
$HelperObject->ConfigSettingChange(
Valid => 1,
Key => 'Ticket::Frontend::AgentTicketCompose###RequiredLock',
Value => 0
);
$HelperObject->ConfigSettingChange(
Valid => 1,
Key => 'Ticket::Frontend::AgentTicketCompose###MessageIsVisibleForCustomer',
Value => '1'
);
# Use test email backend.
$HelperObject->ConfigSettingChange(
Valid => 1,
Key => 'SendmailModule',
Value => 'Kernel::System::Email::Test',
);
my $RandomID = $HelperObject->GetRandomID();
my %DynamicFields = (
Text => {
Name => 'TestText' . $RandomID,
Label => 'TestText' . $RandomID,
FieldOrder => 9990,
FieldType => 'Text',
ObjectType => 'Ticket',
Config => {
DefaultValue => '',
Link => '',
},
Reorder => 1,
ValidID => 1,
UserID => 1,
},
Dropdown => {
Name => 'TestDropdown' . $RandomID,
Label => 'TestDropdown' . $RandomID,
FieldOrder => 9990,
FieldType => 'Dropdown',
ObjectType => 'Ticket',
Config => {
DefaultValue => '',
Link => '',
PossibleNone => 0,
PossibleValues => {
0 => 'No',
1 => 'Yes',
},
TranslatableValues => 1,
},
Reorder => 1,
ValidID => 1,
UserID => 1,
},
Multiselect => {
Name => 'TestMultiselect' . $RandomID,
Label => 'TestMultiselect' . $RandomID,
FieldOrder => 9990,
FieldType => 'Multiselect',
ObjectType => 'Ticket',
Config => {
DefaultValue => '',
Link => '',
PossibleNone => 0,
PossibleValues => {
year => 'year',
month => 'month',
week => 'week',
},
TranslatableValues => 1,
},
Reorder => 1,
ValidID => 1,
UserID => 1,
},
Date => {
Name => 'TestDate' . $RandomID,
Label => 'TestDate' . $RandomID,
FieldOrder => 9990,
FieldType => 'Date',
ObjectType => 'Ticket',
Config => {
DefaultValue => 0,
YearsInFuture => 0,
YearsInPast => 0,
YearsPeriod => 0,
},
Reorder => 1,
ValidID => 1,
UserID => 1,
},
DateTime => {
Name => 'TestDateTime' . $RandomID,
Label => 'TestDateTime' . $RandomID,
FieldOrder => 9990,
FieldType => 'DateTime',
ObjectType => 'Ticket',
Config => {
DefaultValue => 0,
YearsInFuture => 0,
YearsInPast => 0,
YearsPeriod => 0,
},
Reorder => 1,
ValidID => 1,
UserID => 1,
},
);
my @DynamicFieldIDs;
# Create test dynamic fields.
for my $DynamicFieldType ( sort keys %DynamicFields ) {
my $DynamicFieldID = $DynamicFieldObject->DynamicFieldAdd(
%{ $DynamicFields{$DynamicFieldType} },
);
$Self->True(
$DynamicFieldID,
"Dynamic field $DynamicFields{$DynamicFieldType}->{Name} - ID $DynamicFieldID - created",
);
push @DynamicFieldIDs, $DynamicFieldID;
}
# Create a new template.
my $TemplateID = $StandardTemplateObject->StandardTemplateAdd(
Name => 'New Standard Template' . $RandomID,
Template => "Thank you for your email.
Ticket state: <OTRS_TICKET_State>.\n
Ticket lock: <OTRS_TICKET_Lock>.\n
Ticket priority: <OTRS_TICKET_Priority>.\n
Ticket created: <OTRS_TICKET_Created>.\n
Ticket pending until time: <OTRS_TICKET_UntilTime>.\n
Ticket will not be used till: <OTRS_TICKET_RealTillTimeNotUsed>.\n
DynamicField Text: <OTRS_TICKET_DynamicField_" . $DynamicFields{Text}->{Name} . "_Value>
DynamicField Dropdown: <OTRS_TICKET_DynamicField_"
. $DynamicFields{Dropdown}->{Name}
. "_Value>
DynamicField Multiselect: <OTRS_TICKET_DynamicField_"
. $DynamicFields{Multiselect}->{Name}
. "_Value>
DynamicField Date: <OTRS_TICKET_DynamicField_" . $DynamicFields{Date}->{Name} . "_Value>
DynamicField DateTime: <OTRS_TICKET_DynamicField_"
. $DynamicFields{DateTime}->{Name}
. "_Value>
",
ContentType => 'text/plain; charset=utf-8',
TemplateType => 'Answer',
ValidID => 1,
UserID => 1,
);
$Self->True(
$TemplateID,
"Standard template is created - ID $TemplateID",
);
# Assign template to the queue.
my $Success = $Kernel::OM->Get('Kernel::System::Queue')->QueueStandardTemplateMemberAdd(
QueueID => 1,
StandardTemplateID => $TemplateID,
Active => 1,
UserID => 1,
);
$Self->True(
$Success,
"$TemplateID is assigned to the queue.",
);
# Create test user with admin permissions.
my $UserName = "Name$RandomID";
my $UserID = $Kernel::OM->Get('Kernel::System::User')->UserAdd(
UserFirstname => $UserName,
UserLastname => $UserName,
UserLogin => $UserName,
UserEmail => "$UserName\@example.com",
ValidID => 1,
ChangeUserID => 1,
);
$Self->True(
$UserID,
"UserID $UserID is created",
);
my $GroupObject = $Kernel::OM->Get('Kernel::System::Group');
my $GroupID = $GroupObject->GroupLookup(
Group => 'admin',
);
$Success = $GroupObject->PermissionGroupUserAdd(
GID => $GroupID,
UID => $UserID,
Permission => {
ro => 1,
move_into => 1,
create => 1,
owner => 1,
priority => 1,
rw => 1,
},
UserID => 1,
);
$Self->True(
$Success,
"UserID '$UserID' set permission for 'admin' group"
);
# Create test customer.
my $TestCustomer = 'Customer' . $RandomID;
my $CustomerEmail = "$TestCustomer\@localhost.com";
my $TestCustomerUserID = $CustomerUserObject->CustomerUserAdd(
Source => 'CustomerUser',
UserFirstname => $TestCustomer,
UserLastname => $TestCustomer,
UserCustomerID => $TestCustomer,
UserLogin => $TestCustomer,
UserEmail => $CustomerEmail,
ValidID => 1,
UserID => 1
);
$Self->True(
$TestCustomerUserID,
"CustomerUserAdd - ID $TestCustomerUserID",
);
# Set customer user language.
my $Language = 'es';
$Success = $CustomerUserObject->SetPreferences(
Key => 'UserLanguage',
Value => $Language,
UserID => $TestCustomer,
);
$Self->True(
$Success,
"Customer user language is set.",
);
# Create test ticket.
my %TicketData = (
State => 'pending reminder',
Priority => '4 high',
Lock => 'unlock',
UntilTime => '1 d 23 h'
);
my %DynamicFieldValues = (
Text => "Test Text $RandomID",
Dropdown => '1',
Multiselect => 'year',
);
my %DynamicFieldDateValues = (
Date => '2016-04-13 00:00:00',
DateTime => '2016-04-13 14:20:00',
);
my $TicketID = $TicketObject->TicketCreate(
Title => 'Selenium ticket',
QueueID => 1,
Lock => $TicketData{Lock},
Priority => $TicketData{Priority},
State => 'new',
CustomerID => 'SeleniumCustomer',
CustomerUser => $TestCustomer,
OwnerID => 1,
UserID => 1,
);
$Self->True(
$TicketID,
"Ticket is created - ID $TicketID",
);
# Set dynamic field values.
for my $DynamicFieldType ( sort keys %DynamicFieldValues, sort keys %DynamicFieldDateValues ) {
my $DynamicFieldConfig = $DynamicFieldObject->DynamicFieldGet(
Name => $DynamicFields{$DynamicFieldType}->{Name},
);
$DynamicFieldBackendObject->ValueSet(
DynamicFieldConfig => $DynamicFieldConfig,
ObjectID => $TicketID,
Value => $DynamicFieldValues{$DynamicFieldType} || $DynamicFieldDateValues{$DynamicFieldType},
UserID => 1,
);
}
my $ArticleBackendObject
= $Kernel::OM->Get('Kernel::System::Ticket::Article')->BackendForChannel( ChannelName => 'Email' );
# Create test email article.
my $ArticleID = $ArticleBackendObject->ArticleCreate(
TicketID => $TicketID,
IsVisibleForCustomer => 1,
SenderType => 'customer',
Subject => 'some short description',
Body => 'the message text',
From => "\"$TestCustomer $TestCustomer\" <${CustomerEmail}>",
To => 'Some Customer A <customer-a@example.com>',
Charset => 'ISO-8859-15',
MimeType => 'text/plain',
HistoryType => 'EmailCustomer',
HistoryComment => 'Some free text!',
UserID => 1,
);
$Self->True(
$ArticleID,
"Article is created - ID $ArticleID",
);
# Set state to 'pending reminder' for next 2 days.
$Success = $TicketObject->TicketStateSet(
State => $TicketData{State},
TicketID => $TicketID,
UserID => 1,
);
$Self->True(
$Success,
"TicketID $TicketID - set state to pending reminder successfully",
);
$Success = $TicketObject->TicketPendingTimeSet(
Diff => ( 2 * 24 * 60 ),
TicketID => $TicketID,
UserID => 1,
);
$Self->True(
$Success,
"Set pending time successfully",
);
my %CreatedTicketData = $TicketObject->TicketGet(
TicketID => $TicketID,
);
# Create test user and login.
my $TestUserLogin = $HelperObject->TestUserCreate(
Groups => [ 'admin', 'users' ],
) || die "Did not get test user";
$Selenium->Login(
Type => 'Agent',
User => $TestUserLogin,
Password => $TestUserLogin,
);
my $ScriptAlias = $Kernel::OM->Get('Kernel::Config')->Get('ScriptAlias');
# Navigate to AgentTicketCompose page.
$Selenium->VerifiedGet(
"${ScriptAlias}index.pl?Action=AgentTicketCompose;TicketID=$TicketID;ArticleID=$ArticleID;ResponseID=$TemplateID"
);
$Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && $("#ToCustomer").length;' );
my $Message = 'Article subject will be empty if the subject contains only the ticket hook!';
$Self->True(
$Selenium->execute_script("return \$('.MessageBox.Notice:contains(\"$Message\")').length == 0;"),
"No Notification about empty subject is shown",
);
$Selenium->execute_script("\$('#Subject').val( \$('#Subject').val().replace(/].*/, ']') ).trigger('change');");
$Selenium->WaitFor( JavaScript => "return \$('.MessageBox.Notice:contains(\"$Message\")').length;" );
$Self->True(
$Selenium->execute_script("return \$('.MessageBox.Notice:contains(\"$Message\")').length;"),
"Notification about empty subject is found",
);
$Selenium->execute_script("\$('#Subject').val( \$('#Subject').val() + ' some text' );");
# Check duplication of customer user who doesn't exist in the system (see bug#13784).
$Selenium->find_element( "#ToCustomer", 'css' )->send_keys( 'Test', "\N{U+E007}" );
$Selenium->WaitFor( JavaScript => 'return $("#RemoveCustomerTicket_2").length;' );
$Selenium->find_element( "#ToCustomer", 'css' )->send_keys( 'Test', "\N{U+E007}" );
$Selenium->WaitFor(
JavaScript =>
'return typeof($) === "function" && $(".Dialog.Modal.Alert:visible").length;'
);
$Self->Is(
$Selenium->execute_script('return $(".Dialog.Modal.Alert").length;'),
1,
"Alert dialog is found.",
);
$Selenium->WaitForjQueryEventBound(
CSSSelector => '#DialogButton1',
);
$Selenium->execute_script("\$('#DialogButton1').click();");
$Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && !$(".Dialog.Modal").length;' );
# Change focus from #ToCustomer input field.
$Selenium->find_element( "body", 'css' )->click();
$Selenium->WaitFor( JavaScript => 'return $("#RemoveCustomerTicket_2").length;' );
# Remove entered 'Test' for customer user.
$Selenium->find_element( "#RemoveCustomerTicket_2", 'css' )->click();
$Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && !$("#RemoveCustomerTicket_2").length;' );
# Input required field and select customer.
$Selenium->VerifiedRefresh();
$Selenium->WaitForjQueryEventBound(
CSSSelector => '#ToCustomer',
Event => 'change',
);
$Selenium->find_element( "#ToCustomer", 'css' )->send_keys($TestCustomer);
$Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && $("li.ui-menu-item:visible").length;' );
$Selenium->execute_script("\$('li.ui-menu-item:contains($TestCustomer)').click();");
$Selenium->WaitFor(
JavaScript =>
'return typeof($) === "function" && $(".Dialog.Modal.Alert:visible").length;'
);
$Self->Is(
$Selenium->execute_script('return $(".Dialog.Modal.Alert").length;'),
1,
"Error message found.",
);
$Selenium->execute_script("\$('#DialogButton1').click();");
$Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && !$(".Dialog.Modal").length;' );
# Check AgentTicketCompose page.
for my $ID (
qw(ToCustomer CcCustomer BccCustomer Subject RichText
FileUpload StateID IsVisibleForCustomer submitRichText)
)
{
my $Element = $Selenium->find_element( "#$ID", 'css' );
$Element->is_enabled();
}
$Self->Is(
$Selenium->execute_script('return $("#IsVisibleForCustomer").val();'),
1,
"Default customer visibility is honored",
);
# Test bug #11810 - http://bugs.otrs.org/show_bug.cgi?id=11810.
# Translate ticket data tags (e.g. <OTRS_TICKET_State> ) in standard template.
$Kernel::OM->ObjectParamAdd(
'Kernel::Language' => {
UserLanguage => $Language,
},
);
my $LanguageObject = $Kernel::OM->Get('Kernel::Language');
# Check translated values.
for my $Item ( sort keys %TicketData ) {
my $TransletedTicketValue = $LanguageObject->Translate( $TicketData{$Item} );
$Self->True(
index( $Selenium->get_page_source(), $TransletedTicketValue ) > -1,
"Translated \'$Item\' value is found - $TransletedTicketValue .",
);
}
# Check if the transformed date value exists.
my $TranslatedTicketCreated = $LanguageObject->FormatTimeString(
$CreatedTicketData{Created},
'DateFormat',
'NoSeconds',
);
$Self->True(
index( $Selenium->get_page_source(), $TranslatedTicketCreated ) > -1,
"Translated 'Created' value is found - $TranslatedTicketCreated.",
);
my $RealTillTimeNotUsed = $Kernel::OM->Create(
'Kernel::System::DateTime',
ObjectParams => {
Epoch => $CreatedTicketData{RealTillTimeNotUsed},
}
)->ToString();
$RealTillTimeNotUsed = $LanguageObject->FormatTimeString(
$RealTillTimeNotUsed,
'DateFormat',
'NoSeconds',
);
$Self->True(
index( $Selenium->get_page_source(), $RealTillTimeNotUsed ) > -1,
"Translated 'RealTillTimeNotUsed' value is found - $RealTillTimeNotUsed.",
);
for my $DynamicFieldType ( sort keys %DynamicFieldValues ) {
my $Value = $DynamicFields{$DynamicFieldType}->{Config}->{PossibleValues}
? $DynamicFields{$DynamicFieldType}->{Config}->{PossibleValues}
->{ $DynamicFieldValues{$DynamicFieldType} }
: $DynamicFieldValues{$DynamicFieldType};
my $TransletedDynamicFieldValue = $LanguageObject->Translate($Value);
# Check dynamic field date format.
$Self->True(
index( $Selenium->get_page_source(), $DynamicFieldType . ': ' . $TransletedDynamicFieldValue . "\n" )
> -1,
"Translated date format for \'DynamicField_$DynamicFields{$DynamicFieldType}->{Name}\' value is found - $TransletedDynamicFieldValue.",
);
}
for my $DynamicFieldType ( sort keys %DynamicFieldDateValues ) {
my $DateFormat = $DynamicFieldType eq 'Date' ? 'DateFormatShort' : 'DateFormat';
my $LanguageFormatDateValue = $LanguageObject->FormatTimeString(
$DynamicFieldDateValues{$DynamicFieldType},
$DateFormat,
'NoSeconds',
);
# Check dynamic field date format.
$Self->True(
index( $Selenium->get_page_source(), $DynamicFieldType . ': ' . $LanguageFormatDateValue . "\n" ) > -1,
"Translated date format for \'DynamicField_$DynamicFields{$DynamicFieldType}->{Name}\' value is found - $LanguageFormatDateValue.",
);
}
# Input required fields and submit compose.
$Selenium->find_element( "#RichText", 'css' )->send_keys('Selenium Compose Text');
$Selenium->find_element( "#submitRichText", 'css' )->VerifiedClick();
# Navigate to AgentTicketHistory page.
$Selenium->VerifiedGet("${ScriptAlias}index.pl?Action=AgentTicketHistory;TicketID=$TicketID");
# Wait until page has loaded, if necessary.
$Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && $(".CancelClosePopup").length;' );
# Verify that compose worked as expected.
my $HistoryText = "Sent email to \"\"$TestCustomer $TestCustomer\"";
$Self->True(
index( $Selenium->get_page_source(), $HistoryText ) > -1,
'Compose executed correctly'
);
$HelperObject->ConfigSettingChange(
Valid => 1,
Key => 'Ticket::Frontend::ResponseFormat',
Value => '[% Data.TicketNumber | html%]',
);
# Test ticket lock and owner after closing AgentTicketCompose popup (see bug#12479).
# Enable RequiredLock for AgentTicketCompose.
$HelperObject->ConfigSettingChange(
Valid => 1,
Key => 'Ticket::Frontend::AgentTicketCompose###RequiredLock',
Value => 1,
);
# Set test created user as ticket owner.
my $OwnerSet = $TicketObject->TicketOwnerSet(
TicketID => $TicketID,
UserID => 1,
NewUserID => $UserID,
);
$Self->Is(
$OwnerSet,
1,
"UserID '$UserID' is set successfully as ticket owner for TicketID '$TicketID'"
);
# Navigate to created test ticket in AgentTicketZoom page.
$Selenium->VerifiedGet("${ScriptAlias}index.pl?Action=AgentTicketZoom;TicketID=$TicketID");
$Selenium->WaitFor( JavaScript => "return typeof(\$) === 'function' && \$('#ResponseID$ArticleID').length;" );
my %TicketDataBeforeUndo = $TicketObject->TicketGet(
TicketID => $TicketID,
);
$Self->Is(
$TicketDataBeforeUndo{Lock},
'unlock',
"Before undo - Ticket lock is 'unlock'"
);
$Self->Is(
$TicketDataBeforeUndo{OwnerID},
$UserID,
"Before undo - Ticket owner is test user $UserID"
);
# Click on reply.
$Selenium->InputFieldValueSet(
Element => "#ResponseID$ArticleID",
Value => $TemplateID,
);
# Switch to compose window.
$Selenium->WaitFor( WindowCount => 2 );
my $Handles = $Selenium->get_window_handles();
$Selenium->switch_to_window( $Handles->[1] );
$Selenium->WaitForjQueryEventBound(
CSSSelector => '.UndoClosePopup',
);
# Check if Ticket number is shown correctly in text field.
# See bug#133995 https://bugs.otrs.org/show_bug.cgi?id=13995
my $TicketNumber = $TicketObject->TicketNumberLookup(
TicketID => $TicketID,
);
$Self->Is(
$Selenium->execute_script('return $("#RichText").val().trim();'),
$TicketNumber,
"Text field contains ticket number $TicketNumber"
);
# Click on 'Undo&Close' to close popup and set state and owner to the previous values.
$Selenium->execute_script('$(".UndoClosePopup").click();');
$Selenium->WaitFor( WindowCount => 1 );
$Selenium->switch_to_window( $Handles->[0] );
# Wait for reload to kick in.
sleep 1;
$Selenium->WaitFor(
JavaScript =>
'return typeof(Core) == "object" && typeof(Core.App) == "object" && Core.App.PageLoadComplete'
);
# Clean Ticket cache, to get refreshed test ticket data.
my $CacheObject = $Kernel::OM->Get('Kernel::System::Cache');
$CacheObject->CleanUp( Type => 'Ticket' );
# Navigate to created test ticket in AgentTicketZoom page.
$Selenium->VerifiedGet("${ScriptAlias}index.pl?Action=AgentTicketZoom;TicketID=$TicketID");
my %TicketDataAfterUndo = $TicketObject->TicketGet(
TicketID => $TicketID,
);
$Self->Is(
$TicketDataAfterUndo{Lock},
'unlock',
"After undo - Ticket lock is still 'unlock'"
) || die;
$Self->Is(
$TicketDataAfterUndo{OwnerID},
$UserID,
"After undo - Ticket owner is still test user $UserID"
) || die;
# Create article in OTRS channel.
my $InternalArticleBackendObject
= $Kernel::OM->Get('Kernel::System::Ticket::Article')->BackendForChannel( ChannelName => 'Internal' );
$ArticleID = $InternalArticleBackendObject->ArticleCreate(
TicketID => $TicketID,
SenderType => 'agent',
IsVisibleForCustomer => 1,
From => 'Test Agent <email@example.com>',
To => 'Customer A <customer-a@example.com>',
Cc => 'Customert B <customer-b@example.com>',
Subject => 'Test Subject',
Body => 'Test Body',
Charset => 'ISO-8859-15',
MimeType => 'text/plain',
HistoryType => 'AddNote',
HistoryComment => 'Some free text!',
UserID => 1,
);
$Self->True(
$ArticleID,
"Article is created - ID $ArticleID",
);
# Refresh screen and verify there is a reply button for internal type article. See bug#14958 for more details.
$Selenium->VerifiedRefresh();
$Self->True(
$Selenium->execute_script("return \$('#ResponseID$ArticleID').length;"),
"Reply for internal article typo found."
);
# Delete test ticket.
$Success = $TicketObject->TicketDelete(
TicketID => $TicketID,
UserID => 1,
);
# Ticket deletion could fail if apache still writes to ticket history. Try again in this case.
if ( !$Success ) {
sleep 3;
$Success = $TicketObject->TicketDelete(
TicketID => $TicketID,
UserID => 1,
);
}
$Self->True(
$Success,
"Ticket with ticket ID $TicketID is deleted"
);
# Delete standard template.
$Success = $StandardTemplateObject->StandardTemplateDelete(
ID => $TemplateID,
);
$Self->True(
$Success,
"Standard template is deleted - ID $TemplateID"
);
# Delete test customer user.
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
$TestCustomer = $DBObject->Quote($TestCustomer);
$Success = $DBObject->Do(
SQL => "DELETE FROM customer_user WHERE login = ?",
Bind => [ \$TestCustomer ],
);
$Self->True(
$Success,
"Delete customer user - $TestCustomer",
);
# Delete created test dynamic fields.
for my $DynamicFieldID (@DynamicFieldIDs) {
$Success = $DynamicFieldObject->DynamicFieldDelete(
ID => $DynamicFieldID,
UserID => 1,
);
$Self->True(
$Success,
"Dynamic field - ID $DynamicFieldID - deleted",
);
}
# Delete group-user relation.
$Success = $DBObject->Do(
SQL => "DELETE FROM group_user WHERE group_id = ?",
Bind => [ \$GroupID ],
);
$Self->True(
$Success,
"Relation for group ID $GroupID is deleted",
);
# Delete test created user.
$Success = $DBObject->Do(
SQL => "DELETE FROM user_preferences WHERE user_id = ?",
Bind => [ \$UserID ],
);
$Self->True(
$Success,
"User preferences for $UserID is deleted",
);
$Success = $DBObject->Do(
SQL => "DELETE FROM users WHERE id = ?",
Bind => [ \$UserID ],
);
$Self->True(
$Success,
"UserID $UserID is deleted",
);
# Make sure the cache is correct.
for my $Cache (qw( Ticket CustomerUser User )) {
$CacheObject->CleanUp(
Type => $Cache,
);
}
}
);
1;
|