diff --git a/.cypress/cypress/integration/northumberland.js b/.cypress/cypress/integration/northumberland.js index 787b15124fb..a56d73f06e4 100644 --- a/.cypress/cypress/integration/northumberland.js +++ b/.cypress/cypress/integration/northumberland.js @@ -11,3 +11,51 @@ it('toggles the aerial map', function() { cy.get('.map-layer-toggle').click(); cy.get('.map-layer-toggle').should('have.class', 'aerial'); }); + +describe('Abandoned vehicle behaviour', function() { + beforeEach(function() { + cy.server(); + cy.route('/report/new/ajax*').as('report-ajax'); + cy.route('/around\?ajax*').as('update-results'); + cy.visit('http://northumberland.localhost:3001/'); + cy.contains('Northumberland'); + cy.get('[name=pc]').type('NE61 1BE'); + cy.get('[name=pc]').parents('form').submit(); + cy.wait('@update-results'); + cy.get('#map_box').click(322, 307); + cy.wait('@report-ajax'); + cy.pickCategory('Vehicle abandoned on your property'); + cy.nextPageReporting(); + }); + + it('No reg plate', function() { + cy.get('.js-reporting-page--active').contains('No').click(); + cy.nextPageReporting(); + cy.get('[name=question]').should('have.value', ''); + }); + + it('Said yes but no reg plate', function() { + cy.get('.js-reporting-page--active').contains('Yes').click(); + cy.nextPageReporting(); + cy.contains('This field is required'); + }); + + it('Gave an okay reg plate', function() { + cy.route('POST', '/report/dvla', 'fixture:bucks_dvla_ok.json').as('dvla'); + cy.get('.js-reporting-page--active').contains('Yes').click(); + cy.get('[name=dvla_reg]').type('G00D'); + cy.nextPageReporting(); + cy.wait('@dvla'); + cy.contains('White Audi, Petrol, 2016'); + cy.contains('that are taxed or have a valid MOT'); + }); + + it('Gave an untaxed reg plate', function() { + cy.route('POST', '/report/dvla', 'fixture:bucks_dvla_notok.json').as('dvla'); + cy.get('.js-reporting-page--active').contains('Yes').click(); + cy.get('[name=dvla_reg]').type('B4D'); + cy.nextPageReporting(); + cy.wait('@dvla'); + cy.get('[name=question]').invoke('val').should('include', 'B4D'); + }); +}); diff --git a/bin/fixmystreet.com/fixture b/bin/fixmystreet.com/fixture index 581a7f7403b..296043794a4 100755 --- a/bin/fixmystreet.com/fixture +++ b/bin/fixmystreet.com/fixture @@ -227,6 +227,7 @@ if ($opt->test_fixtures) { { area_id => 2488, categories => [ 'Grass verges / shrub beds - littering' , 'Pavement damage', 'Fly-tipping', 'Dog fouling'], name => 'Brent Council', cobrand => 'brent' }, { area_id => 2535, categories => [ 'Abandoned vehicles', 'Graffiti', 'Street lights'], name => 'Sandwell Borough Council' }, { area_id => 2242, categories => [ 'Abandoned vehicles', 'Graffiti', 'Street lights', 'Flooding inside a building'], name => 'Surrey County Council' }, + { area_id => 2248, categories => [ 'Vehicle abandoned on your property', 'Graffiti', 'Street lights', 'Flooding inside a building'], name => 'Northumberland County Council' }, ) { $bodies->{$_->{area_id}} = FixMyStreet::DB::Factory::Body->find_or_create($_); if ($_->{cobrand}) { @@ -322,6 +323,15 @@ if ($opt->test_fixtures) { ); $child_cat->update; + $child_cat = FixMyStreet::DB->resultset("Contact")->find({ + body => $bodies->{2248}, + category => 'Vehicle abandoned on your property', + }); + $child_cat->set_extra_fields( + {"code" => "question", "datatype" => "string", "required" => "true", "variable" => "true", "protected" => "false", "description" => "Vehicle registration number"}, + ); + $child_cat->update; + $child_cat = FixMyStreet::DB->resultset("Contact")->find({ body => $bodies->{53822}, category => 'Grass cutting', diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm index 3f61ed04269..b039ef47a66 100644 --- a/t/Mock/MapIt.pm +++ b/t/Mock/MapIt.pm @@ -122,6 +122,7 @@ my @PLACES = ( [ 'DL10 6BN', 54.45012, -1.65621, 2406, 'Richmondshire District Council', 'DIS' ], [ 'CA12 5FJ', 54.60102, -3.13648, 2274, 'Allerdale Borough Council', 'DIS' ], [ 'NE61 1BE', 55.169081, -1.691012, 2248, 'Northumberland County Council', 'UTA' ], + [ '?', 55.168943, -1.690776, 2248, 'Northumberland County Council', 'UTA' ], [ 'SG17 5TQ', 52.03553, -0.36067, 21070, 'Central Bedfordshire Council', 'UTA' ], [ '?', 51.558568, -0.207702, 2489, 'Barnet Borough Council', 'DIS' ], [ '?', 51.418776, 0.005357, 2492, 'Lewisham Borough Council', 'DIS' ], diff --git a/templates/web/northumberland/footer_extra_js.html b/templates/web/northumberland/footer_extra_js.html index 703f2e6fa2c..99492f9a256 100644 --- a/templates/web/northumberland/footer_extra_js.html +++ b/templates/web/northumberland/footer_extra_js.html @@ -1 +1 @@ -[% PROCESS 'footer_extra_js_base.html' highways=1 roadworks=1 ~%] +[% PROCESS 'footer_extra_js_base.html' highways=1 roadworks=1 dvla=1 ~%] diff --git a/web/cobrands/fixmystreet-uk-councils/dvla.js b/web/cobrands/fixmystreet-uk-councils/dvla.js index c494b0774f9..41811281792 100644 --- a/web/cobrands/fixmystreet-uk-councils/dvla.js +++ b/web/cobrands/fixmystreet-uk-councils/dvla.js @@ -20,6 +20,14 @@ const FIELDS = { 'yes': 'Y', 'no': 'N' } + }, + 'northumberland': { + 'block': 'true', + 'categories': [ + 'Vehicle abandoned on your property', + 'Vehicle being repaired on road or pavement', + ], + 'summary': 'question', } }; @@ -51,7 +59,7 @@ function dvla_lookup(e) { const yesno = document.querySelector('input[name=dvla_reg_have]:checked'); if (!yesno) return; - if (!yesno.value) { + if (!yesno.value && fields.reg) { const field = document.querySelector('input[name*="' + fields.reg + '"]'); if (field) { field.value = 'Not known'; @@ -120,19 +128,22 @@ function dvla_lookup(e) { if (data.make) make_and_colour.push(data.make); if (data.colour) make_and_colour.push(data.colour); data.make_and_colour = make_and_colour.join(' / '); + data.summary = `registration: ${reg}, make: ${data.make}, colour: ${data.colour}`; const type = data.typeApproval || ''; const wheelplan = data.wheelplan || ''; let types = TYPES[fixmystreet.cobrand]; let vehicle_type = ''; - if (type.match(/L[1-7]|motorcycle/i) || wheelplan.match(/motorcycle|moped|2 wheel/i)) { - vehicle_type = types.Motorbike; - } else if (type.match(/N1|commercial/i) || wheelplan.match(/van|commercial/i)) { - vehicle_type = types.Van; - } else if (type.match(/M1/i)) { - vehicle_type = types.Car; - } else if (type.match(/M[23]|N[23]/i) || wheelplan.match(/& artic|3 axle rigid|multi-axle rigid/i)) { - vehicle_type = types.Other; + if (types) { + if (type.match(/L[1-7]|motorcycle/i) || wheelplan.match(/motorcycle|moped|2 wheel/i)) { + vehicle_type = types.Motorbike; + } else if (type.match(/N1|commercial/i) || wheelplan.match(/van|commercial/i)) { + vehicle_type = types.Van; + } else if (type.match(/M1/i)) { + vehicle_type = types.Car; + } else if (type.match(/M[23]|N[23]/i) || wheelplan.match(/& artic|3 axle rigid|multi-axle rigid/i)) { + vehicle_type = types.Other; + } } const config = FIELDS[fixmystreet.cobrand] || {}; @@ -154,12 +165,16 @@ function dvla_lookup(e) { const height = wrapper.getBoundingClientRect().height; document.querySelector('.js-reporting-page--active').style.paddingBottom = height; } else { - ['make', 'colour', 'reg', 'make_and_colour'].forEach(name => { + ['make', 'colour', 'reg', 'make_and_colour', 'summary'].forEach(name => { if (fields[name] && data[name]) { let field = document.querySelector('input[name*="' + fields[name] + '"]'); if (field) { field.value = data[name]; } + field = document.querySelector('textarea[name*="' + fields[name] + '"]'); + if (field) { + field.value = data[name]; + } } });