diff options
Diffstat (limited to '.cypress/cypress')
-rw-r--r-- | .cypress/cypress/fixtures/bus_stops.json | 7 | ||||
-rw-r--r-- | .cypress/cypress/fixtures/bus_stops_none.json | 3 | ||||
-rw-r--r-- | .cypress/cypress/fixtures/iow_roadworks.json | 109 | ||||
-rw-r--r-- | .cypress/cypress/integration/around_filters.js | 2 | ||||
-rw-r--r-- | .cypress/cypress/integration/bathnes.js | 2 | ||||
-rw-r--r-- | .cypress/cypress/integration/borsetshire.js | 23 | ||||
-rw-r--r-- | .cypress/cypress/integration/duplicates.js | 31 | ||||
-rw-r--r-- | .cypress/cypress/integration/hackney.js | 19 | ||||
-rw-r--r-- | .cypress/cypress/integration/isleofwight.js | 13 | ||||
-rw-r--r-- | .cypress/cypress/integration/northamptonshire.js | 14 | ||||
-rw-r--r-- | .cypress/cypress/integration/oxfordshire.js | 25 | ||||
-rw-r--r-- | .cypress/cypress/integration/peterborough.js | 7 | ||||
-rw-r--r-- | .cypress/cypress/integration/regressions.js | 2 | ||||
-rw-r--r-- | .cypress/cypress/integration/simple_spec.js | 5 | ||||
-rw-r--r-- | .cypress/cypress/plugins/index.js | 6 | ||||
-rw-r--r-- | .cypress/cypress/support/index.js | 2 |
16 files changed, 152 insertions, 118 deletions
diff --git a/.cypress/cypress/fixtures/bus_stops.json b/.cypress/cypress/fixtures/bus_stops.json index f3808c912..dbfb44e68 100644 --- a/.cypress/cypress/fixtures/bus_stops.json +++ b/.cypress/cypress/fixtures/bus_stops.json @@ -1,14 +1,13 @@ { - "type": "FeatureCollection", - "features": [ + "results": [ { "type": "Feature", "id": "307.9404949", "geometry": { "type": "Point", "coordinates": [ - -99073, - 6843328 + -0.889992, + 52.238301 ] }, "properties": { diff --git a/.cypress/cypress/fixtures/bus_stops_none.json b/.cypress/cypress/fixtures/bus_stops_none.json index 3102a72dd..749921de7 100644 --- a/.cypress/cypress/fixtures/bus_stops_none.json +++ b/.cypress/cypress/fixtures/bus_stops_none.json @@ -1,6 +1,5 @@ { - "type": "FeatureCollection", - "features": [ + "results": [ ], "crs": { "properties": { diff --git a/.cypress/cypress/fixtures/iow_roadworks.json b/.cypress/cypress/fixtures/iow_roadworks.json index b20dd8514..d6d7bb31b 100644 --- a/.cypress/cypress/fixtures/iow_roadworks.json +++ b/.cypress/cypress/fixtures/iow_roadworks.json @@ -1,97 +1,16 @@ { - "query": { - "recordcount": 38, - "columnlist": "se_id,phase_id,u_se_id,longitude,latitude,gsymbol_id,tooltip,swtype,org_name_disp,promoter,source,promoter_works_ref,originator_ref,swa_org_ref,promoter_org_ref,publisher_orgref,publisher_organisation_id,promoter_organisation_id,organisation_id,lha_id,start_date,end_date,works_state,impact,works_desc,geom_type,geojson_wgs84,tm_cat", - "data": { - "se_id": [ - 114013162 - ], - "phase_id": [ - 1 - ], - "u_se_id": [ - "114013162:1" - ], - "longitude": [ - -1.29574 - ], - "latitude": [ - 50.71086 - ], - "gsymbol_id": [ - "gcln01y" - ], - "tooltip": [ - "B3401 Whitepit Lane, Newport, Isle of Wight\\n18 Jun 2019 - 23 Jul 2019\\ndelays unlikely" - ], - "swtype": [ - "cw" - ], - "org_name_disp": [ - "Island Roads on behalf of the Isle of Wight Council" - ], - "promoter": [ - "Island Roads on behalf of the Isle of Wight Council" - ], - "source": [ - "SW" - ], - "promoter_works_ref": [ - "RF101BT0103000021728" - ], - "originator_ref": [ - "RF101BT0103000021728" - ], - "swa_org_ref": [ - 2114 - ], - "promoter_org_ref": [ - 2114 - ], - "publisher_orgref": [ - 2114 - ], - "publisher_organisation_id": [ - 1062 - ], - "promoter_organisation_id": [ - 1062 - ], - "organisation_id": [ - 1062 - ], - "lha_id": [ - 62 - ], - "start_date": [ - "{ts '2019-06-18 00:00:00'}" - ], - "end_date": [ - "{ts '2030-07-23 23:59:59'}" - ], - "works_state": [ - 4 - ], - "impact": [ - 1 - ], - "works_desc": [ - "Parapet improvement NEWPORT" - ], - "geom_type": [ - 1 - ], - "geojson_wgs84": [ - "{\"type\":\"Point\",\"coordinates\":[-1.295784,50.71086]}" - ], - "tm_cat": [ - "" - ] - } - }, - "reqtoken": "", - "filterimpact": "1,2,3,4", - "filterenddate": "16/10/2019", - "filterstartdate": "16/07/2019", - "timeperiod": "cw" + "type":"FeatureCollection", + "features":[ + { + "type":"Feature", + "geometry":{"type":"Point","coordinates":[449822,90373]}, + "properties":{ + "start_date":"2019-06-18T00:00:00.000Z", + "end_date":"2040-07-23T23:59:59.000Z", + "summary":"B3401 Whitepit Lane, Newport, Isle of Wight", + "description":"Parapet improvement NEWPORT", + "promoter":"Island Roads on behalf of the Isle of Wight Council" + } + } + ] } diff --git a/.cypress/cypress/integration/around_filters.js b/.cypress/cypress/integration/around_filters.js index 46d1f8477..c79359574 100644 --- a/.cypress/cypress/integration/around_filters.js +++ b/.cypress/cypress/integration/around_filters.js @@ -112,7 +112,7 @@ describe('Around page filtering and push state', function() { cy.route('/report/*').as('show-report'); cy.route('/reports/*').as('show-all'); cy.route('/mapit/area/*').as('get-geometry'); - cy.visit('/around?lon=-2.295894&lat=51.526877&zoom=6'); + cy.visit('/around?lon=-2.295894&lat=51.526877&zoom=0'); // get the second image which is the pin, first is the shadow cy.get('image[title="Lights out in tunnel"]:last').invoke('attr', 'xlink:href').should('contain', 'small'); // force to hopefully work around apparent Cypress SVG issue diff --git a/.cypress/cypress/integration/bathnes.js b/.cypress/cypress/integration/bathnes.js index 1acbd3602..5598409d9 100644 --- a/.cypress/cypress/integration/bathnes.js +++ b/.cypress/cypress/integration/bathnes.js @@ -19,7 +19,7 @@ it('loads the staff layer correctly', function() { cy.window().then(function(win){ var llpg = 0; win.fixmystreet.map.layers.forEach(function(lyr) { - if (lyr.fixmystreet && lyr.fixmystreet.http_options.params.TYPENAME === 'LLPG') { + if (lyr.fixmystreet && lyr.fixmystreet.http_options && lyr.fixmystreet.http_options.params && lyr.fixmystreet.http_options.params.TYPENAME === 'LLPG') { llpg++; } }); diff --git a/.cypress/cypress/integration/borsetshire.js b/.cypress/cypress/integration/borsetshire.js new file mode 100644 index 000000000..e3529a9aa --- /dev/null +++ b/.cypress/cypress/integration/borsetshire.js @@ -0,0 +1,23 @@ +it('loads the right front page', function() { + cy.visit('http://borsetshire.localhost:3001/'); + cy.contains('Borsetshire'); +}); + +it('logs in without fuss', function() { + cy.contains('Sign in').click(); + cy.contains('Customer service').click(); + cy.url().should('include', '/reports'); + + cy.contains('Your account').click(); + cy.contains('Sign out').click(); + cy.contains('Sign in').click(); + cy.contains('Inspector').click(); + cy.url().should('include', '/my/planned'); + + cy.visit('http://borsetshire.localhost:3001/auth'); + cy.get('[name=username]').type('super@example.org'); + cy.contains('Sign in with a password').click(); + cy.get('[name=password_sign_in]').type('password'); + cy.get('[name=sign_in_by_password]').last().click(); + cy.url().should('include', '/admin'); +}); diff --git a/.cypress/cypress/integration/duplicates.js b/.cypress/cypress/integration/duplicates.js index 406b3fb67..c014e0593 100644 --- a/.cypress/cypress/integration/duplicates.js +++ b/.cypress/cypress/integration/duplicates.js @@ -51,12 +51,12 @@ describe('Duplicate tests', function() { }); it('lets an inspector see duplicate reports coming from /reports', function() { - cy.request({ - method: 'POST', - url: 'http://borsetshire.localhost:3001/auth?r=/reports', - form: true, - body: { username: 'admin@example.org', password_sign_in: 'password' } - }); + cy.visit('http://borsetshire.localhost:3001/auth'); + cy.get('[name=username]').type('admin@example.org'); + cy.contains('Sign in with a password').click(); + cy.get('[name=password_sign_in]').type('password'); + cy.get('[name=sign_in_by_password]').last().click(); + cy.url().should('include', '/my'); cy.visit('http://borsetshire.localhost:3001/reports'); cy.get('[href$="/report/1"]:last').click(); cy.get('#report_inspect_form #state').select('Duplicate'); @@ -77,4 +77,23 @@ describe('Duplicate tests', function() { cy.get('#js-duplicate-reports li h3 a').should('have.attr', 'href', '/report/1'); }); + it('does not redisplay duplicates when stopper questions are changed', function() { + cy.server(); + cy.route('/report/new/ajax*').as('report-ajax'); + cy.visit('http://borsetshire.localhost:3001/_test/setup/regression-duplicate-stopper'); // Server-side setup + cy.visit('http://borsetshire.localhost:3001/report/1'); + cy.contains('Report another problem here').click(); + cy.wait('@report-ajax'); + cy.get('[id=category_group]').select('Flytipping'); + cy.get('.extra-category-questions').should('not.be.visible'); + cy.get('.js-hide-duplicate-suggestions:first').click(); + cy.get('.js-hide-duplicate-suggestions:first').should('not.be.visible'); + cy.get('.extra-category-questions').should('be.visible'); + cy.get('[id=form_hazardous]').select('No'); + cy.wait(500); + cy.get('.extra-category-questions').should('be.visible'); + cy.get('.js-hide-duplicate-suggestions:first').should('not.be.visible'); + cy.visit('http://borsetshire.localhost:3001/_test/teardown/regression-duplicate-stopper'); // Server-side setup + }); + }); diff --git a/.cypress/cypress/integration/hackney.js b/.cypress/cypress/integration/hackney.js new file mode 100644 index 000000000..a4293b028 --- /dev/null +++ b/.cypress/cypress/integration/hackney.js @@ -0,0 +1,19 @@ +describe('When you look at the Hackney site', function() { + + beforeEach(function() { + cy.server(); + cy.route('/report/new/ajax*').as('report-ajax'); + cy.visit('http://hackney.localhost:3001/'); + cy.contains('Hackney Council'); + cy.should('not.contain', 'Hackney Borough'); + cy.get('[name=pc]').type('E8 1DY'); + cy.get('[name=pc]').parents('form').submit(); + }); + + it('uses the correct name', function() { + cy.get('#map_box').click(); + cy.wait('@report-ajax'); + cy.get('select:eq(4)').select('Potholes'); + cy.contains('sent to Hackney Council'); + }); +}); diff --git a/.cypress/cypress/integration/isleofwight.js b/.cypress/cypress/integration/isleofwight.js index ab7039a5f..7cfb21c82 100644 --- a/.cypress/cypress/integration/isleofwight.js +++ b/.cypress/cypress/integration/isleofwight.js @@ -20,4 +20,17 @@ describe('When you look at the Island Roads site', function() { cy.get('select:eq(4)').select('Extra'); cy.contains('Help Island Roads'); }); + + it('displays nearby roadworks', function() { + cy.fixture('iow_roadworks.json'); + cy.route('/streetmanager.php**', 'fixture:iow_roadworks.json').as('roadworks'); + cy.visit('http://isleofwight.localhost:3001/'); + cy.get('[name=pc]').type('PO30 5XJ'); + cy.get('[name=pc]').parents('form').submit(); + cy.get('#map_box').click(); + cy.wait('@report-ajax'); + cy.wait('@roadworks'); + cy.contains('Roadworks are scheduled near this location'); + cy.contains('Parapet improvement'); + }); }); diff --git a/.cypress/cypress/integration/northamptonshire.js b/.cypress/cypress/integration/northamptonshire.js index 76ce8ff44..0de02d8c3 100644 --- a/.cypress/cypress/integration/northamptonshire.js +++ b/.cypress/cypress/integration/northamptonshire.js @@ -7,8 +7,8 @@ it('prevents clicking unless asset selected', function() { cy.server(); cy.fixture('bus_stops.json'); cy.fixture('bus_stops_none.json'); - cy.route('**/render-layer/**', 'fixture:bus_stops_none.json').as('empty-bus_stops-layer'); - cy.route('**/16301/10787**', 'fixture:bus_stops.json').as('bus_stops-layer'); + cy.route('**/northants.staging/**', 'fixture:bus_stops_none.json').as('empty-bus_stops-layer'); + cy.route('**/32602/21575/**', 'fixture:bus_stops.json').as('bus_stops-layer'); cy.route('/report/new/ajax*').as('report-ajax'); cy.visit('http://northamptonshire.localhost:3001/'); cy.get('[name=pc]').type('NN1 1NS'); @@ -29,8 +29,8 @@ it('selecting an asset allows a report', function() { cy.server(); cy.fixture('bus_stops.json'); cy.fixture('bus_stops_none.json'); - cy.route('**/render-layer/**', 'fixture:bus_stops_none.json').as('empty-bus_stops-layer'); - cy.route('**/16301/10787**', 'fixture:bus_stops.json').as('bus_stops-layer'); + cy.route('**/northants.staging/**', 'fixture:bus_stops_none.json').as('empty-bus_stops-layer'); + cy.route('**/32602/21575/**', 'fixture:bus_stops.json').as('bus_stops-layer'); cy.route('/report/new/ajax*').as('report-ajax'); cy.visit('http://northamptonshire.localhost:3001/'); cy.get('[name=pc]').type('NN1 2NS'); @@ -51,9 +51,9 @@ it('detects multiple assets at same location', function() { cy.server(); cy.fixture('bus_stops.json'); cy.fixture('bus_stops_none.json'); - cy.route('**/render-layer/**', 'fixture:bus_stops_none.json').as('empty-bus_stops-layer'); - cy.route('**/16301/10787**', 'fixture:bus_stops.json').as('bus_stops-layer'); - cy.route('**/16301/10788**', 'fixture:bus_stops.json').as('bus_stops-layer2'); + cy.route('**/northants.staging/**', 'fixture:bus_stops_none.json').as('empty-bus_stops-layer'); + cy.route('**/32602/21575/**', 'fixture:bus_stops.json').as('bus_stops-layer'); + cy.route('**/32602/21576/**', 'fixture:bus_stops.json').as('bus_stops-layer2'); cy.route('/report/new/ajax*').as('report-ajax'); cy.visit('http://northamptonshire.localhost:3001/'); cy.get('[name=pc]').type('NN1 2NS'); diff --git a/.cypress/cypress/integration/oxfordshire.js b/.cypress/cypress/integration/oxfordshire.js new file mode 100644 index 000000000..f235802e6 --- /dev/null +++ b/.cypress/cypress/integration/oxfordshire.js @@ -0,0 +1,25 @@ +describe("Oxfordshire cobrand", function() { + it("allows inspectors to instruct defects", function() { + cy.server(); + cy.request({ + method: 'POST', + url: 'http://oxfordshire.localhost:3001/auth', + form: true, + body: { username: 'inspector-instructor@example.org', password_sign_in: 'password' } + }); + cy.visit('http://oxfordshire.localhost:3001/report/1'); + cy.contains('Oxfordshire'); + + cy.get('#report_inspect_form').should('be.visible'); + cy.get('#js-inspect-action-scheduled').should('not.be.visible'); + cy.get('#raise_defect_yes').should('not.have.attr', 'required'); + + cy.get('#report_inspect_form select[name=state]').select('Action scheduled'); + cy.get('#js-inspect-action-scheduled').should('be.visible'); + cy.get('#raise_defect_yes').should('have.attr', 'required', 'required'); + + cy.get('#report_inspect_form select[name=state]').select('No further action'); + cy.get('#js-inspect-action-scheduled').should('not.be.visible'); + cy.get('#raise_defect_yes').should('not.have.attr', 'required'); + }); +}); diff --git a/.cypress/cypress/integration/peterborough.js b/.cypress/cypress/integration/peterborough.js index 67c468be8..452795d8c 100644 --- a/.cypress/cypress/integration/peterborough.js +++ b/.cypress/cypress/integration/peterborough.js @@ -31,4 +31,11 @@ describe('new report form', function() { cy.get('.js-hide-if-invalid-category').should('be.visible'); }); + it('correctly changes the asset select message', function() { + cy.get('select:eq(4)').select('Street lighting'); + cy.get('.category_meta_message').should('contain', 'You can pick a light from the map'); + cy.get('select:eq(4)').select('Trees'); + cy.get('.category_meta_message').should('contain', 'You can pick a tree from the map'); + }); + }); diff --git a/.cypress/cypress/integration/regressions.js b/.cypress/cypress/integration/regressions.js index f1f557219..57176223f 100644 --- a/.cypress/cypress/integration/regressions.js +++ b/.cypress/cypress/integration/regressions.js @@ -46,7 +46,7 @@ describe('Regression tests', function() { it('hides the report when going from around to report to form', function() { cy.server(); cy.route('/report/*').as('show-report'); - cy.visit('/around?lon=-2.295894&lat=51.526877&zoom=6'); + cy.visit('/around?lon=-2.295894&lat=51.526877&zoom=0'); // force to hopefully work around apparent Cypress SVG issue cy.get('image[title="Lights out in tunnel"]:last').click({force: true}); cy.wait('@show-report'); diff --git a/.cypress/cypress/integration/simple_spec.js b/.cypress/cypress/integration/simple_spec.js index 8b658b21b..074bf72bd 100644 --- a/.cypress/cypress/integration/simple_spec.js +++ b/.cypress/cypress/integration/simple_spec.js @@ -20,6 +20,9 @@ describe('Clicking the map', function() { cy.get('#map_sidebar').should('contain', 'check and confirm your details'); cy.get('#map_sidebar').parents('form').submit(); cy.get('body').should('contain', 'Thank you for reporting this issue'); + cy.visit('http://fixmystreet.localhost:3001/_test/setup/simple-service-check').then(function(w) { + expect(w.document.documentElement.innerText).to.equal('desktop'); + }); }); }); @@ -47,7 +50,7 @@ describe('Leaving updates', function() { cy.route('/report/*').as('show-report'); cy.route('/reports/*').as('show-all'); cy.route('/mapit/area/*').as('get-geometry'); - cy.visit('/around?lon=-2.295894&lat=51.526877&zoom=6'); + cy.visit('/around?lon=-2.295894&lat=51.526877&zoom=0'); // force to hopefully work around apparent Cypress SVG issue cy.get('image[title="Lights out in tunnel"]:last').click({force: true}); cy.wait('@show-report'); diff --git a/.cypress/cypress/plugins/index.js b/.cypress/cypress/plugins/index.js new file mode 100644 index 000000000..218e6bfde --- /dev/null +++ b/.cypress/cypress/plugins/index.js @@ -0,0 +1,6 @@ +// jshint esversion: 6 + +module.exports = (on, config) => { + require('@cypress/code-coverage/task')(on, config); + return config; +}; diff --git a/.cypress/cypress/support/index.js b/.cypress/cypress/support/index.js new file mode 100644 index 000000000..227dd57f0 --- /dev/null +++ b/.cypress/cypress/support/index.js @@ -0,0 +1,2 @@ +// jshint esversion: 6 +import '@cypress/code-coverage/support'; |