]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16165 Fix multi select of author facet
authorMathieu Suen <mathieu.suen@sonarsource.com>
Tue, 29 Mar 2022 12:49:34 +0000 (14:49 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 29 Mar 2022 20:03:37 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts
server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesApp-test.tsx
server/sonar-web/src/main/js/apps/issues/utils.ts

index 91651e35d9d412bdebf11cb98eccc37e508f6760..a220b5fb9082cd7e0322c2fcb66ba61f8a2e1065 100644 (file)
@@ -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(() => ({}));
index 5a43255cc15cef10970549bda0673bed2b0dfef2..ff7dfd752adf126f2d950639315f5df2332c4a4e 100644 (file)
@@ -173,6 +173,7 @@ it('should handle my issue change properly', () => {
     pathname: '/issues',
     query: {
       id: 'foo',
+      author: [],
       myIssues: 'true'
     }
   });
index 4ce712a782592c886780e7a7ca290dcd1850809c..0805f292f4e3f06b1c831df70eec7a4abe99228a 100644 (file)
@@ -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),