-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support pagination on testrail API (when there are more than 25…
…0 results) (#41) * chore: testrail-js-api up to 0.3.2 * feat: support navigation on next set of results * refactor: helper functions to navigate on testrailAPI (getAllTests & getAllCases) * style: resolved warnings (npm run lint) Co-authored-by: Jérémy Torralba <[email protected]>
- Loading branch information
1 parent
acb89a2
commit 07f257d
Showing
4 changed files
with
85 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { TestRail } from "testrail-js-api"; | ||
import type { Config } from "../types"; | ||
import { throwOnApiError } from "./misc"; | ||
|
||
export const getAllCases = async (testrailAPI: TestRail, config: Config) => { | ||
let { value: caseListResult } = await throwOnApiError( | ||
testrailAPI.getCases(config.projectId, { suite_id: config.suiteId }) | ||
); | ||
let cases = caseListResult?.cases || []; | ||
let offsetVal = 0; | ||
while (caseListResult._links.next !== null) { | ||
offsetVal += 250; | ||
({ value: caseListResult } = await throwOnApiError( | ||
testrailAPI.getCases(config.projectId, { | ||
suite_id: config.suiteId, | ||
offset: offsetVal, | ||
}) | ||
)); | ||
cases = cases.concat(caseListResult?.cases); | ||
} | ||
return cases; | ||
}; | ||
|
||
export const getAllTests = async (testrailAPI: TestRail, config: Config) => { | ||
let { value: testsResult } = await throwOnApiError( | ||
testrailAPI.getTests(config.runId) | ||
); | ||
let tests = testsResult.tests || []; | ||
let offsetVal = 0; | ||
while (testsResult._links.next !== null) { | ||
offsetVal += 250; | ||
({ value: testsResult } = await throwOnApiError( | ||
testrailAPI.getTests(config.runId, { offset: offsetVal }) | ||
)); | ||
tests = tests.concat(testsResult.tests); | ||
} | ||
return tests; | ||
}; |