aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/report_new_open311.t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-08-09 17:02:58 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-08-28 13:16:39 +0100
commit22c12ab78128788bb44b8567d8735671b73b02e6 (patch)
tree11fa75561358f257accc3f321aec352cf0c6f124 /t/app/controller/report_new_open311.t
parent60629c93d6f6ebb48ba00e16abffd8df4df79abe (diff)
Remove need for category_extras ajax call.
Add by_category output to the /report/new/ajax call, containing all the data that /report/new/category_extras returns for one category. Then alter the JS to use that data immediately when needed.
Diffstat (limited to 't/app/controller/report_new_open311.t')
-rw-r--r--t/app/controller/report_new_open311.t41
1 files changed, 25 insertions, 16 deletions
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index 17b489447..7d4f5429f 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -249,13 +249,18 @@ subtest "Category extras omits description label when all fields are hidden" =>
ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
MAPIT_URL => 'http://mapit.uk/',
}, sub {
- my $json = $mech->get_ok_json('/report/new/category_extras?category=Pothole&latitude=55.952055&longitude=-3.189579');
- my $category_extra = $json->{category_extra};
- contains_string($category_extra, "usrn");
- contains_string($category_extra, "central_asset_id");
- lacks_string($category_extra, "USRN", "Lacks 'USRN' label");
- lacks_string($category_extra, "Asset ID", "Lacks 'Asset ID' label");
- lacks_string($category_extra, "resolve your problem quicker, by providing some extra detail", "Lacks description text");
+ for (
+ { url => '/report/new/ajax?' },
+ { url => '/report/new/category_extras?category=Pothole' },
+ ) {
+ my $json = $mech->get_ok_json($_->{url} . '&latitude=55.952055&longitude=-3.189579');
+ my $category_extra = $json->{by_category} ? $json->{by_category}{Pothole}{category_extra} : $json->{category_extra};
+ contains_string($category_extra, "usrn");
+ contains_string($category_extra, "central_asset_id");
+ lacks_string($category_extra, "USRN", "Lacks 'USRN' label");
+ lacks_string($category_extra, "Asset ID", "Lacks 'Asset ID' label");
+ lacks_string($category_extra, "resolve your problem quicker, by providing some extra detail", "Lacks description text");
+ }
};
};
@@ -266,15 +271,19 @@ subtest "Category extras includes description label for user" => sub {
}, sub {
$contact4->push_extra_fields({ description => 'Size?', code => 'size', required => 'true', automated => '', variable => 'true', order => '3' });
$contact4->update;
-
- my $json = $mech->get_ok_json('/report/new/category_extras?category=Pothole&latitude=55.952055&longitude=-3.189579');
- my $category_extra = $json->{category_extra};
- contains_string($category_extra, "usrn");
- contains_string($category_extra, "central_asset_id");
- lacks_string($category_extra, "USRN", "Lacks 'USRN' label");
- lacks_string($category_extra, "Asset ID", "Lacks 'Asset ID' label");
- contains_string($category_extra, "Size?");
- contains_string($category_extra, "resolve your problem quicker, by providing some extra detail", "Contains description text");
+ for (
+ { url => '/report/new/ajax?' },
+ { url => '/report/new/category_extras?category=Pothole' },
+ ) {
+ my $json = $mech->get_ok_json($_->{url} . '&latitude=55.952055&longitude=-3.189579');
+ my $category_extra = $json->{by_category} ? $json->{by_category}{Pothole}{category_extra} : $json->{category_extra};
+ contains_string($category_extra, "usrn");
+ contains_string($category_extra, "central_asset_id");
+ lacks_string($category_extra, "USRN", "Lacks 'USRN' label");
+ lacks_string($category_extra, "Asset ID", "Lacks 'Asset ID' label");
+ contains_string($category_extra, "Size?");
+ contains_string($category_extra, "resolve your problem quicker, by providing some extra detail", "Contains description text");
+ }
};
};