qase-javascript-commons 2.0.7 → 2.0.8

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/changelog.md CHANGED
@@ -1,8 +1,14 @@
1
+ # qase-javascript-commons@2.0.8
2
+
3
+ ## What's new
4
+
5
+ Fixed an issue with creating a test run with environment when the reporter ignored the `environment` parameter in the configuration.
6
+
1
7
  # qase-javascript-commons@2.0.7
2
8
 
3
9
  ## What's new
4
10
 
5
- Fixed an issue with creating a defect for failed tests when the report generator ignored the `defect` parameter in the configuration.
11
+ Fixed an issue with creating a defect for failed tests when the reporter ignored the `defect` parameter in the configuration.
6
12
 
7
13
  # qase-javascript-commons@2.0.6
8
14
 
@@ -24,7 +24,7 @@ exports.configValidationSchema = {
24
24
  nullable: true,
25
25
  },
26
26
  environment: {
27
- type: ['string', 'number'],
27
+ type: 'string',
28
28
  nullable: true,
29
29
  },
30
30
  captureLogs: {
@@ -5,7 +5,7 @@ export type EnvType = {
5
5
  [EnvEnum.mode]?: `${ModeEnum}`;
6
6
  [EnvEnum.fallback]?: `${ModeEnum}`;
7
7
  [EnvEnum.debug]?: boolean;
8
- [EnvEnum.environment]?: string | number;
8
+ [EnvEnum.environment]?: string;
9
9
  [EnvEnum.captureLogs]?: boolean;
10
10
  [EnvTestOpsEnum.project]?: string;
11
11
  [EnvTestOpsEnum.uploadAttachments]?: boolean;
@@ -25,7 +25,7 @@ exports.envValidationSchema = {
25
25
  nullable: true,
26
26
  },
27
27
  [env_enum_1.EnvEnum.environment]: {
28
- type: ['string', 'number'],
28
+ type: 'string',
29
29
  nullable: true,
30
30
  },
31
31
  [env_enum_1.EnvEnum.captureLogs]: {
@@ -23,7 +23,7 @@ export type OptionsType = {
23
23
  fallback?: `${ModeEnum}` | undefined;
24
24
  captureLogs?: boolean | undefined;
25
25
  debug?: boolean | undefined;
26
- environment?: string | number | undefined;
26
+ environment?: string | undefined;
27
27
  testops?: (RecursivePartial<TestOpsOptionsType> & AdditionalTestOpsOptionsType) | undefined;
28
28
  report?: RecursivePartial<AdditionalReportOptionsType> | undefined;
29
29
  };
package/dist/qase.js CHANGED
@@ -279,12 +279,12 @@ class QaseReporter {
279
279
  batch,
280
280
  useV2,
281
281
  defect,
282
- }, apiClient, typeof environment === 'number' ? environment : undefined);
282
+ }, apiClient, environment);
283
283
  }
284
284
  case options_1.ModeEnum.report: {
285
285
  const localOptions = report.connections?.[writer_1.DriverEnum.local];
286
286
  const writer = new writer_1.FsWriter(localOptions);
287
- return new reporters_1.ReportReporter(this.logger, writer, typeof environment === 'number' ? environment.toString() : environment, testops.run?.id);
287
+ return new reporters_1.ReportReporter(this.logger, writer, environment, testops.run?.id);
288
288
  }
289
289
  case options_1.ModeEnum.off:
290
290
  throw new disabled_exception_1.DisabledException();
@@ -97,7 +97,7 @@ export declare class TestOpsReporter extends AbstractReporter {
97
97
  * @param {QaseApiInterface} api
98
98
  * @param {number} environment
99
99
  */
100
- constructor(logger: LoggerInterface, options: TestOpsOptionsType, api: QaseApiInterface, environment?: number);
100
+ constructor(logger: LoggerInterface, options: TestOpsOptionsType, api: QaseApiInterface, environment?: string);
101
101
  /**
102
102
  * @returns {Promise<void>}
103
103
  */
@@ -79,7 +79,20 @@ class TestOpsReporter extends abstract_reporter_1.AbstractReporter {
79
79
  return;
80
80
  }
81
81
  this.logger.logDebug('Create test run');
82
- const { result } = await this.createRun(this.run.title, this.run.description, this.environment);
82
+ let environmentId;
83
+ if (this.environment != undefined) {
84
+ try {
85
+ const { data } = await this.api.environment.getEnvironments(this.projectCode, 100);
86
+ const env = data.result?.entities?.find((env) => env.slug === this.environment);
87
+ if (env) {
88
+ environmentId = env.id;
89
+ }
90
+ }
91
+ catch (error) {
92
+ throw new qase_error_1.QaseError('Cannot get environments', { cause: error });
93
+ }
94
+ }
95
+ const { result } = await this.createRun(this.run.title, this.run.description, environmentId);
83
96
  if (!result?.id) {
84
97
  throw new Error('Cannot create run.');
85
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qase-javascript-commons",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "Qase JS Reporters",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",