diff options
-rw-r--r-- | .cypress/cypress/integration/simple_spec.js | 37 | ||||
-rw-r--r-- | templates/web/base/report/form/private_details.html | 2 | ||||
-rw-r--r-- | templates/web/base/report/form/user.html | 4 | ||||
-rw-r--r-- | templates/web/base/report/form/user_loggedout_password.html | 4 | ||||
-rw-r--r-- | templates/web/base/report/new/form_user.html | 2 | ||||
-rw-r--r-- | templates/web/base/report/update/form_user.html | 2 | ||||
-rw-r--r-- | templates/web/bromley/report/form/private_details.html | 2 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 10 |
8 files changed, 48 insertions, 15 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('/'); diff --git a/templates/web/base/report/form/private_details.html b/templates/web/base/report/form/private_details.html index 7184d7e25..5e5c23c24 100644 --- a/templates/web/base/report/form/private_details.html +++ b/templates/web/base/report/form/private_details.html @@ -3,7 +3,7 @@ [% UNLESS c.user_exists %] <p class="hidden-nojs js-new-report-sign-in-hidden"> - <a id="js-new-report-show-sign-in" href="#">[% loc('Or sign in with password to prefill this information.') %]</a> + <a class="js-new-report-show-sign-in" href="#">[% loc('Or sign in with password to prefill this information.') %]</a> </p> [% END %] diff --git a/templates/web/base/report/form/user.html b/templates/web/base/report/form/user.html index 9e5eaf3af..6381d2928 100644 --- a/templates/web/base/report/form/user.html +++ b/templates/web/base/report/form/user.html @@ -5,7 +5,7 @@ [% loc('Next:') %] [% loc('Tell us about you') %] </h2> [% IF c.user_exists OR NOT c.cobrand.social_auth_enabled %] - <button id="js-new-report-user-show" class="btn btn--block hidden-nojs">[% loc('Continue') %]</button> + <button class="btn btn--block hidden-nojs js-new-report-user-show">[% loc('Continue') %]</button> [% ELSE %] [% IF c.config.FACEBOOK_APP_ID %] <button name="facebook_sign_in" id="facebook_sign_in" value="facebook_sign_in" class="btn btn--block btn--social btn--facebook"> @@ -19,7 +19,7 @@ [% loc('Log in with Twitter') %] </button> [% END %] - <button id="js-new-report-user-show" class="btn btn--block hidden-nojs">[% loc('Log in with email') %]</button> + <button class="btn btn--block hidden-nojs js-new-report-user-show">[% loc('Log in with email') %]</button> [% END %] </div> <!-- /report/form/user.html --> diff --git a/templates/web/base/report/form/user_loggedout_password.html b/templates/web/base/report/form/user_loggedout_password.html index dfd7d0d14..02cfc9525 100644 --- a/templates/web/base/report/form/user_loggedout_password.html +++ b/templates/web/base/report/form/user_loggedout_password.html @@ -5,7 +5,7 @@ <p class="hidden-nojs"> [% loc('No account?') %] - <a id="js-new-report-hide-sign-in" href="#">[% loc('Fill in your details manually.') %]</a> + <a class="js-new-report-hide-sign-in" href="#">[% loc('Fill in your details manually.') %]</a> </p> [% IF c.cobrand.social_auth_enabled %] @@ -22,7 +22,7 @@ <p class="hidden-nojs"> [% loc('Forgotten your password?') %] - <a id="js-new-report-sign-in-forgotten" href="#">[% loc('Fill in your details manually.') %]</a> + <a class="js-new-report-sign-in-forgotten" href="#">[% loc('Fill in your details manually.') %]</a> </p> <div class="general-notes"> diff --git a/templates/web/base/report/new/form_user.html b/templates/web/base/report/new/form_user.html index a3f236964..33f40486b 100644 --- a/templates/web/base/report/new/form_user.html +++ b/templates/web/base/report/new/form_user.html @@ -10,7 +10,7 @@ <strong class="js-form-section-preview" data-source="#form_title"></strong> <span class="js-form-section-preview" data-source="#form_detail"></span> </p> - <button id="js-new-report-user-hide" class="btn btn--block">[% loc('Edit report details') %]</button> + <button class="btn btn--block js-new-report-user-hide">[% loc('Edit report details') %]</button> </div> [% IF c.user_exists %] diff --git a/templates/web/base/report/update/form_user.html b/templates/web/base/report/update/form_user.html index 47ba18c12..ed47c8181 100644 --- a/templates/web/base/report/update/form_user.html +++ b/templates/web/base/report/update/form_user.html @@ -4,7 +4,7 @@ <div class="hidden-nojs form-section-preview"> <h2 class="form-section-heading">[% loc('Your update') %]</h2> <p class="js-form-section-preview" data-source="#form_update"></p> - <button id="js-new-report-user-hide" class="btn btn--block">[% loc('Edit your update') %]</button> + <button class="btn btn--block js-new-report-user-hide">[% loc('Edit your update') %]</button> </div> [% IF c.user_exists %] diff --git a/templates/web/bromley/report/form/private_details.html b/templates/web/bromley/report/form/private_details.html index d146c7ca3..0de56a748 100644 --- a/templates/web/bromley/report/form/private_details.html +++ b/templates/web/bromley/report/form/private_details.html @@ -3,7 +3,7 @@ [% UNLESS c.user_exists %] <p class="hidden-nojs js-new-report-sign-in-hidden"> - <a id="js-new-report-show-sign-in" href="#">[% loc('Or sign in with password to prefill this information.') %]</a> + <a class="js-new-report-show-sign-in" href="#">[% loc('Or sign in with password to prefill this information.') %]</a> </p> [% END %] diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index 5163501c1..c15fe0375 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -880,13 +880,13 @@ $.extend(fixmystreet.set_up, { // Display tweak $('.js-new-report-sign-in-hidden.form-box, .js-new-report-sign-in-shown.form-box').removeClass('form-box'); - $('#js-new-report-user-hide').click(function(e) { + $('.js-new-report-user-hide').click(function(e) { e.preventDefault(); $('.js-new-report-user-shown')[0].scrollIntoView({behavior: "smooth"}); hide('.js-new-report-user-shown'); show('.js-new-report-user-hidden'); }); - $('#js-new-report-user-show').click(function(e) { + $('.js-new-report-user-show').click(function(e) { e.preventDefault(); if (!$(this).closest('form').validate().form()) { return; @@ -898,20 +898,20 @@ $.extend(fixmystreet.set_up, { }); }); - $('#js-new-report-show-sign-in').click(function(e) { + $('.js-new-report-show-sign-in').click(function(e) { $('.js-new-report-sign-in-shown').removeClass('hidden-js'); $('.js-new-report-sign-in-hidden').addClass('hidden-js'); focusFirstVisibleInput(); }); - $('#js-new-report-hide-sign-in').click(function(e) { + $('.js-new-report-hide-sign-in').click(function(e) { e.preventDefault(); $('.js-new-report-sign-in-shown').addClass('hidden-js'); $('.js-new-report-sign-in-hidden').removeClass('hidden-js'); focusFirstVisibleInput(); }); - $('#js-new-report-sign-in-forgotten').click(function() { + $('.js-new-report-sign-in-forgotten').click(function() { $('.js-new-report-sign-in-shown').addClass('hidden-js'); $('.js-new-report-sign-in-hidden').removeClass('hidden-js'); $('.js-new-report-forgotten-shown').removeClass('hidden-js'); |