Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 28 additions & 26 deletions src/jira.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,20 @@ export class Jira {
async getIssuesByID(issues: string[]) {
this.JQL = `issue in (${issues.join(',')}) ORDER BY id DESC`;

const response = await this.api.issueSearch.searchForIssuesUsingJqlPost({
jql: this.JQL,
fields: [
'id',
'issuetype',
'status',
'components',
'summary',
'assignee',
this.fields.storyPoints,
this.fields.priority,
],
});
const response =
await this.api.issueSearch.searchForIssuesUsingJqlEnhancedSearchPost({
jql: this.JQL,
fields: [
'id',
'issuetype',
'status',
'components',
'summary',
'assignee',
this.fields.storyPoints,
this.fields.priority,
],
});

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

const response = await this.api.issueSearch.searchForIssuesUsingJqlPost({
jql: this.JQL,
fields: [
'id',
'issuetype',
'status',
'components',
'summary',
'assignee',
this.fields.storyPoints,
this.fields.priority,
],
});
const response =
await this.api.issueSearch.searchForIssuesUsingJqlEnhancedSearchPost({
jql: this.JQL,
fields: [
'id',
'issuetype',
'status',
'components',
'summary',
'assignee',
this.fields.storyPoints,
this.fields.priority,
],
});

// TODO: if no issues found dont fail
return response.issues ?? raise('Jira.getIssues(): missing issues.');
Expand Down
15 changes: 10 additions & 5 deletions test/unit/jira.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Jira } from '../../src/jira';
const mocks = vi.hoisted(() => {
return {
getServerInfo: vi.fn(),
searchForIssuesUsingJqlPost: vi.fn(),
searchForIssuesUsingJqlEnhancedSearchPost: vi.fn(),
editIssue: vi.fn(),
};
});
Expand All @@ -17,7 +17,8 @@ vi.mock('jira.js', () => {
getServerInfo: mocks.getServerInfo,
},
issueSearch: {
searchForIssuesUsingJqlPost: mocks.searchForIssuesUsingJqlPost,
searchForIssuesUsingJqlEnhancedSearchPost:
mocks.searchForIssuesUsingJqlEnhancedSearchPost,
},
issues: {
editIssue: mocks.editIssue,
Expand All @@ -39,7 +40,7 @@ describe('Jira functions', () => {
version: '8.0.0',
});

mocks.searchForIssuesUsingJqlPost.mockReturnValue({
mocks.searchForIssuesUsingJqlEnhancedSearchPost.mockReturnValue({
issues: [
{
key: 'RHEL-1234',
Expand Down Expand Up @@ -107,7 +108,9 @@ describe('Jira functions', () => {
expect(jira.JQL).toMatchInlineSnapshot(
`"issue in (RHEL-1234,RHEL-1235) ORDER BY id DESC"`
);
expect(mocks.searchForIssuesUsingJqlPost).toHaveBeenCalledWith({
expect(
mocks.searchForIssuesUsingJqlEnhancedSearchPost
).toHaveBeenCalledWith({
fields: [
'id',
'issuetype',
Expand Down Expand Up @@ -175,7 +178,9 @@ describe('Jira functions', () => {
expect(jira.JQL).toMatchInlineSnapshot(
`"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"`
);
expect(mocks.searchForIssuesUsingJqlPost).toHaveBeenCalledWith({
expect(
mocks.searchForIssuesUsingJqlEnhancedSearchPost
).toHaveBeenCalledWith({
fields: [
'id',
'issuetype',
Expand Down