aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/admin/reportextrafields.t
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller/admin/reportextrafields.t')
-rw-r--r--t/app/controller/admin/reportextrafields.t122
1 files changed, 56 insertions, 66 deletions
diff --git a/t/app/controller/admin/reportextrafields.t b/t/app/controller/admin/reportextrafields.t
index 070e3e2fc..1714e8521 100644
--- a/t/app/controller/admin/reportextrafields.t
+++ b/t/app/controller/admin/reportextrafields.t
@@ -62,13 +62,12 @@ FixMyStreet::override_config {
$mech->get_ok("/admin/body/" . $body->id . "/" . $contact->category);
$mech->submit_form_ok( { with_fields => {
- "metadata[0].order" => "1",
- "metadata[0].code" => "string_test",
- "metadata[0].required" => "on",
- "metadata[0].notice" => "",
- "metadata[0].description" => "this is a test description",
- "metadata[0].datatype_description" => "hint here",
- "metadata[0].datatype" => "string",
+ "metadata[9999].order" => "1",
+ "metadata[9999].code" => "string_test",
+ "metadata[9999].required" => 1,
+ "metadata[9999].behaviour" => "question",
+ "metadata[9999].description" => "this is a test description",
+ "metadata[9999].datatype" => "string",
"note" => "Added extra field",
}});
$mech->content_contains('Values updated');
@@ -80,26 +79,21 @@ FixMyStreet::override_config {
variable => "true",
protected => "false",
description => "this is a test description",
- datatype_description => "hint here",
datatype => "string",
- disable_form => "false",
};
$contact->discard_changes;
is_deeply $contact->get_extra_fields, $contact_extra_fields, 'new string field was added';
-
$mech->get_ok("/admin/body/" . $body->id . "/" . $contact->category);
$mech->submit_form_ok( { with_fields => {
- "metadata[1].order" => "2",
- "metadata[1].code" => "list_test",
- "metadata[1].required" => undef,
- "metadata[1].notice" => "",
- "metadata[1].disable_form" => "on",
- "metadata[1].description" => "this field is a list",
- "metadata[1].datatype_description" => "",
- "metadata[1].datatype" => "list",
- "metadata[1].values[0].key" => "key1",
- "metadata[1].values[0].name" => "name1",
+ "metadata[9999].order" => "2",
+ "metadata[9999].code" => "list_test",
+ "metadata[9999].required" => undef,
+ "metadata[9999].behaviour" => "question",
+ "metadata[9999].description" => "this field is a list",
+ "metadata[9999].datatype" => "singlevaluelist",
+ "metadata[9999].values[8888].key" => "key1",
+ "metadata[9999].values[8888].name" => "name1",
"note" => "Added extra list field",
}});
$mech->content_contains('Values updated');
@@ -110,9 +104,7 @@ FixMyStreet::override_config {
required => "false",
variable => "true",
protected => "false",
- disable_form => "true",
description => "this field is a list",
- datatype_description => "",
datatype => "singlevaluelist",
values => [
{ name => "name1", key => "key1" },
@@ -121,6 +113,28 @@ FixMyStreet::override_config {
$contact->discard_changes;
is_deeply $contact->get_extra_fields, $contact_extra_fields, 'new list field was added';
+ $mech->get_ok("/admin/body/" . $body->id . "/" . $contact->category);
+ $mech->submit_form_ok( { with_fields => {
+ "metadata[9999].order" => "3",
+ "metadata[9999].code" => "emergency",
+ "metadata[9999].behaviour" => "notice",
+ "metadata[9999].disable_form" => "1",
+ "metadata[9999].description" => "please ring",
+ "note" => "Added notice field",
+ }});
+ $mech->content_contains('Values updated');
+
+ push @$contact_extra_fields, {
+ order => "3",
+ code => "emergency",
+ protected => "false",
+ description => "please ring",
+ disable_form => 'true',
+ variable => 'false',
+ };
+ $contact->discard_changes;
+ is_deeply $contact->get_extra_fields, $contact_extra_fields, 'new field was added';
+
$contact->set_extra_fields();
$contact->update;
};
@@ -142,13 +156,7 @@ FixMyStreet::override_config {
is $contact->email, 'test4@example.com', 'contact updated';
is_deeply $meta_data, [ {
order => 0,
- datatype => 'string',
- datatype_description => '',
- description => '',
- required => 'false',
- variable => 'true',
protected => 'false',
- disable_form => 'false',
code => 'POT',
automated => 'server_set'
} ], "automated fields not unset";
@@ -168,13 +176,12 @@ FixMyStreet::override_config {
name => "Test extra fields",
cobrand => "tester",
language => undef,
- "metadata[0].order" => "1",
- "metadata[0].code" => "string_test",
- "metadata[0].required" => "on",
- "metadata[0].notice" => "",
- "metadata[0].description" => "this is a test description",
- "metadata[0].datatype_description" => "hint here",
- "metadata[0].datatype" => "string",
+ "metadata[9999].order" => "1",
+ "metadata[9999].code" => "string_test",
+ "metadata[9999].required" => 1,
+ "metadata[9999].behaviour" => "question",
+ "metadata[9999].description" => "this is a test description",
+ "metadata[9999].datatype" => "string",
}});
is $model->count, 1, 'new ReportExtraFields created';
@@ -185,9 +192,7 @@ FixMyStreet::override_config {
required => "true",
variable => "true",
protected => "false",
- disable_form => "false",
description => "this is a test description",
- datatype_description => "hint here",
datatype => "string",
};
is_deeply $object->get_extra_fields, $extra_fields, 'new string field was added';
@@ -197,15 +202,14 @@ FixMyStreet::override_config {
$mech->get_ok("/admin/reportextrafields/" . $object->id);
$mech->submit_form_ok( { with_fields => {
"language" => "en-gb",
- "metadata[1].order" => "2",
- "metadata[1].code" => "list_test",
- "metadata[1].required" => undef,
- "metadata[1].notice" => "",
- "metadata[1].description" => "this field is a list",
- "metadata[1].datatype_description" => "",
- "metadata[1].datatype" => "list",
- "metadata[1].values[0].key" => "key1",
- "metadata[1].values[0].name" => "name1",
+ "metadata[9999].order" => "2",
+ "metadata[9999].code" => "list_test",
+ "metadata[9999].required" => undef,
+ "metadata[9999].behaviour" => "question",
+ "metadata[9999].description" => "this field is a list",
+ "metadata[9999].datatype" => "singlevaluelist",
+ "metadata[9999].values[8888].key" => "key1",
+ "metadata[9999].values[8888].name" => "name1",
}});
push @$extra_fields, {
@@ -214,9 +218,7 @@ FixMyStreet::override_config {
required => "false",
variable => "true",
protected => "false",
- disable_form => "false",
description => "this field is a list",
- datatype_description => "",
datatype => "singlevaluelist",
values => [
{ name => "name1", key => "key1" },
@@ -229,26 +231,16 @@ FixMyStreet::override_config {
$mech->get_ok("/admin/reportextrafields/" . $object->id);
$mech->submit_form_ok({ with_fields => {
- "metadata[2].order" => "3",
- "metadata[2].code" => "automated_test",
- "metadata[2].required" => undef,
- "metadata[2].notice" => "",
- "metadata[2].description" => "",
- "metadata[2].datatype_description" => "",
- "metadata[2].datatype" => "string",
- "metadata[2].automated" => "server_set",
+ "metadata[9999].order" => "3",
+ "metadata[9999].code" => "automated_test",
+ "metadata[9999].required" => undef,
+ "metadata[9999].behaviour" => "server",
}});
push @$extra_fields, {
order => "3",
code => "automated_test",
- required => "false",
- variable => "true",
protected => "false",
- disable_form => "false",
- description => "",
- datatype_description => "",
- datatype => "string",
automated => "server_set",
};
@@ -258,8 +250,8 @@ FixMyStreet::override_config {
$mech->get_ok("/admin/reportextrafields/" . $object->id);
$mech->submit_form_ok( { with_fields => {
- "metadata[1].values[1].key" => "key2",
- "metadata[1].values[1].name" => "name2",
+ "metadata[1].values[8888].key" => "key2",
+ "metadata[1].values[8888].name" => "name2",
}});
push @{$extra_fields->[1]->{values}}, { name => "name2", key => "key2" };
@@ -333,7 +325,6 @@ subtest 'Reports are created with correct extra metadata' => sub {
required => "true",
variable => "true",
description => "this is a test description",
- datatype_description => "hint here",
datatype => "string",
});
$extra_fields->push_extra_fields({
@@ -342,7 +333,6 @@ subtest 'Reports are created with correct extra metadata' => sub {
required => "false",
variable => "true",
description => "this field is a list",
- datatype_description => "",
datatype => "singlevaluelist",
values => [
{ name => "name1", key => "key1" },