aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/my_planned.t
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller/my_planned.t')
-rw-r--r--t/app/controller/my_planned.t42
1 files changed, 29 insertions, 13 deletions
diff --git a/t/app/controller/my_planned.t b/t/app/controller/my_planned.t
index fa463e61e..51ea0297e 100644
--- a/t/app/controller/my_planned.t
+++ b/t/app/controller/my_planned.t
@@ -1,15 +1,10 @@
-use strict;
-use warnings;
-
-use Test::More;
-
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
$mech->get_ok('/my/planned');
is $mech->uri->path, '/auth', "got sent to the sign in page";
-my $body = $mech->create_body_ok(2237, 'Oxfordshire');
+my $body = $mech->create_body_ok(2237, 'Oxfordshire County Council');
my ($problem) = $mech->create_problems_for_body(1, $body->id, 'Test Title');
$mech->get_ok($problem->url);
@@ -39,11 +34,11 @@ $mech->get_ok('/my/planned');
$mech->content_contains('Test Title');
$mech->get_ok($problem->url);
-$mech->content_contains('Shortlisted');
+$mech->text_contains('Shortlisted');
$mech->submit_form_ok({ with_fields => { 'shortlist-remove' => 1 } });
-$mech->content_contains('Shortlist');
+$mech->text_contains('Shortlist');
$mech->submit_form_ok({ with_fields => { 'shortlist-add' => 1 } });
-$mech->content_contains('Shortlisted');
+$mech->text_contains('Shortlisted');
$mech->get_ok('/my/planned?sort=shortlist&ajax=1');
$mech->content_contains('shortlist-up');
@@ -57,8 +52,29 @@ $mech->get_ok('/my/planned?ajax=1');
$mech->content_contains('shortlist-up');
$mech->content_contains('shortlist-down');
-done_testing();
+subtest "POSTing multiple problems to my/planned/change adds all to shortlist" => sub {
+ my ($problem1, $problem2, $problem3) = $mech->create_problems_for_body(3, $body->id, 'New Problem');
+
+ # Grab CSRF token
+ $mech->get_ok($problem1->url);
+ my ($csrf) = $mech->content =~ /meta content="([^"]*)" name="csrf-token"/;
+
+ $mech->post_ok( '/my/planned/change_multiple', {
+ 'ids[]' => [
+ $problem1->id,
+ $problem2->id,
+ $problem3->id,
+ ],
+ token => $csrf,
+ }
+ );
+
+ $mech->get_ok($problem1->url);
+ $mech->text_contains('Shortlisted');
+ $mech->get_ok($problem2->url);
+ $mech->text_contains('Shortlisted');
+ $mech->get_ok($problem3->url);
+ $mech->text_contains('Shortlisted');
+};
-END {
- $mech->delete_user($user);
-}
+done_testing();