Skip to content

Commit

Permalink
qase-javascript-commons: add support for loading results in chunks
Browse files Browse the repository at this point in the history
--
Add support for loading results in chunks to testops reporter. Default chunk size is 200.
  • Loading branch information
Dmitrii Gridnev committed Mar 26, 2024
1 parent 362e2e9 commit 7ea4b60
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions qase-javascript-commons/src/qase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export class QaseReporter extends AbstractReporter {
...run
} = {},
plan = {},
chunk,
uploadAttachments,
} = testops;

Expand Down Expand Up @@ -330,6 +331,7 @@ export class QaseReporter extends AbstractReporter {
...run,
},
plan,
chunk,
...commonOptions,
},
apiClient,
Expand Down
22 changes: 15 additions & 7 deletions qase-javascript-commons/src/reporters/testops-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {

import { QaseError } from '../utils/qase-error';

const defaultChunkSize = 200;

export type TestOpsRunType = {
id?: number | undefined;
title: string;
Expand Down Expand Up @@ -96,13 +98,16 @@ export class TestOpsReporter extends AbstractReporter {
* @private
*/
private run: TestOpsRunType;

/**
* @type { number | undefined}
* @private
*/
private environment: number | undefined;

/**
* @type {TestResultType[]}
* @private
*/
private chunk: number;
/**
* @type {Record<string, string[]>}
* @private
Expand Down Expand Up @@ -142,6 +147,7 @@ export class TestOpsReporter extends AbstractReporter {
this.uploadAttachments = uploadAttachments;
this.run = { complete: true, ...run };
this.environment = environment;
this.chunk = options.chunk || defaultChunkSize;
}

/**
Expand Down Expand Up @@ -200,11 +206,13 @@ export class TestOpsReporter extends AbstractReporter {
await this.prepareAttachments();
}

await this.api.result.createResultsV2(this.projectCode, runId, {
results: this.results.map((result) =>
this.transformTestResult(result),
),
});
let results = this.results.map((result) => this.transformTestResult(result));

Check failure on line 209 in qase-javascript-commons/src/reporters/testops-reporter.ts

View workflow job for this annotation

GitHub Actions / Project qase-javascript-commons - Node 16

'results' is never reassigned. Use 'const' instead

for (let i = 0; i < results.length; i += this.chunk) {
await this.api.result.createResultsV2(this.projectCode, runId, {
results: results.slice(i, i + this.chunk),
});
}

this.log(chalk`{green ${this.results.length} result(s) sent to Qase}`);

Expand Down

0 comments on commit 7ea4b60

Please sign in to comment.