aboutsummaryrefslogtreecommitdiffstats
path: root/.cypress
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-12-05 19:03:35 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-12-05 19:29:35 +0000
commitfda50e07fc671eefa68257fbc9d9bdea63dd4b0f (patch)
treee6cc50fc1fccbad38bbd256540a467bb75c27f83 /.cypress
parent07b3bb46fd7369bda5ce90df6c5edb62f8d853db (diff)
Fix issue with multiple button IDs on page.
When a report is pulled in via ajax, it means there are then two sets of login flow buttons on the page, and the JS setup only attaches to the first of these.
Diffstat (limited to '.cypress')
-rw-r--r--.cypress/cypress/integration/simple_spec.js37
1 files changed, 35 insertions, 2 deletions
diff --git a/.cypress/cypress/integration/simple_spec.js b/.cypress/cypress/integration/simple_spec.js
index 7040681a3..48c80840b 100644
--- a/.cypress/cypress/integration/simple_spec.js
+++ b/.cypress/cypress/integration/simple_spec.js
@@ -11,8 +11,8 @@ describe('Clicking the map', function() {
cy.get('#map_box').click(200, 200);
cy.get('[name=title]').type('Title');
cy.get('[name=detail]').type('Detail');
- cy.get('#js-new-report-user-show').click();
- cy.get('#js-new-report-show-sign-in').click();
+ cy.get('.js-new-report-user-show').click();
+ cy.get('.js-new-report-show-sign-in').should('be.visible').click();
cy.get('#form_username_sign_in').type('user@example.org');
cy.get('[name=password_sign_in]').type('password');
cy.get('[name=password_sign_in]').parents('form').submit();
@@ -22,6 +22,39 @@ describe('Clicking the map', function() {
});
});
+describe('Leaving updates', function() {
+ function leave_update() {
+ cy.get('[name=update]').type('Update');
+ cy.get('.js-new-report-user-show:last').click();
+ cy.get('.js-new-report-show-sign-in:last').should('be.visible').click();
+ // [id=]:last due to #2341
+ cy.get('[id=form_username_sign_in]:last').type('user@example.org');
+ cy.get('[name=password_sign_in]:last').type('password');
+ cy.get('[name=password_sign_in]:last').parents('form:first').submit();
+ cy.get('#map_sidebar').should('contain', 'check and confirm your details');
+ cy.get('.js-new-report-user-show').click(); // Should not have to do this, #2340
+ cy.get('[name=submit_register]').parents('form').submit();
+ cy.get('body').should('contain', 'Thank you for updating this issue');
+ }
+
+ it('works when visited directly', function() {
+ cy.visit('/report/15');
+ leave_update();
+ });
+
+ it('works when pulled in via JS', function() {
+ cy.server();
+ 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');
+ // 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');
+ leave_update();
+ });
+});
+
describe('Clicking the "big green banner" on a map page', function() {
before(function() {
cy.visit('/');