Skip to content

Commit

Permalink
Merge pull request #8 from wollmers/issue-#7-adapt-selenium-tests
Browse files Browse the repository at this point in the history
Issue #7 adapt selenium tests for OTOBO 10.0.7
  • Loading branch information
bschmalhofer authored Aug 15, 2021
2 parents ac27698 + ebe4b46 commit 9eafe04
Show file tree
Hide file tree
Showing 31 changed files with 395 additions and 299 deletions.
5 changes: 4 additions & 1 deletion scripts/test/Selenium/Agent/AgentFAQAdd.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;

use vars (qw($Self));

# get selenium object
Expand Down Expand Up @@ -157,4 +160,4 @@ $Selenium->RunTest(
}
);

1;
$Self->DoneTesting();
5 changes: 4 additions & 1 deletion scripts/test/Selenium/Agent/AgentFAQCategory.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;

use vars (qw($Self));

my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
Expand Down Expand Up @@ -109,4 +112,4 @@ $Selenium->RunTest(
}
);

1;
$Self->DoneTesting();
5 changes: 4 additions & 1 deletion scripts/test/Selenium/Agent/AgentFAQDelete.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;

use vars (qw($Self));

my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
Expand Down Expand Up @@ -94,4 +97,4 @@ $Selenium->RunTest(
}
);

1;
$Self->DoneTesting();
5 changes: 4 additions & 1 deletion scripts/test/Selenium/Agent/AgentFAQEdit.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;

use vars (qw($Self));

my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
Expand Down Expand Up @@ -349,4 +352,4 @@ $Selenium->RunTest(
}
);

1;
$Self->DoneTesting();
5 changes: 4 additions & 1 deletion scripts/test/Selenium/Agent/AgentFAQExplorer.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;

use vars (qw($Self));

# get selenium object
Expand Down Expand Up @@ -176,4 +179,4 @@ $Selenium->RunTest(
}
);

1;
$Self->DoneTesting();
5 changes: 4 additions & 1 deletion scripts/test/Selenium/Agent/AgentFAQHistory.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;

use vars (qw($Self));

my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
Expand Down Expand Up @@ -111,4 +114,4 @@ $Selenium->RunTest(
}
);

1;
$Self->DoneTesting();
5 changes: 4 additions & 1 deletion scripts/test/Selenium/Agent/AgentFAQJournal.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;

use vars (qw($Self));

# get selenium object
Expand Down Expand Up @@ -123,4 +126,4 @@ $Selenium->RunTest(
}
);

1;
$Self->DoneTesting();
5 changes: 4 additions & 1 deletion scripts/test/Selenium/Agent/AgentFAQLanguage.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;

use vars (qw($Self));

my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
Expand Down Expand Up @@ -149,4 +152,4 @@ $Selenium->RunTest(
}
);

1;
$Self->DoneTesting();
5 changes: 4 additions & 1 deletion scripts/test/Selenium/Agent/AgentFAQLinkObject.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;

use vars (qw($Self));

my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
Expand Down Expand Up @@ -386,4 +389,4 @@ $Selenium->RunTest(
}
);

1;
$Self->DoneTesting();
198 changes: 101 additions & 97 deletions scripts/test/Selenium/Agent/AgentFAQPrint.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,117 +19,121 @@ use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;

use vars (qw($Self));

my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');

if ( $Selenium->{browser_name} ne 'firefox' ) {
if ( !$Selenium->{browser_name} || $Selenium->{browser_name} ne 'firefox' ) {
$Self->True(
1,
'PDF test currently supports Firefox only'
'PDF test currently supports Firefox only, skipping test'
);
return 1;
##return 1;
}
else {
$Selenium->RunTest(
sub {

# get helper object
my $Helper = $Kernel::OM->Get('Kernel::System::UnitTest::Helper');

# get FAQ object
my $FAQObject = $Kernel::OM->Get('Kernel::System::FAQ');

# create test FAQ
# test params
my $FAQTitle = 'FAQ ' . $Helper->GetRandomID();
my $FAQSymptom = 'Selenium Symptom';
my $FAQProblem = 'Selenium Problem';
my $FAQSolution = 'Selenium Solution';
my $FAQComment = 'Selenium Comment';

my $ItemID = $FAQObject->FAQAdd(
Title => $FAQTitle,
CategoryID => 1,
StateID => 1,
LanguageID => 1,
Keywords => 'some keywords',
Field1 => $FAQSymptom,
Field2 => $FAQProblem,
Field3 => $FAQSolution,
Field6 => $FAQComment,
ValidID => 1,
UserID => 1,
ContentType => 'text/html',
);

$Self->True(
$ItemID,
"FAQ item is created - ID $ItemID",
);

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

$Selenium->RunTest(
sub {

# get helper object
my $Helper = $Kernel::OM->Get('Kernel::System::UnitTest::Helper');

# get FAQ object
my $FAQObject = $Kernel::OM->Get('Kernel::System::FAQ');

# create test FAQ
# test params
my $FAQTitle = 'FAQ ' . $Helper->GetRandomID();
my $FAQSymptom = 'Selenium Symptom';
my $FAQProblem = 'Selenium Problem';
my $FAQSolution = 'Selenium Solution';
my $FAQComment = 'Selenium Comment';

my $ItemID = $FAQObject->FAQAdd(
Title => $FAQTitle,
CategoryID => 1,
StateID => 1,
LanguageID => 1,
Keywords => 'some keywords',
Field1 => $FAQSymptom,
Field2 => $FAQProblem,
Field3 => $FAQSolution,
Field6 => $FAQComment,
ValidID => 1,
UserID => 1,
ContentType => 'text/html',
);

$Self->True(
$ItemID,
"FAQ item is created - ID $ItemID",
);

# create test user and login
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');

# navigate to AgentFAQPrint screen of created test FAQ
$Selenium->get("${ScriptAlias}index.pl?Action=AgentFAQPrint;ItemID=$ItemID");

# wait until print screen is loaded
ACTIVESLEEP:
for my $Second ( 1 .. 20 ) {
if ( index( $Selenium->get_page_source(), $FAQComment ) > -1, ) {
last ACTIVESLEEP;
$Selenium->Login(
Type => 'Agent',
User => $TestUserLogin,
Password => $TestUserLogin,
);

# get script alias
my $ScriptAlias = $Kernel::OM->Get('Kernel::Config')->Get('ScriptAlias');

# navigate to AgentFAQPrint screen of created test FAQ
$Selenium->get("${ScriptAlias}index.pl?Action=AgentFAQPrint;ItemID=$ItemID");

# wait until print screen is loaded
ACTIVESLEEP:
for my $Second ( 1 .. 20 ) {
if ( index( $Selenium->get_page_source(), $FAQComment ) > -1, ) {
last ACTIVESLEEP;
}
sleep 1;
}
sleep 1;
}

my @Tests = (
{
FAQData => $FAQSymptom,
},
{
FAQData => $FAQProblem,
},
{
FAQData => $FAQSolution,
},
{
FAQData => $FAQComment,
},

);
for my $Test (@Tests) {
$Self->True(
index( $Selenium->get_page_source(), $Test->{FAQData} ) > -1,
"$Test->{FAQData} is found on print screen",
my @Tests = (
{
FAQData => $FAQSymptom,
},
{
FAQData => $FAQProblem,
},
{
FAQData => $FAQSolution,
},
{
FAQData => $FAQComment,
},

);
}
for my $Test (@Tests) {
$Self->True(
index( $Selenium->get_page_source(), $Test->{FAQData} ) > -1,
"$Test->{FAQData} is found on print screen",
);
}

my $Success = $FAQObject->FAQDelete(
ItemID => $ItemID,
UserID => 1,
);
$Self->True(
$Success,
"FAQ item is deleted - ID $ItemID",
);
my $Success = $FAQObject->FAQDelete(
ItemID => $ItemID,
UserID => 1,
);
$Self->True(
$Success,
"FAQ item is deleted - ID $ItemID",
);

# make sure the cache is correct
$Kernel::OM->Get('Kernel::System::Cache')->CleanUp( Type => "FAQ" );
# make sure the cache is correct
$Kernel::OM->Get('Kernel::System::Cache')->CleanUp( Type => "FAQ" );

}
}

);
);
}

1;
$Self->DoneTesting();
5 changes: 4 additions & 1 deletion scripts/test/Selenium/Agent/AgentFAQSearch.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;

use vars (qw($Self));

my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
Expand Down Expand Up @@ -387,4 +390,4 @@ $Selenium->RunTest(
}
);

1;
$Self->DoneTesting();
5 changes: 4 additions & 1 deletion scripts/test/Selenium/Agent/AgentFAQZoom.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;

use vars (qw($Self));

my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
Expand Down Expand Up @@ -156,4 +159,4 @@ $Selenium->RunTest(

);

1;
$Self->DoneTesting();
Loading

0 comments on commit 9eafe04

Please sign in to comment.