3 # This file is part of Koha.
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.
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.
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>.
20 use Test::More tests => 2;
25 my $superlibrarian = {
27 firstname => 'Librarian',
28 cardnumber => '143749305',
30 password => 'aA1bB2cC3dD4'
44 eval { require Selenium::Remote::Driver; };
45 skip "Selenium::Remote::Driver is needed for selenium tests.", 2 if $@;
47 my $s = t::lib::Selenium->new;
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');
54 $driver->get($base_url."mainpage.pl");
56 my $lang = "en"; # The idea here is to loop on all languages
58 $driver->set_window_size(3840,1080);
59 # Welcome to the Koha web installer
60 $s->fill_form({userid => $db_user, password => $db_pass });
63 # Choose your language
64 $s->fill_form({ language => $languages->{$lang} });
67 # Check Perl dependencies
74 # Connection established
75 $s->driver->find_element('//div[@class="alert alert-success"]');
82 # Database tables created
83 $s->driver->find_element('//div[@class="alert alert-success"]');
86 # Install basic configuration settings
89 # Select your MARC flavor
90 $s->fill_form({ marcflavour => 'MARC21' });
93 # Selecting default settings
94 # Do not check otherwise no onboarding
95 #my @checkboxes = $driver->find_elements('//input[@type="checkbox" and not(@checked="checked")]');
96 #for my $c ( @checkboxes ) {
101 for (1..20){ # FIXME This is really ugly, but for an unknown reason the next submit_form is resubmitting the same form. So waiting for the next page to be effectively loaded
102 my $title = $s->driver->get_title;
103 last if $title =~ m|Default data loaded|;
107 # Default data loaded
110 $s->click( { href => '/installer/onboarding.pl', main => 'installer-step3' } );
113 $s->fill_form({ branchcode => 'CPL', branchname => 'Centerville' });
117 $s->driver->find_element('//div[@class="alert alert-success"]');
118 # Create a patron category
119 $s->fill_form({ categorycode => 'S', description => 'Staff', enrolmentperiod => 12 });
122 # Patron category created!
123 $s->driver->find_element('//div[@class="alert alert-success"]');
124 # Create Koha administrator patron
125 $s->fill_form({ %$superlibrarian, password2 => $superlibrarian->{password} });
128 #Administrator account created!
129 $s->driver->find_element('//div[@class="alert alert-success"]');
130 # Create a new item type
131 $s->fill_form({ itemtype => 'BK', description => 'Book' });
134 # New item type created!
135 $s->driver->find_element('//div[@class="alert alert-success"]');
136 # Create a new circulation rule
137 # Keep default values
140 # Get the interface in the correct language
141 C4::Context->set_preference('language', $languages->{$lang} );
142 C4::Context->set_preference('opaclanguages', $languages->{$lang} );
144 $s->click( { href => '/mainpage.pl', main => 'onboarding-step5' } );
146 $s->fill_form({ userid => $superlibrarian->{userid}, password => $superlibrarian->{password} });
148 like( $s->driver->get_title, qr(Log in to Koha), 'After the onboarding process the user should have landed in the login form page');
151 is( $s->driver->get_title, 'Koha staff interface', 'The credentials we created should work');