From 364c71ae74f031951dfe2d1a8d1dd4e4f35d5f24 Mon Sep 17 00:00:00 2001 From: Nityanand Rai Date: Fri, 9 Dec 2022 11:18:39 +0530 Subject: [PATCH] [MI-2337]: Fixed CI errors and few review comments of PR #894 --- server/client.go | 10 +- .../channel_subscription_filter.test.tsx.snap | 28 +++ ...channel_subscription_filters.test.tsx.snap | 28 +++ .../edit_channel_subscription.test.tsx.snap | 170 ++++++++++++++++++ webapp/src/utils/jira_issue_metadata.test.tsx | 65 ++++--- 5 files changed, 271 insertions(+), 30 deletions(-) diff --git a/server/client.go b/server/client.go index be01c6d39..28a0aa11d 100644 --- a/server/client.go +++ b/server/client.go @@ -255,16 +255,16 @@ type AutoCompleteResult struct { Results []Result `json:"results"` } -type GroupItem struct { +type JiraUserGroup struct { Name string `json:"name"` } -type GroupsInfo struct { - GroupsItem []GroupItem `json:"items"` +type JiraUserGroupCollection struct { + GroupsItem []JiraUserGroup `json:"items"` } type CommentVisibilityResult struct { - Groups GroupsInfo `json:"groups"` + Groups JiraUserGroupCollection `json:"groups"` } // SearchAutoCompleteFields searches fieldValue specified in the params and returns autocomplete suggestions @@ -286,7 +286,7 @@ func (client JiraClient) SearchCommentVisibilityFields(params map[string]string) if err := client.RESTGet(commentVisibilityRoute, params, result); err != nil { return nil, err } - result.Groups.GroupsItem = append(result.Groups.GroupsItem, GroupItem{visibleToAllUsers}) + result.Groups.GroupsItem = append(result.Groups.GroupsItem, JiraUserGroup{visibleToAllUsers}) return result, nil } diff --git a/webapp/src/components/modals/channel_subscriptions/__snapshots__/channel_subscription_filter.test.tsx.snap b/webapp/src/components/modals/channel_subscriptions/__snapshots__/channel_subscription_filter.test.tsx.snap index 8cd36dee5..fee5b34ec 100644 --- a/webapp/src/components/modals/channel_subscriptions/__snapshots__/channel_subscription_filter.test.tsx.snap +++ b/webapp/src/components/modals/channel_subscriptions/__snapshots__/channel_subscription_filter.test.tsx.snap @@ -50,6 +50,34 @@ exports[`components/ChannelSubscriptionFilter should match snapshot 1`] = ` "label": "Affects versions", "value": "versions", }, + Object { + "label": "Comment Visibility", + "value": "commentVisibility", + }, + Object { + "label": "Comment Visibility", + "value": "commentVisibility", + }, + Object { + "label": "Comment Visibility", + "value": "commentVisibility", + }, + Object { + "label": "Comment Visibility", + "value": "commentVisibility", + }, + Object { + "label": "Comment Visibility", + "value": "commentVisibility", + }, + Object { + "label": "Comment Visibility", + "value": "commentVisibility", + }, + Object { + "label": "Comment Visibility", + "value": "commentVisibility", + }, Object { "label": "Epic Link", "value": "customfield_10014", diff --git a/webapp/src/components/modals/channel_subscriptions/__snapshots__/channel_subscription_filters.test.tsx.snap b/webapp/src/components/modals/channel_subscriptions/__snapshots__/channel_subscription_filters.test.tsx.snap index ef1cfd844..ace7afebc 100644 --- a/webapp/src/components/modals/channel_subscriptions/__snapshots__/channel_subscription_filters.test.tsx.snap +++ b/webapp/src/components/modals/channel_subscriptions/__snapshots__/channel_subscription_filters.test.tsx.snap @@ -60,6 +60,20 @@ exports[`components/ChannelSubscriptionFilters should match snapshot 1`] = ` } fields={ Array [ + Object { + "issueTypes": Array [ + Object { + "id": "10001", + "name": "Bug", + }, + ], + "key": "commentVisibility", + "name": "Comment Visibility", + "schema": Object { + "type": "commentVisibility", + }, + "values": Array [], + }, Object { "issueTypes": Array [ Object { @@ -177,6 +191,20 @@ exports[`components/ChannelSubscriptionFilters should match snapshot 1`] = ` } fields={ Array [ + Object { + "issueTypes": Array [ + Object { + "id": "10001", + "name": "Bug", + }, + ], + "key": "commentVisibility", + "name": "Comment Visibility", + "schema": Object { + "type": "commentVisibility", + }, + "values": Array [], + }, Object { "issueTypes": Array [ Object { diff --git a/webapp/src/components/modals/channel_subscriptions/__snapshots__/edit_channel_subscription.test.tsx.snap b/webapp/src/components/modals/channel_subscriptions/__snapshots__/edit_channel_subscription.test.tsx.snap index 9ff6146e3..d6bbae96e 100644 --- a/webapp/src/components/modals/channel_subscriptions/__snapshots__/edit_channel_subscription.test.tsx.snap +++ b/webapp/src/components/modals/channel_subscriptions/__snapshots__/edit_channel_subscription.test.tsx.snap @@ -521,6 +521,176 @@ exports[`components/EditChannelSubscription should match snapshot after fetching }, ], }, + Object { + "issueTypes": Array [ + Object { + "id": "10004", + "name": "Bug", + }, + ], + "key": "commentVisibility", + "name": "Comment Visibility", + "schema": Object { + "type": "commentVisibility", + }, + "values": Array [], + }, + Object { + "issueTypes": Array [ + Object { + "id": "10002", + "name": "Task", + }, + Object { + "id": "10001", + "name": "Story", + }, + Object { + "id": "10004", + "name": "Bug", + }, + Object { + "id": "10000", + "name": "Epic", + }, + ], + "key": "commentVisibility", + "name": "Comment Visibility", + "schema": Object { + "type": "commentVisibility", + }, + "values": Array [], + }, + Object { + "issueTypes": Array [ + Object { + "id": "10002", + "name": "Task", + }, + Object { + "id": "10001", + "name": "Story", + }, + Object { + "id": "10004", + "name": "Bug", + }, + Object { + "id": "10000", + "name": "Epic", + }, + ], + "key": "commentVisibility", + "name": "Comment Visibility", + "schema": Object { + "type": "commentVisibility", + }, + "values": Array [], + }, + Object { + "issueTypes": Array [ + Object { + "id": "10002", + "name": "Task", + }, + Object { + "id": "10001", + "name": "Story", + }, + Object { + "id": "10004", + "name": "Bug", + }, + Object { + "id": "10000", + "name": "Epic", + }, + ], + "key": "commentVisibility", + "name": "Comment Visibility", + "schema": Object { + "type": "commentVisibility", + }, + "values": Array [], + }, + Object { + "issueTypes": Array [ + Object { + "id": "10002", + "name": "Task", + }, + Object { + "id": "10001", + "name": "Story", + }, + Object { + "id": "10004", + "name": "Bug", + }, + Object { + "id": "10000", + "name": "Epic", + }, + ], + "key": "commentVisibility", + "name": "Comment Visibility", + "schema": Object { + "type": "commentVisibility", + }, + "values": Array [], + }, + Object { + "issueTypes": Array [ + Object { + "id": "10002", + "name": "Task", + }, + Object { + "id": "10001", + "name": "Story", + }, + Object { + "id": "10004", + "name": "Bug", + }, + Object { + "id": "10000", + "name": "Epic", + }, + ], + "key": "commentVisibility", + "name": "Comment Visibility", + "schema": Object { + "type": "commentVisibility", + }, + "values": Array [], + }, + Object { + "issueTypes": Array [ + Object { + "id": "10002", + "name": "Task", + }, + Object { + "id": "10001", + "name": "Story", + }, + Object { + "id": "10004", + "name": "Bug", + }, + Object { + "id": "10000", + "name": "Epic", + }, + ], + "key": "commentVisibility", + "name": "Comment Visibility", + "schema": Object { + "type": "commentVisibility", + }, + "values": Array [], + }, Object { "issueTypes": Array [ Object { diff --git a/webapp/src/utils/jira_issue_metadata.test.tsx b/webapp/src/utils/jira_issue_metadata.test.tsx index a69cbdd96..f202db464 100644 --- a/webapp/src/utils/jira_issue_metadata.test.tsx +++ b/webapp/src/utils/jira_issue_metadata.test.tsx @@ -92,11 +92,14 @@ describe('utils/jira_issue_metadata', () => { const actual = getCustomFieldFiltersForProjects(metadata, [projectKey]); expect(actual).not.toBe(null); - expect(actual.length).toBe(1); - - expect(actual[0].key).toEqual('custom1'); - expect(actual[0].name).toEqual('MJK - Checkbox'); - expect(actual[0].values).toEqual([{value: '10033', label: '1'}, {value: '10034', label: '2'}]); + expect(actual.length).toBe(2); + + expect(actual[0].key).toEqual('commentVisibility'); + expect(actual[0].name).toEqual('Comment Visibility'); + expect(actual[0].values).toEqual([]); + expect(actual[1].key).toEqual('custom1'); + expect(actual[1].name).toEqual('MJK - Checkbox'); + expect(actual[1].values).toEqual([{value: '10033', label: '1'}, {value: '10034', label: '2'}]); }); test('should return options for single-select options', () => { @@ -132,11 +135,14 @@ describe('utils/jira_issue_metadata', () => { const actual = getCustomFieldFiltersForProjects(metadata, [projectKey]); expect(actual).not.toBe(null); - expect(actual.length).toBe(1); - - expect(actual[0].key).toEqual('custom1'); - expect(actual[0].name).toEqual('MJK - Radio Buttons'); - expect(actual[0].values).toEqual([{value: '10035', label: '1'}, {value: '10036', label: '2'}]); + expect(actual.length).toBe(2); + + expect(actual[0].key).toEqual('commentVisibility'); + expect(actual[0].name).toEqual('Comment Visibility'); + expect(actual[0].values).toEqual([]); + expect(actual[1].key).toEqual('custom1'); + expect(actual[1].name).toEqual('MJK - Radio Buttons'); + expect(actual[1].values).toEqual([{value: '10035', label: '1'}, {value: '10036', label: '2'}]); }); test('should return options for priority', () => { @@ -197,11 +203,14 @@ describe('utils/jira_issue_metadata', () => { const actual = getCustomFieldFiltersForProjects(metadata, [projectKey]); expect(actual).not.toBe(null); - expect(actual.length).toBe(1); - - expect(actual[0].key).toEqual('priority'); - expect(actual[0].name).toEqual('Priority'); - expect(actual[0].values).toEqual([{value: '1', label: 'Highest'}, {value: '2', label: 'High'}, {value: '3', label: 'Medium'}, {value: '4', label: 'Low'}, {value: '5', label: 'Lowest'}]); + expect(actual.length).toBe(2); + + expect(actual[0].key).toEqual('commentVisibility'); + expect(actual[0].name).toEqual('Comment Visibility'); + expect(actual[0].values).toEqual([]); + expect(actual[1].key).toEqual('priority'); + expect(actual[1].name).toEqual('Priority'); + expect(actual[1].values).toEqual([{value: '1', label: 'Highest'}, {value: '2', label: 'High'}, {value: '3', label: 'Medium'}, {value: '4', label: 'Low'}, {value: '5', label: 'Lowest'}]); }); test('should return options for fix version', () => { @@ -231,11 +240,14 @@ describe('utils/jira_issue_metadata', () => { const actual = getCustomFieldFiltersForProjects(metadata, [projectKey]); expect(actual).not.toBe(null); - expect(actual.length).toBe(1); - - expect(actual[0].key).toEqual('fixVersions'); - expect(actual[0].name).toEqual('Fix versions'); - expect(actual[0].values).toEqual([{value: '10000', label: '5.14 (August 2019)'}]); + expect(actual.length).toBe(2); + + expect(actual[0].key).toEqual('commentVisibility'); + expect(actual[0].name).toEqual('Comment Visibility'); + expect(actual[0].values).toEqual([]); + expect(actual[1].key).toEqual('fixVersions'); + expect(actual[1].name).toEqual('Fix versions'); + expect(actual[1].values).toEqual([{value: '10000', label: '5.14 (August 2019)'}]); }); test('should return options for security level', () => { @@ -284,11 +296,14 @@ describe('utils/jira_issue_metadata', () => { const actual = getCustomFieldFiltersForProjects(metadata, [projectKey]); expect(actual).not.toBe(null); - expect(actual.length).toBe(1); - - expect(actual[0].key).toEqual('security'); - expect(actual[0].name).toEqual('Security Level'); - expect(actual[0].values).toEqual([{value: '10001', label: 'Admin only'}, {value: '10000', label: 'Everyone'}, {value: '10002', label: 'Staff'}]); + expect(actual.length).toBe(2); + + expect(actual[0].key).toEqual('commentVisibility'); + expect(actual[0].name).toEqual('Comment Visibility'); + expect(actual[0].values).toEqual([]); + expect(actual[1].key).toEqual('security'); + expect(actual[1].name).toEqual('Security Level'); + expect(actual[1].values).toEqual([{value: '10001', label: 'Admin only'}, {value: '10000', label: 'Everyone'}, {value: '10002', label: 'Staff'}]); }); test('should return options with a `userDefined` flag for array of strings', () => {