transit-core-taf 1.0.10 → 1.0.11

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.
@@ -2,7 +2,8 @@ import { Reporter, FullConfig, Suite, TestCase, TestResult } from '@playwright/t
2
2
  export interface TestRailReporterOptions {
3
3
  host: string;
4
4
  user: string;
5
- token: string;
5
+ token?: string;
6
+ password?: string;
6
7
  projectId: string;
7
8
  suiteId: number;
8
9
  runName?: string;
@@ -14,12 +14,13 @@ class TestRailReporter {
14
14
  try {
15
15
  const host = options?.host ?? process.env.TESTRAIL_HOST;
16
16
  const user = options?.user ?? process.env.TESTRAIL_USER;
17
- const token = options?.token ?? process.env.TESTRAIL_PASSWORD;
17
+ const token = options?.token ?? process.env.TESTRAIL_TOKEN;
18
+ const password = options?.password ?? process.env.TESTRAIL_PASSWORD;
18
19
  const projectId = options?.projectId ?? process.env.TESTRAIL_PROJECT_ID;
19
- if (!host || !user || !token || !projectId) {
20
- throw new Error('TestRail credentials are not fully set in options or environment variables.');
20
+ if (!host || !user || !(token || password) || !projectId) {
21
+ throw new Error('TestRail credentials (host, user, projectId, and token/password) are not fully set in options or environment variables.');
21
22
  }
22
- this.client = new client_1.TestRailClient(host, user, token, projectId);
23
+ this.client = new client_1.TestRailClient({ host, user, projectId, token, password });
23
24
  const suiteIdEnv = options?.suiteId?.toString() ?? process.env.TESTRAIL_SUITE_ID;
24
25
  if (!suiteIdEnv) {
25
26
  throw new Error('TESTRAIL_SUITE_ID is not set in options or environment variables.');
@@ -1,13 +1,19 @@
1
1
  declare const statusMap: {
2
2
  [key: string]: number;
3
3
  };
4
+ export interface TestRailClientOptions {
5
+ host: string;
6
+ user: string;
7
+ projectId: string;
8
+ token?: string;
9
+ password?: string;
10
+ }
4
11
  export declare class TestRailClient {
5
12
  private host;
6
13
  private user;
7
- private token;
8
14
  private projectId;
9
15
  private auth;
10
- constructor(host: string, user: string, token: string, projectId: string);
16
+ constructor(options: TestRailClientOptions);
11
17
  private apiPost;
12
18
  createTestRun(suiteId: number, name: string, description: string): Promise<any>;
13
19
  addResultForCase(runId: number, caseId: number, status: keyof typeof statusMap, comment?: string): Promise<any>;
@@ -14,18 +14,18 @@ const statusMap = {
14
14
  class TestRailClient {
15
15
  host;
16
16
  user;
17
- token;
18
17
  projectId;
19
18
  auth;
20
- constructor(host, user, token, projectId) {
21
- if (!host || !user || !token || !projectId) {
22
- throw new Error('TestRail host, user, token, or project ID is missing.');
19
+ constructor(options) {
20
+ const { host, user, projectId, token, password } = options;
21
+ if (!host || !user || !projectId || !(token || password)) {
22
+ throw new Error('TestRail host, user, project ID, and a token or password are required.');
23
23
  }
24
24
  this.host = host;
25
25
  this.user = user;
26
- this.token = token;
27
26
  this.projectId = projectId;
28
- this.auth = `Basic ${Buffer.from(`${this.user}:${this.token}`).toString('base64')}`;
27
+ const credentials = token ?? password;
28
+ this.auth = `Basic ${Buffer.from(`${this.user}:${credentials}`).toString('base64')}`;
29
29
  }
30
30
  async apiPost(endpoint, data) {
31
31
  const url = `${this.host}index.php?/api/v2/${endpoint}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "transit-core-taf",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "Transit Core Automation Framework",
5
5
  "main": "dist/transit-core-taf/index.js",
6
6
  "types": "dist/transit-core-taf/index.d.ts",