diff options
author | Struan Donald <struan@exo.org.uk> | 2019-08-22 10:52:59 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2019-09-27 17:43:38 +0100 |
commit | 9d6c2382eea3fae293f1035ca249e86339f2a611 (patch) | |
tree | baa8d26e334cfd76d44481aa3c90284682db0bf7 /t/cobrand | |
parent | 863c29fda1198e06bc9e1b424532e570cb70ca37 (diff) |
[IsleOfWight] correctly handle triage categories on reports/around pages
Add in some cobrand handlers to make sure
a) the appropriate categories are show to staff/non staff users on the
around and reports pages
b) that those categories are correctly expanded to the child
categories when using the category filter to search reports
This is because non staff users should only be shown Isle of Wight
categories with a send_method of 'Triage', however once those reports
are triaged the post triage categories need to be included in any
filtering
Diffstat (limited to 't/cobrand')
-rw-r--r-- | t/cobrand/isleofwight.t | 64 |
1 files changed, 60 insertions, 4 deletions
diff --git a/t/cobrand/isleofwight.t b/t/cobrand/isleofwight.t index 414b683cd..5700e410b 100644 --- a/t/cobrand/isleofwight.t +++ b/t/cobrand/isleofwight.t @@ -47,6 +47,13 @@ my $contact2 = $mech->create_contact_ok( send_method => 'Triage', ); +my $admin_user = $mech->create_user_ok('admin-user@example.org', name => 'Admin User', from_body => $isleofwight); + +$admin_user->user_body_permissions->create({ + body => $isleofwight, + permission_type => 'triage' +}); + my @reports = $mech->create_problems_for_body(1, $isleofwight->id, 'An Isle of wight report', { confirmed => '2019-05-25 09:00', lastupdate => '2019-05-25 09:00', @@ -326,7 +333,7 @@ subtest "sends branded confirmation emails" => sub { photo1 => '', name => 'Joe Bloggs', username => 'test-1@example.com', - category => 'Potholes', + category => 'Roads', } }, "submit good details" @@ -368,8 +375,8 @@ subtest "check category extra uses correct name" => sub { order => 1, datatype_description => 'datatype', } ); - $contact->set_extra_fields( @extras ); - $contact->update; + $contact2->set_extra_fields( @extras ); + $contact2->update; my $extra_details; @@ -377,7 +384,7 @@ subtest "check category extra uses correct name" => sub { MAPIT_URL => 'http://mapit.uk/', ALLOWED_COBRANDS => ['isleofwight','fixmystreet'], }, sub { - $extra_details = $mech->get_ok_json('/report/new/category_extras?category=Potholes&latitude=50.71086&longitude=-1.29573'); + $extra_details = $mech->get_ok_json('/report/new/category_extras?category=Roads&latitude=50.71086&longitude=-1.29573'); }; like $extra_details->{category_extra}, qr/Island Roads/, 'correct name in category extras'; @@ -424,4 +431,53 @@ subtest "reports are marked for triage upon submission" => sub { }; }; +for my $cobrand ( 'fixmystreet', 'isleofwight' ) { + subtest "only categories for Triage are displayed on " . $cobrand => sub { + $mech->log_out_ok; + $mech->get_ok('/around'); + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ $cobrand ], + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->submit_form_ok( { with_fields => { pc => 'PO30 5XJ', } }, + "submit location" ); + + # click through to the report page + $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, + "follow 'skip this step' link" ); + + my $f = $mech->form_name('mapSkippedForm'); + ok $f, 'found form'; + my $cats = $f->find_input('category'); + ok $cats, 'found category element'; + my @values = $cats->possible_values; + is_deeply \@values, [ '-- Pick a category --', 'Roads' ], 'correct category list'; + }; + }; + + subtest "staff user can see non Triage categories on " . $cobrand => sub { + $mech->log_out_ok; + $mech->log_in_ok($admin_user->email); + $mech->get_ok('/around'); + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ $cobrand ], + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->submit_form_ok( { with_fields => { pc => 'PO30 5XJ', } }, + "submit location" ); + + # click through to the report page + $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, + "follow 'skip this step' link" ); + + my $f = $mech->form_name('mapSkippedForm'); + ok $f, 'found form'; + my $cats = $f->find_input('category'); + ok $cats, 'found category element'; + my @values = $cats->possible_values; + is_deeply \@values, [ '-- Pick a category --', 'Potholes' ], 'correct category list'; + }; + }; +} + done_testing(); |