diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-10-14 14:06:41 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-10-15 09:55:29 +0100 |
commit | b9bf7359af5ae992f09ec770681fa7354ccb68eb (patch) | |
tree | 39d62b9d60a4b7abb09d77801cfd6cbe1ddd61ac | |
parent | 6a55d13ba170a49bff5cde04d800ded9c68c74a3 (diff) |
Fix issue loading inspector duplicates on /around.
As there are two category drop-downs in this situation (one in the
hidden reporting form, one in the inspect form), the correct entry
needs to be specified.
-rw-r--r-- | .cypress/cypress/integration/duplicates.js | 27 | ||||
-rw-r--r-- | web/js/duplicates.js | 9 |
2 files changed, 33 insertions, 3 deletions
diff --git a/.cypress/cypress/integration/duplicates.js b/.cypress/cypress/integration/duplicates.js index 988a6a602..406b3fb67 100644 --- a/.cypress/cypress/integration/duplicates.js +++ b/.cypress/cypress/integration/duplicates.js @@ -50,4 +50,31 @@ describe('Duplicate tests', function() { cy.get('#js-duplicate-reports').should('not.exist'); }); + 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/reports'); + cy.get('[href$="/report/1"]:last').click(); + cy.get('#report_inspect_form #state').select('Duplicate'); + cy.get('#js-duplicate-reports li h3 a').should('have.attr', 'href', '/report/1'); + }); + + it('lets an inspector see duplicate reports coming from /around', 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/report/1'); + cy.contains('Back to all').click(); + cy.get('[href$="/report/1"]:last').click(); + cy.get('#report_inspect_form #state').select('Duplicate'); + cy.get('#js-duplicate-reports li h3 a').should('have.attr', 'href', '/report/1'); + }); + }); diff --git a/web/js/duplicates.js b/web/js/duplicates.js index a8aceb9e3..ede22dc18 100644 --- a/web/js/duplicates.js +++ b/web/js/duplicates.js @@ -13,12 +13,14 @@ // but undefined on new report page. var report_id = $("#report_inspect_form .js-report-id").text() || undefined; - function refresh_duplicate_list(evt, params) { + function refresh_duplicate_list(evt, params, category) { if (params && params.skip_duplicates) { return; } - var category = $('select[name="category"]').val(); + if (!category) { + category = $('select[name="category"]').val(); + } if (category === '-- Pick a category --') { return; } @@ -195,7 +197,8 @@ if (!!duplicate_of) { return; } - refresh_duplicate_list(); + var category = $("#report_inspect_form [name=category]").val(); + refresh_duplicate_list(undefined, {}, category); } function take_effect() { |