qase-javascript-commons 2.4.8 → 2.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,7 +29,6 @@ Qase JS Reporters can be configured in multiple ways:
29
29
  * using a config file `qase.config.json`
30
30
  * using environment variables
31
31
 
32
-
33
32
  All configuration options are listed in the table below:
34
33
 
35
34
  | Description | Config file | Environment variable | Default value | Required | Possible values |
@@ -67,6 +66,7 @@ All configuration options are listed in the table below:
67
66
  | Filter test results by status (comma-separated list of statuses to exclude from reporting) | `testops.statusFilter` | `QASE_TESTOPS_STATUS_FILTER` | undefined | No | Array of strings (`passed`, `failed`, `skipped`, `invalid`) |
68
67
  | Configuration values to create/find in groups (format: `group1=value1,group2=value2`) | `testops.configurations.values` | `QASE_TESTOPS_CONFIGURATIONS_VALUES` | undefined | No | Comma-separated key=value pairs |
69
68
  | Create configuration groups if they don't exist | `testops.configurations.createIfNotExists` | `QASE_TESTOPS_CONFIGURATIONS_CREATE_IF_NOT_EXISTS` | `false` | No | `True`, `False` |
69
+ | Enable public report link generation and display after test run completion | `testops.showPublicReportLink` | `QASE_TESTOPS_SHOW_PUBLIC_REPORT_LINK` | `False` | No | `True`, `False` |
70
70
 
71
71
  ### Example `qase.config.json` config
72
72
 
@@ -112,6 +112,7 @@ All configuration options are listed in the table below:
112
112
  "defect": false,
113
113
  "project": "<project_code>",
114
114
  "uploadAttachments": true,
115
+ "showPublicReportLink": true,
115
116
  "statusFilter": ["passed", "skipped"],
116
117
  "batch": {
117
118
  "size": 100
@@ -151,4 +152,7 @@ export QASE_STATUS_MAPPING="invalid=failed,skipped=passed"
151
152
  # Logging configuration
152
153
  export QASE_LOGGING_CONSOLE=false # Disable console output
153
154
  export QASE_LOGGING_FILE=true # Enable file output
155
+
156
+ # Enable public report link generation
157
+ export QASE_TESTOPS_SHOW_PUBLIC_REPORT_LINK=true
154
158
  ```
package/changelog.md CHANGED
@@ -1,3 +1,10 @@
1
+ # qase-javascript-commons@2.4.9
2
+
3
+ ## What's new
4
+
5
+ Added support for public report link in the test run.
6
+ You can now generate a public report link for the test run.
7
+
1
8
  # qase-javascript-commons@2.4.8
2
9
 
3
10
  ## What's new
@@ -17,6 +17,8 @@ export declare class ClientV1 implements IClient {
17
17
  uploadResults(_runId: number, _results: TestResultType[]): Promise<void>;
18
18
  createRun(): Promise<number>;
19
19
  completeRun(runId: number): Promise<void>;
20
+ enablePublicReport(runId: number): Promise<void>;
21
+ private getErrorMessage;
20
22
  uploadAttachment(attachment: Attachment): Promise<string>;
21
23
  protected uploadAttachments(attachments: Attachment[]): Promise<string[]>;
22
24
  private prepareAttachmentData;
@@ -111,6 +111,25 @@ class ClientV1 {
111
111
  this.logger.log((0, chalk_1.default) `{blue Test run link: ${runUrl}}`);
112
112
  }
113
113
  }
114
+ async enablePublicReport(runId) {
115
+ try {
116
+ const { data } = await this.runClient.updateRunPublicity(this.config.project, runId, { status: true });
117
+ if (data.result?.url) {
118
+ this.logger.log((0, chalk_1.default) `{blue Public report link: ${data.result.url}}`);
119
+ }
120
+ }
121
+ catch (error) {
122
+ this.logger.log((0, chalk_1.default) `{yellow Failed to generate public report link: ${this.getErrorMessage(error)}}`);
123
+ }
124
+ }
125
+ getErrorMessage(error) {
126
+ if ((0, is_axios_error_1.isAxiosError)(error)) {
127
+ const err = error;
128
+ const errorData = err.response?.data;
129
+ return errorData?.errorMessage ?? errorData?.error ?? errorData?.message ?? 'Unknown API error';
130
+ }
131
+ return error instanceof Error ? error.message : 'Unknown error';
132
+ }
114
133
  async uploadAttachment(attachment) {
115
134
  try {
116
135
  const data = this.prepareAttachmentData(attachment);
@@ -4,4 +4,5 @@ export interface IClient {
4
4
  completeRun(runId: number): Promise<void>;
5
5
  uploadResults(runId: number, results: TestResultType[]): Promise<void>;
6
6
  uploadAttachment(attachment: Attachment): Promise<string>;
7
+ enablePublicReport(runId: number): Promise<void>;
7
8
  }
@@ -17,7 +17,8 @@ export declare enum EnvTestOpsEnum {
17
17
  project = "QASE_TESTOPS_PROJECT",
18
18
  uploadAttachments = "QASE_TESTOPS_UPLOAD_ATTACHMENTS",
19
19
  defect = "QASE_TESTOPS_DEFECT",
20
- statusFilter = "QASE_TESTOPS_STATUS_FILTER"
20
+ statusFilter = "QASE_TESTOPS_STATUS_FILTER",
21
+ showPublicReportLink = "QASE_TESTOPS_SHOW_PUBLIC_REPORT_LINK"
21
22
  }
22
23
  /**
23
24
  * @enum {string}
@@ -23,6 +23,7 @@ var EnvTestOpsEnum;
23
23
  EnvTestOpsEnum["uploadAttachments"] = "QASE_TESTOPS_UPLOAD_ATTACHMENTS";
24
24
  EnvTestOpsEnum["defect"] = "QASE_TESTOPS_DEFECT";
25
25
  EnvTestOpsEnum["statusFilter"] = "QASE_TESTOPS_STATUS_FILTER";
26
+ EnvTestOpsEnum["showPublicReportLink"] = "QASE_TESTOPS_SHOW_PUBLIC_REPORT_LINK";
26
27
  })(EnvTestOpsEnum || (exports.EnvTestOpsEnum = EnvTestOpsEnum = {}));
27
28
  /**
28
29
  * @enum {string}
@@ -22,6 +22,7 @@ const envToConfig = (env) => ({
22
22
  project: env[env_enum_1.EnvTestOpsEnum.project],
23
23
  uploadAttachments: env[env_enum_1.EnvTestOpsEnum.uploadAttachments],
24
24
  statusFilter: env[env_enum_1.EnvTestOpsEnum.statusFilter]?.split(',').map(status => status.trim()) ?? undefined,
25
+ showPublicReportLink: env[env_enum_1.EnvTestOpsEnum.showPublicReportLink],
25
26
  api: {
26
27
  token: env[env_enum_1.EnvApiEnum.token],
27
28
  host: env[env_enum_1.EnvApiEnum.host],
@@ -13,6 +13,7 @@ export interface EnvType {
13
13
  [EnvTestOpsEnum.uploadAttachments]?: boolean;
14
14
  [EnvTestOpsEnum.defect]?: boolean;
15
15
  [EnvTestOpsEnum.statusFilter]?: string;
16
+ [EnvTestOpsEnum.showPublicReportLink]?: boolean;
16
17
  [EnvApiEnum.token]?: string;
17
18
  [EnvApiEnum.host]?: string;
18
19
  [EnvRunEnum.id]?: number;
@@ -56,6 +56,10 @@ exports.envValidationSchema = {
56
56
  type: 'string',
57
57
  nullable: true,
58
58
  },
59
+ [env_enum_1.EnvTestOpsEnum.showPublicReportLink]: {
60
+ type: 'boolean',
61
+ nullable: true,
62
+ },
59
63
  [env_enum_1.EnvApiEnum.token]: {
60
64
  type: 'string',
61
65
  nullable: true,
@@ -8,6 +8,7 @@ export interface TestOpsOptionsType {
8
8
  defect?: boolean | undefined;
9
9
  configurations?: TestOpsConfigurationType | undefined;
10
10
  statusFilter?: string[] | undefined;
11
+ showPublicReportLink?: boolean | undefined;
11
12
  }
12
13
  export interface TestOpsConfigurationType {
13
14
  values: TestOpsConfigurationValueType[];
package/dist/qase.js CHANGED
@@ -449,7 +449,7 @@ class QaseReporter {
449
449
  throw new Error(`Either "testops.project" parameter or "${env_1.EnvTestOpsEnum.project}" environment variable is required in "testops" mode`);
450
450
  }
451
451
  const apiClient = new clientV2_1.ClientV2(this.logger, options.testops, options.environment, options.rootSuite);
452
- return new reporters_1.TestOpsReporter(this.logger, apiClient, this.withState, options.testops.project, options.testops.api.host, options.testops.batch?.size, options.testops.run?.id);
452
+ return new reporters_1.TestOpsReporter(this.logger, apiClient, this.withState, options.testops.project, options.testops.api.host, options.testops.batch?.size, options.testops.run?.id, options.testops.showPublicReportLink);
453
453
  }
454
454
  case options_1.ModeEnum.report: {
455
455
  const localOptions = options.report?.connections?.[writer_1.DriverEnum.local];
@@ -10,6 +10,7 @@ export declare class TestOpsReporter extends AbstractReporter {
10
10
  private api;
11
11
  private withState;
12
12
  private projectCode;
13
+ private showPublicReportLink?;
13
14
  private readonly baseUrl;
14
15
  private readonly batchSize;
15
16
  private runId;
@@ -24,7 +25,7 @@ export declare class TestOpsReporter extends AbstractReporter {
24
25
  * @param {string | undefined} baseUrl
25
26
  * @param {number | undefined} batchSize
26
27
  */
27
- constructor(logger: LoggerInterface, api: IClient, withState: boolean, projectCode: string, baseUrl?: string, batchSize?: number, runId?: number);
28
+ constructor(logger: LoggerInterface, api: IClient, withState: boolean, projectCode: string, baseUrl?: string, batchSize?: number, runId?: number, showPublicReportLink?: boolean | undefined);
28
29
  /**
29
30
  * @returns {Promise<void>}
30
31
  */
@@ -18,6 +18,7 @@ class TestOpsReporter extends abstract_reporter_1.AbstractReporter {
18
18
  api;
19
19
  withState;
20
20
  projectCode;
21
+ showPublicReportLink;
21
22
  baseUrl;
22
23
  batchSize;
23
24
  runId;
@@ -32,11 +33,12 @@ class TestOpsReporter extends abstract_reporter_1.AbstractReporter {
32
33
  * @param {string | undefined} baseUrl
33
34
  * @param {number | undefined} batchSize
34
35
  */
35
- constructor(logger, api, withState, projectCode, baseUrl, batchSize, runId) {
36
+ constructor(logger, api, withState, projectCode, baseUrl, batchSize, runId, showPublicReportLink) {
36
37
  super(logger);
37
38
  this.api = api;
38
39
  this.withState = withState;
39
40
  this.projectCode = projectCode;
41
+ this.showPublicReportLink = showPublicReportLink;
40
42
  this.baseUrl = this.getBaseUrl(baseUrl);
41
43
  this.batchSize = batchSize ?? defaultChunkSize;
42
44
  this.runId = runId;
@@ -148,6 +150,14 @@ class TestOpsReporter extends abstract_reporter_1.AbstractReporter {
148
150
  throw new Error('Run ID is not set');
149
151
  }
150
152
  await this.api.completeRun(this.runId);
153
+ if (this.showPublicReportLink) {
154
+ try {
155
+ await this.api.enablePublicReport(this.runId);
156
+ }
157
+ catch (error) {
158
+ // Error is already logged in enablePublicReport
159
+ }
160
+ }
151
161
  this.logger.log((0, chalk_1.default) `{green Run ${this.runId} completed}`);
152
162
  }
153
163
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qase-javascript-commons",
3
- "version": "2.4.8",
3
+ "version": "2.4.9",
4
4
  "description": "Qase JS Reporters",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",