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
|
# --
# Copyright (C) 2001-2017 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
use strict;
use warnings;
use utf8;
use vars (qw($Self));
# get selenium object
my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
$Selenium->RunTest(
sub {
# get needed objects
my $Helper = $Kernel::OM->Get('Kernel::System::UnitTest::Helper');
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
my $SystemAddressObject = $Kernel::OM->Get('Kernel::System::SystemAddress');
my @TicketIDs;
# create test system address
my $SystemAddressID = $SystemAddressObject->SystemAddressAdd(
Name => 'systemaddress@localhost.com',
Realname => 'SeleniumSystemAddress',
ValidID => 1,
QueueID => 1,
Comment => 'Selenium test address',
UserID => 1,
);
# create test ticket
my $TicketID = $TicketObject->TicketCreate(
Title => 'First test ticket',
Queue => 'Raw',
Lock => 'unlock',
Priority => '3 normal',
State => 'new',
CustomerID => '123465',
CustomerUser => 'customer@localhost.com',
OwnerID => 1,
UserID => 1,
);
$Self->True(
$TicketID,
"TicketID $TicketID - created",
);
# get create article data
my $Customer = 'customer' . $Helper->GetRandomID();
my $ToCustomer = "to$Customer\@localhost.com";
my $FromCustomer = "from$Customer\@localhost.com";
my @TestArticles = (
{
SenderType => 'customer',
From => "From Customer <$FromCustomer>",
To => 'Raw',
},
{
SenderType => 'system',
From => 'SeleniumSystemAddress <systemaddress@localhost.com>',
To => "To Customer <$ToCustomer>",
},
{
SenderType => 'customer',
From => "From Customer <$FromCustomer>",
To => "To Customer <$ToCustomer>",
},
);
# create test articles for test ticket
my @ArticleIDs;
for my $TestArticle (@TestArticles) {
my $ArticleID = $TicketObject->ArticleCreate(
TicketID => $TicketID,
ArticleType => 'email-external',
SenderType => $TestArticle->{SenderType},
From => $TestArticle->{From},
To => $TestArticle->{To},
Subject => 'Selenium test',
Body => 'Just a test body for selenium testing',
Charset => 'ISO-8859-15',
MimeType => 'text/plain',
HistoryType => 'PhoneCallCustomer',
HistoryComment => 'Selenium testing',
UserID => 1,
);
$Self->True(
$ArticleID,
"ArticleID $ArticleID - created",
);
push @ArticleIDs, $ArticleID;
}
# create and login test user
my $TestUserLogin = $Helper->TestUserCreate(
Groups => [ 'admin', 'users' ],
) || die "Did not get test user";
$Selenium->Login(
Type => 'Agent',
User => $TestUserLogin,
Password => $TestUserLogin,
);
# get script alias
my $ScriptAlias = $Kernel::OM->Get('Kernel::Config')->Get('ScriptAlias');
# get test data
my @Tests = (
{
ArticleID => $ArticleIDs[0],
ToValueOnSplit => $FromCustomer,
ResultMessage => 'From is Customer, To is Queue',
},
{
ArticleID => $ArticleIDs[1],
ToValueOnSplit => $ToCustomer,
ResultMessage => 'From is SystemAddress, To is Customer'
},
{
ArticleID => $ArticleIDs[2],
ToValueOnSplit => $FromCustomer,
ResultMessage => 'From is Customer, To is Customer'
},
);
# run test scenarios
for my $Test (@Tests) {
# navigate to split ticket of test ticket first article
$Selenium->VerifiedGet(
"${ScriptAlias}index.pl?Action=AgentTicketPhone;TicketID=$TicketID;ArticleID=$Test->{ArticleID};LinkTicketID=$TicketID"
);
$Self->Is(
$Selenium->find_element("//input[\@type='text'][\@name='CustomerTicketText_1']")->get_value(),
"$Test->{ToValueOnSplit}",
"$Test->{ResultMessage} - on article split value From",
);
}
# delete test system address
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
my $Success = $DBObject->Do(
SQL => "DELETE FROM system_address WHERE id= $SystemAddressID",
);
$Self->True(
$Success,
"SystemAddressID $SystemAddressID - deleted",
);
# delete test created ticket
$Success = $TicketObject->TicketDelete(
TicketID => $TicketID,
UserID => 1,
);
$Self->True(
$Success,
"TicketID $TicketID - deleted",
);
}
);
1;
|