Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
Follow-up fix: Improved filters in ticket overview screens.
Browse files Browse the repository at this point in the history
  • Loading branch information
zilibasic committed Oct 21, 2019
1 parent 5339cf8 commit d873fde
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 35 deletions.
8 changes: 4 additions & 4 deletions Kernel/Modules/AgentTicketWatchView.pm
Expand Up @@ -218,7 +218,7 @@ sub Run {
OrderBy => $OrderBy,
SortBy => $SortByS,
WatchUserIDs => [ $Self->{UserID} ],
UserID => $Self->{UserID},
UserID => 1,
Permission => 'ro',
},
},
Expand All @@ -233,7 +233,7 @@ sub Run {
TicketFlagUserID => $Self->{UserID},
OrderBy => $OrderBy,
SortBy => $SortByS,
UserID => $Self->{UserID},
UserID => 1,
Permission => 'ro',
},
},
Expand All @@ -245,7 +245,7 @@ sub Run {
WatchUserIDs => [ $Self->{UserID} ],
OrderBy => $OrderBy,
SortBy => $SortByS,
UserID => $Self->{UserID},
UserID => 1,
Permission => 'ro',
},
},
Expand All @@ -258,7 +258,7 @@ sub Run {
WatchUserIDs => [ $Self->{UserID} ],
OrderBy => $OrderBy,
SortBy => $SortByS,
UserID => $Self->{UserID},
UserID => 1,
Permission => 'ro',
},
},
Expand Down
6 changes: 3 additions & 3 deletions Kernel/Output/HTML/ToolBar/TicketWatcher.pm
Expand Up @@ -80,7 +80,7 @@ sub Run {
my $Count = $TicketObject->TicketSearch(
Result => 'COUNT',
WatchUserIDs => [ $Self->{UserID} ],
UserID => $Self->{UserID},
UserID => 1,
Permission => 'ro',
) || 0;
my $CountNew = $TicketObject->TicketSearch(
Expand All @@ -90,7 +90,7 @@ sub Run {
Seen => 1,
},
TicketFlagUserID => $Self->{UserID},
UserID => $Self->{UserID},
UserID => 1,
Permission => 'ro',
) || 0;
$CountNew = $Count - $CountNew;
Expand All @@ -100,7 +100,7 @@ sub Run {
StateType => ['pending reminder'],
WatchUserIDs => [ $Self->{UserID} ],
TicketPendingTimeOlderMinutes => 1,
UserID => $Self->{UserID},
UserID => 1,
Permission => 'ro',
) || 0;

Expand Down
4 changes: 2 additions & 2 deletions scripts/test/Selenium/Output/ToolBar/TicketLocked.t
Expand Up @@ -127,10 +127,10 @@ $Selenium->RunTest(
# Refresh dashboard page.
$Selenium->VerifiedRefresh();

# click on tool bar AgentTicketLockedView
# Click on tool bar AgentTicketLockedView.
$Selenium->find_element("//a[contains(\@title, \'Locked Tickets Total:\' )]")->VerifiedClick();

# verify that test is on the correct screen
# Verify that test is on the correct screen.
my $ScriptAlias = $Kernel::OM->Get('Kernel::Config')->Get('ScriptAlias');
my $ExpectedURL = "${ScriptAlias}index.pl?Action=AgentTicketLockedView";

Expand Down
187 changes: 161 additions & 26 deletions scripts/test/Selenium/Output/ToolBar/TicketWatcher.t
Expand Up @@ -12,78 +12,176 @@ 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 $Helper = $Kernel::OM->Get('Kernel::System::UnitTest::Helper');
my $Helper = $Kernel::OM->Get('Kernel::System::UnitTest::Helper');
my $GroupObject = $Kernel::OM->Get('Kernel::System::Group');
my $QueueObject = $Kernel::OM->Get('Kernel::System::Queue');
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');

# enable ticket watcher feature
# Enable ticket watcher feature.
$Helper->ConfigSettingChange(
Valid => 1,
Key => 'Ticket::Watcher',
Value => 1
);

# create test user and login
my $TestUserLogin = $Helper->TestUserCreate(
Groups => [ 'admin', 'users' ],
) || die "Did not get test user";
my $RandomID = $Helper->GetRandomID();
my @Groups;
my @Queues;
my @Users;
my @Tickets;
for my $Item ( 1 .. 2 ) {

# Create test group.
my $GroupName = "Group$Item-$RandomID";
my $GroupID = $GroupObject->GroupAdd(
Name => $GroupName,
ValidID => 1,
UserID => 1,
);

$Self->True(
$GroupID,
"Test group $GroupName created",
);

push @Groups, {
GroupID => $GroupID,
GroupName => $GroupName,
};

# Create test queue.
my $QueueName = "Queue$Item-$RandomID";
my $QueueID = $QueueObject->QueueAdd(
Name => $QueueName,
ValidID => 1,
GroupID => $GroupID,
FirstResponseTime => 0,
FirstResponseNotify => 0,
UpdateTime => 0,
UpdateNotify => 0,
SolutionTime => 0,
SolutionNotify => 0,
SystemAddressID => 1,
SalutationID => 1,
SignatureID => 1,
Comment => 'Some Comment',
UserID => 1,
);

$Self->True(
$QueueID,
"Test queue $QueueName created",
);

push @Queues, {
QueueID => $QueueID,
QueueName => $QueueName,
};

}

# Create test user.
my ( $TestUserLogin, $TestUserID ) = $Helper->TestUserCreate(
Groups => [ 'admin', 'users', $Groups[0]->{GroupName} ],
);

$Selenium->Login(
Type => 'Agent',
User => $TestUserLogin,
Password => $TestUserLogin,
);

# get ticket object
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');

# create test ticket
my $TicketID = $TicketObject->TicketCreate(
# Create test ticket.
my $TicketNumber = $TicketObject->TicketCreateNumber();
my $TicketID = $TicketObject->TicketCreate(
TN => $TicketNumber,
Title => 'Selenium test ticket',
Queue => 'Raw',
Lock => 'unlock',
Queue => $Queues[0]->{QueueName},
Lock => 'lock',
Priority => '3 normal',
State => 'open',
CustomerID => 'SeleniumCustomerID',
CustomerUser => 'test@localhost.com',
OwnerID => 1,
CustomerUser => "test\@localhost.com",
OwnerID => $TestUserID,
UserID => 1,
ResponsibleID => 1,
ResponsibleID => $TestUserID,
);

$Self->True(
$TicketID,
"Ticket is created - ID $TicketID"
);
) || die;

# Refresh dashboard page.
$Selenium->VerifiedRefresh();

my $ScriptAlias = $Kernel::OM->Get('Kernel::Config')->Get('ScriptAlias');

# go to AgentTicketZoom and check watcher feature - subscribe ticket to watch it
# Go to AgentTicketZoom and check watcher feature - subscribe ticket to watch it
$Selenium->VerifiedGet("${ScriptAlias}index.pl?Action=AgentTicketZoom;TicketID=$TicketID");
$Selenium->find_element("//a[contains(\@href, \'Action=AgentTicketWatcher\' )]")->VerifiedClick();
$Selenium->find_element("//a[contains(\@href, \'Action=AgentTicketWatcher;Subaction=Subscribe;TicketID\' )]")
->VerifiedClick();

# click on tool bar AgentTicketWatchView
# Click on tool bar AgentTicketWatchView
$Selenium->find_element("//a[contains(\@title, \'Watched Tickets Total:\' )]")->VerifiedClick();

# verify that test is on the correct screen
# Verify that test is on the correct screen.
my $ExpectedURL = "${ScriptAlias}index.pl?Action=AgentTicketWatchView";

$Self->True(
index( $Selenium->get_current_url(), $ExpectedURL ) > -1,
"ToolBar AgentTicketWatcherView shortcut - success",
);

# delete test ticket
my $Success = $TicketObject->TicketDelete(
# Test ticket is watched.
$Self->Is(
$Selenium->execute_script("return \$('a.MasterActionLink').html().trim();"),
$TicketNumber,
"Ticket $TicketNumber from $Queues[0]->{QueueName} is found",
);

# Move ticket in such Queue, that user doesn't have permission.
# User still should have access to the ticket, because of watcher feature.
my $Success = $TicketObject->TicketQueueSet(
QueueID => $Queues[1]->{QueueID},
TicketID => $TicketID,
UserID => 1,
);

$Self->True(
$Success,
"TicketQueueSet: TicketID: $TicketID move into $Queues[1]->{QueueName}",
) || die;

# Refresh AgentTicketWatchView page.
$Selenium->VerifiedRefresh();

# If user don't have permission there will not be any tickets in watch list.
$Self->False(
$Selenium->execute_script("return \$('#EmptyMessageSmall').length;"),
"There is watched ticket",
);

# User still have access to the ticket.
$Self->Is(
$Selenium->execute_script("return \$('a.MasterActionLink').html().trim();"),
$TicketNumber,
"Moved Ticket $TicketNumber in $Queues[1]->{QueueName} is found",
) || die;

my $DBObject = $Kernel::OM->Get('Kernel::System::DB');

# Delete test ticket.
$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;
Expand All @@ -92,10 +190,47 @@ $Selenium->RunTest(
UserID => 1,
);
}

$Self->True(
$Success,
"Ticket is deleted - $TicketID"
"Ticket with ID $TicketID is deleted!",
);

# Delete queues.
for my $Queue (@Queues) {
my $Success = $DBObject->Do(
SQL => "DELETE FROM queue WHERE id = $Queue->{QueueID}",
);
$Self->True(
$Success,
"Queue with ID $Queue->{QueueID} is deleted!",
);
}

# Delete group-user relations.
for my $Group (@Groups) {
my $Success = $DBObject->Do(
SQL => "DELETE FROM group_user WHERE group_id = $Group->{GroupID}",
);
$Self->True(
$Success,
"GroupUserDelete for ID $Group->{GroupID}",
);

# Delete test group.
$Success = $DBObject->Do(
SQL => "DELETE FROM groups_table WHERE id = ?",
Bind => [ \$Group->{GroupID} ],
);
$Self->True(
$Success,
"Deleted test group - $Group->{GroupID}"
);
}

# Make sure the cache is correct.
$Kernel::OM->Get('Kernel::System::Cache')->CleanUp();

}
);

Expand Down

0 comments on commit d873fde

Please sign in to comment.