Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
5 |
# Koha is free software; you can redistribute it and/or modify it |
6 |
# under the terms of the GNU General Public License as published by |
7 |
# the Free Software Foundation; either version 3 of the License, or |
8 |
# (at your option) any later version. |
9 |
# |
10 |
# Koha is distributed in the hope that it will be useful, but |
11 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
# GNU General Public License for more details. |
14 |
# |
15 |
# You should have received a copy of the GNU General Public License |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
17 |
|
18 |
use Modern::Perl; |
19 |
|
20 |
use Test::More tests => 2; |
21 |
|
22 |
use t::lib::Selenium; |
23 |
use C4::Context; |
24 |
|
25 |
my $superlibrarian = { |
26 |
surname => 'Super', |
27 |
firstname => 'Librarian', |
28 |
cardnumber => '143749305', |
29 |
userid => 'SuperL', |
30 |
password => 'aA1bB2cC3dD4' |
31 |
}; |
32 |
my $languages = { |
33 |
en => 'en', |
34 |
ar => 'ar-Arab', |
35 |
es => 'es-ES', |
36 |
fr => 'fr-FR', |
37 |
it => 'it-IT', |
38 |
pt_BR => 'pt-BR', |
39 |
tr => 'tr-TR', |
40 |
zh_TW => 'zh-Hans-TW' |
41 |
}; |
42 |
|
43 |
SKIP: { |
44 |
eval { require Selenium::Remote::Driver; }; |
45 |
skip "Selenium::Remote::Driver is needed for selenium tests.", 2 if $@; |
46 |
|
47 |
my $s = t::lib::Selenium->new; |
48 |
|
49 |
my $driver = $s->driver; |
50 |
my $base_url = $s->base_url; |
51 |
my $db_user = C4::Context->config('user'); |
52 |
my $db_pass = C4::Context->config('pass'); |
53 |
|
54 |
$driver->get($base_url."mainpage.pl"); |
55 |
|
56 |
my $lang = "en"; # The idea here is to loop on all languages |
57 |
|
58 |
# Welcome to the Koha web installer |
59 |
$s->fill_form({userid => $db_user, password => $db_pass }); |
60 |
$s->submit_form; |
61 |
|
62 |
# Choose your language |
63 |
$s->fill_form({ language => $languages->{$lang} }); |
64 |
$s->submit_form; |
65 |
|
66 |
# Check Perl dependencies |
67 |
$s->submit_form; |
68 |
|
69 |
# Database settings |
70 |
$s->submit_form; |
71 |
|
72 |
# Database settings |
73 |
# Connection established |
74 |
$s->driver->find_element('//div[@class="alert alert-success"]'); |
75 |
$s->submit_form; |
76 |
|
77 |
# Set up database |
78 |
$s->submit_form; |
79 |
|
80 |
# Success |
81 |
# Database tables created |
82 |
$s->driver->find_element('//div[@class="alert alert-success"]'); |
83 |
$s->submit_form; |
84 |
|
85 |
# Install basic configuration settings |
86 |
$s->submit_form; |
87 |
|
88 |
# Select your MARC flavor |
89 |
$s->fill_form({ marcflavour => 'MARC21' }); |
90 |
$s->submit_form; |
91 |
|
92 |
# Selecting default settings |
93 |
# Do not check otherwise no onboarding |
94 |
#my @checkboxes = $driver->find_elements('//input[@type="checkbox" and not(@checked="checked")]'); |
95 |
#for my $c ( @checkboxes ) { |
96 |
# $c->click; |
97 |
#} |
98 |
$s->submit_form; |
99 |
|
100 |
# Default data loaded |
101 |
$s->submit_form; |
102 |
|
103 |
#$s->submit_form; |
104 |
$s->click( { href => '/installer/onboarding.pl', main => 'installer-step3' } ); |
105 |
|
106 |
# Create a library |
107 |
$s->fill_form({ branchcode => 'CPL', branchname => 'Centerville' }); |
108 |
$s->submit_form; |
109 |
|
110 |
# Library created! |
111 |
$s->driver->find_element('//div[@class="alert alert-success"]'); |
112 |
# Create a patron category |
113 |
$s->fill_form({ categorycode => 'S', description => 'Staff', enrolmentperiod => 12 }); |
114 |
$s->submit_form; |
115 |
|
116 |
# Patron category created! |
117 |
$s->driver->find_element('//div[@class="alert alert-success"]'); |
118 |
# Create Koha administrator patron |
119 |
$s->fill_form({ %$superlibrarian, password2 => $superlibrarian->{password} }); |
120 |
$s->submit_form; |
121 |
|
122 |
#Administrator account created! |
123 |
$s->driver->find_element('//div[@class="alert alert-success"]'); |
124 |
# Create a new item type |
125 |
$s->fill_form({ itemtype => 'BK', description => 'Book' }); |
126 |
$s->submit_form; |
127 |
|
128 |
# New item type created! |
129 |
$s->driver->find_element('//div[@class="alert alert-success"]'); |
130 |
# Create a new circulation rule |
131 |
# Keep default values |
132 |
$s->submit_form; |
133 |
|
134 |
# Get the interface in the correct language |
135 |
C4::Context->set_preference('language', $languages->{$lang} ); |
136 |
C4::Context->set_preference('opaclanguages', $languages->{$lang} ); |
137 |
|
138 |
$s->click( { href => '/mainpage.pl', main => 'onboarding-step5' } ); |
139 |
|
140 |
$s->fill_form({ userid => $superlibrarian->{userid}, password => $superlibrarian->{password} }); |
141 |
|
142 |
like( $s->driver->get_title, qr(Log in to Koha), 'After the onboarding process the user should have landed in the login form page'); |
143 |
$s->submit_form; |
144 |
|
145 |
is( $s->driver->get_title, 'Koha staff client', 'The credentials we created should work'); |
146 |
|
147 |
$driver->quit(); |
148 |
}; |