@testomatio/reporter 2.1.3-beta.1-xml-import → 2.1.3-beta.1-multi-links

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.
@@ -50,18 +50,17 @@ function CodeceptReporter(config) {
50
50
  };
51
51
  output.debug = function (msg) {
52
52
  originalOutput.debug(msg);
53
- data_storage_js_1.dataStorage.putData('log', repeat(this?.stepShift || 0) + picocolors_1.default.cyan(msg.toString()));
53
+ data_storage_js_1.dataStorage.putData('log', repeat(this.stepShift) + picocolors_1.default.cyan(msg.toString()));
54
54
  };
55
55
  output.say = function (message, color = 'cyan') {
56
56
  originalOutput.say(message, color);
57
- const sayMsg = repeat(this?.stepShift || 0) + ` ${picocolors_1.default.bold(picocolors_1.default[color](message))}`;
57
+ const sayMsg = repeat(this.stepShift) + ` ${picocolors_1.default.bold(picocolors_1.default[color](message))}`;
58
58
  data_storage_js_1.dataStorage.putData('log', sayMsg);
59
59
  };
60
60
  output.log = function (msg) {
61
61
  originalOutput.log(msg);
62
- data_storage_js_1.dataStorage.putData('log', repeat(this?.stepShift || 0) + picocolors_1.default.gray(msg));
62
+ data_storage_js_1.dataStorage.putData('log', repeat(this.stepShift) + picocolors_1.default.gray(msg));
63
63
  };
64
- output.stepShift = 0;
65
64
  recorder.startUnlessRunning();
66
65
  const hookSteps = new Map();
67
66
  let currentHook = null;
@@ -140,7 +139,7 @@ function CodeceptReporter(config) {
140
139
  const manuallyAttachedArtifacts = index_js_1.services.artifacts.get(test.fullTitle());
141
140
  const keyValues = index_js_1.services.keyValues.get(test.fullTitle());
142
141
  const stepHierarchy = buildUnifiedStepHierarchy(test.steps, hookSteps);
143
- const links = index_js_1.services.links.get(test.fullTitle());
142
+ const labels = index_js_1.services.labels.get(test.fullTitle());
144
143
  index_js_1.services.setContext(null);
145
144
  client.addTestRun(test.state, {
146
145
  ...stripExampleFromTitle(title),
@@ -153,7 +152,7 @@ function CodeceptReporter(config) {
153
152
  files,
154
153
  steps: stepHierarchy, // Array of step objects per API schema
155
154
  logs,
156
- links,
155
+ labels,
157
156
  manuallyAttachedArtifacts,
158
157
  meta: { ...keyValues, ...test.meta },
159
158
  });
@@ -43,7 +43,6 @@ function MochaReporter(runner, opts) {
43
43
  const logs = getTestLogs(test);
44
44
  const artifacts = index_js_1.services.artifacts.get(test.fullTitle());
45
45
  const keyValues = index_js_1.services.keyValues.get(test.fullTitle());
46
- const links = index_js_1.services.links.get(test.fullTitle());
47
46
  client.addTestRun(constants_js_1.STATUS.PASSED, {
48
47
  test_id: testId,
49
48
  suite_title: getSuiteTitle(test),
@@ -54,16 +53,12 @@ function MochaReporter(runner, opts) {
54
53
  logs,
55
54
  manuallyAttachedArtifacts: artifacts,
56
55
  meta: keyValues,
57
- links,
58
56
  });
59
57
  });
60
58
  runner.on(EVENT_TEST_PENDING, test => {
61
59
  skipped += 1;
62
60
  console.log('skip: %s', test.fullTitle());
63
61
  const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(test.title);
64
- const artifacts = index_js_1.services.artifacts.get(test.fullTitle());
65
- const keyValues = index_js_1.services.keyValues.get(test.fullTitle());
66
- const links = index_js_1.services.links.get(test.fullTitle());
67
62
  client.addTestRun(constants_js_1.STATUS.SKIPPED, {
68
63
  title: getTestName(test),
69
64
  suite_title: getSuiteTitle(test),
@@ -71,9 +66,6 @@ function MochaReporter(runner, opts) {
71
66
  file: getFile(test),
72
67
  test_id: testId,
73
68
  time: test.duration,
74
- manuallyAttachedArtifacts: artifacts,
75
- meta: keyValues,
76
- links,
77
69
  });
78
70
  });
79
71
  runner.on(EVENT_TEST_FAIL, async (test, err) => {
@@ -81,9 +73,6 @@ function MochaReporter(runner, opts) {
81
73
  console.log(picocolors_1.default.bold(picocolors_1.default.red('✖')), test.fullTitle(), picocolors_1.default.gray(err.message));
82
74
  const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(test.title);
83
75
  const logs = getTestLogs(test);
84
- const artifacts = index_js_1.services.artifacts.get(test.fullTitle());
85
- const keyValues = index_js_1.services.keyValues.get(test.fullTitle());
86
- const links = index_js_1.services.links.get(test.fullTitle());
87
76
  client.addTestRun(constants_js_1.STATUS.FAILED, {
88
77
  error: err,
89
78
  suite_title: getSuiteTitle(test),
@@ -93,9 +82,6 @@ function MochaReporter(runner, opts) {
93
82
  code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
94
83
  time: test.duration,
95
84
  logs,
96
- manuallyAttachedArtifacts: artifacts,
97
- meta: keyValues,
98
- links,
99
85
  });
100
86
  });
101
87
  runner.on(EVENT_RUN_END, () => {
@@ -78,13 +78,11 @@ class WebdriverReporter extends reporter_1.default {
78
78
  test.suite = test.parent;
79
79
  const logs = getTestLogs(test.fullTitle);
80
80
  // TODO: FIX: artifacts for some reason leads to empty report on Testomat.io
81
- // ^ not reproduced anymore (Jul 2025)
82
- // but still be under investigation
83
- const artifacts = index_js_1.services.artifacts.get(test.fullTitle);
84
- const keyValues = index_js_1.services.keyValues.get(test.fullTitle);
81
+ // const artifacts = services.artifacts.get(test.fullTitle);
82
+ // const keyValues = services.keyValues.get(test.fullTitle);
85
83
  test.logs = logs;
86
- test.artifacts = artifacts;
87
- test.meta = keyValues;
84
+ // test.artifacts = artifacts;
85
+ // test.meta = keyValues;
88
86
  this._addTestPromises.push(this.addTest(test));
89
87
  }
90
88
  // wdio-cucumber does not trigger onTestEnd hook, thus, using this one
@@ -4,50 +4,103 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const node_child_process_1 = require("node:child_process");
8
- const node_path_1 = require("node:path");
9
- const utils_js_1 = require("../utils/utils.js");
7
+ const cross_spawn_1 = require("cross-spawn");
8
+ const commander_1 = require("commander");
10
9
  const picocolors_1 = __importDefault(require("picocolors"));
11
- // Define __dirname - this will be replaced by build script with actual __dirname for CommonJS
12
- const cliPath = (0, node_path_1.join)(__dirname, 'cli.js');
10
+ const client_js_1 = __importDefault(require("../client.js"));
11
+ const constants_js_1 = require("../constants.js");
12
+ const utils_js_1 = require("../utils/utils.js");
13
+ const config_js_1 = require("../config.js");
14
+ const dotenv_1 = __importDefault(require("dotenv"));
13
15
  const version = (0, utils_js_1.getPackageVersion)();
14
16
  console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io Reporter v${version}`)));
15
- // Parse command line arguments to map start-test-run options to @testomatio/reporter run format
16
- const args = process.argv.slice(2);
17
- const newArgs = ['run'];
18
- let i = 0;
19
- while (i < args.length) {
20
- const arg = args[i];
21
- if (arg === '-c' || arg === '--command') {
22
- // Map -c/--command to positional argument for run command
23
- i++;
24
- if (i < args.length) {
25
- newArgs.push(args[i]);
26
- }
17
+ const program = new commander_1.Command();
18
+ program
19
+ .option('-c, --command <cmd>', 'Test runner command')
20
+ .option('--launch', 'Start a new run and return its ID')
21
+ .option('--finish', 'Finish Run by its ID')
22
+ .option('--env-file <envfile>', 'Load environment variables from env file')
23
+ .option('--filter <filter>', 'Additional execution filter')
24
+ .action(async (opts) => {
25
+ const { launch, finish, filter } = opts;
26
+ let { command } = opts;
27
+ if (opts.envFile)
28
+ dotenv_1.default.config({ path: opts.envFile });
29
+ const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config_js_1.config.TESTOMATIO;
30
+ const title = process.env.TESTOMATIO_TITLE;
31
+ if (launch) {
32
+ console.log('Starting a new Run on Testomat.io...');
33
+ const client = new client_js_1.default({ apiKey });
34
+ client.createRun().then(() => {
35
+ console.log(process.env.runId);
36
+ process.exit(0);
37
+ });
38
+ return;
27
39
  }
28
- else if (arg.startsWith('--command=')) {
29
- // Handle --command=value format
30
- const command = arg.split('=', 2)[1];
31
- newArgs.push(command);
40
+ if (finish) {
41
+ // TODO: add error in case of TESTOMATIO environment variable is not set
42
+ // because command is fine in console, but actually (on testomat.io) run is not finished
43
+ if (!process.env.TESTOMATIO_RUN) {
44
+ console.log('TESTOMATIO_RUN environment variable must be set.');
45
+ return process.exit(1);
46
+ }
47
+ console.log('Finishing Run on Testomat.io...');
48
+ const client = new client_js_1.default({ apiKey });
49
+ // @ts-ignore
50
+ client.updateRunStatus(constants_js_1.STATUS.FINISHED).then(() => {
51
+ console.log(picocolors_1.default.yellow(`Run ${process.env.TESTOMATIO_RUN} was finished`));
52
+ process.exit(0);
53
+ });
54
+ return;
32
55
  }
33
- else if (arg === '--launch') {
34
- // Map --launch to start command
35
- newArgs[0] = 'start';
56
+ let exitCode = 0;
57
+ if (!command.split) {
58
+ process.exitCode = 255;
59
+ console.log(constants_js_1.APP_PREFIX, `No command provided. Use -c option to launch a test runner.`);
60
+ return;
36
61
  }
37
- else if (arg === '--finish') {
38
- // Map --finish to finish command
39
- newArgs[0] = 'finish';
62
+ const client = new client_js_1.default({ apiKey, title, parallel: true });
63
+ if (filter) {
64
+ const [pipe, ...optsArray] = filter.split(':');
65
+ const pipeOptions = optsArray.join(':');
66
+ try {
67
+ const tests = await client.prepareRun({ pipe, pipeOptions });
68
+ if (!tests || tests.length === 0) {
69
+ return;
70
+ }
71
+ const grep = ` --grep (${tests.join('|')})`;
72
+ command += grep;
73
+ }
74
+ catch (err) {
75
+ console.log(constants_js_1.APP_PREFIX, err);
76
+ }
40
77
  }
41
- else {
42
- // Pass through other arguments
43
- newArgs.push(arg);
78
+ const testCmds = command.split(' ');
79
+ console.log(constants_js_1.APP_PREFIX, `🚀 Running`, picocolors_1.default.green(command));
80
+ if (!apiKey) {
81
+ const cmd = (0, cross_spawn_1.spawn)(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
82
+ cmd.on('close', code => {
83
+ console.log(constants_js_1.APP_PREFIX, '⚠️ ', `Runner exited with ${picocolors_1.default.bold(code)}, report is ignored`);
84
+ if (code > exitCode)
85
+ exitCode = code;
86
+ process.exitCode = exitCode;
87
+ });
88
+ return;
44
89
  }
45
- i++;
46
- }
47
- // Execute the main CLI with mapped arguments
48
- const child = (0, node_child_process_1.spawn)(process.execPath, [cliPath, ...newArgs], {
49
- stdio: 'inherit'
50
- });
51
- child.on('exit', (code) => {
52
- process.exit(code);
90
+ client.createRun().then(() => {
91
+ const cmd = (0, cross_spawn_1.spawn)(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
92
+ cmd.on('close', code => {
93
+ const emoji = code === 0 ? '🟢' : '🔴';
94
+ console.log(constants_js_1.APP_PREFIX, emoji, `Runner exited with ${picocolors_1.default.bold(code)}`);
95
+ const status = code === 0 ? 'passed' : 'failed';
96
+ client.updateRunStatus(status, true);
97
+ if (code > exitCode)
98
+ exitCode = code;
99
+ process.exitCode = exitCode;
100
+ });
101
+ });
53
102
  });
103
+ if (process.argv.length <= 2) {
104
+ program.outputHelp();
105
+ }
106
+ program.parse(process.argv);
package/lib/client.js CHANGED
@@ -50,7 +50,6 @@ const path_1 = __importStar(require("path"));
50
50
  const node_url_1 = require("node:url");
51
51
  const uploader_js_1 = require("./uploader.js");
52
52
  const utils_js_1 = require("./utils/utils.js");
53
- const links_js_1 = require("./services/links.js");
54
53
  const filesize_1 = require("filesize");
55
54
  const debug = (0, debug_1.default)('@testomatio/reporter:client');
56
55
  // removed __dirname usage, because:
@@ -182,7 +181,7 @@ class Client {
182
181
  /**
183
182
  * @type {TestData}
184
183
  */
185
- const { rid, error = null, time = 0, example = null, files = [], filesBuffers = [], steps, code = null, title, file, suite_title, suite_id, test_id, timestamp, manuallyAttachedArtifacts, overwrite, } = testData;
184
+ const { rid, error = null, time = 0, example = null, files = [], filesBuffers = [], steps, code = null, title, file, suite_title, suite_id, test_id, timestamp, manuallyAttachedArtifacts, labels, overwrite, } = testData;
186
185
  let { message = '', meta = {} } = testData;
187
186
  // stringify meta values and limit keys and values length to 255
188
187
  meta = Object.entries(meta)
@@ -221,9 +220,7 @@ class Client {
221
220
  acc[key] = value;
222
221
  return acc;
223
222
  }, {});
224
- // Get links from storage using the test context
225
- const testContext = suite_title ? `${suite_title} ${title}` : title;
226
- const links = links_js_1.linkStorage.get(testContext) || [];
223
+ // Labels are simple array of strings, no processing needed
227
224
  let errorFormatted = '';
228
225
  if (error) {
229
226
  errorFormatted += this.formatError(error) || '';
@@ -271,7 +268,7 @@ class Client {
271
268
  timestamp,
272
269
  artifacts,
273
270
  meta,
274
- links,
271
+ labels,
275
272
  overwrite,
276
273
  ...(rootSuiteId && { root_suite_id: rootSuiteId }),
277
274
  };
@@ -12,22 +12,22 @@ declare class DataStorage {
12
12
  /**
13
13
  * Puts any data to storage (file or global variable).
14
14
  * If file: stores data as text, if global variable – stores as array of data.
15
- * @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
15
+ * @param {'log' | 'artifact' | 'keyvalue' | 'labels'} dataType
16
16
  * @param {*} data anything you want to store (string, object, array, etc)
17
17
  * @param {*} context could be testId or any context (test name, suite name, including their IDs etc)
18
18
  * suite name + test name is used by default
19
19
  * @returns
20
20
  */
21
- putData(dataType: "log" | "artifact" | "keyvalue" | "links", data: any, context?: any): void;
21
+ putData(dataType: "log" | "artifact" | "keyvalue" | "labels", data: any, context?: any): void;
22
22
  /**
23
23
  * Returns data, stored for specific test/context (or data which was stored without test id specified).
24
24
  * This method will get data from global variable and/or from from file (previosly saved with put method).
25
25
  *
26
- * @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
26
+ * @param {'log' | 'artifact' | 'keyvalue' | 'labels'} dataType
27
27
  * @param {string} context
28
28
  * @returns {any []} array of data (any type), null (if no data found for context) or string (if data type is log)
29
29
  */
30
- getData(dataType: "log" | "artifact" | "keyvalue" | "links", context: string): any[];
30
+ getData(dataType: "log" | "artifact" | "keyvalue" | "labels", context: string): any[];
31
31
  #private;
32
32
  }
33
33
  export function stringToMD5Hash(str: any): string;
@@ -75,7 +75,7 @@ class DataStorage {
75
75
  /**
76
76
  * Puts any data to storage (file or global variable).
77
77
  * If file: stores data as text, if global variable – stores as array of data.
78
- * @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
78
+ * @param {'log' | 'artifact' | 'keyvalue' | 'labels'} dataType
79
79
  * @param {*} data anything you want to store (string, object, array, etc)
80
80
  * @param {*} context could be testId or any context (test name, suite name, including their IDs etc)
81
81
  * suite name + test name is used by default
@@ -103,7 +103,7 @@ class DataStorage {
103
103
  * Returns data, stored for specific test/context (or data which was stored without test id specified).
104
104
  * This method will get data from global variable and/or from from file (previosly saved with put method).
105
105
  *
106
- * @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
106
+ * @param {'log' | 'artifact' | 'keyvalue' | 'labels'} dataType
107
107
  * @param {string} context
108
108
  * @returns {any []} array of data (any type), null (if no data found for context) or string (if data type is log)
109
109
  */
@@ -134,7 +134,7 @@ class DataStorage {
134
134
  return null;
135
135
  }
136
136
  /**
137
- * @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
137
+ * @param {'log' | 'artifact' | 'keyvalue' | 'labels'} dataType
138
138
  * @param {string} context
139
139
  * @returns aray of data (any type)
140
140
  */
@@ -154,7 +154,7 @@ class DataStorage {
154
154
  }
155
155
  }
156
156
  /**
157
- * @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
157
+ * @param {'log' | 'artifact' | 'keyvalue' | 'labels'} dataType
158
158
  * @param {*} context
159
159
  * @returns array of data (any type)
160
160
  */
@@ -179,7 +179,7 @@ class DataStorage {
179
179
  }
180
180
  /**
181
181
  * Puts data to global variable. Unlike the file storage, stores data in array (file storage just append as string).
182
- * @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
182
+ * @param {'log' | 'artifact' | 'keyvalue' | 'labels'} dataType
183
183
  * @param {*} data
184
184
  * @param {*} context
185
185
  */
@@ -195,7 +195,7 @@ class DataStorage {
195
195
  }
196
196
  /**
197
197
  * Puts data to file. Unlike the global variable storage, stores data as string
198
- * @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
198
+ * @param {'log' | 'artifact' | 'keyvalue' | 'labels'} dataType
199
199
  * @param {*} data
200
200
  * @param {string} context
201
201
  * @returns
@@ -113,7 +113,8 @@ class TestomatioPipe {
113
113
  const resp = await this.client.request({
114
114
  method: 'GET',
115
115
  url: '/api/test_grep',
116
- ...q,
116
+ params: q.params,
117
+ responseType: q.responseType
117
118
  });
118
119
  if (Array.isArray(resp.data?.tests) && resp.data?.tests?.length > 0) {
119
120
  (0, utils_js_1.foundedTestLog)(constants_js_1.APP_PREFIX, resp.data.tests);
@@ -4,14 +4,11 @@ declare namespace _default {
4
4
  export { addStep as step };
5
5
  export { setKeyValue as keyValue };
6
6
  export { setLabel as label };
7
- export { linkTest };
8
7
  }
9
8
  export default _default;
10
9
  /**
11
10
  * Stores path to file as artifact and uploads it to the S3 storage
12
11
  * @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
13
- * @param {any} [context=null] - optional context parameter
14
- * @returns {void}
15
12
  */
16
13
  declare function saveArtifact(data: string | {
17
14
  path: string;
@@ -20,35 +17,25 @@ declare function saveArtifact(data: string | {
20
17
  }, context?: any): void;
21
18
  /**
22
19
  * Attach log message(s) to the test report
23
- * @param {...any} args - log messages to attach
24
- * @returns {void}
20
+ * @param string
25
21
  */
26
22
  declare function logMessage(...args: any[]): void;
27
23
  /**
28
24
  * Similar to "log" function but marks message in report as a step
29
- * @param {string} message - step message
30
- * @returns {void}
25
+ * @param {string} message
31
26
  */
32
27
  declare function addStep(message: string): void;
33
28
  /**
34
29
  * Add key-value pair(s) to the test report
35
- * @param {{[key: string]: string} | string} keyValue - object { key: value } (multiple props allowed) or key (string)
36
- * @param {string|null} [value=null] - optional value when keyValue is a string
37
- * @returns {void}
30
+ * @param {{[key: string]: string} | string} keyValue object { key: value } (multiple props allowed) or key (string)
31
+ * @param {string?} value
38
32
  */
39
33
  declare function setKeyValue(keyValue: {
40
34
  [key: string]: string;
41
35
  } | string, value?: string | null): void;
42
36
  /**
43
- * Add label(s) to the test report
37
+ * Add a single label to the test report
44
38
  * @param {string} key - label key (e.g. 'severity', 'feature', or just 'smoke' for labels without values)
45
- * @param {string|string[]|null} [value=null] - optional label value(s) (e.g. 'high', 'login') or array of values
46
- * @returns {void}
39
+ * @param {string} [value] - optional label value (e.g. 'high', 'login')
47
40
  */
48
- declare function setLabel(key: string, value?: string | string[] | null): void;
49
- /**
50
- * Add link(s) to the test report
51
- * @param {...string} testIds - test IDs to link
52
- * @returns {void}
53
- */
54
- declare function linkTest(...testIds: string[]): void;
41
+ declare function setLabel(key: string, value?: string): void;
@@ -4,8 +4,6 @@ const index_js_1 = require("./services/index.js");
4
4
  /**
5
5
  * Stores path to file as artifact and uploads it to the S3 storage
6
6
  * @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
7
- * @param {any} [context=null] - optional context parameter
8
- * @returns {void}
9
7
  */
10
8
  function saveArtifact(data, context = null) {
11
9
  if (process.env.IS_PLAYWRIGHT)
@@ -17,8 +15,7 @@ function saveArtifact(data, context = null) {
17
15
  }
18
16
  /**
19
17
  * Attach log message(s) to the test report
20
- * @param {...any} args - log messages to attach
21
- * @returns {void}
18
+ * @param string
22
19
  */
23
20
  function logMessage(...args) {
24
21
  if (process.env.IS_PLAYWRIGHT)
@@ -27,8 +24,7 @@ function logMessage(...args) {
27
24
  }
28
25
  /**
29
26
  * Similar to "log" function but marks message in report as a step
30
- * @param {string} message - step message
31
- * @returns {void}
27
+ * @param {string} message
32
28
  */
33
29
  function addStep(message) {
34
30
  if (process.env.IS_PLAYWRIGHT)
@@ -37,9 +33,8 @@ function addStep(message) {
37
33
  }
38
34
  /**
39
35
  * Add key-value pair(s) to the test report
40
- * @param {{[key: string]: string} | string} keyValue - object { key: value } (multiple props allowed) or key (string)
41
- * @param {string|null} [value=null] - optional value when keyValue is a string
42
- * @returns {void}
36
+ * @param {{[key: string]: string} | string} keyValue object { key: value } (multiple props allowed) or key (string)
37
+ * @param {string?} value
43
38
  */
44
39
  function setKeyValue(keyValue, value = null) {
45
40
  if (process.env.IS_PLAYWRIGHT)
@@ -50,29 +45,43 @@ function setKeyValue(keyValue, value = null) {
50
45
  index_js_1.services.keyValues.put(keyValue);
51
46
  }
52
47
  /**
53
- * Add label(s) to the test report
48
+ * Add a single label to the test report
54
49
  * @param {string} key - label key (e.g. 'severity', 'feature', or just 'smoke' for labels without values)
55
- * @param {string|string[]|null} [value=null] - optional label value(s) (e.g. 'high', 'login') or array of values
56
- * @returns {void}
50
+ * @param {string} [value] - optional label value (e.g. 'high', 'login')
57
51
  */
58
52
  function setLabel(key, value = null) {
59
53
  if (Array.isArray(value)) {
60
- value.forEach(val => setLabel(key, val));
54
+ value.forEach(v => setLabel(key, v));
61
55
  return;
62
56
  }
63
- const labelObject = value !== null && value !== undefined && value !== ''
64
- ? { label: `${key}:${value}` }
65
- : { label: key };
66
- index_js_1.services.links.put([labelObject]);
67
- }
68
- /**
69
- * Add link(s) to the test report
70
- * @param {...string} testIds - test IDs to link
71
- * @returns {void}
72
- */
73
- function linkTest(...testIds) {
74
- const links = testIds.map(testId => ({ test: testId }));
75
- index_js_1.services.links.put(links);
57
+ if (!key || typeof key !== 'string') {
58
+ console.warn('Label key must be a non-empty string');
59
+ return;
60
+ }
61
+ // Limit key length to 255 characters
62
+ if (key.length > 255) {
63
+ console.warn('Label key is too long, trimmed to 255 characters:', key);
64
+ key = key.substring(0, 255);
65
+ }
66
+ let labelString = key;
67
+ if (value !== null && value !== undefined && value !== '') {
68
+ if (typeof value !== 'string') {
69
+ console.warn('Label value must be a string, converting:', value);
70
+ value = String(value);
71
+ }
72
+ // Limit value length to 255 characters
73
+ if (value.length > 255) {
74
+ console.warn('Label value is too long, trimmed to 255 characters:', value);
75
+ value = value.substring(0, 255);
76
+ }
77
+ labelString = `${key}:${value}`;
78
+ }
79
+ // Limit total label length to 255 characters
80
+ if (labelString.length > 255) {
81
+ console.warn('Label is too long, trimmed to 255 characters:', labelString);
82
+ labelString = labelString.substring(0, 255);
83
+ }
84
+ index_js_1.services.labels.put([labelString]);
76
85
  }
77
86
  module.exports = {
78
87
  artifact: saveArtifact,
@@ -80,5 +89,4 @@ module.exports = {
80
89
  step: addStep,
81
90
  keyValue: setKeyValue,
82
91
  label: setLabel,
83
- linkTest,
84
92
  };