Bug 19337: Make basic_workflow.t configurable through ENV

This patch makes the basic_workflow.t selenium tests read ENV for the
following vars:

KOHA_USER
KOHA_PASS
KOHA_INTRANET_URL
SELENIUM_ADDR
SELENIUM_PORT

to properly configure the running environment. If absent, all variables
fallback to current behaviour:

KOHA_USER // 'koha'
KOHA_PASS // 'koha'
KOHA_INTRANET_URL (unchanged)
SELENIUM_ADDR // 'localhost'
SELENIUM_PORT // 4444

[*] Selenium defaults are documented on the Selenium::Remote::Driver docs.

Prerequisites:
Make sure you have a working environment for the Selenium tests:
- Run:
  $ sudo apt update
  $ sudo apt install xvfb firefox-esr

To test:
- Run:
  $ sudo koha-shell kohadev
 k$ cd kohaclone
 k$ wget https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar \
     -O /tmp/selenium.jar
 k$ SELENIUM_PATH=/tmp/selenium.jar
 k$ Xvfb :1 -screen 0 1024x768x24 2>&1 >/dev/null &
 k$ DISPLAY=:1 java -jar $SELENIUM_PATH &
 k$ prove t/db_dependent/selenium/basic_workflow.t
=> SUCCESS: Tests pass
- Apply this patch
- Run:
 k$ prove t/db_dependent/selenium/basic_workflow.t
=> SUCCESS: Tests pass!
- Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 5bb19808bb)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit f2b53042bd)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
This commit is contained in:
Tomas Cohen Arazi 2017-09-18 15:58:15 -03:00 committed by Katrin Fischer
parent ea2dd33e30
commit e2ee7118d0
1 changed files with 15 additions and 6 deletions

View File

@ -42,10 +42,15 @@ use Test::More tests => 20;
use MARC::Record;
use MARC::Field;
my $dbh = C4::Context->dbh;
my $login = 'koha';
my $password = 'koha';
my $base_url= ( $ENV{KOHA_INTRANET_URL} || 'http://'.C4::Context->preference("staffClientBaseURL") ) . "/cgi-bin/koha/";
my $dbh = C4::Context->dbh;
my $login = $ENV{KOHA_USER} || 'koha';
my $password = $ENV{KOHA_PASS} || 'koha';
my $base_url
= ( $ENV{KOHA_INTRANET_URL} || 'http://' . C4::Context->preference("staffClientBaseURL") )
. "/cgi-bin/koha/";
my $selenium_addr = $ENV{SELENIUM_ADDR} || 'localhost';
my $selenium_port = $ENV{SELENIUM_PORT} || 4444;
my $number_of_biblios_to_insert = 3;
@ -89,7 +94,11 @@ SKIP: {
open my $fh, '>>', '/tmp/output.txt';
my $driver = Selenium::Remote::Driver->new;
my $driver = Selenium::Remote::Driver->new(
port => $selenium_port,
remote_server_addr => $selenium_addr
);
$start = gettimeofday;
$prev_time = $start;
$driver->get($base_url."mainpage.pl");
@ -202,7 +211,7 @@ END {
sub auth {
my ( $driver, $login, $password) = @_;
fill_form( $driver, { userid => 'koha', password => 'koha' } );
fill_form( $driver, { userid => $login, password => $password } );
my $login_button = $driver->find_element('//input[@id="submit"]');
$login_button->submit();
}