Skip to content

Commit

Permalink
[MI-2337]: Fixed CI errors and few review comments of PR mattermost#894
Browse files Browse the repository at this point in the history
  • Loading branch information
Nityanand13 committed Dec 9, 2022
1 parent 188870e commit 364c71a
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 30 deletions.
10 changes: 5 additions & 5 deletions server/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
65 changes: 40 additions & 25 deletions webapp/src/utils/jira_issue_metadata.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down

0 comments on commit 364c71a

Please sign in to comment.