diff options
-rw-r--r-- | .cypress/cypress.json | 5 | ||||
-rw-r--r-- | .cypress/cypress/integration/bathnes.js | 12 | ||||
-rw-r--r-- | .cypress/cypress/integration/northamptonshire.js | 133 | ||||
-rwxr-xr-x | bin/browser-tests | 15 |
4 files changed, 75 insertions, 90 deletions
diff --git a/.cypress/cypress.json b/.cypress/cypress.json index 7aeb54e08..9b424ef69 100644 --- a/.cypress/cypress.json +++ b/.cypress/cypress.json @@ -1,8 +1,11 @@ { - "baseUrl": "http://localhost:3001", + "baseUrl": "http://fixmystreet.localhost:3001", "projectId": "y8vvs1", "blacklistHosts": ["gaze.mysociety.org", "*.openstreetmap.org"], "env": { "postcode": "BS10 5EE" + }, + "hosts": { + "*.localhost": "127.0.0.1" } } diff --git a/.cypress/cypress/integration/bathnes.js b/.cypress/cypress/integration/bathnes.js index 29037fc00..c675c34fa 100644 --- a/.cypress/cypress/integration/bathnes.js +++ b/.cypress/cypress/integration/bathnes.js @@ -1,10 +1,4 @@ -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'); - }); +it('loads the right front page', function() { + cy.visit('http://bathnes.localhost:3001/'); + cy.contains('North East Somerset'); }); diff --git a/.cypress/cypress/integration/northamptonshire.js b/.cypress/cypress/integration/northamptonshire.js index c4e6da85f..082f03de1 100644 --- a/.cypress/cypress/integration/northamptonshire.js +++ b/.cypress/cypress/integration/northamptonshire.js @@ -1,85 +1,72 @@ -/* - * These don't run by default, need to run the tests with - * ./bin/browser-tests run --cobrand northamptonshire --area_id 2234 --coords '52.236251,0.892052' - * - * NB: most of the non northamptonshire tests will then fail - */ - -var cobrand = Cypress.env('cobrand'); -var only_or_skip = (cobrand == 'northamptonshire') ? describe.only : describe.skip; - -only_or_skip('Northamptonshire cobrand specific testing', function() { - - it('loads the right front page', function() { - cy.visit('/'); - cy.contains('Northamptonshire'); - }); - - it('prevents clicking unless asset selected', function() { - cy.server(); - cy.fixture('trees.json'); - cy.fixture('trees_none.json'); - cy.route('**/render-layer/**', 'fixture:trees_none.json').as('empty-trees-layer'); - cy.route('**/16463/10787**', 'fixture:trees.json').as('trees-layer'); - cy.route('/report/new/ajax*').as('report-ajax'); - cy.visit('/'); - cy.get('[name=pc]').type('NN1 1NS'); - cy.get('[name=pc]').parents('form').submit(); - - cy.get('#map_box').click(); - - cy.get('[id=category_group]').select('Fallen Tree'); +it('loads the right front page', function() { + cy.visit('http://northamptonshire.localhost:3001/'); + cy.contains('Northamptonshire'); +}); - cy.wait('@report-ajax'); - cy.wait('@trees-layer'); - cy.wait('@empty-trees-layer'); - cy.contains(/Please select a.*tree.*from the map/); - cy.get('#js-councils_text').should('be.hidden'); - }); +it('prevents clicking unless asset selected', function() { + cy.server(); + cy.fixture('trees.json'); + cy.fixture('trees_none.json'); + cy.route('**/render-layer/**', 'fixture:trees_none.json').as('empty-trees-layer'); + cy.route('**/16463/10787**', 'fixture:trees.json').as('trees-layer'); + cy.route('/report/new/ajax*').as('report-ajax'); + cy.visit('http://northamptonshire.localhost:3001/'); + cy.get('[name=pc]').type('NN1 1NS'); + cy.get('[name=pc]').parents('form').submit(); + + cy.get('#map_box').click(); + cy.wait('@report-ajax'); + + cy.get('[id=category_group]').select('Fallen Tree'); + + cy.wait('@trees-layer'); + cy.wait('@empty-trees-layer'); + cy.contains(/Please select a.*tree.*from the map/); + cy.get('#js-councils_text').should('be.hidden'); +}); - it('selecting an asset allows a report', function() { - cy.server(); - cy.fixture('trees.json'); - cy.fixture('trees_none.json'); - cy.route('**/render-layer/**', 'fixture:trees_none.json').as('empty-trees-layer'); - cy.route('**/16463/10787**', 'fixture:trees.json').as('trees-layer'); - cy.route('/report/new/ajax*').as('report-ajax'); - cy.visit('/'); - cy.get('[name=pc]').type('NN1 2NS'); - cy.get('[name=pc]').parents('form').submit(); +it('selecting an asset allows a report', function() { + cy.server(); + cy.fixture('trees.json'); + cy.fixture('trees_none.json'); + cy.route('**/render-layer/**', 'fixture:trees_none.json').as('empty-trees-layer'); + cy.route('**/16463/10787**', 'fixture:trees.json').as('trees-layer'); + cy.route('/report/new/ajax*').as('report-ajax'); + cy.visit('http://northamptonshire.localhost:3001/'); + cy.get('[name=pc]').type('NN1 2NS'); + cy.get('[name=pc]').parents('form').submit(); - cy.get('#map_box').click(); + cy.get('#map_box').click(); + cy.wait('@report-ajax'); - cy.get('[id=category_group]').select('Fallen Tree'); + cy.get('[id=category_group]').select('Fallen Tree'); - cy.wait('@trees-layer'); - cy.wait('@empty-trees-layer'); - cy.wait('@report-ajax'); + cy.wait('@trees-layer'); + cy.wait('@empty-trees-layer'); - cy.get('#js-councils_text').should('be.visible'); - }); + cy.get('#js-councils_text').should('be.visible'); +}); - it('detects multiple assets at same location', function() { - cy.server(); - cy.fixture('trees.json'); - cy.fixture('trees_none.json'); - cy.route('**/render-layer/**', 'fixture:trees_none.json').as('empty-trees-layer'); - cy.route('**/16463/10787**', 'fixture:trees.json').as('trees-layer'); - cy.route('**/16463/10788**', 'fixture:trees.json').as('trees-layer2'); - cy.route('/report/new/ajax*').as('report-ajax'); - cy.visit('/'); - cy.get('[name=pc]').type('NN1 2NS'); - cy.get('[name=pc]').parents('form').submit(); +it('detects multiple assets at same location', function() { + cy.server(); + cy.fixture('trees.json'); + cy.fixture('trees_none.json'); + cy.route('**/render-layer/**', 'fixture:trees_none.json').as('empty-trees-layer'); + cy.route('**/16463/10787**', 'fixture:trees.json').as('trees-layer'); + cy.route('**/16463/10788**', 'fixture:trees.json').as('trees-layer2'); + cy.route('/report/new/ajax*').as('report-ajax'); + cy.visit('http://northamptonshire.localhost:3001/'); + cy.get('[name=pc]').type('NN1 2NS'); + cy.get('[name=pc]').parents('form').submit(); - cy.get('#map_box').click(); + cy.get('#map_box').click(); + cy.wait('@report-ajax'); - cy.get('[id=category_group]').select('Fallen Tree'); + cy.get('[id=category_group]').select('Fallen Tree'); - cy.wait('@trees-layer'); - cy.wait('@trees-layer2'); - cy.wait('@empty-trees-layer'); - cy.wait('@report-ajax'); + cy.wait('@trees-layer'); + cy.wait('@trees-layer2'); + cy.wait('@empty-trees-layer'); - cy.contains('more than one tree at this location'); - }); + cy.contains('more than one tree at this location'); }); diff --git a/bin/browser-tests b/bin/browser-tests index 20f2f761d..fd3fc19d7 100755 --- a/bin/browser-tests +++ b/bin/browser-tests @@ -14,7 +14,7 @@ use Getopt::Long ':config' => qw(pass_through auto_help); my ($run_server, $run_cypress, $vagrant); my $config_file = 'conf/general.yml-example'; -my $cobrand = 'fixmystreet'; +my $cobrand = [ 'fixmystreet', 'northamptonshire', 'bathnes' ]; my $coords = '51.532851,-2.284277'; my $area_id = 2608; my $name = 'Borsetshire'; @@ -25,12 +25,13 @@ GetOptions( 'server' => \$run_server, 'cypress' => \$run_cypress, 'vagrant' => \$vagrant, - 'cobrand=s' => \$cobrand, + 'cobrand=s@' => \$cobrand, 'coords=s' => \$coords, 'area_id=s' => \$area_id, 'name=s' => \$name, 'mapit_url=s' => \$mapit_url, ); +$cobrand = [ split(',', join(',', @$cobrand)) ]; if ($vagrant) { # Test inception @@ -71,14 +72,14 @@ sub run { my $config_out = FixMyStreet::TestAppProve->get_config({ config_file => $config_file, # Want this to be like .com - ALLOWED_COBRANDS => [ $cobrand ], + ALLOWED_COBRANDS => $cobrand, MAPIT_URL => $mapit_url, - BASE_URL => 'http://localhost:3001', + BASE_URL => 'http://fixmystreet.localhost:3001', }); $ENV{FMS_OVERRIDE_CONFIG} = $config_out; # Set up, and load in some data - system('bin/make_css', 'fixmystreet.com'); + system('bin/make_css', map { $_ eq 'fixmystreet' ? 'fixmystreet.com' : $_ } @$cobrand); system('bin/fixmystreet.com/fixture', '--test_fixtures', '--nonrandom', '--coords', $coords, '--name', $name, '--area-id', $area_id, '--commit'); } @@ -90,7 +91,7 @@ sub run { if (($run_cypress && !$run_server) || $pid) { # Parent, run the test runner (then kill the child) - my $exit = system("cypress", $cmd, '--config', 'pluginsFile=false,supportFile=false', '--project', '.cypress', '--env', "cobrand=$cobrand", @ARGV); + my $exit = system("cypress", $cmd, '--config', 'pluginsFile=false,supportFile=false,blacklistHosts=[gaze.mysociety.org,*.openstreetmap.org]', '--project', '.cypress', @ARGV); kill 'TERM', $pid if $pid; exit $exit >> 8; } else { @@ -128,7 +129,7 @@ browser-tests [running options] [fixture options] [cypress options] --help this help message Fixture option: - --cobrand Cobrand to use, default 'fixmystreet' + --cobrand Cobrand(s) to use, default is fixmystreet,northamptonshire,bathnes --coords Default co-ordinates for created reports --area_id Area ID to use for created body --name Name to use for created body |