Skip to content

Commit 84553f7

Browse files
committed
fix: don't use deprecated searchForIssuesUsingJqlPost() method
1 parent b273508 commit 84553f7

File tree

2 files changed

+38
-31
lines changed

2 files changed

+38
-31
lines changed

src/jira.ts

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,20 @@ export class Jira {
3636
async getIssuesByID(issues: string[]) {
3737
this.JQL = `issue in (${issues.join(',')}) ORDER BY id DESC`;
3838

39-
const response = await this.api.issueSearch.searchForIssuesUsingJqlPost({
40-
jql: this.JQL,
41-
fields: [
42-
'id',
43-
'issuetype',
44-
'status',
45-
'components',
46-
'summary',
47-
'assignee',
48-
this.fields.storyPoints,
49-
this.fields.priority,
50-
],
51-
});
39+
const response =
40+
await this.api.issueSearch.searchForIssuesUsingJqlEnhancedSearchPost({
41+
jql: this.JQL,
42+
fields: [
43+
'id',
44+
'issuetype',
45+
'status',
46+
'components',
47+
'summary',
48+
'assignee',
49+
this.fields.storyPoints,
50+
this.fields.priority,
51+
],
52+
});
5253

5354
// TODO: if no issues found dont fail
5455
return response.issues ?? raise('Jira.getIssuesByID(): missing issues.');
@@ -69,19 +70,20 @@ export class Jira {
6970
this.JQL += this.composeOptionsJQL('AssignedTeam', team);
7071
this.JQL += ' ORDER BY id DESC';
7172

72-
const response = await this.api.issueSearch.searchForIssuesUsingJqlPost({
73-
jql: this.JQL,
74-
fields: [
75-
'id',
76-
'issuetype',
77-
'status',
78-
'components',
79-
'summary',
80-
'assignee',
81-
this.fields.storyPoints,
82-
this.fields.priority,
83-
],
84-
});
73+
const response =
74+
await this.api.issueSearch.searchForIssuesUsingJqlEnhancedSearchPost({
75+
jql: this.JQL,
76+
fields: [
77+
'id',
78+
'issuetype',
79+
'status',
80+
'components',
81+
'summary',
82+
'assignee',
83+
this.fields.storyPoints,
84+
this.fields.priority,
85+
],
86+
});
8587

8688
// TODO: if no issues found dont fail
8789
return response.issues ?? raise('Jira.getIssues(): missing issues.');

test/unit/jira.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Jira } from '../../src/jira';
55
const mocks = vi.hoisted(() => {
66
return {
77
getServerInfo: vi.fn(),
8-
searchForIssuesUsingJqlPost: vi.fn(),
8+
searchForIssuesUsingJqlEnhancedSearchPost: vi.fn(),
99
editIssue: vi.fn(),
1010
};
1111
});
@@ -17,7 +17,8 @@ vi.mock('jira.js', () => {
1717
getServerInfo: mocks.getServerInfo,
1818
},
1919
issueSearch: {
20-
searchForIssuesUsingJqlPost: mocks.searchForIssuesUsingJqlPost,
20+
searchForIssuesUsingJqlEnhancedSearchPost:
21+
mocks.searchForIssuesUsingJqlEnhancedSearchPost,
2122
},
2223
issues: {
2324
editIssue: mocks.editIssue,
@@ -39,7 +40,7 @@ describe('Jira functions', () => {
3940
version: '8.0.0',
4041
});
4142

42-
mocks.searchForIssuesUsingJqlPost.mockReturnValue({
43+
mocks.searchForIssuesUsingJqlEnhancedSearchPost.mockReturnValue({
4344
issues: [
4445
{
4546
key: 'RHEL-1234',
@@ -107,7 +108,9 @@ describe('Jira functions', () => {
107108
expect(jira.JQL).toMatchInlineSnapshot(
108109
`"issue in (RHEL-1234,RHEL-1235) ORDER BY id DESC"`
109110
);
110-
expect(mocks.searchForIssuesUsingJqlPost).toHaveBeenCalledWith({
111+
expect(
112+
mocks.searchForIssuesUsingJqlEnhancedSearchPost
113+
).toHaveBeenCalledWith({
111114
fields: [
112115
'id',
113116
'issuetype',
@@ -175,7 +178,9 @@ describe('Jira functions', () => {
175178
expect(jira.JQL).toMatchInlineSnapshot(
176179
`"Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed ORDER BY id DESC"`
177180
);
178-
expect(mocks.searchForIssuesUsingJqlPost).toHaveBeenCalledWith({
181+
expect(
182+
mocks.searchForIssuesUsingJqlEnhancedSearchPost
183+
).toHaveBeenCalledWith({
179184
fields: [
180185
'id',
181186
'issuetype',

0 commit comments

Comments
 (0)