From f859c30704f868b11e0b5bbfb8185d4966ba0606 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 28 Feb 2024 10:13:08 +0100 Subject: [PATCH] Bug 34478: Fix www/auth_values_input_www.t See bug 36189, we need to rewrite this using Selenium. Signed-off-by: Jonathan Druart --- t/db_dependent/www/auth_values_input_www.t | 44 +--------------------- 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/t/db_dependent/www/auth_values_input_www.t b/t/db_dependent/www/auth_values_input_www.t index 78255b3f2b..6a5fecd709 100755 --- a/t/db_dependent/www/auth_values_input_www.t +++ b/t/db_dependent/www/auth_values_input_www.t @@ -49,7 +49,7 @@ elsif (not defined $intranet) { plan skip_all => "Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n"; } else { - plan tests => 34; + plan tests => 30; } my $dbh = C4::Context->dbh; @@ -57,7 +57,7 @@ my $dbh = C4::Context->dbh; $intranet =~ s#/$##; my $agent = Test::WWW::Mechanize->new( autocheck => 1 ); -my ($category, $expected_base, $add_form_link_exists, $delete_form_link_exists); +my ($category, $expected_base, $add_form_link_exists); # -------------------------------------------------- LOGIN @@ -102,18 +102,13 @@ $agent->click_ok( '', "Create a new value for the category" ); $agent->base_like(qr|$expected_base|, "check base"); $add_form_link_exists = 0; -$delete_form_link_exists = 0; my $add_form_re = q|authorised_values.pl\?op=add_form&category=| . uri_escape_utf8($category); -my $delete_re = q|authorised_values.pl\?op=delete&searchfield=| . uri_escape_utf8($category); for my $link ( $agent->links() ) { if ( $link->url =~ qr|$add_form_re| ) { $add_form_link_exists = 1; - } elsif ( $link->url =~ qr|$delete_re| ) { - $delete_form_link_exists = 1; } } is( $add_form_link_exists, 1, 'Add a new category button should be displayed'); -is( $delete_form_link_exists, 1, ''); $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl", 'Return to Authorized values page' ); $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?searchfield=" . uri_escape_utf8($category) . "&offset=0", 'Search the values inserted' ); @@ -123,21 +118,6 @@ ok ( ( length(Encode::encode('UTF-8', $text)) != length($text) ) , 'UTF-8 are mu ok ($text =~ m/学協会μμ/, 'UTF-8 (Asia) chars are correctly present. Good'); ok ($text =~ m/επιμεq/, 'UTF-8 (Greek) chars are correctly present. Good'); ok ($text =~ m/😀/, 'UTF-8 (emoji) chars are correctly present. Good'); -my @links = $agent->links; -my $id_to_del =''; -$delete_re = q|op=delete\&searchfield=| . uri_escape_utf8($category) . '\&id=(\d+)'; -foreach my $dato (@links){ - my $link = $dato->url; - if ($link =~ qr|$delete_re| ) { - $id_to_del = $1; - last; - } -} -if ($id_to_del) { - $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?op=delete&searchfield=" . uri_escape_utf8($category) . "&id=$id_to_del", 'UTF_8 auth. value deleted' ); -}else{ - ok($id_to_del ne undef, "error, link to delete not working"); -} Koha::AuthorisedValueCategories->find($category)->delete; # Clean up @@ -164,18 +144,13 @@ $agent->click_ok( '', "Create a new value for the category" ); $expected_base = q|authorised_values.pl|; $agent->base_like(qr|$expected_base|, "check base"); $add_form_link_exists = 0; -$delete_form_link_exists = 0; $add_form_re = q|authorised_values.pl\?op=add_form&category=| . uri_escape_utf8($category); -$delete_re = q|authorised_values.pl\?op=delete&searchfield=| . uri_escape_utf8($category); for my $link ( $agent->links() ) { if ( $link->url =~ qr|$add_form_re| ) { $add_form_link_exists = 1; - }elsif( $link->url =~ qr|$delete_re| ) { - $delete_form_link_exists = 1; } } is( $add_form_link_exists, 1, ); -is( $delete_form_link_exists, 1, ); $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl", 'Return to Authorized values page' ); $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?searchfield=tòmas&offset=0", 'Search the values inserted' ); @@ -184,20 +159,5 @@ my $text2 = $agent->text() ; ok ( ( length(Encode::encode('UTF-8', $text)) != length($text) ) , 'UTF-8 are multi-byte. Good') ; ok ($text2 =~ m/tòmas/, 'UTF-8 not Latin-1 first test is OK. Good'); ok ($text2=~ m/ràmen/, 'UTF-8 not Latin-1 second test is OK. Good'); -my @links2 = $agent->links; -my $id_to_del2 =''; -$delete_re = q|op=delete\&searchfield=| . uri_escape_utf8($category) . q|\&id=(\d+)|; -foreach my $dato (@links2){ - my $link = $dato->url; - if ($link =~ qr|$delete_re| ){ - $id_to_del2 = $1; - last; - } -} -if ($id_to_del2) { - $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?op=delete&searchfield=tòmas&id=$id_to_del2", 'UTF_8 auth. value deleted' ); -}else{ - ok($id_to_del2 ne undef, "error, link to delete not working"); -} Koha::AuthorisedValueCategories->find($category)->delete; # Clean up -- 2.39.5