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
|
# --
# 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));
# get selenium object
my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
$Selenium->RunTest(
sub {
# get helper object
my $HelperObject = $Kernel::OM->Get('Kernel::System::UnitTest::Helper');
# enable ticket responsible and watch feature
for my $SysConfigResWatch (qw( Responsible Watcher )) {
$HelperObject->ConfigSettingChange(
Valid => 1,
Key => "Ticket::$SysConfigResWatch",
Value => 1
);
}
# Set to change queue for ticket in a new window.
$HelperObject->ConfigSettingChange(
Valid => 1,
Key => 'Ticket::Frontend::MoveType',
Value => 'link'
);
# get menu config params
my @TicketMenu = (
{
SysConfigItem => {
Active => "AgentTicketMove",
Description => "Delete this ticket",
Link => "Action=AgentTicketMove;TicketID=[% Data.TicketID %];DestQueue=Delete",
Module => "Kernel::Output::HTML::TicketMenu::Generic",
Name => "Delete",
PopupType => "",
Target => "",
},
Key => "Ticket::Frontend::MenuModule###460-Delete",
},
{
SysConfigItem => {
Active => "AgentTicketMove",
Description => "Mark this ticket as junk!",
Link => "Action=AgentTicketMove;TicketID=[% Data.TicketID %];DestQueue=Junk",
Module => "Kernel::Output::HTML::TicketMenu::Generic",
Name => "Spam",
PopupType => "",
Target => "",
},
Key => "Ticket::Frontend::MenuModule###470-Junk",
},
{
SysConfigItem => {
Active => "AgentTicketMove",
Description => "Delete this ticket",
Link => "Action=AgentTicketMove;TicketID=[% Data.TicketID %];DestQueue=Delete",
Module => "Kernel::Output::HTML::TicketMenu::Generic",
Name => "Delete",
PopupType => "",
Target => "",
},
Key => "Ticket::Frontend::PreMenuModule###450-Delete",
},
{
SysConfigItem => {
Active => "AgentTicketMove",
Description => "Mark as Spam!",
Link => "Action=AgentTicketMove;TicketID=[% Data.TicketID %];DestQueue=Junk",
Module => "Kernel::Output::HTML::TicketMenu::Generic",
Name => "Spam",
PopupType => "",
Target => "",
},
Key => "Ticket::Frontend::PreMenuModule###460-Spam",
},
);
# enable delete and spam menu in sysconfig
for my $SysConfigItem (@TicketMenu) {
$HelperObject->ConfigSettingChange(
Key => $SysConfigItem->{Key},
Value => $SysConfigItem->{SysConfigItem},
);
$HelperObject->ConfigSettingChange(
Valid => 1,
Key => $SysConfigItem->{Key},
Value => $SysConfigItem->{SysConfigItem},
);
}
# 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,
);
# get test user ID
my $TestUserID = $Kernel::OM->Get('Kernel::System::User')->UserLookup(
UserLogin => $TestUserLogin,
);
# get ticket object
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
# create test ticket
my $TicketID = $TicketObject->TicketCreate(
Title => 'Some Ticket Title',
Queue => 'Raw',
Lock => 'unlock',
Priority => '3 normal',
State => 'new',
CustomerID => 'TestCustomer',
CustomerUser => 'customer@example.com',
OwnerID => $TestUserID,
UserID => $TestUserID,
);
$Self->True(
$TicketID,
"TicketID $TicketID - created"
);
my $ScriptAlias = $Kernel::OM->Get('Kernel::Config')->Get('ScriptAlias');
# go to raw queue view with focus on created test ticket
$Selenium->VerifiedGet(
"${ScriptAlias}index.pl?Action=AgentTicketQueue;Filter=Unlocked;OrderBy=Down;QueueID=2;SortBy=Age;View=Preview;"
);
# create pre menu module test params
my @PreMenuModule = (
{
Name => "Lock",
Action => "AgentTicket"
},
{
Name => "Zoom",
Action => "AgentTicketZoom",
},
{
Name => "History",
Action => "AgentTicketHistory",
},
{
Name => "Priority",
Action => "AgentTicketPriority",
},
{
Name => "Note",
Action => "AgentTicketNote",
},
{
Name => "Move",
Action => "AgentTicketMove",
},
{
Name => "Delete",
Action => "AgentTicketMove;TicketID=$TicketID;DestQueue=Delete",
},
{
Name => "Spam",
Action => "AgentTicketMove;TicketID=$TicketID;DestQueue=Junk",
},
);
# check ticket pre menu modules
for my $MenuModulePre (@PreMenuModule) {
my $NameForID;
$NameForID = $MenuModulePre->{Name};
$NameForID =~ s/ /-/g if ( $NameForID =~ m/ / );
# check pre menu module link
$Self->True(
$Selenium->find_elements("//a[contains(\@href, \'Action=$MenuModulePre->{Action}' )]")->[0],
"Ticket pre menu $MenuModulePre->{Name} is found"
);
# check pre menu module name
$Self->True(
$Selenium->find_element( "#$NameForID$TicketID", 'css' ),
"Ticket menu name $MenuModulePre->{Name} is found"
);
}
# go to test created ticket zoom
$Selenium->VerifiedGet("${ScriptAlias}index.pl?Action=AgentTicketZoom;TicketID=$TicketID");
# create menu module test params
my @MenuModule = (
{
Name => "Back",
Action => "AgentDashboard",
},
{
Name => "Lock",
Action => "AgentTicket"
},
{
Name => "History",
Action => "AgentTicketHistory",
},
{
Name => "Print",
Action => "AgentTicketPrint",
},
{
Name => "Priority",
Action => "AgentTicketPriority",
},
{
Name => "Free Fields",
Action => "AgentTicketFreeText",
},
{
Name => "Link",
Action => "AgentLinkObject",
},
{
Name => "Owner",
Action => "AgentTicketOwner",
},
{
Name => "Responsible",
Action => "AgentTicketResponsible",
},
{
Name => "Customer",
Action => "AgentTicketCustomer",
},
{
Name => "Note",
Action => "AgentTicketNote",
},
{
Name => "Phone Call Outbound",
Action => "AgentTicketPhoneOutbound",
},
{
Name => "Phone Call Inbound",
Action => "AgentTicketPhoneInbound",
},
{
Name => "E-Mail Outbound",
Action => "AgentTicketEmailOutbound",
},
{
Name => "Merge",
Action => "AgentTicketMerge",
},
{
Name => "Pending",
Action => "AgentTicketPending",
},
{
Name => "Watch",
Action => "AgentTicketWatcher",
},
{
Name => "Close",
Action => "AgentTicketClose",
},
{
Name => "Delete",
Action => "AgentTicketMove;TicketID=$TicketID;DestQueue=Delete",
},
{
Name => "Spam",
Action => "AgentTicketMove;TicketID=$TicketID;DestQueue=Junk",
},
{
Name => "People",
Type => "Cluster",
},
{
Name => "Communication",
Type => "Cluster",
},
{
Name => "Miscellaneous",
Type => "Cluster",
},
);
# check ticket menu modules
for my $ZoomMenuModule (@MenuModule) {
my $NameForID = $ZoomMenuModule->{Name};
$NameForID =~ s/ /-/g if ( $NameForID =~ m/ / );
if ( defined $ZoomMenuModule->{Type} && $ZoomMenuModule->{Type} eq 'Cluster' ) {
# check menu module link
$Self->True(
$Selenium->find_element( "li ul#nav-$NameForID-container", 'css' ),
"Ticket menu link $ZoomMenuModule->{Name} is found"
);
}
else {
# check menu module link
$Self->True(
$Selenium->find_element("//a[contains(\@href, \'Action=$ZoomMenuModule->{Action}' )]"),
"Ticket menu link $ZoomMenuModule->{Name} is found"
);
}
# check menu module name
$Self->True(
$Selenium->find_element( "li#nav-$NameForID", 'css' ),
"Ticket menu name $ZoomMenuModule->{Name} is found"
);
}
# delete created test tickets
my $Success = $TicketObject->TicketDelete(
TicketID => $TicketID,
UserID => $TestUserID,
);
# 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 => $TestUserID,
);
}
$Self->True(
$Success,
"Delete ticket - $TicketID"
);
# make sure the cache is correct.
$Kernel::OM->Get('Kernel::System::Cache')->CleanUp(
Type => 'Ticket',
);
}
);
1;
|