@@ -19,117 +19,121 @@ use strict;
19
19
use warnings;
20
20
use utf8;
21
21
22
+ # Set up the test driver $Self when we are running as a standalone script.
23
+ use Kernel::System::UnitTest::RegisterDriver;
24
+
22
25
use vars (qw( $Self) );
23
26
24
27
my $Selenium = $Kernel::OM -> Get(' Kernel::System::UnitTest::Selenium' );
25
28
26
- if ( $Selenium -> {browser_name } ne ' firefox' ) {
29
+ if ( ! $Selenium -> { browser_name } || $Selenium -> {browser_name } ne ' firefox' ) {
27
30
$Self -> True(
28
31
1,
29
- ' PDF test currently supports Firefox only'
32
+ ' PDF test currently supports Firefox only, skipping test '
30
33
);
31
- return 1;
34
+ # # return 1;
32
35
}
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" ;
33
78
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;
93
98
}
94
- sleep 1;
95
- }
96
99
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
+
116
114
);
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
+ }
118
121
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
+ );
127
130
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" );
130
133
131
- }
134
+ }
132
135
133
- );
136
+ );
137
+ }
134
138
135
- 1 ;
139
+ $Self -> DoneTesting() ;
0 commit comments