Skip to content

Commit 9eafe04

Browse files
authored
Merge pull request #8 from wollmers/issue-#7-adapt-selenium-tests
Issue #7 adapt selenium tests for OTOBO 10.0.7
2 parents ac27698 + ebe4b46 commit 9eafe04

31 files changed

+395
-299
lines changed

scripts/test/Selenium/Agent/AgentFAQAdd.t

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use strict;
1919
use warnings;
2020
use utf8;
2121

22+
# Set up the test driver $Self when we are running as a standalone script.
23+
use Kernel::System::UnitTest::RegisterDriver;
24+
2225
use vars (qw($Self));
2326

2427
# get selenium object
@@ -157,4 +160,4 @@ $Selenium->RunTest(
157160
}
158161
);
159162

160-
1;
163+
$Self->DoneTesting();

scripts/test/Selenium/Agent/AgentFAQCategory.t

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use strict;
1919
use warnings;
2020
use utf8;
2121

22+
# Set up the test driver $Self when we are running as a standalone script.
23+
use Kernel::System::UnitTest::RegisterDriver;
24+
2225
use vars (qw($Self));
2326

2427
my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
@@ -109,4 +112,4 @@ $Selenium->RunTest(
109112
}
110113
);
111114

112-
1;
115+
$Self->DoneTesting();

scripts/test/Selenium/Agent/AgentFAQDelete.t

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use strict;
1919
use warnings;
2020
use utf8;
2121

22+
# Set up the test driver $Self when we are running as a standalone script.
23+
use Kernel::System::UnitTest::RegisterDriver;
24+
2225
use vars (qw($Self));
2326

2427
my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
@@ -94,4 +97,4 @@ $Selenium->RunTest(
9497
}
9598
);
9699

97-
1;
100+
$Self->DoneTesting();

scripts/test/Selenium/Agent/AgentFAQEdit.t

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use strict;
1919
use warnings;
2020
use utf8;
2121

22+
# Set up the test driver $Self when we are running as a standalone script.
23+
use Kernel::System::UnitTest::RegisterDriver;
24+
2225
use vars (qw($Self));
2326

2427
my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
@@ -349,4 +352,4 @@ $Selenium->RunTest(
349352
}
350353
);
351354

352-
1;
355+
$Self->DoneTesting();

scripts/test/Selenium/Agent/AgentFAQExplorer.t

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use strict;
1919
use warnings;
2020
use utf8;
2121

22+
# Set up the test driver $Self when we are running as a standalone script.
23+
use Kernel::System::UnitTest::RegisterDriver;
24+
2225
use vars (qw($Self));
2326

2427
# get selenium object
@@ -176,4 +179,4 @@ $Selenium->RunTest(
176179
}
177180
);
178181

179-
1;
182+
$Self->DoneTesting();

scripts/test/Selenium/Agent/AgentFAQHistory.t

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use strict;
1919
use warnings;
2020
use utf8;
2121

22+
# Set up the test driver $Self when we are running as a standalone script.
23+
use Kernel::System::UnitTest::RegisterDriver;
24+
2225
use vars (qw($Self));
2326

2427
my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
@@ -111,4 +114,4 @@ $Selenium->RunTest(
111114
}
112115
);
113116

114-
1;
117+
$Self->DoneTesting();

scripts/test/Selenium/Agent/AgentFAQJournal.t

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use strict;
1919
use warnings;
2020
use utf8;
2121

22+
# Set up the test driver $Self when we are running as a standalone script.
23+
use Kernel::System::UnitTest::RegisterDriver;
24+
2225
use vars (qw($Self));
2326

2427
# get selenium object
@@ -123,4 +126,4 @@ $Selenium->RunTest(
123126
}
124127
);
125128

126-
1;
129+
$Self->DoneTesting();

scripts/test/Selenium/Agent/AgentFAQLanguage.t

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use strict;
1919
use warnings;
2020
use utf8;
2121

22+
# Set up the test driver $Self when we are running as a standalone script.
23+
use Kernel::System::UnitTest::RegisterDriver;
24+
2225
use vars (qw($Self));
2326

2427
my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
@@ -149,4 +152,4 @@ $Selenium->RunTest(
149152
}
150153
);
151154

152-
1;
155+
$Self->DoneTesting();

scripts/test/Selenium/Agent/AgentFAQLinkObject.t

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use strict;
1919
use warnings;
2020
use utf8;
2121

22+
# Set up the test driver $Self when we are running as a standalone script.
23+
use Kernel::System::UnitTest::RegisterDriver;
24+
2225
use vars (qw($Self));
2326

2427
my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
@@ -386,4 +389,4 @@ $Selenium->RunTest(
386389
}
387390
);
388391

389-
1;
392+
$Self->DoneTesting();

scripts/test/Selenium/Agent/AgentFAQPrint.t

+101-97
Original file line numberDiff line numberDiff line change
@@ -19,117 +19,121 @@ use strict;
1919
use warnings;
2020
use utf8;
2121

22+
# Set up the test driver $Self when we are running as a standalone script.
23+
use Kernel::System::UnitTest::RegisterDriver;
24+
2225
use vars (qw($Self));
2326

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

26-
if ( $Selenium->{browser_name} ne 'firefox' ) {
29+
if ( !$Selenium->{browser_name} || $Selenium->{browser_name} ne 'firefox' ) {
2730
$Self->True(
2831
1,
29-
'PDF test currently supports Firefox only'
32+
'PDF test currently supports Firefox only, skipping test'
3033
);
31-
return 1;
34+
##return 1;
3235
}
36+
else {
37+
$Selenium->RunTest(
38+
sub {
39+
40+
# get helper object
41+
my $Helper = $Kernel::OM->Get('Kernel::System::UnitTest::Helper');
42+
43+
# get FAQ object
44+
my $FAQObject = $Kernel::OM->Get('Kernel::System::FAQ');
45+
46+
# create test FAQ
47+
# test params
48+
my $FAQTitle = 'FAQ ' . $Helper->GetRandomID();
49+
my $FAQSymptom = 'Selenium Symptom';
50+
my $FAQProblem = 'Selenium Problem';
51+
my $FAQSolution = 'Selenium Solution';
52+
my $FAQComment = 'Selenium Comment';
53+
54+
my $ItemID = $FAQObject->FAQAdd(
55+
Title => $FAQTitle,
56+
CategoryID => 1,
57+
StateID => 1,
58+
LanguageID => 1,
59+
Keywords => 'some keywords',
60+
Field1 => $FAQSymptom,
61+
Field2 => $FAQProblem,
62+
Field3 => $FAQSolution,
63+
Field6 => $FAQComment,
64+
ValidID => 1,
65+
UserID => 1,
66+
ContentType => 'text/html',
67+
);
68+
69+
$Self->True(
70+
$ItemID,
71+
"FAQ item is created - ID $ItemID",
72+
);
73+
74+
# create test user and login
75+
my $TestUserLogin = $Helper->TestUserCreate(
76+
Groups => [ 'admin', 'users' ],
77+
) || die "Did not get test user";
3378

34-
$Selenium->RunTest(
35-
sub {
36-
37-
# get helper object
38-
my $Helper = $Kernel::OM->Get('Kernel::System::UnitTest::Helper');
39-
40-
# get FAQ object
41-
my $FAQObject = $Kernel::OM->Get('Kernel::System::FAQ');
42-
43-
# create test FAQ
44-
# test params
45-
my $FAQTitle = 'FAQ ' . $Helper->GetRandomID();
46-
my $FAQSymptom = 'Selenium Symptom';
47-
my $FAQProblem = 'Selenium Problem';
48-
my $FAQSolution = 'Selenium Solution';
49-
my $FAQComment = 'Selenium Comment';
50-
51-
my $ItemID = $FAQObject->FAQAdd(
52-
Title => $FAQTitle,
53-
CategoryID => 1,
54-
StateID => 1,
55-
LanguageID => 1,
56-
Keywords => 'some keywords',
57-
Field1 => $FAQSymptom,
58-
Field2 => $FAQProblem,
59-
Field3 => $FAQSolution,
60-
Field6 => $FAQComment,
61-
ValidID => 1,
62-
UserID => 1,
63-
ContentType => 'text/html',
64-
);
65-
66-
$Self->True(
67-
$ItemID,
68-
"FAQ item is created - ID $ItemID",
69-
);
70-
71-
# create test user and login
72-
my $TestUserLogin = $Helper->TestUserCreate(
73-
Groups => [ 'admin', 'users' ],
74-
) || die "Did not get test user";
75-
76-
$Selenium->Login(
77-
Type => 'Agent',
78-
User => $TestUserLogin,
79-
Password => $TestUserLogin,
80-
);
81-
82-
# get script alias
83-
my $ScriptAlias = $Kernel::OM->Get('Kernel::Config')->Get('ScriptAlias');
84-
85-
# navigate to AgentFAQPrint screen of created test FAQ
86-
$Selenium->get("${ScriptAlias}index.pl?Action=AgentFAQPrint;ItemID=$ItemID");
87-
88-
# wait until print screen is loaded
89-
ACTIVESLEEP:
90-
for my $Second ( 1 .. 20 ) {
91-
if ( index( $Selenium->get_page_source(), $FAQComment ) > -1, ) {
92-
last ACTIVESLEEP;
79+
$Selenium->Login(
80+
Type => 'Agent',
81+
User => $TestUserLogin,
82+
Password => $TestUserLogin,
83+
);
84+
85+
# get script alias
86+
my $ScriptAlias = $Kernel::OM->Get('Kernel::Config')->Get('ScriptAlias');
87+
88+
# navigate to AgentFAQPrint screen of created test FAQ
89+
$Selenium->get("${ScriptAlias}index.pl?Action=AgentFAQPrint;ItemID=$ItemID");
90+
91+
# wait until print screen is loaded
92+
ACTIVESLEEP:
93+
for my $Second ( 1 .. 20 ) {
94+
if ( index( $Selenium->get_page_source(), $FAQComment ) > -1, ) {
95+
last ACTIVESLEEP;
96+
}
97+
sleep 1;
9398
}
94-
sleep 1;
95-
}
9699

97-
my @Tests = (
98-
{
99-
FAQData => $FAQSymptom,
100-
},
101-
{
102-
FAQData => $FAQProblem,
103-
},
104-
{
105-
FAQData => $FAQSolution,
106-
},
107-
{
108-
FAQData => $FAQComment,
109-
},
110-
111-
);
112-
for my $Test (@Tests) {
113-
$Self->True(
114-
index( $Selenium->get_page_source(), $Test->{FAQData} ) > -1,
115-
"$Test->{FAQData} is found on print screen",
100+
my @Tests = (
101+
{
102+
FAQData => $FAQSymptom,
103+
},
104+
{
105+
FAQData => $FAQProblem,
106+
},
107+
{
108+
FAQData => $FAQSolution,
109+
},
110+
{
111+
FAQData => $FAQComment,
112+
},
113+
116114
);
117-
}
115+
for my $Test (@Tests) {
116+
$Self->True(
117+
index( $Selenium->get_page_source(), $Test->{FAQData} ) > -1,
118+
"$Test->{FAQData} is found on print screen",
119+
);
120+
}
118121

119-
my $Success = $FAQObject->FAQDelete(
120-
ItemID => $ItemID,
121-
UserID => 1,
122-
);
123-
$Self->True(
124-
$Success,
125-
"FAQ item is deleted - ID $ItemID",
126-
);
122+
my $Success = $FAQObject->FAQDelete(
123+
ItemID => $ItemID,
124+
UserID => 1,
125+
);
126+
$Self->True(
127+
$Success,
128+
"FAQ item is deleted - ID $ItemID",
129+
);
127130

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

131-
}
134+
}
132135

133-
);
136+
);
137+
}
134138

135-
1;
139+
$Self->DoneTesting();

scripts/test/Selenium/Agent/AgentFAQSearch.t

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use strict;
1919
use warnings;
2020
use utf8;
2121

22+
# Set up the test driver $Self when we are running as a standalone script.
23+
use Kernel::System::UnitTest::RegisterDriver;
24+
2225
use vars (qw($Self));
2326

2427
my $Selenium = $Kernel::OM->Get('Kernel::System::UnitTest::Selenium');
@@ -387,4 +390,4 @@ $Selenium->RunTest(
387390
}
388391
);
389392

390-
1;
393+
$Self->DoneTesting();

scripts/test/Selenium/Agent/AgentFAQZoom.t

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use strict;
1919
use warnings;
2020
use utf8;
2121

22+
# Set up the test driver $Self when we are running as a standalone script.
23+
use Kernel::System::UnitTest::RegisterDriver;
24+
2225
use vars (qw($Self));
2326

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

157160
);
158161

159-
1;
162+
$Self->DoneTesting();

0 commit comments

Comments
 (0)