Skip to content

Commit

Permalink
feature: add group parameters
Browse files Browse the repository at this point in the history
Add support the group parameters in the JS reporters
  • Loading branch information
gibiw committed Aug 27, 2024
1 parent 07bf11f commit 09bc0c8
Show file tree
Hide file tree
Showing 29 changed files with 252 additions and 57 deletions.
70 changes: 40 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions qase-cucumberjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cucumberjs-qase-reporter",
"version": "2.0.0",
"version": "2.0.1",
"description": "Qase TMS CucumberJS Reporter",
"homepage": "https://github.com/qase-tms/qase-javascript",
"main": "./dist/index.js",
Expand Down Expand Up @@ -40,7 +40,7 @@
"license": "Apache-2.0",
"dependencies": {
"@cucumber/messages": "^22.0.0",
"qase-javascript-commons": "^2.0.0-beta.8"
"qase-javascript-commons": "^2.2.0"
},
"peerDependencies": {
"@cucumber/cucumber": ">=7.0.0"
Expand Down
1 change: 1 addition & 0 deletions qase-cucumberjs/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export class Storage {
message: null,
muted: false,
params: {},
group_params: {},
relations: relations,
run_id: null,
signature: this.getSignature(pickle, metadata.ids),
Expand Down
4 changes: 2 additions & 2 deletions qase-cypress/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress-qase-reporter",
"version": "2.1.0",
"version": "2.1.1",
"description": "Qase Cypress Reporter",
"homepage": "https://github.com/qase-tms/qase-javascript",
"sideEffects": false,
Expand Down Expand Up @@ -46,7 +46,7 @@
"author": "Qase Team <[email protected]>",
"license": "Apache-2.0",
"dependencies": {
"qase-javascript-commons": "~2.1.0",
"qase-javascript-commons": "~2.2.0",
"uuid": "^9.0.1"
},
"peerDependencies": {
Expand Down
1 change: 1 addition & 0 deletions qase-cypress/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export class CypressQaseReporter extends reporters.Base {
message: test.err?.message ?? null,
muted: false,
params: {},
group_params: {},
relations: relations,
run_id: null,
signature: this.getSignature(test, ids),
Expand Down
4 changes: 2 additions & 2 deletions qase-javascript-commons/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qase-javascript-commons",
"version": "2.1.3",
"version": "2.2.0",
"description": "Qase JS Reporters",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -33,7 +33,7 @@
"lodash.merge": "^4.6.2",
"lodash.mergewith": "^4.6.2",
"mime-types": "^2.1.33",
"qaseio": "~2.2.0",
"qaseio": "~2.3.0",
"strip-ansi": "^6.0.1",
"uuid": "^9.0.0"
},
Expand Down
2 changes: 2 additions & 0 deletions qase-javascript-commons/src/models/test-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class TestResultType {
attachments: Attachment[];
steps: TestStepType[];
params: Record<string, string>;
group_params: Record<string, string>;
author: string | null;
relations: Relation | null;
muted: boolean;
Expand All @@ -29,6 +30,7 @@ export class TestResultType {
this.attachments = [];
this.steps = [];
this.params = {};
this.group_params = {};
this.author = null;
this.relations = null;
this.muted = false;
Expand Down
45 changes: 36 additions & 9 deletions qase-javascript-commons/src/reporters/testops-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,30 @@ import { StateManager } from '../state/state';

const defaultChunkSize = 200;

export type TestOpsRunType = {
export interface TestOpsRunType {
id?: number | undefined;
title: string;
description: string;
complete?: boolean | undefined;
};
}

export type TestOpsPlanType = {
export interface TestOpsPlanType {
id?: number | undefined;
};
}

export type TestOpsBatchType = {
export interface TestOpsBatchType {
size?: number | undefined;
}

export type TestOpsOptionsType = {
export interface TestOpsOptionsType {
project: string;
uploadAttachments?: boolean | undefined;
run: TestOpsRunType;
plan: TestOpsPlanType;
batch?: TestOpsBatchType;
defect?: boolean | undefined;
useV2?: boolean | undefined;
};
}

/**
* @class TestOpsReporter
Expand Down Expand Up @@ -401,11 +401,38 @@ export class TestOpsReporter extends AbstractReporter {
const attachments = await this.uploadAttachments(result.attachments);
const steps = await this.transformStepsV1(result.steps, result.title);

const param: Record<string, string> = {};

for (const key in result.params) {
const value = result.params[key];
if (!value) {
continue;
}
param[key] = value;
}

const group_params: string[][] = [];

const keys = Object.keys(result.group_params);
if (keys.length > 0) {
group_params.push(keys);
}

for (const key in result.group_params) {
const value = result.group_params[key];
if (!value) {
continue;
}
param[key] = value;
}


const resultCreate: ResultCreate = {
attachments: attachments,
comment: result.message,
defect: this.defect,
param: result.params,
param: param,
param_groups: group_params,
stacktrace: result.execution.stacktrace,
start_time: result.execution.start_time ? result.execution.start_time | 0 : null,
status: result.execution.status,
Expand All @@ -422,7 +449,7 @@ export class TestOpsReporter extends AbstractReporter {
const rootSuite = this.rootSuite ? `${this.rootSuite}\t` : '';
resultCreate.case = {
title: result.title,
suite_title: result.relations?.suite ? `${rootSuite}${result.relations?.suite?.data.map((suite) => suite.title).join('\t')}` : rootSuite,
suite_title: result.relations?.suite ? `${rootSuite}${result.relations.suite.data.map((suite) => suite.title).join('\t')}` : rootSuite,
description: result.fields['description'] ?? null,
postconditions: result.fields['postconditions'] ?? null,
preconditions: result.fields['preconditions'] ?? null,
Expand Down
4 changes: 2 additions & 2 deletions qase-jest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jest-qase-reporter",
"version": "2.0.1",
"version": "2.0.2",
"description": "Qase TMS Jest Reporter",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"lodash.get": "^4.4.2",
"lodash.has": "^4.5.2",
"qase-javascript-commons": "^2.0.0",
"qase-javascript-commons": "~2.2.0",
"uuid": "^9.0.0"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions qase-jest/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export class JestQaseReporter implements Reporter {
message: error?.message ?? null,
muted: false,
params: {},
group_params: {},
relations: this.getRelations(filePath, ancestorTitles),
run_id: null,
signature: this.getSignature(filePath, fullName, ids),
Expand Down
13 changes: 13 additions & 0 deletions qase-mocha/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# [email protected]

## What's new

Support group parameters for test cases. You can specify the group parameters in the test case using the following format:

```ts
it('test', () => {
this.groupParameters({ param1: 'value1', param2: 'value2' });
expect(true).to.equal(true);
});
```

# [email protected]

## What's new
Expand Down
Loading

0 comments on commit 09bc0c8

Please sign in to comment.