Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: qaseio 2.1.3 , qase-javascript-commons 2.0.9 and qase-playwright 2.0.3 #615

Merged
merged 4 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion qase-javascript-commons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ All configuration options are listed in the table below:
| Mode of reporter | `mode` | `QASE_MODE` | `testops` | No | `testops`, `report`, `off` |
| Fallback mode of reporter | `fallback` | `QASE_FALLBACK` | `off` | No | `testops`, `report`, `off` |
| Environment | `environment` | `QASE_ENVIRONMENT` | `local` | No | Any string |
| Root suite | `rootSuite` | `QASE_ROOT_SUITE` | | No | Any string |
| Enable debug logs | `debug` | `QASE_DEBUG` | `False` | No | `True`, `False` |
| Enable capture logs from `stdout` and `stderr` | `testops.defect` | `QASE_CAPTURE_LOGS` | `False` | No | `True`, `False` |
| **Qase Report configuration** | | | | | |
Expand All @@ -45,7 +46,8 @@ All configuration options are listed in the table below:
| Local report format | `report.connection.format` | `QASE_REPORT_CONNECTION_FORMAT` | `json` | | `json`, `jsonp` |
| **Qase TestOps configuration** | | | | | |
| Token for [API access](https://developers.qase.io/#authentication) | `testops.api.token` | `QASE_TESTOPS_API_TOKEN` | | Yes | Any string |
| Qase API host | `testops.api.host` | `QASE_TESTOPS_API_HOST` | `qase.io` | No | Any string |
| Qase API host. For enterprise users, specify full address: `api-example.qase.io` | `testops.api.host` | `QASE_TESTOPS_API_HOST` | `qase.io` | No | Any string |
| Qase enterprise environment | `testops.api.enterprise` | `QASE_TESTOPS_API_ENTERPRISE` | `False` | No | `True`, `False` |
| Code of your project, which you can take from the URL: `https://app.qase.io/project/DEMOTR` - `DEMOTR` is the project code | `testops.project` | `QASE_TESTOPS_PROJECT` | | Yes | Any string |
| Qase test run ID | `testops.run.id` | `QASE_TESTOPS_RUN_ID` | | No | Any integer |
| Qase test run title | `testops.run.title` | `QASE_TESTOPS_RUN_TITLE` | `Automated run <Current date and time>` | No | Any string |
Expand Down
17 changes: 17 additions & 0 deletions qase-javascript-commons/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# [email protected]

## What's new

Added new configuration option `rootSuite` to specify a root suite.
This option is available in the config file and the `QASE_ROOT_SUITE` env variable
gibiw marked this conversation as resolved.
Show resolved Hide resolved

```diff
{
"mode": "testops",
"fallback": "report",
"environment": "local",
+ "rootSuite": "Root Suite",
NickVolynkin marked this conversation as resolved.
Show resolved Hide resolved
...
}
```

# [email protected]

## What's new
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.0.8",
"version": "2.0.9",
gibiw marked this conversation as resolved.
Show resolved Hide resolved
"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.1.0",
"qaseio": "^2.1.3",
"strip-ansi": "^6.0.1",
"uuid": "^9.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export const configValidationSchema: JSONSchemaType<ConfigType> = {
type: 'boolean',
nullable: true,
},
rootSuite: {
type: 'string',
nullable: true,
},

testops: {
type: 'object',
Expand All @@ -49,7 +53,7 @@ export const configValidationSchema: JSONSchemaType<ConfigType> = {
nullable: true,
},

baseUrl: {
host: {
type: 'string',
nullable: true,
},
Expand Down
3 changes: 2 additions & 1 deletion qase-javascript-commons/src/env/env-enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum EnvEnum {
debug = 'QASE_DEBUG',
environment = 'QASE_ENVIRONMENT',
captureLogs = 'QASE_CAPTURE_LOGS',
rootSuite = 'QASE_ROOT_SUITE',
}

/**
Expand All @@ -24,7 +25,7 @@ export enum EnvTestOpsEnum {
*/
export enum EnvApiEnum {
token = 'QASE_TESTOPS_API_TOKEN',
baseUrl = 'QASE_TESTOPS_API_HOST',
host = 'QASE_TESTOPS_API_HOST',
}

/**
Expand Down
3 changes: 2 additions & 1 deletion qase-javascript-commons/src/env/env-to-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ export const envToConfig = (env: EnvType): ConfigType => ({
debug: env[EnvEnum.debug],
environment: env[EnvEnum.environment],
captureLogs: env[EnvEnum.captureLogs],
rootSuite: env[EnvEnum.rootSuite],

testops: {
project: env[EnvTestOpsEnum.project],
uploadAttachments: env[EnvTestOpsEnum.uploadAttachments],

api: {
token: env[EnvApiEnum.token],
baseUrl: env[EnvApiEnum.baseUrl],
host: env[EnvApiEnum.host],
},

run: {
Expand Down
3 changes: 2 additions & 1 deletion qase-javascript-commons/src/env/env-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@
import { ModeEnum } from '../options';
import { FormatEnum } from '../writer';

export type EnvType = {

Check warning on line 13 in qase-javascript-commons/src/env/env-type.ts

View workflow job for this annotation

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

Use an `interface` instead of a `type`

Check warning on line 13 in qase-javascript-commons/src/env/env-type.ts

View workflow job for this annotation

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

Use an `interface` instead of a `type`
[EnvEnum.mode]?: `${ModeEnum}`;
[EnvEnum.fallback]?: `${ModeEnum}`;
[EnvEnum.debug]?: boolean;
[EnvEnum.environment]?: string;
[EnvEnum.captureLogs]?: boolean;
[EnvEnum.rootSuite]?: string;

[EnvTestOpsEnum.project]?: string;
[EnvTestOpsEnum.uploadAttachments]?: boolean;
[EnvTestOpsEnum.defect]?: boolean;
[EnvTestOpsEnum.useV2]?: boolean;

[EnvApiEnum.token]?: string;
[EnvApiEnum.baseUrl]?: string;
[EnvApiEnum.host]?: string;

[EnvRunEnum.id]?: number;
[EnvRunEnum.title]?: string;
Expand Down
6 changes: 5 additions & 1 deletion qase-javascript-commons/src/env/env-validation-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export const envValidationSchema: JSONSchemaType<EnvType> = {
type: 'boolean',
nullable: true,
},
[EnvEnum.rootSuite]: {
type: 'string',
nullable: true,
},

[EnvTestOpsEnum.project]: {
type: 'string',
Expand All @@ -64,7 +68,7 @@ export const envValidationSchema: JSONSchemaType<EnvType> = {
type: 'string',
nullable: true,
},
[EnvApiEnum.baseUrl]: {
[EnvApiEnum.host]: {
type: 'string',
nullable: true,
},
Expand Down
1 change: 1 addition & 0 deletions qase-javascript-commons/src/options/options-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type OptionsType = {
captureLogs?: boolean | undefined;
debug?: boolean | undefined;
environment?: string | undefined;
rootSuite?: string | undefined;
testops?:
| (RecursivePartial<TestOpsOptionsType> & AdditionalTestOpsOptionsType)
| undefined;
Expand Down
3 changes: 3 additions & 0 deletions qase-javascript-commons/src/qase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ export class QaseReporter implements ReporterInterface {
frameworkName,
reporterName,
environment,
rootSuite,
report = {},
testops = {},
} = options;
Expand Down Expand Up @@ -408,6 +409,7 @@ export class QaseReporter implements ReporterInterface {
},
apiClient,
environment,
rootSuite,
);
}

Expand All @@ -419,6 +421,7 @@ export class QaseReporter implements ReporterInterface {
this.logger,
writer,
environment,
rootSuite,
testops.run?.id);
}

Expand Down
24 changes: 24 additions & 0 deletions qase-javascript-commons/src/reporters/report-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,27 @@ import { LoggerInterface } from '../utils/logger';
export class ReportReporter extends AbstractReporter {
private readonly environment: string | undefined;
private readonly runId: number | undefined;
private readonly rootSuite: string | undefined;
private startTime: number = Date.now();

/**
* @param {LoggerInterface} logger
* @param {WriterInterface} writer
* @param {string | undefined} environment
* @param {string | undefined} rootSuite
* @param {number | undefined} runId
*/
constructor(
logger: LoggerInterface,
private writer: WriterInterface,
environment?: string,
rootSuite?: string,
runId?: number,
) {
super(logger);
this.environment = environment;
this.runId = runId;
this.rootSuite = rootSuite;
}

/**
Expand Down Expand Up @@ -111,6 +115,26 @@ export class ReportReporter extends AbstractReporter {

result.steps = this.copyStepAttachments(result.steps);
result.run_id = this.runId ?? null;
if (result.relations != null && this.rootSuite != null) {
const data = {
title: this.rootSuite,
public_id: null,
};

result.relations.suite?.data.unshift(data);
} else if (this.rootSuite != null) {
result.relations = {
suite: {
data: [
{
title: this.rootSuite,
public_id: null,
},
],
},
};
}

await this.writer.writeTestResult(result);
}

Expand Down
38 changes: 34 additions & 4 deletions qase-javascript-commons/src/reporters/testops-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ export class TestOpsReporter extends AbstractReporter {
*/
private readonly defect: boolean;

/**
* @type {string | undefined}
* @private
*/
private readonly rootSuite: string | undefined;

/**
* @type {number}
* @private
Expand All @@ -155,13 +161,15 @@ export class TestOpsReporter extends AbstractReporter {
* @param {LoggerInterface} logger
* @param {ReporterOptionsType & TestOpsOptionsType} options
* @param {QaseApiInterface} api
* @param {number} environment
* @param {string | undefined} environment
* @param {string | undefined} rootSuite
*/
constructor(
logger: LoggerInterface,
options: TestOpsOptionsType,
private api: QaseApiInterface,
environment?: string,
rootSuite?: string,
) {
const {
project,
Expand All @@ -181,6 +189,7 @@ export class TestOpsReporter extends AbstractReporter {
this.batchSize = options.batch?.size ?? defaultChunkSize;
this.useV2 = options.useV2 ?? false;
this.defect = options.defect ?? false;
this.rootSuite = rootSuite;
}

/**
Expand Down Expand Up @@ -370,9 +379,10 @@ export class TestOpsReporter extends AbstractReporter {
return resultCreate;
}

const rootSuite = this.rootSuite ? `${this.rootSuite}\t` : '';
NickVolynkin marked this conversation as resolved.
Show resolved Hide resolved
resultCreate.case = {
title: result.title,
suite_title: result.relations?.suite ? result.relations?.suite?.data.map((suite) => suite.title).join('\t') : null,
suite_title: result.relations?.suite ? `${rootSuite}${result.relations?.suite?.data.map((suite) => suite.title).join('\t')}` : rootSuite,
};

this.logger.logDebug(`Transformed result: ${JSON.stringify(resultCreate)}`);
Expand Down Expand Up @@ -402,11 +412,31 @@ export class TestOpsReporter extends AbstractReporter {
* @private
*/
private getRelation(relation: Relation | null): ResultRelations {
if (!relation || !relation.suite) {
return {};
if (!relation?.suite) {
if (this.rootSuite == undefined) {
return {};
}

return {
suite: {
data: [
{
public_id: null,
title: this.rootSuite,
},
],
},
};
}

const suiteData: SuiteData[] = [];
if (this.rootSuite != undefined) {
suiteData.push({
public_id: null,
title: this.rootSuite,
});
}

for (const data of relation.suite.data) {
suiteData.push({
public_id: null,
Expand Down
17 changes: 17 additions & 0 deletions qase-playwright/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# [email protected]

## What's new

Added new annotation `qase.suite()`.
Tests marked with it will be reported to the specified suite in the Qase.

If you don't specify the suite name, the reporter will take a suites from the test file path.
If you use the root suite, the reporter will take the root suite as the first level of the suite and your value of the `qase.suite()` as the second level.

```js
test('test', async ({ page }) => {
qase.suite("Custom suite");
await page.goto('https://example.com');
});
NickVolynkin marked this conversation as resolved.
Show resolved Hide resolved
```

# [email protected]

## What's new
Expand Down
2 changes: 1 addition & 1 deletion qase-playwright/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "playwright-qase-reporter",
"version": "2.0.2",
"version": "2.0.3",
NickVolynkin marked this conversation as resolved.
Show resolved Hide resolved
"description": "Qase TMS Playwright Reporter",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
17 changes: 17 additions & 0 deletions qase-playwright/src/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface MetadataMessage {
fields?: Record<string, string>;
parameters?: Record<string, string>;
ignore?: boolean;
suite?: string;
}

/**
Expand Down Expand Up @@ -182,6 +183,22 @@ qase.ignore = function() {
return this;
};

/**
* Set a suite for the test case
* @param {string} value
* @example
* test('test', async ({ page }) => {
* qase.suite("Suite");
* await page.goto('https://example.com');
* });
*/
qase.suite = function(value: string) {
NickVolynkin marked this conversation as resolved.
Show resolved Hide resolved
addMetadata({
suite: value,
});
return this;
};

const addMetadata = (metadata: MetadataMessage): void => {
test.info().attach('qase-metadata.json', {
contentType: ReporterContentType,
Expand Down
Loading
Loading