From b1a5a41d254bacf3064a741e53d3ab67e8c8f2d2 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 5 May 2023 11:05:04 +0000 Subject: [PATCH] Bug 32721: (QA follow-up) Add exec flag to DB update and expand tests Added tests for case of no branch specific settings and when no branch passed Signed-off-by: Nick Clemens --- .../bug_32721-add_branch_level_js.pl | 0 t/db_dependent/Template/Plugin/Branches.t | 31 ++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) mode change 100644 => 100755 installer/data/mysql/atomicupdate/bug_32721-add_branch_level_js.pl diff --git a/installer/data/mysql/atomicupdate/bug_32721-add_branch_level_js.pl b/installer/data/mysql/atomicupdate/bug_32721-add_branch_level_js.pl old mode 100644 new mode 100755 diff --git a/t/db_dependent/Template/Plugin/Branches.t b/t/db_dependent/Template/Plugin/Branches.t index 47722038ad..0c37ae0416 100755 --- a/t/db_dependent/Template/Plugin/Branches.t +++ b/t/db_dependent/Template/Plugin/Branches.t @@ -220,27 +220,42 @@ subtest 'pickup_locations() tests' => sub { subtest 'branch specific js and css' => sub { - plan tests => 2; + plan tests => 6; $schema->storage->txn_begin; - my $newbranch = $builder->build({ + my $newbranch_with = $builder->build({ source => 'Branch', value => { - branchcode => 'AAA', - branchname => 'Specific Branch', userjs => 'console.log(\'Hello World\');', usercss => 'body { background-color: blue; }' } }); + my $newbranch_none = $builder->build({ + source => 'Branch', + value => { + userjs => '', + usercss => '' + } + }); my $plugin = Koha::Template::Plugin::Branches->new(); - my $userjs = $plugin->GetBranchSpecificJS($newbranch->{branchcode}); - is($userjs, $newbranch->{userjs},'received correct JS string from function'); + my $userjs = $plugin->GetBranchSpecificJS($newbranch_with->{branchcode}); + is($userjs, $newbranch_with->{userjs},'received correct JS string from function'); + + my $usercss = $plugin->GetBranchSpecificCSS($newbranch_with->{branchcode}); + is($usercss, $newbranch_with->{usercss},'received correct CSS string from function'); + + $userjs = $plugin->GetBranchSpecificJS($newbranch_none->{branchcode}); + $usercss = $plugin->GetBranchSpecificCSS($newbranch_none->{branchcode}); + is($userjs, q{},'received correct blank string from function when branch has none'); + is($usercss, q{},'received correct blank string from function when branch has none'); - my $usercss = $plugin->GetBranchSpecificCSS($newbranch->{branchcode}); - is($usercss, $newbranch->{usercss},'received correct CSS string from function'); + $userjs = $plugin->GetBranchSpecificJS(); + $usercss = $plugin->GetBranchSpecificCSS(); + is($userjs, q{},'received correct blank string from function when no branch set'); + is($usercss, q{},'received correct blank string from function when no branch set'); $schema->storage->txn_rollback; }; -- 2.30.2