diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-12-06 15:59:05 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-12-08 09:29:58 +0000 |
commit | 0e84e1a8f51af275b1b0e8400d23b6dffeb4303c (patch) | |
tree | 1694917f7d0515324d81ae44ac97e709b1054e56 | |
parent | fda50e07fc671eefa68257fbc9d9bdea63dd4b0f (diff) |
[fixmystreet.com] More categories in fixture.
-rw-r--r-- | .cypress/cypress/integration/category_tests.js | 27 | ||||
-rwxr-xr-x | bin/fixmystreet.com/fixture | 35 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Factories.pm | 20 |
3 files changed, 71 insertions, 11 deletions
diff --git a/.cypress/cypress/integration/category_tests.js b/.cypress/cypress/integration/category_tests.js index a40ec3fcd..8bd21acaa 100644 --- a/.cypress/cypress/integration/category_tests.js +++ b/.cypress/cypress/integration/category_tests.js @@ -6,6 +6,31 @@ describe('Basic categories', function() { cy.get('[name=pc]').parents('form').submit(); }); + var categories = [ + '-- Pick a category --', + 'Abandoned vehicles', + 'Bins', + 'Bus stops', + 'Dog fouling', + 'Flyposting', + 'Flytipping', + 'Footpath/bridleway away from road', + 'Graffiti', + 'Parks/landscapes', + 'Pavements', + 'Potholes', + 'Public toilets', + 'Road traffic signs', + 'Roads/highways', + 'Rubbish (refuse and recycling)', + 'Street cleaning', + 'Street lighting', + 'Street nameplates', + 'Traffic lights', + 'Trees', + 'Other' + ]; + it('category dropdown contains the expected values', function() { cy.server(); cy.route('/report/new/ajax*').as('report-ajax'); @@ -13,7 +38,6 @@ describe('Basic categories', function() { cy.get('#map_box').click(210, 200); cy.wait('@report-ajax'); cy.get('[name=category]').should('not.be.visible'); - var categories = ['-- Pick a category --', 'Bins', 'Graffiti', 'Potholes', 'Street lighting', 'Other' ]; cy.get('select:eq(3) option').each(function (obj, i) { expect(obj[0].value).to.equal(categories[i]); }); @@ -29,7 +53,6 @@ describe('Basic categories', function() { cy.route('/report/new/ajax*').as('report-ajax'); cy.visit('/report/new?latitude=51.496194&longitude=-2.603482'); cy.get('[name=category]').should('not.be.visible'); - var categories = ['-- Pick a category --', 'Bins', 'Graffiti', 'Potholes', 'Street lighting', 'Other' ]; cy.get('select:eq(1) option').each(function (obj, i) { expect(obj[0].value).to.equal(categories[i]); }); diff --git a/bin/fixmystreet.com/fixture b/bin/fixmystreet.com/fixture index 1ca840c71..52e38e2aa 100755 --- a/bin/fixmystreet.com/fixture +++ b/bin/fixmystreet.com/fixture @@ -38,7 +38,28 @@ print($usage->text), exit if $opt->help; FixMyStreet::DB::Factories->setup($opt); # Body + categories -my $categories = ['Potholes', 'Street lighting', 'Graffiti', 'Other']; +my $categories = [ + 'Abandoned vehicles', + 'Bus stops', + 'Dog fouling', + 'Flyposting', + 'Flytipping', + 'Footpath/bridleway away from road', + 'Graffiti', + 'Parks/landscapes', + 'Pavements', + 'Potholes', + 'Public toilets', + 'Roads/highways', + 'Road traffic signs', + 'Rubbish (refuse and recycling)', + 'Street cleaning', + 'Street lighting', + 'Street nameplates', + 'Traffic lights', + 'Trees', + 'Other', +]; my $body = FixMyStreet::DB::Factory::Body->find_or_create({ area_id => $opt->area_id, categories => $categories, @@ -131,7 +152,7 @@ foreach (FixMyStreet::Cobrand->available_cobrand_classes) { FixMyStreet::PhotoStorage::backend->init(); my $user = $users{'user@example.org'}; -my $num = $opt->nonrandom ? 21 : 20; +my $num = $opt->nonrandom ? 21 : 50; say "Created $num problems around '$location' in cobrand '$cobrand'"; my $confirmed = DateTime->today->subtract(days => 1)->add(hours => 8); @@ -182,7 +203,7 @@ for (0..$num-1) { }); } -for (1..3) { +for (1..5) { my $p = $problems->[int(rand(@$problems))]; $users{'inspector@example.org'}->add_to_planned_reports($p); } @@ -201,7 +222,7 @@ my @fixed_user = ( my @problems = $opt->nonrandom ? @$problems : shuffle(@$problems); -my @range = $opt->nonrandom ? (1, 7, 12) : (1..3); +my @range = $opt->nonrandom ? (1, 7, 12) : (1..10); for (@range) { my $problem = $problems[$_]; $confirmed->add(seconds => rand(10000)); @@ -259,11 +280,11 @@ my @open_user = ( 'Ongoing issue.', 'Council rang to say they’re aware and it’s on their list.', 'Still awaiting news on this one.', - 'Council let me know it’s not a top priority, which TBH I do understand now they’ve talked it through.', + 'Council let me know it’s not a top priority, which TBH I do understand now they’ve talked it through.', ); my $updates = []; -@range = $opt->nonrandom ? (13, 8, 2) : (5..9); +@range = $opt->nonrandom ? (13, 8, 2) : (11..20); for my $i (@range) { $confirmed->add(seconds => rand(10000)); my @range_u = $opt->nonrandom ? (1..$i) : (1); @@ -277,7 +298,7 @@ for my $i (@range) { } # Some not responsible updates -@range = $opt->nonrandom ? (3, 9, 20) : (11..13); +@range = $opt->nonrandom ? (3, 9, 20) : (21..25); for (@range) { my $problem = $problems[$_]; $confirmed->add(seconds => rand(10000)); diff --git a/perllib/FixMyStreet/DB/Factories.pm b/perllib/FixMyStreet/DB/Factories.pm index b66b27c5d..4cbab4753 100644 --- a/perllib/FixMyStreet/DB/Factories.pm +++ b/perllib/FixMyStreet/DB/Factories.pm @@ -94,9 +94,25 @@ sub data { my $self = shift; my %titles = ( + 'Abandoned vehicles' => ['Car on pavement, has been there for months', 'Silver car outside house, never used'], + 'Bus stops' => ['Bus stop sign wonky', 'Information board broken'], + 'Dog fouling' => ['Bad dog fouling in alley way', 'Inconsiderate dog owner' ], + 'Flyposting' => ['Fence by road covered in posters', 'Under the bridge is a poster haven'], + 'Flytipping' => ['Flytipping on country lane', 'Ten bags of rubbish'], + 'Footpath/bridleway away from road' => ['Vehicle blocking footpath'], + 'Graffiti' => ['Graffiti', 'Graffiti', 'Offensive graffiti', 'Graffiti on the bridge', 'Remove graffiti'], + 'Parks/landscapes' => ['Full litter bins', 'Allotment gate needs repair'], + 'Pavements' => ['Hedge encroaching pavement', 'Many cracked slabs on street corner'], 'Potholes' => ['Deep pothole', 'Small pothole', 'Pothole in cycle lane', 'Pothole on busy pavement', 'Large pothole', 'Sinking manhole'], + 'Public toilets' => ['Door will not open'], + 'Roads/highways' => ['Restricted sight line by zig-zag lines', 'Missing lane markings'], + 'Road traffic signs' => ['Bent sign', 'Zebra crossing', 'Bollard missing'], + 'Rubbish (refuse and recycling)' => ['Missing bin', 'Bags left uncollected'], + 'Street cleaning' => ['Two abandoned trollies', 'Yet more litter'], 'Street lighting' => ['Faulty light', 'Street light not working', 'Lights out in tunnel', 'Light not coming on', 'Light not going off'], - 'Graffiti' => ['Graffiti', 'Graffiti', 'Offensive graffiti', 'Graffiti on the bridge', 'Remove graffiti'], + 'Street nameplates' => ['Broken nameplate', 'Missing nameplate'], + 'Traffic lights' => ['Out of sync lights', 'Always on green', 'Broken light'], + 'Trees' => ['Young tree damaged', 'Tree looks dangerous in wind'], 'Other' => ['Loose drain cover', 'Flytipping on country lane', 'Vehicle blocking footpath', 'Hedge encroaching pavement', 'Full litter bins'], ); my %photos = ( @@ -172,7 +188,7 @@ sub create_problem { $params->{latitude} += rand(2 * $inaccurate_km) - $inaccurate_km; $params->{longitude} += rand(3 * $inaccurate_km) - 1.5 * $inaccurate_km, $params->{title} ||= $titles->[$rand]; - $params->{detail} ||= $descs->[$rand]; + $params->{detail} ||= $descs->[$rand] || 'Please deal with this issue, thank you.'; $params->{photo_id} = $photo; $params->{confirmed} = DateTime::Format::Pg->format_datetime($params->{confirmed}); return $self->create($params); |