Skip to content

Commit eb53bb9

Browse files
adds apiVersion option to Jira configuration (inluxc#56)
Co-authored-by: Roman Tuomisto <roman.tuomisto@sap.com>
1 parent 916daa9 commit eb53bb9

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-23
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const config: PlaywrightTestConfig = {
3131
jira: {
3232
url: 'https://your-jira-url',
3333
type: 'cloud',
34+
apiVersion: '1.0',
3435
},
3536
cloud: {
3637
client_id: '',
@@ -61,6 +62,7 @@ const config: PlaywrightTestConfig = {
6162
jira: {
6263
url: 'https://your-jira-url',
6364
type: 'server',
65+
apiVersion: '1.0',
6466
},
6567
server: {
6668
token: 'YOUR_SERVER_TOKEN',
@@ -101,6 +103,7 @@ const config: PlaywrightTestConfig = {
101103
jira: {
102104
url: 'https://your-jira-url',
103105
type: 'server',
106+
apiVersion: '1.0',
104107
},
105108
cloud: {
106109
client_id: '',
@@ -140,6 +143,7 @@ const config: PlaywrightTestConfig = {
140143
jira: {
141144
url: 'https://your-jira-url',
142145
type: 'server',
146+
apiVersion: '1.0',
143147
},
144148
cloud: {
145149
client_id: '',
@@ -241,6 +245,7 @@ const config: PlaywrightTestConfig = {
241245
jira: {
242246
url: 'https://your-jira-url',
243247
type: 'server',
248+
apiVersion: '1.0',
244249
},
245250
server: {
246251
token: 'YOUR_SERVER_TOKEN',

src/types/xray.types.ts

+23-22
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
import { AxiosProxyConfig } from "axios";
1+
import { AxiosProxyConfig } from 'axios';
22

33
export interface XrayOptions {
4-
jira: {
5-
url: string,
6-
type: string
7-
},
8-
cloud?: {
9-
client_id?: string;
10-
client_secret?: string;
11-
},
12-
server?: {
13-
token: string
14-
}
15-
projectKey: string;
16-
testPlan: string;
17-
testExecution?: string;
18-
revision?: string;
19-
description?: string;
20-
testEnvironments?: string[];
21-
version?: string;
22-
debug: boolean;
23-
proxy?: AxiosProxyConfig;
24-
}
4+
jira: {
5+
url: string;
6+
type: string;
7+
apiVersion: string;
8+
};
9+
cloud?: {
10+
client_id?: string;
11+
client_secret?: string;
12+
};
13+
server?: {
14+
token: string;
15+
};
16+
projectKey: string;
17+
testPlan: string;
18+
testExecution?: string;
19+
revision?: string;
20+
description?: string;
21+
testEnvironments?: string[];
22+
version?: string;
23+
debug: boolean;
24+
proxy?: AxiosProxyConfig;
25+
}

src/xray.service.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class XrayService {
1818
private readonly password: string;
1919
private readonly token: string;
2020
private readonly type: string;
21+
private readonly apiVersion: string;
2122
private readonly requestUrl: string;
2223
private readonly options: XrayOptions;
2324
private axios: Axios;
@@ -41,6 +42,10 @@ export class XrayService {
4142
if (!options.jira.type) throw new Error('"jira.type" option is missed. Please, provide it in the config');
4243
this.type = options.jira.type;
4344

45+
// Set Jira API apiVersion
46+
if (!options.jira.apiVersion) throw new Error('"jira.apiVersion" option is missed. Please, provide it in the config');
47+
this.apiVersion = options.jira.apiVersion;
48+
4449
// Init axios instance
4550
this.axios = axios;
4651

@@ -95,7 +100,7 @@ export class XrayService {
95100
this.token = options.server?.token;
96101

97102
// Set Request URL
98-
this.requestUrl = this.xray + 'rest/raven/1.0';
103+
this.requestUrl = this.xray + this.apiVersion !== '1.0' ? `rest/raven/${this.apiVersion}/api` : 'rest/raven/1.0';
99104

100105
//Create Axios Instance with Auth
101106
this.axios = axios.create({

0 commit comments

Comments
 (0)