diff options
author | Chris Mytton <chrism@mysociety.org> | 2020-01-29 07:55:45 +0000 |
---|---|---|
committer | Chris Mytton <chrism@mysociety.org> | 2020-01-29 07:56:32 +0000 |
commit | 23662cf0b4e55b210976e486fb7ccbd565e00a9f (patch) | |
tree | 4ff88703872f9e0b966d05ed14898dab8a13a781 | |
parent | 86c5ce6b9b0ac945d4939f132bcf7235ff3ce25f (diff) |
[Peterborough] Add test for multiple questions disabling new report form
-rw-r--r-- | .cypress/cypress/integration/peterborough.js | 34 | ||||
-rwxr-xr-x | bin/browser-tests | 4 | ||||
-rwxr-xr-x | bin/fixmystreet.com/fixture | 33 |
3 files changed, 69 insertions, 2 deletions
diff --git a/.cypress/cypress/integration/peterborough.js b/.cypress/cypress/integration/peterborough.js new file mode 100644 index 000000000..67c468be8 --- /dev/null +++ b/.cypress/cypress/integration/peterborough.js @@ -0,0 +1,34 @@ +describe('new report form', function() { + + beforeEach(function() { + cy.server(); + cy.route('/report/new/ajax*').as('report-ajax'); + cy.visit('http://peterborough.localhost:3001/'); + cy.contains('Peterborough'); + cy.get('[name=pc]').type('PE1 1HF'); + cy.get('[name=pc]').parents('form').submit(); + cy.get('#map_box').click(); + cy.wait('@report-ajax'); + }); + + it('is hidden when emergency option is yes', function() { + cy.get('select:eq(4)').select('Fallen branch'); + cy.get('#form_emergency').select('yes'); + cy.get('#js-category-stopper').should('contain', 'Please phone customer services to report this problem.'); + cy.get('.js-hide-if-invalid-category').should('be.hidden'); + cy.get('#form_emergency').select('no'); + cy.get('#js-category-stopper').should('not.contain', 'Please phone customer services to report this problem.'); + cy.get('.js-hide-if-invalid-category').should('be.visible'); + }); + + it('is hidden when private land option is yes', function() { + cy.get('select:eq(4)').select('Fallen branch'); + cy.get('#form_private_land').select('yes'); + cy.get('#js-category-stopper').should('contain', 'The council do not have powers to address issues on private land.'); + cy.get('.js-hide-if-invalid-category').should('be.hidden'); + cy.get('#form_private_land').select('no'); + cy.get('#js-category-stopper').should('not.contain', 'The council do not have powers to address issues on private land.'); + cy.get('.js-hide-if-invalid-category').should('be.visible'); + }); + +}); diff --git a/bin/browser-tests b/bin/browser-tests index 0180db0b5..04b019880 100755 --- a/bin/browser-tests +++ b/bin/browser-tests @@ -11,7 +11,7 @@ my ($cobrand, $coords, $area_id, $name, $mapit_url); BEGIN { $config_file = 'conf/general.yml-example'; - $cobrand = [ 'borsetshire', 'fixmystreet', 'northamptonshire', 'bathnes', 'buckinghamshire', 'hounslow', 'isleofwight' ]; + $cobrand = [ 'borsetshire', 'fixmystreet', 'northamptonshire', 'bathnes', 'buckinghamshire', 'hounslow', 'isleofwight', 'peterborough' ]; $coords = '51.532851,-2.284277'; $area_id = 2608; $name = 'Borsetshire'; @@ -150,7 +150,7 @@ browser-tests [running options] [fixture options] [cypress options] --help this help message Fixture option: - --cobrand Cobrand(s) to use, default is fixmystreet,northamptonshire,bathnes,buckinghamshire,isleofwight + --cobrand Cobrand(s) to use, default is fixmystreet,northamptonshire,bathnes,buckinghamshire,isleofwight,peterborough --coords Default co-ordinates for created reports --area_id Area ID to use for created body --name Name to use for created body diff --git a/bin/fixmystreet.com/fixture b/bin/fixmystreet.com/fixture index 1fa17dfad..98b086eb2 100755 --- a/bin/fixmystreet.com/fixture +++ b/bin/fixmystreet.com/fixture @@ -100,6 +100,7 @@ if ($opt->test_fixtures) { { area_id => 2397, categories => [ 'Graffiti' ], name => 'Northampton Borough Council' }, { area_id => 2483, categories => [ 'Potholes', 'Other' ], name => 'Hounslow Borough Council' }, { area_id => 2636, categories => [ 'Potholes', 'Private', 'Extra' ], name => 'Isle of Wight Council' }, + { area_id => 2566, categories => [ 'Fallen branch' ], name => 'Peterborough City Council' }, ) { $bodies->{$_->{area_id}} = FixMyStreet::DB::Factory::Body->find_or_create($_); my $cats = join(', ', @{$_->{categories}}); @@ -190,6 +191,38 @@ if ($opt->test_fixtures) { variable => 'true', }); $child_cat->update; + + $child_cat = FixMyStreet::DB->resultset("Contact")->find({ + body => $bodies->{2566}, + category => 'Fallen branch', + }); + $child_cat->set_extra_fields( + { + code => 'emergency', + datatype => 'singlevaluelist', + description => 'Is it blocking a footpath or a highway?', + order => 0, + variable => 'true', + required => 'true', + values => [ + { key => 'yes', name => 'Yes', disable => 1, disable_message => 'Please phone customer services to report this problem.' }, + { key => 'no', name => 'No' }, + ] + }, + { + code => 'private_land', + datatype => 'singlevaluelist', + description => 'Is this problem on private land?', + order => 0, + variable => 'true', + required => 'true', + values => [ + { key => 'yes', name => 'Yes', disable => 1, disable_message => 'The council do not have powers to address issues on private land.' }, + { key => 'no', name => 'No' }, + ] + } + ); + $child_cat->update; } FixMyStreet::DB::Factory::ResponseTemplate->create({ |