diff --git a/dist/testrail.js b/dist/testrail.js index d22239fe..b391a1fb 100644 --- a/dist/testrail.js +++ b/dist/testrail.js @@ -55,12 +55,13 @@ var path = require('path'); var FormData = require('form-data'); var TestRailLogger = require('./testrail.logger'); var TestRailCache = require('./testrail.cache'); +var apiVersionPath = '/api/v2'; var TestRail = /** @class */ (function () { function TestRail(options) { this.options = options; this.includeAll = true; this.caseIds = []; - this.base = options.host + "/index.php?/api/v2"; + this.base = options.host + "/index.php?"; this.runId; } /** @@ -84,7 +85,8 @@ var TestRail = /** @class */ (function () { return result; }; TestRail.prototype.getCases = function (suiteId) { - var url = this.base + "/get_cases/" + this.options.projectId + "&suite_id=" + suiteId; + var _this = this; + var url = "" + this.base + apiVersionPath + "/get_cases/" + this.options.projectId + "&suite_id=" + suiteId; if (this.options.groupId) { url += "§ion_id=" + this.options.groupId; } @@ -94,19 +96,30 @@ var TestRail = /** @class */ (function () { if (this.options.typeId) { url += "&type_id=" + this.options.typeId; } - return this.makeSync(axios({ - method: 'get', - url: url, - headers: { 'Content-Type': 'application/json' }, - auth: { - username: this.options.username, - password: this.options.password - } - }) - .then(function (response) { - return response.data.cases.map(function (item) { return item.id; }); - }) - .catch(function (error) { return console.error(error); })); + var cases = []; + var previousUrl = null; + while (url != previousUrl) { + previousUrl = url; + this.makeSync(axios({ + method: 'get', + url: url, + headers: { 'Content-Type': 'application/json' }, + auth: { + username: this.options.username, + password: this.options.password + } + }) + .then(function (response) { + cases = cases.concat(response.data.cases.map(function (item) { return item.id; })); + if (response.data._links.next) { + url = "" + _this.base + apiVersionPath + response.data._links.next; + } + }) + .catch(function (error) { + console.error(error); + })); + } + return cases; }; TestRail.prototype.createRun = function (name, description, suiteId) { var _this = this; @@ -116,7 +129,7 @@ var TestRail = /** @class */ (function () { } this.makeSync(axios({ method: 'post', - url: this.base + "/add_run/" + this.options.projectId, + url: "" + this.base + apiVersionPath + "/add_run/" + this.options.projectId, headers: { 'Content-Type': 'application/json' }, auth: { username: this.options.username, @@ -141,7 +154,7 @@ var TestRail = /** @class */ (function () { this.runId = TestRailCache.retrieve('runId'); this.makeSync(axios({ method: 'post', - url: this.base + "/delete_run/" + this.runId, + url: "" + this.base + apiVersionPath + "/delete_run/" + this.runId, headers: { 'Content-Type': 'application/json' }, auth: { username: this.options.username, @@ -153,7 +166,7 @@ var TestRail = /** @class */ (function () { this.runId = TestRailCache.retrieve('runId'); return this.makeSync(axios({ method: 'post', - url: this.base + "/add_results_for_cases/" + this.runId, + url: "" + this.base + apiVersionPath + "/add_results_for_cases/" + this.runId, headers: { 'Content-Type': 'application/json' }, auth: { username: this.options.username, @@ -171,7 +184,7 @@ var TestRail = /** @class */ (function () { form.append('attachment', fs.createReadStream(path)); this.makeSync(axios({ method: 'post', - url: this.base + "/add_attachment_to_result/" + resultId, + url: "" + this.base + apiVersionPath + "/add_attachment_to_result/" + resultId, headers: __assign({}, form.getHeaders()), auth: { username: this.options.username, @@ -205,7 +218,7 @@ var TestRail = /** @class */ (function () { this.runId = TestRailCache.retrieve('runId'); this.makeSync(axios({ method: 'post', - url: this.base + "/close_run/" + this.runId, + url: "" + this.base + apiVersionPath + "/close_run/" + this.runId, headers: { 'Content-Type': 'application/json' }, auth: { username: this.options.username, diff --git a/dist/testrail.js.map b/dist/testrail.js.map index b621cdb3..2e643a77 100644 --- a/dist/testrail.js.map +++ b/dist/testrail.js.map @@ -1 +1 @@ -{"version":3,"file":"testrail.js","sourceRoot":"","sources":["../src/lib/testrail.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/B,IAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,IAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,IAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,IAAM,QAAQ,GAAG,O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gB,CAAC,QAAQ,EAAE,uBAAuB,GAAG,IAAI,CAAC,CAAA;qBAChE;oBAAC,OAAO,GAAG,EAAE;wBACZ,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAA;qBAC9C;iBACF;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAAA,CAAC;IAEK,2BAAQ,GAAf;QACE,IAAI,CAAC,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,CACX,KAAK,CAAC;YACJ,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,KAAG,IAAI,CAAC,IAAI,GAAG,cAAc,mBAAc,IAAI,CAAC,KAAO;YAC5D,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE;gBACJ,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;gBAC/B,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;aAChC;SACF,CAAC;aACD,IAAI,CAAC;YACF,cAAc,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;QACvD,CAAC,CAAC;aACD,KAAK,CAAC,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAApB,CAAoB,CAAC,CACtC,CAAC;IACJ,CAAC;IACH,eAAC;AAAD,CAAC,AA7LD,IA6LC;AA7LY,4BAAQ"} \ No newline at end of file diff --git a/src/lib/testrail.ts b/src/lib/testrail.ts index f0b7f41c..f68775b8 100644 --- a/src/lib/testrail.ts +++ b/src/lib/testrail.ts @@ -5,8 +5,9 @@ const path = require('path'); const FormData = require('form-data'); const TestRailLogger = require('./testrail.logger'); const TestRailCache = require('./testrail.cache'); -import { TestRailOptions, TestRailResult } from './testrail.interface'; +import {TestRailOptions, TestRailResult} from './testrail.interface'; +const apiVersionPath = '/api/v2' export class TestRail { private base: String; private runId: Number; @@ -15,7 +16,7 @@ export class TestRail { private retries: number; constructor(private options: TestRailOptions) { - this.base = `${options.host}/index.php?/api/v2`; + this.base = `${options.host}/index.php?`; this.runId; } @@ -35,7 +36,7 @@ export class TestRail { } public getCases (suiteId: number) { - let url = `${this.base}/get_cases/${this.options.projectId}&suite_id=${suiteId}` + let url = `${this.base}${apiVersionPath}/get_cases/${this.options.projectId}&suite_id=${suiteId}` if (this.options.groupId) { url += `§ion_id=${this.options.groupId}` } @@ -45,21 +46,32 @@ export class TestRail { if (this.options.typeId) { url += `&type_id=${this.options.typeId}` } - return this.makeSync( - axios({ - method:'get', - url: url, - headers: { 'Content-Type': 'application/json' }, - auth: { + let cases = [] + let previousUrl = null + while (url != previousUrl) { + previousUrl = url; + this.makeSync( + axios({ + method: 'get', + url: url, + headers: {'Content-Type': 'application/json'}, + auth: { username: this.options.username, password: this.options.password - } - }) - .then(response => { - return response.data.cases.map(item =>item.id) - }) - .catch(error => console.error(error)) - ) + } + }) + .then(response => { + cases = cases.concat(response.data.cases.map(item => item.id)) + if (response.data._links.next) { + url = `${this.base}${apiVersionPath}${response.data._links.next}` + } + }) + .catch(error => { + console.error(error) + }) + ) + } + return cases } public createRun (name: string, description: string, suiteId: number) { @@ -70,7 +82,7 @@ export class TestRail { this.makeSync( axios({ method: 'post', - url: `${this.base}/add_run/${this.options.projectId}`, + url: `${this.base}${apiVersionPath}/add_run/${this.options.projectId}`, headers: { 'Content-Type': 'application/json' }, auth: { username: this.options.username, @@ -98,7 +110,7 @@ export class TestRail { this.makeSync( axios({ method: 'post', - url: `${this.base}/delete_run/${this.runId}`, + url: `${this.base}${apiVersionPath}/delete_run/${this.runId}`, headers: { 'Content-Type': 'application/json' }, auth: { username: this.options.username, @@ -113,7 +125,7 @@ export class TestRail { return this.makeSync( axios({ method: 'post', - url: `${this.base}/add_results_for_cases/${this.runId}`, + url: `${this.base}${apiVersionPath}/add_results_for_cases/${this.runId}`, headers: { 'Content-Type': 'application/json' }, auth: { username: this.options.username, @@ -135,7 +147,7 @@ export class TestRail { this.makeSync( axios({ method: 'post', - url: `${this.base}/add_attachment_to_result/${resultId}`, + url: `${this.base}${apiVersionPath}/add_attachment_to_result/${resultId}`, headers: { ...form.getHeaders() }, auth: { username: this.options.username, @@ -172,7 +184,7 @@ export class TestRail { this.makeSync( axios({ method: 'post', - url: `${this.base}/close_run/${this.runId}`, + url: `${this.base}${apiVersionPath}/close_run/${this.runId}`, headers: { 'Content-Type': 'application/json' }, auth: { username: this.options.username,