diff options
| -rw-r--r-- | .cypress/cypress.json | 5 | ||||
| -rw-r--r-- | .cypress/cypress/integration/bathnes.js | 10 | ||||
| -rw-r--r-- | .cypress/cypress/integration/regressions.js | 6 | ||||
| -rw-r--r-- | .cypress/cypress/integration/responsive.js | 6 | ||||
| -rw-r--r-- | .cypress/cypress/integration/simple_spec.js | 4 | ||||
| -rwxr-xr-x | bin/browser-tests | 34 | ||||
| -rw-r--r-- | templates/web/base/report/new/form_report.html | 2 | ||||
| -rw-r--r-- | templates/web/base/report/new/form_user.html | 2 | ||||
| -rw-r--r-- | templates/web/fixmystreet.com/footer_extra_js.html | 1 | ||||
| -rw-r--r-- | templates/web/oxfordshire/footer_extra_js.html | 1 | ||||
| -rw-r--r-- | web/cobrands/oxfordshire/assets.js | 18 | ||||
| -rw-r--r-- | web/cobrands/oxfordshire/base.scss | 5 | 
12 files changed, 76 insertions, 18 deletions
| diff --git a/.cypress/cypress.json b/.cypress/cypress.json index dd3beceef..554495d4b 100644 --- a/.cypress/cypress.json +++ b/.cypress/cypress.json @@ -1,4 +1,7 @@  {    "baseUrl": "http://localhost:3001", -  "projectId": "y8vvs1" +  "projectId": "y8vvs1", +  "env": { +     "postcode": "BS10 5EE" +  }  } diff --git a/.cypress/cypress/integration/bathnes.js b/.cypress/cypress/integration/bathnes.js new file mode 100644 index 000000000..29037fc00 --- /dev/null +++ b/.cypress/cypress/integration/bathnes.js @@ -0,0 +1,10 @@ +var cobrand = Cypress.env('cobrand'); +var only_or_skip = (cobrand == 'bathnes') ? describe.only : describe.skip; + +only_or_skip('Bath cobrand specific testing', function() { + +    it('loads the right front page', function() { +        cy.visit('/'); +        cy.contains('North East Somerset'); +    }); +}); diff --git a/.cypress/cypress/integration/regressions.js b/.cypress/cypress/integration/regressions.js index c54bc8e9f..00e92f5ad 100644 --- a/.cypress/cypress/integration/regressions.js +++ b/.cypress/cypress/integration/regressions.js @@ -8,19 +8,19 @@ Cypress.Commands.add('cleanUpXHR', function() {  describe('Regression tests', function() {      it('Shows the sub-map links after clicking Try again', function() {          cy.viewport(480, 800); -        cy.visit('/around?pc=BS10+5EE&js=1'); +        cy.visit('/around?pc=' + Cypress.env('postcode') + '&js=1');          cy.get('#map_box').click(200, 200);          cy.get('#try_again').click();          cy.get('#sub_map_links').should('be.visible');          cy.cleanUpXHR();      });      it('Does not fade on new pin hover', function() { -        cy.visit('/around?pc=BS10+5EE&js=1'); +        cy.visit('/around?pc=' + Cypress.env('postcode') + '&js=1');          cy.get('#map_box').click(200, 200);          cy.get('#map_box image').last().trigger('mousemove').should('have.css', 'opacity', '1');      });      it('Does not hide the new report pin even if you click really quick', function() { -        cy.visit('/around?pc=BS10+5EE&js=1'); +        cy.visit('/around?pc=' + Cypress.env('postcode') + '&js=1');          cy.get('#map_box').click(200, 200);          cy.get('#loading-indicator').should('be.hidden');          cy.get('#map_box image').should('be.visible'); diff --git a/.cypress/cypress/integration/responsive.js b/.cypress/cypress/integration/responsive.js index 6d1601cea..1a5540590 100644 --- a/.cypress/cypress/integration/responsive.js +++ b/.cypress/cypress/integration/responsive.js @@ -28,7 +28,7 @@ describe('Front page responsive design tests', function() {  describe('Around page responsive design tests', function() {      it('Shows correct things on mobile', function() {          cy.viewport(480, 800); -        cy.visit('/around?pc=BS10+5EE&js=1'); +        cy.visit('/around?pc=' + Cypress.env('postcode') + '&js=1');          cy.get('.mobile-map-banner').should('be.visible');          cy.get('#sub_map_links').should('be.visible');          cy.get('#map_links_toggle').should('not.be.visible'); @@ -41,7 +41,7 @@ describe('Around page responsive design tests', function() {      it('Shows correct things on tablet', function() {          cy.viewport(800, 800); -        cy.visit('/around?pc=BS10+5EE&js=1'); +        cy.visit('/around?pc=' + Cypress.env('postcode') + '&js=1');          cy.get('.mobile-map-banner').should('not.be.visible');          cy.get('#map_sidebar').should('be.visible');          cy.get('#side-form').should('not.be.visible'); @@ -55,7 +55,7 @@ describe('Around page responsive design tests', function() {      it('Shows correct things on desktop', function() {          cy.viewport(1024, 800); -        cy.visit('/around?pc=BS10+5EE&js=1'); +        cy.visit('/around?pc=' + Cypress.env('postcode') + '&js=1');          cy.get('.mobile-map-banner').should('not.be.visible');          cy.get('#map_sidebar').should('be.visible');          cy.get('#sub_map_links').should('be.visible'); diff --git a/.cypress/cypress/integration/simple_spec.js b/.cypress/cypress/integration/simple_spec.js index 30f2a0218..003662d59 100644 --- a/.cypress/cypress/integration/simple_spec.js +++ b/.cypress/cypress/integration/simple_spec.js @@ -2,7 +2,7 @@ describe('Clicking the map', function() {      before(function(){          cy.visit('/');          cy.contains('Go'); -        cy.get('[name=pc]').type('BS10 5EE'); +        cy.get('[name=pc]').type(Cypress.env('postcode'));          cy.get('[name=pc]').parents('form').submit();      }); @@ -23,7 +23,7 @@ describe('Clicking the map', function() {  describe('Clicking the "big green banner" on a map page', function() {      before(function() {          cy.visit('/'); -        cy.get('[name=pc]').type('BS10 5EE'); +        cy.get('[name=pc]').type(Cypress.env('postcode'));          cy.get('[name=pc]').parents('form').submit();          cy.get('.big-green-banner').click();      }); diff --git a/bin/browser-tests b/bin/browser-tests index a8568a583..00cfbc346 100755 --- a/bin/browser-tests +++ b/bin/browser-tests @@ -12,15 +12,24 @@ BEGIN {  use Getopt::Long ':config' => qw(pass_through auto_help); +my ($run_server, $run_cypress, $vagrant);  my $config_file = 'conf/general.yml-example'; -my $run_server; -my $run_cypress; -my $vagrant; +my $cobrand = 'fixmystreet'; +my $coords = '51.532851,-2.284277'; +my $area_id = 2608; +my $name = 'Borsetshire'; +my $mapit_url = 'https://mapit.uk/'; +  GetOptions(      'config=s' => \$config_file,      'server' => \$run_server,      'cypress' => \$run_cypress,      'vagrant' => \$vagrant, +    'cobrand=s' => \$cobrand, +    'coords=s' => \$coords, +    'area_id=s' => \$area_id, +    'name=s' => \$name, +    'mapit_url=s' => \$mapit_url,  );  if ($vagrant) { @@ -62,15 +71,15 @@ sub run {          my $config_out = FixMyStreet::TestAppProve->get_config({              config_file => $config_file,              # Want this to be like .com -            ALLOWED_COBRANDS => [ 'fixmystreet' ], -            MAPIT_URL => 'https://mapit.uk/', +            ALLOWED_COBRANDS => [ $cobrand ], +            MAPIT_URL => $mapit_url,              BASE_URL => 'http://localhost:3001',          });          $ENV{FMS_OVERRIDE_CONFIG} = $config_out;          # Set up, and load in some data          system('bin/make_css', 'fixmystreet.com'); -        system('bin/fixmystreet.com/fixture', '--nonrandom', '--coords', '51.532851,-2.284277', '--name', 'Borsetshire', '--area-id', 2608, '--commit'); +        system('bin/fixmystreet.com/fixture', '--nonrandom', '--coords', $coords, '--name', $name, '--area-id', $area_id, '--commit');      }      my $pid; @@ -81,7 +90,7 @@ sub run {      if (($run_cypress && !$run_server) || $pid) {          # Parent, run the test runner (then kill the child) -        my $exit = system("cypress", $cmd, '--config', 'fixturesFolder=false,pluginsFile=false,supportFile=false,blacklistHosts=[gaze.mysociety.org,*.openstreetmap.org]', '--project', '.cypress', @ARGV); +        my $exit = system("cypress", $cmd, '--config', 'fixturesFolder=false,pluginsFile=false,supportFile=false,blacklistHosts=[gaze.mysociety.org,*.openstreetmap.org]', '--project', '.cypress', '--env', "cobrand=$cobrand", @ARGV);          kill 'TERM', $pid if $pid;          exit $exit >> 8;      } else { @@ -105,15 +114,22 @@ browser-tests - Run Cypress browser tests, set up for FixMyStreet.  =head1 SYNOPSIS -browser-tests [options] [cypress options] +browser-tests [running options] [fixture options] [cypress options] - Options: + Running options:     --config         provide an override general.yml file     --server         only run the test server, not cypress     --cypress        only run cypress, not the test server     --vagrant        run test server inside Vagrant, cypress outside     --help           this help message + Fixture option: +   --cobrand        Cobrand to use, default 'fixmystreet' +   --coords         Default co-ordinates for created reports +   --area_id        Area ID to use for created body +   --name           Name to use for created body +   --mapit_url      MapIt URL to use, default mock +  Use browser-tests instead of running cypress directly, so that a clean  database is set up for Cypress to use, not affecting your normal dev database.  If you're running FixMyStreet in a VM, you can use this script to run the test diff --git a/templates/web/base/report/new/form_report.html b/templates/web/base/report/new/form_report.html index b4688f950..24c3ff4d1 100644 --- a/templates/web/base/report/new/form_report.html +++ b/templates/web/base/report/new/form_report.html @@ -6,6 +6,7 @@  [% PROCESS "report/new/category_wrapper.html" %]  [% TRY %][% PROCESS 'report/new/after_category.html' %][% CATCH file %][% END %] +<div id="post_category_details_form">  [% TRY %][% PROCESS 'report/new/_form_labels.html' %][% CATCH file %][% END %]      <h2 class="form-section-heading">[% loc( 'Public details' ) %]</h2> @@ -75,3 +76,4 @@      <input type="hidden" id="single_body_only" name="single_body_only" value="">      <input type="hidden" id="do_not_send" name="do_not_send" value="">      <input type="hidden" name="submit_problem" value="1"> +</div> diff --git a/templates/web/base/report/new/form_user.html b/templates/web/base/report/new/form_user.html index 68a226693..3e0af10a3 100644 --- a/templates/web/base/report/new/form_user.html +++ b/templates/web/base/report/new/form_user.html @@ -1,3 +1,4 @@ +<div id="private_form">  <h2 class="form-section-heading form-section-heading--private">[% loc('Private details') %]</h2>  <p class="form-section-description" id="js-councils_text_private">    [% IF js %] @@ -13,3 +14,4 @@  [% ELSE %]    [% PROCESS "report/new/form_user_loggedout.html" %]  [% END %] +</div> diff --git a/templates/web/fixmystreet.com/footer_extra_js.html b/templates/web/fixmystreet.com/footer_extra_js.html index c1d1b09b0..bb7c9780c 100644 --- a/templates/web/fixmystreet.com/footer_extra_js.html +++ b/templates/web/fixmystreet.com/footer_extra_js.html @@ -9,6 +9,7 @@ IF bodyclass.match('mappage');      scripts.push( version('/cobrands/bromley/assets.js') );      scripts.push( version('/cobrands/buckinghamshire/assets.js') );      scripts.push( version('/cobrands/lincolnshire/assets.js') ); +    scripts.push( version('/cobrands/oxfordshire/assets.js') );      scripts.push(          version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'),      ); diff --git a/templates/web/oxfordshire/footer_extra_js.html b/templates/web/oxfordshire/footer_extra_js.html index 541e2ee16..e05e16707 100644 --- a/templates/web/oxfordshire/footer_extra_js.html +++ b/templates/web/oxfordshire/footer_extra_js.html @@ -1,4 +1,5 @@  [% scripts.push(      version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'),      version('/cobrands/oxfordshire/js.js'), +    version('/cobrands/oxfordshire/assets.js'),  ) %] diff --git a/web/cobrands/oxfordshire/assets.js b/web/cobrands/oxfordshire/assets.js new file mode 100644 index 000000000..8858ee66e --- /dev/null +++ b/web/cobrands/oxfordshire/assets.js @@ -0,0 +1,18 @@ +(function(){ +  function disable_form(disable) { +    $('#post_category_details_form').toggle(!disable); +    $('#private_form').toggle(!disable); +  } + +  function check_rights_of_way() { +    if (OpenLayers.Util.indexOf(fixmystreet.bodies, 'Oxfordshire County Council') > -1 && $('#form_category').val() == 'Countryside Paths / Public Rights of Way (usually not tarmac)') { +        $('#category_meta').html('<p class="category-message">Please report problems with rights of way using <a href="https://publicrightsofway.oxfordshire.gov.uk/web/standardmap.aspx">this page</a>.</p>'); +        disable_form(true); +    } else { +        $('#category_meta').html(''); +        disable_form(false); +    } +  } + +  $(fixmystreet).on('report_new:category_change', check_rights_of_way); +})(); diff --git a/web/cobrands/oxfordshire/base.scss b/web/cobrands/oxfordshire/base.scss index aaaaa186c..6d4bad117 100644 --- a/web/cobrands/oxfordshire/base.scss +++ b/web/cobrands/oxfordshire/base.scss @@ -275,6 +275,11 @@ textarea {    }  } +.category-message { +  padding: 1em; +  background-color: $color-oxfordshire-pale-grey-green; +} +  .item-list--reports__item {      small {          font-style: inherit; | 
