qase-javascript-commons 2.6.6 → 2.7.0

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,3 +1,11 @@
1
+ ## 2.7.0
2
+
3
+ ### Added
4
+ - New internal subpath `qase-javascript-commons/internal` exposing helpers for use by Qase reporters in this monorepo: `removeQaseIdsFromTitle`, `extractAndCleanStep`, `getFile`, `parseQaseIdsFromString`, `normalizeSuitePart`. The `/internal` subpath is intended for Qase-owned reporter packages and may change without a major version bump.
5
+
6
+ ### Changed
7
+ - `removeQaseIdsFromTitle` regex unified across reporters to `/\(Qase ID:? ([\d,]+)\)$/i`. This is more permissive than the previous mocha/wdio variants (case-insensitive; also accepts `(Qase ID 1)` without colon) and adds a trailing-position anchor (`$`).
8
+
1
9
  # qase-javascript-commons@2.6.6
2
10
 
3
11
  ## Bug fixes
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Parses a comma-separated string of Qase IDs into an array of numbers.
3
+ * Whitespace around each entry is trimmed; non-numeric entries are skipped.
4
+ *
5
+ * Examples: "1,2,3" → [1, 2, 3], "42" → [42], "" → [].
6
+ */
7
+ export declare function parseQaseIdsFromString(value: string): number[];
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseQaseIdsFromString = parseQaseIdsFromString;
4
+ /**
5
+ * Parses a comma-separated string of Qase IDs into an array of numbers.
6
+ * Whitespace around each entry is trimmed; non-numeric entries are skipped.
7
+ *
8
+ * Examples: "1,2,3" → [1, 2, 3], "42" → [42], "" → [].
9
+ */
10
+ function parseQaseIdsFromString(value) {
11
+ if (!value?.trim()) {
12
+ return [];
13
+ }
14
+ return value
15
+ .split(',')
16
+ .map((part) => parseInt(part.trim(), 10))
17
+ .filter((n) => !Number.isNaN(n));
18
+ }
@@ -0,0 +1,7 @@
1
+ export { removeQaseIdsFromTitle } from './title';
2
+ export { extractAndCleanStep } from './step-parser';
3
+ export type { ExtractedStep } from './step-parser';
4
+ export { getFile } from './suite-file';
5
+ export type { FileSuiteNode } from './suite-file';
6
+ export { parseQaseIdsFromString } from './ids-parser';
7
+ export { normalizeSuitePart } from './suite-normalizer';
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeSuitePart = exports.parseQaseIdsFromString = exports.getFile = exports.extractAndCleanStep = exports.removeQaseIdsFromTitle = void 0;
4
+ var title_1 = require("./title");
5
+ Object.defineProperty(exports, "removeQaseIdsFromTitle", { enumerable: true, get: function () { return title_1.removeQaseIdsFromTitle; } });
6
+ var step_parser_1 = require("./step-parser");
7
+ Object.defineProperty(exports, "extractAndCleanStep", { enumerable: true, get: function () { return step_parser_1.extractAndCleanStep; } });
8
+ var suite_file_1 = require("./suite-file");
9
+ Object.defineProperty(exports, "getFile", { enumerable: true, get: function () { return suite_file_1.getFile; } });
10
+ var ids_parser_1 = require("./ids-parser");
11
+ Object.defineProperty(exports, "parseQaseIdsFromString", { enumerable: true, get: function () { return ids_parser_1.parseQaseIdsFromString; } });
12
+ var suite_normalizer_1 = require("./suite-normalizer");
13
+ Object.defineProperty(exports, "normalizeSuitePart", { enumerable: true, get: function () { return suite_normalizer_1.normalizeSuitePart; } });
@@ -0,0 +1,11 @@
1
+ export interface ExtractedStep {
2
+ expectedResult: string | null;
3
+ data: string | null;
4
+ cleanedString: string;
5
+ }
6
+ /**
7
+ * Parses a step string for inline `QaseExpRes:` (expected result) and `QaseData:`
8
+ * (data) markers. Returns the extracted parts and the input string with markers
9
+ * removed. If no markers are present, returns nulls and the original string.
10
+ */
11
+ export declare function extractAndCleanStep(input: string): ExtractedStep;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractAndCleanStep = extractAndCleanStep;
4
+ /**
5
+ * Parses a step string for inline `QaseExpRes:` (expected result) and `QaseData:`
6
+ * (data) markers. Returns the extracted parts and the input string with markers
7
+ * removed. If no markers are present, returns nulls and the original string.
8
+ */
9
+ function extractAndCleanStep(input) {
10
+ let expectedResult = null;
11
+ let data = null;
12
+ let cleanedString = input;
13
+ const hasExpectedResult = input.includes('QaseExpRes:');
14
+ const hasData = input.includes('QaseData:');
15
+ if (hasExpectedResult || hasData) {
16
+ const regex = /QaseExpRes:\s*:?\s*(.*?)\s*(?=QaseData:|$)QaseData:\s*:?\s*(.*)?/;
17
+ const match = input.match(regex);
18
+ if (match) {
19
+ expectedResult = match[1]?.trim() ?? null;
20
+ data = match[2]?.trim() ?? null;
21
+ cleanedString = input
22
+ .replace(/QaseExpRes:\s*:?\s*.*?(?=QaseData:|$)/, '')
23
+ .replace(/QaseData:\s*:?\s*.*/, '')
24
+ .trim();
25
+ }
26
+ }
27
+ return { expectedResult, data, cleanedString };
28
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Minimal structural shape compatible with both Mocha's `Suite` (used by
3
+ * qase-mocha) and Cypress's runner Suite (used by qase-cypress).
4
+ */
5
+ export interface FileSuiteNode {
6
+ file?: string;
7
+ parent?: FileSuiteNode;
8
+ }
9
+ /**
10
+ * Walks up `node.parent` until a node with a non-empty `file` property is
11
+ * reached. Returns the file path, or undefined if no ancestor has one.
12
+ */
13
+ export declare function getFile(node: FileSuiteNode): string | undefined;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFile = getFile;
4
+ /**
5
+ * Walks up `node.parent` until a node with a non-empty `file` property is
6
+ * reached. Returns the file path, or undefined if no ancestor has one.
7
+ */
8
+ function getFile(node) {
9
+ if (node.file) {
10
+ return node.file;
11
+ }
12
+ if (node.parent) {
13
+ return getFile(node.parent);
14
+ }
15
+ return undefined;
16
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Lowercases the input and replaces every whitespace character with an
3
+ * underscore. Used by reporters to normalize suite/title segments before
4
+ * passing them into `generateSignature`.
5
+ */
6
+ export declare function normalizeSuitePart(value: string): string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeSuitePart = normalizeSuitePart;
4
+ /**
5
+ * Lowercases the input and replaces every whitespace character with an
6
+ * underscore. Used by reporters to normalize suite/title segments before
7
+ * passing them into `generateSignature`.
8
+ */
9
+ function normalizeSuitePart(value) {
10
+ return value.toLowerCase().replace(/\s/g, '_');
11
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Strips a trailing `(Qase ID: 1,2,3)` (or `(Qase ID 1)` without colon) from a test title.
3
+ * Returns the original title untouched if no match is found.
4
+ */
5
+ export declare function removeQaseIdsFromTitle(title: string): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeQaseIdsFromTitle = removeQaseIdsFromTitle;
4
+ const QASE_ID_TRAILER_REGEXP = /\(Qase ID:? ([\d,]+)\)$/i;
5
+ /**
6
+ * Strips a trailing `(Qase ID: 1,2,3)` (or `(Qase ID 1)` without colon) from a test title.
7
+ * Returns the original title untouched if no match is found.
8
+ */
9
+ function removeQaseIdsFromTitle(title) {
10
+ const match = title.match(QASE_ID_TRAILER_REGEXP);
11
+ if (match) {
12
+ return title.replace(match[0], '').trimEnd();
13
+ }
14
+ return title;
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qase-javascript-commons",
3
- "version": "2.6.6",
3
+ "version": "2.7.0",
4
4
  "description": "Qase JS Reporters",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -13,11 +13,16 @@
13
13
  "types": "./dist/profilers/index.d.ts",
14
14
  "default": "./dist/profilers/index.js"
15
15
  },
16
+ "./internal": {
17
+ "types": "./dist/internal/index.d.ts",
18
+ "default": "./dist/internal/index.js"
19
+ },
16
20
  "./package.json": "./package.json"
17
21
  },
18
22
  "typesVersions": {
19
23
  "*": {
20
- "profilers": ["./dist/profilers/index.d.ts"]
24
+ "profilers": ["./dist/profilers/index.d.ts"],
25
+ "internal": ["./dist/internal/index.d.ts"]
21
26
  }
22
27
  },
23
28
  "homepage": "https://github.com/qase-tms/qase-javascript",