Revert "Bug 21479: Zebra index can return different result"
[koha.git] / t / db_dependent / selenium / regressions.t
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 C4::Context;
21
22 use Test::More tests => 1;
23
24 use t::lib::Selenium;
25
26 eval { require Selenium::Remote::Driver; };
27 skip "Selenium::Remote::Driver is needed for selenium tests.", 1 if $@;
28
29 my $s = t::lib::Selenium->new;
30
31 my $driver = $s->driver;
32 my $opac_base_url = $s->opac_base_url;
33
34 subtest 'OPAC - Remove from cart' => sub {
35     plan tests => 4;
36
37     $driver->get( $opac_base_url . "opac-search.pl?q=d" );
38
39     # A better way to do that would be to modify the way we display the basket count
40     # We should show/hide the count instead or recreate the node
41     my @basket_count_elts = $driver->find_elements('//span[@id="basketcount"]/span');
42     is( scalar(@basket_count_elts), 0, 'Basket should be empty');
43
44     $driver->find_element('//a[@class="addtocart cart1"]')->click;
45     my $basket_count_elt = $driver->find_element('//span[@id="basketcount"]/span');
46     is( $basket_count_elt->get_text(),
47         1, 'One element should have been added to the cart' );
48
49     $driver->find_element('//a[@class="addtocart cart3"]')->click;
50     $driver->find_element('//a[@class="addtocart cart5"]')->click;
51     $basket_count_elt = $driver->find_element('//span[@id="basketcount"]/span');
52     is( $basket_count_elt->get_text(),
53         3, '3 elements should have been added to the cart' );
54
55     $driver->find_element('//a[@class="cartRemove cartR3"]')->click;
56     $basket_count_elt = $driver->find_element('//span[@id="basketcount"]/span');
57     is( $basket_count_elt->get_text(),
58         2, '1 element should have been removed from the cart' );
59 };