aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-08-30 15:53:31 +0100
committerMatthew Somerville <matthew@mysociety.org>2019-09-05 12:00:09 +0100
commitb8916dcf8e8eeefea426a4725601bbd22263848e (patch)
tree397e6d5e7626a49f8f051ec7286ff02183dfaa9d /t/app/controller
parentcd405cc208bd1efa36c0ab6e7d5af7e4e56be733 (diff)
Improve user flow when JavaScript is not available
This improves the reporting journey to only ask for category, and then category extra questions if appropriate, first, so that if the choice would lead to the form being disabled, this can be shown immediately.
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/report_new_open311.t47
1 files changed, 47 insertions, 0 deletions
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index b52e0af18..52f1ddc6e 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -62,6 +62,12 @@ my $contact4 = $mech->create_contact_ok(
{ description => 'Asset ID', code => 'central_asset_id', required => 'true', automated => 'hidden_field', variable => 'true', order => '2' },
] },
);
+# Another one to switch to in disable form test
+$mech->create_contact_ok(
+ body_id => $body2->id, # Edinburgh
+ category => 'Something Other',
+ email => '104',
+);
# test that the various bit of form get filled in and errors correctly
# generated.
@@ -310,6 +316,47 @@ subtest "Category extras includes form disabling string" => sub {
answers => [ 'yes' ],
};
}
+
+ # Test new non-JS form disabling flow
+ $mech->get_ok('/report/new?latitude=55.952055&longitude=-3.189579');
+ $mech->content_contains('name="submit_category_part_only"');
+ $mech->submit_form_ok({ with_fields => { category => 'Pothole' } });
+ $mech->content_contains('<div id="js-category-stopper" class="box-warning" role="alert" aria-live="assertive">');
+ $mech->content_contains('Please ring us!');
+ # Switch to another, okay, category
+ $mech->submit_form_ok({ with_fields => { category => 'Something Other' } });
+ $mech->content_lacks('<div id="js-category-stopper" class="box-warning" role="alert" aria-live="assertive">');
+ $mech->content_lacks('Please ring us!');
+
+ # Remove the required extra field so its error checking doesn't get in the way
+ my $extra = $contact4->get_extra_fields;
+ @$extra = grep { $_->{code} ne 'size' } @$extra;
+ $contact4->set_extra_fields(@$extra);
+ $contact4->update;
+
+ # Test submission of whole form, switching back to a blocked category at the same time
+ $mech->submit_form_ok({ with_fields => {
+ category => 'Pothole', title => 'Title', detail => 'Detail',
+ username => 'testing@example.org', name => 'Testing Example',
+ } });
+ $mech->content_contains('<div id="js-category-stopper" class="box-warning" role="alert" aria-live="assertive">');
+ $mech->content_contains('Please ring us!');
+
+ # Test special answer disabling of form
+ $extra = $contact4->get_extra_fields;
+ @$extra = grep { $_->{code} ne 'ring' } @$extra; # Remove that all-category one
+ $contact4->set_extra_fields(@$extra);
+ $contact4->update;
+ $mech->get_ok('/report/new?latitude=55.952055&longitude=-3.189579');
+ $mech->content_contains('name="submit_category_part_only"');
+ $mech->submit_form_ok({ with_fields => { category => 'Pothole' } });
+ $mech->content_contains('name="submit_category_part_only"');
+ $mech->submit_form_ok({ with_fields => { dangerous => 'no' } });
+ $mech->content_lacks('<div id="js-category-stopper" class="box-warning" role="alert" aria-live="assertive">');
+ $mech->content_lacks('Please please ring');
+ $mech->submit_form_ok({ with_fields => { dangerous => 'yes' } });
+ $mech->content_contains('<div id="js-category-stopper" class="box-warning" role="alert" aria-live="assertive">');
+ $mech->content_contains('Please please ring');
};
};