From ad427e3f96096f982a043a58785fbf595a1da62b Mon Sep 17 00:00:00 2001 From: trooperjey01 <64835399+trooperjey01@users.noreply.github.com> Date: Wed, 12 Oct 2022 10:30:07 +0200 Subject: [PATCH] fix: use proper runId for paginated queries (#42) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: runId was required in config * fix: runId replaced by existingRun.id Co-authored-by: Jérémy Torralba --- src/index.ts | 4 ++-- src/utils/testrail-getResults.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index a0cc55f..32b24b9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -71,7 +71,7 @@ const prepareRun = async ( ); } } else if (existingRun) { - const tests = await getAllTests(testrailAPI, config); + const tests = await getAllTests(testrailAPI, existingRun.id); const currentCaseIds = tests?.map((test) => test.case_id) || []; const additionalDescription = "\n" + runDescription; const newDescription = existingRun.description @@ -271,7 +271,7 @@ class TestcafeTestrailReporter { const { value: results } = await throwOnApiError( testrailAPI.addResultsForCases(runId, resultsToPush) ); - const tests = await getAllTests(testrailAPI, this.config); + const tests = await getAllTests(testrailAPI, runId); if (this.config.uploadScreenshots) { await uploadScreenshots({ diff --git a/src/utils/testrail-getResults.ts b/src/utils/testrail-getResults.ts index 3d04aa0..5ff0f86 100644 --- a/src/utils/testrail-getResults.ts +++ b/src/utils/testrail-getResults.ts @@ -21,16 +21,16 @@ export const getAllCases = async (testrailAPI: TestRail, config: Config) => { return cases; }; -export const getAllTests = async (testrailAPI: TestRail, config: Config) => { +export const getAllTests = async (testrailAPI: TestRail, runId: number) => { let { value: testsResult } = await throwOnApiError( - testrailAPI.getTests(config.runId) + testrailAPI.getTests(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 }) + testrailAPI.getTests(runId, { offset: offsetVal }) )); tests = tests.concat(testsResult.tests); }