aboutsummaryrefslogtreecommitdiffstats
path: root/.cypress/cypress/integration/duplicates.js
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-10-14 14:03:44 +0100
committerMatthew Somerville <matthew@mysociety.org>2019-10-15 09:55:29 +0100
commit6a55d13ba170a49bff5cde04d800ded9c68c74a3 (patch)
treeee68e21a88091ce6330b03e1e1113dc4a315e21d /.cypress/cypress/integration/duplicates.js
parent171da27bfdd0858c11f064a6aea78c93a0d5b78e (diff)
Fix issue loading duplicates when not to be shown.
If the duplicates.js file is loaded, then its mechanisms come into play, and it fetches duplicates and hides the reporting form if there are any. So we only want this to happen in the same situations as it being loaded elsewhere, on a relevant cobrand and not just after signing in.
Diffstat (limited to '.cypress/cypress/integration/duplicates.js')
-rw-r--r--.cypress/cypress/integration/duplicates.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/.cypress/cypress/integration/duplicates.js b/.cypress/cypress/integration/duplicates.js
new file mode 100644
index 000000000..988a6a602
--- /dev/null
+++ b/.cypress/cypress/integration/duplicates.js
@@ -0,0 +1,53 @@
+describe('Duplicate tests', function() {
+ it('does not try and fetch duplicates which will not get shown', function() {
+ cy.server();
+ cy.route('/report/new/ajax*').as('report-ajax');
+ cy.request({
+ method: 'POST',
+ url: '/auth?r=/',
+ form: true,
+ body: { username: 'admin@example.org', password_sign_in: 'password' }
+ });
+ cy.visit('http://fixmystreet.localhost:3001/report/1');
+ cy.contains('Report another problem here').click();
+ cy.wait('@report-ajax');
+ cy.get('[id=category_group]').select('Potholes');
+ cy.wait(500);
+ cy.get('[name=title').should('be.visible');
+ });
+
+ it('hides everything when duplicate suggestions are shown', function() {
+ cy.server();
+ cy.route('/report/new/ajax*').as('report-ajax');
+ cy.visit('http://borsetshire.localhost:3001/_test/setup/regression-duplicate-hide'); // 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('Licensing');
+ cy.get('[id=subcategory_Licensing]').select('Skips');
+ cy.get('.extra-category-questions').should('not.be.visible');
+ cy.visit('http://borsetshire.localhost:3001/_test/teardown/regression-duplicate-hide');
+ });
+
+ it('does not show duplicate suggestions when signing in during reporting', function() {
+ cy.server();
+ cy.route('/report/new/ajax*').as('report-ajax');
+ cy.route('/around/nearby*').as('nearby-ajax');
+ 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('Potholes');
+ cy.wait('@nearby-ajax');
+ cy.get('.js-hide-duplicate-suggestions:first').should('be.visible').click();
+ 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').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();
+ cy.get('#map_sidebar').should('contain', 'check and confirm your details');
+ cy.get('#js-duplicate-reports').should('not.exist');
+ });
+
+});