Skip to content

Commit 534e504

Browse files
committed
fix: don't use deprecated searchForIssuesUsingJqlPost() method
1 parent 0759b7e commit 534e504

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
@@ -37,19 +37,20 @@ export class Jira {
3737
async getIssuesByID(issues: string[]) {
3838
this.JQL = `issue in (${issues.join(',')}) ORDER BY id DESC`;
3939

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

5455
// TODO: if no issues found dont fail
5556
return response.issues ?? raise('Jira.getIssuesByID(): missing issues.');
@@ -80,19 +81,20 @@ export class Jira {
8081
this.JQL +=
8182
this.JQL.search(/.*order\s+by/i) === -1 ? ' ORDER BY id DESC' : '';
8283

83-
const response = await this.api.issueSearch.searchForIssuesUsingJqlPost({
84-
jql: this.JQL,
85-
fields: [
86-
'id',
87-
'issuetype',
88-
'status',
89-
'components',
90-
'summary',
91-
'assignee',
92-
this.fields.storyPoints,
93-
this.fields.priority,
94-
],
95-
});
84+
const response =
85+
await this.api.issueSearch.searchForIssuesUsingJqlEnhancedSearchPost({
86+
jql: this.JQL,
87+
fields: [
88+
'id',
89+
'issuetype',
90+
'status',
91+
'components',
92+
'summary',
93+
'assignee',
94+
this.fields.storyPoints,
95+
this.fields.priority,
96+
],
97+
});
9698

9799
// TODO: if no issues found dont fail
98100
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 in (RHEL, "RHEL Miscellaneous", Fedora) 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)