Skip to content

Commit

Permalink
[Peterborough] Fixes checking bodyclass
Browse files Browse the repository at this point in the history
bodyclass can be more than one word and this has an impact on testing
for bodyclass in templates.

Now when testing see if the string contains 'waste' rather than is exactly 'waste'

mysociety/societyworks#4012
  • Loading branch information
MorayMySoc committed Dec 7, 2023
1 parent 4b8be93 commit f3eb247
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
18 changes: 18 additions & 0 deletions t/app/controller/waste_peterborough.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ my $user2 = $mech->create_user_ok('[email protected]', name => 'Very Normal User
my $staff = $mech->create_user_ok('[email protected]', name => 'Staff User', from_body => $body->id);
$staff->user_body_permissions->create({ body => $body, permission_type => 'contribute_as_another_user' });
$staff->user_body_permissions->create({ body => $body, permission_type => 'report_mark_private' });
$staff->user_body_permissions->create({ body => $body, permission_type => 'planned_reports' });
my $super = $mech->create_user_ok('[email protected]', name => 'Super User', is_superuser => 1);

my $bromley = $mech->create_body_ok(2482, 'Bromley Council', {}, { cobrand => 'bromley' });
Expand Down Expand Up @@ -69,6 +70,23 @@ FixMyStreet::override_config {
},
}, sub {
my ($b, $jobs_fsd_get) = shared_bartec_mocks();

subtest 'Footer is shown' => sub {
$mech->get_ok('/waste');
$mech->content_contains('https://www.societyworks.org/services/waste/">SocietyWorks')
};

subtest 'Shortlist link not on WasteWorks pages' => sub {
$mech->get_ok('/');
$mech->content_lacks('Shortlist</a>');
$mech->log_in_ok($staff->email);
$mech->get_ok('/');
$mech->content_contains('Shortlist</a>');
$mech->get_ok('/waste');
$mech->content_lacks('Shortlist</a>');
$mech->log_out_ok;
};

subtest 'Missing address lookup' => sub {
$mech->get_ok('/waste');
$mech->submit_form_ok({ with_fields => { postcode => 'PE1 3NA' } });
Expand Down
2 changes: 1 addition & 1 deletion templates/web/peterborough/footer_extra.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Contact us
</a></li>
</ul>
[% IF bodyclass == 'waste' %]
[% IF bodyclass.match('waste') %]
<div class="peterborough-waste-credits">
<p>Powered by</p>
<p>
Expand Down
2 changes: 1 addition & 1 deletion templates/web/peterborough/header_logo.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<a href="https://www.peterborough.gov.uk/" id="site-logo">Peterborough City Council</a>
<a href="/[%~ IF bodyclass == 'waste' ~%]waste/[%~ END ~%]" id="report-cta" title="[%- loc('Report a problem') -%]">[%- loc('Report') -%]</a>
<a href="/[%~ IF bodyclass.match('waste') ~%]waste/[%~ END ~%]" id="report-cta" title="[%- loc('Report a problem') -%]">[%- loc('Report') -%]</a>
4 changes: 2 additions & 2 deletions templates/web/peterborough/main_nav_items.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[%~ IF bodyclass == 'waste' ~%]
[%~ IF bodyclass.match('waste') ~%]
[%~ INCLUDE navitem uri='/waste/' label=loc('Report a problem') attrs='class="report-a-problem-btn"' ~%]
[%~ ELSE ~%]
[% INCLUDE 'navigation/_report.html' %]
Expand All @@ -10,7 +10,7 @@
[%~ INCLUDE navitem uri='/auth' label=loc('Sign in') ~%]
[%~ END ~%]

[%~ IF bodyclass != 'waste' ~%]
[%~ IF NOT bodyclass.match('waste') ~%]
[%~ IF c.user_exists AND c.user.has_body_permission_to('planned_reports') ~%]
[%~ INCLUDE navitem always_url=1 uri='/my/planned' label=loc('Shortlist') ~%]
[%~ END ~%]
Expand Down

0 comments on commit f3eb247

Please sign in to comment.