Bug 42330: Add an xt test to prevent new occurrences of <main> in staff templates

Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Jonathan Druart 2026-06-16 15:41:59 +02:00 committed by Pedro Amorim
parent 248c0fe224
commit 210aa964f0
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,53 @@
#!/usr/bin/perl
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <https://www.gnu.org/licenses>.
use Modern::Perl;
use File::Slurp qw( read_file );
use Test::More;
use Array::Utils qw( array_minus );
use Test::NoWarnings;
use Koha::Devel::Files;
my $dev_files = Koha::Devel::Files->new( { context => 'core' } );
my @tt_files = $dev_files->ls_tt_files;
# Only for staff
@tt_files = grep {m{/intranet-tmpl/}} @tt_files;
my @exceptions = qw(
koha-tmpl/intranet-tmpl/prog/en/includes/main-container.inc
koha-tmpl/intranet-tmpl/prog/en/includes/wrapper-staff-tool-plugin.inc
);
@tt_files = array_minus( @tt_files, @exceptions );
plan tests => scalar(@tt_files) + 1;
for my $file (@tt_files) {
my @lines = read_file($file);
my ( $has_main, $has_main_container_fluid );
for my $line (@lines) {
#$has_main_container_fluid = 1 if $line =~ m{<div class="main container-fluid">};
$has_main = 1 if $line =~ m{<main>};
}
ok( !$has_main, qq{$file has '<main>', it must use main-container.inc instead.} );
#is( $has_main_container_fluid, 0, qq{$file has '<div class="main container-fluid">', it must use main-container.inc instead.} );
}