<commit_before># --
# ServiceDropdown.t - frontend test AgentTicketPhone
# Copyright (C) 2001-2011 OTRS AG, http://otrs.org/
# --
# $Id: ServiceDropdown.t,v 1.1 2011-04-01 12:41:32 mg Exp $
# --
# 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 vars qw($Self);

use Kernel::System::UnitTest::Helper;
use Kernel::System::Service;
use Kernel::System::Ticket;

use Time::HiRes qw(sleep);

# this test is to check that when AgentTicketPhone is loaded already with
# customer data on it (like when doing Split), the dropdown of Service is
# prefilled with the correct data. This is because of bug
# http://bugs.otrs.org/show_bug.cgi?id=7060

if ( !$Self->{ConfigObject}->Get('SeleniumTestsActive') ) {
    $Self->True( 1, 'Selenium testing is not active' );
    return 1;
}

require Kernel::System::UnitTest::Selenium;

my $Helper = Kernel::System::UnitTest::Helper->new(
    UnitTestObject => $Self,
    %{$Self},
    RestoreSystemConfiguration => 0,
);

my $TestUserLogin = $Helper->TestUserCreate(
    Groups => ['admin'],
) || die "Did not get test user";

for my $SeleniumScenario ( @{ $Helper->SeleniumScenariosGet() } ) {
    eval {
        my $sel = Kernel::System::UnitTest::Selenium->new(
            Verbose        => 1,
            UnitTestObject => $Self,
            %{$SeleniumScenario},
        );

        eval {

            $sel->Login(
                Type     => 'Agent',
                User     => $TestUserLogin,
                Password => $<PASSWORD>,
            );

            my $ScriptAlias = $Self->{ConfigObject}->Get('ScriptAlias');

            # create a customer and a ticket from that customer as previous
            # steps to do the selenium testing

            # create local objects
            my $ConfigObject = Kernel::Config->new();

            # do not checkmx
            $ConfigObject->Set(
                Key   => 'CheckEmailAddresses',
                Value => 0,
            );

            my $ServiceObject = Kernel::System::Service->new(
                %{$Self},
                ConfigObject => $ConfigObject,
            );
            my $TicketObject = Kernel::System::Ticket->new(
                %{$Self},
                ConfigObject => $ConfigObject,
            );

            # create a test customer
            my $TestUserCustomer = $Helper->TestCustomerUserCreate()
                || die "Did not get test customer user";

            # create a ticket from the just created customer
            my $TicketID = $TicketObject->TicketCreate(
                Title        => 'Selenium Test-Some Ticket Title',
                Queue        => 'Raw',
                Lock         => 'unlock',
                Priority     => '3 normal',
                State        => 'closed successful',
                CustomerUser => $TestUserCustomer,
                OwnerID      => 1,
                UserID       => 1,
            );

            my $RandomNumber = int( rand(1000000) );

            # create a test service
            my $ServiceID = $ServiceObject->ServiceAdd(
                Name    => 'SeleniumTestService' . $RandomNumber,
                Comment => 'Selenium Test Service',
                ValidID => 1,
                UserID  => 1,
            );

            # allow access to the just created service to the test user
            $ServiceObject->CustomerUserServiceMemberAdd(
                CustomerUserLogin => $TestUserCustomer,
                ServiceID         => $ServiceID,
                Active            => 1,
                UserID            => 1,
            );

            # create an article for the test ticket
            my $ArticleID = $TicketObject->ArticleCreate(
                TicketID       => $TicketID,
                ArticleType    => 'note-internal',
                SenderType     => 'agent',
                Subject        => 'Selenium test',
                Body           => 'Just a test body for selenium testing',
                Charset        => 'ISO-8859-15',
                MimeType       => 'text/plain',
                HistoryType    => 'AddNote',
                HistoryComment => 'Selenium testing',
                UserID         => 1,
            );

            # real selenium test start
            # open the page that clicking on Split link of the zoom view of the
            # just created ticket would open
            $sel->open_ok(
                "${ScriptAlias}index.pl?Action=AgentTicketPhone;TicketID=$TicketID;ArticleID=$ArticleID"
            );
            $sel->wait_for_page_to_load_ok("30000");

            # verify that the services dropdown has the just created service
            $sel->select_ok( "ServiceID", "label=SeleniumTestService" . $RandomNumber );

            # set the test service to invalid
            $ServiceObject->ServiceUpdate(
                ServiceID => $ServiceID,
                Name      => 'SeleniumTestService' . $RandomNumber,
                ValidID   => 2,
                UserID    => 1,
            );

            return 1;

        } || $Self->True( 0, "Exception in Selenium scenario '$SeleniumScenario->{ID}': $@" );
<commit_msg>Improved test. Deleted test ticket at the end.<commit_after># --
# ServiceDropdown.t - frontend test AgentTicketPhone
# Copyright (C) 2001-2011 OTRS AG, http://otrs.org/
# --
# $Id: ServiceDropdown.t,v 1.2 2011-04-01 21:16:49 en Exp $
# --
# 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 vars qw($Self);

use Kernel::System::UnitTest::Helper;
use Kernel::System::Service;
use Kernel::System::Ticket;

use Time::HiRes qw(sleep);

# this test is to check that when AgentTicketPhone is loaded already with
# customer data on it (like when doing Split), the dropdown of Service is
# prefilled with the correct data. This is because of bug
# http://bugs.otrs.org/show_bug.cgi?id=7060

if ( !$Self->{ConfigObject}->Get('SeleniumTestsActive') ) {
    $Self->True( 1, 'Selenium testing is not active' );
    return 1;
}

require Kernel::System::UnitTest::Selenium;

my $Helper = Kernel::System::UnitTest::Helper->new(
    UnitTestObject => $Self,
    %{$Self},
    RestoreSystemConfiguration => 0,
);

my $TestUserLogin = $Helper->TestUserCreate(
    Groups => ['admin'],
) || die "Did not get test user";

for my $SeleniumScenario ( @{ $Helper->SeleniumScenariosGet() } ) {
    eval {
        my $sel = Kernel::System::UnitTest::Selenium->new(
            Verbose        => 1,
            UnitTestObject => $Self,
            %{$SeleniumScenario},
        );

        eval {

            $sel->Login(
                Type     => 'Agent',
                User     => $TestUserLogin,
                Password => $<PASSWORD>,
            );

            my $ScriptAlias = $Self->{ConfigObject}->Get('ScriptAlias');

            # create a customer and a ticket from that customer as previous
            # steps to do the selenium testing

            # create local objects
            my $ConfigObject = Kernel::Config->new();

            # do not checkmx
            $ConfigObject->Set(
                Key   => 'CheckEmailAddresses',
                Value => 0,
            );

            my $ServiceObject = Kernel::System::Service->new(
                %{$Self},
                ConfigObject => $ConfigObject,
            );
            my $TicketObject = Kernel::System::Ticket->new(
                %{$Self},
                ConfigObject => $ConfigObject,
            );

            # create a test customer
            my $TestUserCustomer = $Helper->TestCustomerUserCreate()
                || die "Did not get test customer user";

            # create a ticket from the just created customer
            my $TicketID = $TicketObject->TicketCreate(
                Title        => 'Selenium Test-Some Ticket Title',
                Queue        => 'Raw',
                Lock         => 'unlock',
                Priority     => '3 normal',
                State        => 'closed successful',
                CustomerUser => $TestUserCustomer,
                OwnerID      => 1,
                UserID       => 1,
            );

            my $RandomNumber = int( rand(1000000) );

            # create a test service
            my $ServiceID = $ServiceObject->ServiceAdd(
                Name    => 'SeleniumTestService' . $RandomNumber,
                Comment => 'Selenium Test Service',
                ValidID => 1,
                UserID  => 1,
            );

            # allow access to the just created service to the test user
            $ServiceObject->CustomerUserServiceMemberAdd(
                CustomerUserLogin => $TestUserCustomer,
                ServiceID         => $ServiceID,
                Active            => 1,
                UserID            => 1,
            );

            # create an article for the test ticket
            my $ArticleID = $TicketObject->ArticleCreate(
                TicketID       => $TicketID,
                ArticleType    => 'note-internal',
                SenderType     => 'agent',
                Subject        => 'Selenium test',
                Body           => 'Just a test body for selenium testing',
                Charset        => 'ISO-8859-15',
                MimeType       => 'text/plain',
                HistoryType    => 'AddNote',
                HistoryComment => 'Selenium testing',
                UserID         => 1,
            );

            # real selenium test start
            # open the page that clicking on Split link of the zoom view of the
            # just created ticket would open
            $sel->open_ok(
                "${ScriptAlias}index.pl?Action=AgentTicketPhone;TicketID=$TicketID;ArticleID=$ArticleID"
            );
            $sel->wait_for_page_to_load_ok("30000");

            # verify that the services dropdown has the just created service
            $sel->select_ok( "ServiceID", "label=SeleniumTestService" . $RandomNumber );

            # set the test service to invalid
            $ServiceObject->ServiceUpdate(
                ServiceID => $ServiceID,
                Name      => 'SeleniumTestService' . $RandomNumber,
                ValidID   => 2,
                UserID    => 1,
            );

            # delete the test ticket
            $TicketObject->TicketDelete(
                TicketID => $TicketID,
                UserID   => 1,
            );

            return 1;

        } || $Self->True( 0, "Exception in Selenium scenario '$SeleniumScenario->{ID}': $@" );

{'fraction_non_alphanumeric': 0.10962443480668081, 'fraction_numerical': 0.01171911045492295, 'mean_word_length': 1.6324993927617197, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 142, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6885794', 'n_tokens_mistral': 3058, 'n_tokens_neox': 2784, 'n_words': 790}