From: Mathieu Suen Date: Tue, 29 Mar 2022 12:49:34 +0000 (+0200) Subject: SONAR-16165 Fix multi select of author facet X-Git-Tag: 9.4.0.54424~36 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=aa9f8f3a84f3bc8eb6090e12e63bc4fc3be59e35;p=sonarqube.git SONAR-16165 Fix multi select of author facet --- diff --git a/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts index 91651e35d9d..a220b5fb908 100644 --- a/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts @@ -21,6 +21,7 @@ import { scrollToElement } from '../../../helpers/scrolling'; import { SecurityStandard } from '../../../types/security'; import { scrollToIssue, + serializeQuery, shouldOpenSonarSourceSecurityFacet, shouldOpenStandardsChildFacet, shouldOpenStandardsFacet @@ -34,6 +35,68 @@ beforeEach(() => { jest.clearAllMocks(); }); +describe('serialize/deserialize', () => { + it('should serlialize correctly', () => { + expect( + serializeQuery({ + assigned: true, + assignees: ['a', 'b'], + author: ['a', 'b'], + createdAfter: new Date(1000000), + createdAt: 'a', + createdBefore: new Date(1000000), + createdInLast: 'a', + cwe: ['18', '19'], + directories: ['a', 'b'], + files: ['a', 'b'], + issues: ['a', 'b'], + languages: ['a', 'b'], + owaspTop10: ['a', 'b'], + 'owaspTop10-2021': ['a', 'b'], + projects: ['a', 'b'], + resolutions: ['a', 'b'], + resolved: true, + rules: ['a', 'b'], + sort: 'rules', + sansTop25: ['a', 'b'], + scopes: ['a', 'b'], + severities: ['a', 'b'], + sinceLeakPeriod: true, + sonarsourceSecurity: ['a', 'b'], + statuses: ['a', 'b'], + tags: ['a', 'b'], + types: ['a', 'b'] + }) + ).toStrictEqual({ + assignees: 'a,b', + author: ['a', 'b'], + createdAt: 'a', + createdBefore: '1970-01-01', + createdAfter: '1970-01-01', + createdInLast: 'a', + cwe: '18,19', + directories: 'a,b', + files: 'a,b', + issues: 'a,b', + languages: 'a,b', + owaspTop10: 'a,b', + 'owaspTop10-2021': 'a,b', + projects: 'a,b', + resolutions: 'a,b', + rules: 'a,b', + s: 'rules', + sansTop25: 'a,b', + scopes: 'a,b', + severities: 'a,b', + sinceLeakPeriod: 'true', + sonarsourceSecurity: 'a,b', + statuses: 'a,b', + tags: 'a,b', + types: 'a,b' + }); + }); +}); + describe('scrollToIssue', () => { it('should scroll to the issue', () => { document.querySelector = jest.fn(() => ({})); diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesApp-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesApp-test.tsx index 5a43255cc15..ff7dfd752ad 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesApp-test.tsx @@ -173,6 +173,7 @@ it('should handle my issue change properly', () => { pathname: '/issues', query: { id: 'foo', + author: [], myIssues: 'true' } }); diff --git a/server/sonar-web/src/main/js/apps/issues/utils.ts b/server/sonar-web/src/main/js/apps/issues/utils.ts index 4ce712a7825..0805f292f4e 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.ts +++ b/server/sonar-web/src/main/js/apps/issues/utils.ts @@ -123,7 +123,7 @@ export function serializeQuery(query: Query): RawQuery { const filter = { assigned: query.assigned ? undefined : 'false', assignees: serializeStringArray(query.assignees), - author: serializeStringArray(query.author), + author: query.author, createdAfter: serializeDateShort(query.createdAfter), createdAt: serializeString(query.createdAt), createdBefore: serializeDateShort(query.createdBefore),