qase-javascript-commons 2.7.3 → 2.7.4
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 +6 -0
- package/dist/internal/filter-positive-ids.d.ts +17 -0
- package/dist/internal/filter-positive-ids.js +38 -0
- package/dist/internal/ids-parser.d.ts +3 -1
- package/dist/internal/ids-parser.js +5 -2
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.js +3 -1
- package/dist/utils/project-mapping-utils.d.ts +3 -2
- package/dist/utils/project-mapping-utils.js +17 -8
- package/package.json +1 -1
package/changelog.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 2.7.4
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
|
|
5
|
+
- Qase test case IDs that are `<= 0` (e.g. an accidental `(Qase ID: 0)` in a test title or `@qaseid(0)` tag) no longer cause the API to reject the whole result batch with HTTP 400. The invalid ID is dropped with a warning and the result is sent without an ID, exactly as if no ID had been specified. Filtering happens in a new internal `filterPositiveIds()` helper applied by `parseQaseIdsFromString`, `parseProjectMappingFromTitle`, and `parseProjectMappingFromTags`. The warning routes through the provided `LoggerInterface` (logged at INFO level with a `Warning:` prefix in the message) or falls back to `console.warn` when no logger is available.
|
|
6
|
+
|
|
1
7
|
## 2.7.3
|
|
2
8
|
|
|
3
9
|
### Fixed
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LoggerInterface } from '../utils/logger';
|
|
2
|
+
/**
|
|
3
|
+
* Filter a list of Qase test case IDs, dropping non-positive (<= 0) and
|
|
4
|
+
* non-finite numbers. Each dropped non-positive ID produces a warning so
|
|
5
|
+
* users can spot accidental "0" IDs in their test code.
|
|
6
|
+
*
|
|
7
|
+
* NaN and non-finite values are dropped silently — they come from upstream
|
|
8
|
+
* parse failures (parseInt('abc') etc.) that are already handled at their
|
|
9
|
+
* source and are not user-facing mistakes worth warning about.
|
|
10
|
+
*
|
|
11
|
+
* Warning routing:
|
|
12
|
+
* - if a logger is provided, it goes through logger.log (INFO level, since
|
|
13
|
+
* the LoggerInterface has no warn level);
|
|
14
|
+
* - otherwise, it falls back to console.warn with a "[qase] " prefix so the
|
|
15
|
+
* message still reaches the user.
|
|
16
|
+
*/
|
|
17
|
+
export declare function filterPositiveIds(ids: number[], logger?: LoggerInterface): number[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterPositiveIds = filterPositiveIds;
|
|
4
|
+
/**
|
|
5
|
+
* Filter a list of Qase test case IDs, dropping non-positive (<= 0) and
|
|
6
|
+
* non-finite numbers. Each dropped non-positive ID produces a warning so
|
|
7
|
+
* users can spot accidental "0" IDs in their test code.
|
|
8
|
+
*
|
|
9
|
+
* NaN and non-finite values are dropped silently — they come from upstream
|
|
10
|
+
* parse failures (parseInt('abc') etc.) that are already handled at their
|
|
11
|
+
* source and are not user-facing mistakes worth warning about.
|
|
12
|
+
*
|
|
13
|
+
* Warning routing:
|
|
14
|
+
* - if a logger is provided, it goes through logger.log (INFO level, since
|
|
15
|
+
* the LoggerInterface has no warn level);
|
|
16
|
+
* - otherwise, it falls back to console.warn with a "[qase] " prefix so the
|
|
17
|
+
* message still reaches the user.
|
|
18
|
+
*/
|
|
19
|
+
function filterPositiveIds(ids, logger) {
|
|
20
|
+
const valid = [];
|
|
21
|
+
for (const n of ids) {
|
|
22
|
+
if (!Number.isFinite(n)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (n <= 0) {
|
|
26
|
+
const message = `Warning: Qase test case ID must be greater than 0, got "${n}". This ID will be ignored and the result will be sent without it.`;
|
|
27
|
+
if (logger) {
|
|
28
|
+
logger.log(message);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
console.warn(`[qase] ${message}`);
|
|
32
|
+
}
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
valid.push(n);
|
|
36
|
+
}
|
|
37
|
+
return valid;
|
|
38
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { LoggerInterface } from '../utils/logger';
|
|
1
2
|
/**
|
|
2
3
|
* Parses a comma-separated string of Qase IDs into an array of numbers.
|
|
3
4
|
* Whitespace around each entry is trimmed; non-numeric entries are skipped.
|
|
5
|
+
* IDs that are not positive integers (<= 0) are filtered out with a warning.
|
|
4
6
|
*
|
|
5
7
|
* Examples: "1,2,3" → [1, 2, 3], "42" → [42], "" → [].
|
|
6
8
|
*/
|
|
7
|
-
export declare function parseQaseIdsFromString(value: string): number[];
|
|
9
|
+
export declare function parseQaseIdsFromString(value: string, logger?: LoggerInterface): number[];
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseQaseIdsFromString = parseQaseIdsFromString;
|
|
4
|
+
const filter_positive_ids_1 = require("./filter-positive-ids");
|
|
4
5
|
/**
|
|
5
6
|
* Parses a comma-separated string of Qase IDs into an array of numbers.
|
|
6
7
|
* Whitespace around each entry is trimmed; non-numeric entries are skipped.
|
|
8
|
+
* IDs that are not positive integers (<= 0) are filtered out with a warning.
|
|
7
9
|
*
|
|
8
10
|
* Examples: "1,2,3" → [1, 2, 3], "42" → [42], "" → [].
|
|
9
11
|
*/
|
|
10
|
-
function parseQaseIdsFromString(value) {
|
|
12
|
+
function parseQaseIdsFromString(value, logger) {
|
|
11
13
|
if (!value?.trim()) {
|
|
12
14
|
return [];
|
|
13
15
|
}
|
|
14
|
-
|
|
16
|
+
const parsed = value
|
|
15
17
|
.split(',')
|
|
16
18
|
.map((part) => parseInt(part.trim(), 10))
|
|
17
19
|
.filter((n) => !Number.isNaN(n));
|
|
20
|
+
return (0, filter_positive_ids_1.filterPositiveIds)(parsed, logger);
|
|
18
21
|
}
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export type { ExtractedStep } from './step-parser';
|
|
|
4
4
|
export { getFile } from './suite-file';
|
|
5
5
|
export type { FileSuiteNode } from './suite-file';
|
|
6
6
|
export { parseQaseIdsFromString } from './ids-parser';
|
|
7
|
+
export { filterPositiveIds } from './filter-positive-ids';
|
|
7
8
|
export { normalizeSuitePart } from './suite-normalizer';
|
package/dist/internal/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeSuitePart = exports.parseQaseIdsFromString = exports.getFile = exports.extractAndCleanStep = exports.removeQaseIdsFromTitle = void 0;
|
|
3
|
+
exports.normalizeSuitePart = exports.filterPositiveIds = exports.parseQaseIdsFromString = exports.getFile = exports.extractAndCleanStep = exports.removeQaseIdsFromTitle = void 0;
|
|
4
4
|
var title_1 = require("./title");
|
|
5
5
|
Object.defineProperty(exports, "removeQaseIdsFromTitle", { enumerable: true, get: function () { return title_1.removeQaseIdsFromTitle; } });
|
|
6
6
|
var step_parser_1 = require("./step-parser");
|
|
@@ -9,5 +9,7 @@ var suite_file_1 = require("./suite-file");
|
|
|
9
9
|
Object.defineProperty(exports, "getFile", { enumerable: true, get: function () { return suite_file_1.getFile; } });
|
|
10
10
|
var ids_parser_1 = require("./ids-parser");
|
|
11
11
|
Object.defineProperty(exports, "parseQaseIdsFromString", { enumerable: true, get: function () { return ids_parser_1.parseQaseIdsFromString; } });
|
|
12
|
+
var filter_positive_ids_1 = require("./filter-positive-ids");
|
|
13
|
+
Object.defineProperty(exports, "filterPositiveIds", { enumerable: true, get: function () { return filter_positive_ids_1.filterPositiveIds; } });
|
|
12
14
|
var suite_normalizer_1 = require("./suite-normalizer");
|
|
13
15
|
Object.defineProperty(exports, "normalizeSuitePart", { enumerable: true, get: function () { return suite_normalizer_1.normalizeSuitePart; } });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TestopsProjectMapping } from '../models';
|
|
2
|
+
import { LoggerInterface } from './logger';
|
|
2
3
|
/**
|
|
3
4
|
* Result of parsing project/ID markers from a test title.
|
|
4
5
|
* - legacyIds: from "(Qase ID: 123)" or "(Qase ID: 123,124)" — single-project mode.
|
|
@@ -25,7 +26,7 @@ export interface ParsedTagsProjectMapping {
|
|
|
25
26
|
* @param tags — e.g. ["@qaseid(1,2)", "@qaseid.PROJ2(3)"]
|
|
26
27
|
* @returns legacyIds from @qaseid(...), projectMapping from @qaseid.PROJ(...)
|
|
27
28
|
*/
|
|
28
|
-
export declare function parseProjectMappingFromTags(tags: string[]): ParsedTagsProjectMapping;
|
|
29
|
+
export declare function parseProjectMappingFromTags(tags: string[], logger?: LoggerInterface): ParsedTagsProjectMapping;
|
|
29
30
|
/**
|
|
30
31
|
* Parse multi-project and legacy Qase ID markers from a test title.
|
|
31
32
|
* - "(Qase ID: 123)" or "(Qase ID: 123,124)" → legacyIds, single-project.
|
|
@@ -34,7 +35,7 @@ export declare function parseProjectMappingFromTags(tags: string[]): ParsedTagsP
|
|
|
34
35
|
* @param title — test title that may contain "(Qase ID: …)" or "(Qase PROJECT_CODE: …)".
|
|
35
36
|
* @returns legacyIds, projectMapping, and cleanedTitle with all markers stripped.
|
|
36
37
|
*/
|
|
37
|
-
export declare function parseProjectMappingFromTitle(title: string): ParsedProjectMapping;
|
|
38
|
+
export declare function parseProjectMappingFromTitle(title: string, logger?: LoggerInterface): ParsedProjectMapping;
|
|
38
39
|
/**
|
|
39
40
|
* Build a test title with multi-project markers for use in test names.
|
|
40
41
|
* Use this (or framework-specific qase.projects()) so the reporter can parse project and IDs.
|
|
@@ -3,15 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseProjectMappingFromTags = parseProjectMappingFromTags;
|
|
4
4
|
exports.parseProjectMappingFromTitle = parseProjectMappingFromTitle;
|
|
5
5
|
exports.formatTitleWithProjectMapping = formatTitleWithProjectMapping;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const filter_positive_ids_1 = require("../internal/filter-positive-ids");
|
|
7
|
+
/** Matches @qaseid(123) or @qaseid.PROJ1(123,124). Allows negative numbers. */
|
|
8
|
+
const QASEID_TAG_REGEXP = /@qaseid(?:\.([A-Za-z0-9_]+))?\(([-\d,]+)\)/gi;
|
|
8
9
|
/**
|
|
9
10
|
* Parse @qaseid and @qaseid.PROJECT tags into legacy IDs and project mapping.
|
|
10
11
|
*
|
|
11
12
|
* @param tags — e.g. ["@qaseid(1,2)", "@qaseid.PROJ2(3)"]
|
|
12
13
|
* @returns legacyIds from @qaseid(...), projectMapping from @qaseid.PROJ(...)
|
|
13
14
|
*/
|
|
14
|
-
function parseProjectMappingFromTags(tags) {
|
|
15
|
+
function parseProjectMappingFromTags(tags, logger) {
|
|
15
16
|
const legacyIds = [];
|
|
16
17
|
const projectMapping = {};
|
|
17
18
|
for (const tag of tags) {
|
|
@@ -20,7 +21,11 @@ function parseProjectMappingFromTags(tags) {
|
|
|
20
21
|
while ((m = re.exec(tag)) !== null) {
|
|
21
22
|
const projectCode = m[1]; // undefined for @qaseid(1)
|
|
22
23
|
const idsStr = m[2] ?? '';
|
|
23
|
-
const
|
|
24
|
+
const rawIds = idsStr
|
|
25
|
+
.split(',')
|
|
26
|
+
.map((s) => parseInt(s, 10))
|
|
27
|
+
.filter((n) => !Number.isNaN(n));
|
|
28
|
+
const ids = (0, filter_positive_ids_1.filterPositiveIds)(rawIds, logger);
|
|
24
29
|
if (!projectCode || projectCode.toUpperCase() === 'ID') {
|
|
25
30
|
legacyIds.push(...ids);
|
|
26
31
|
}
|
|
@@ -32,8 +37,8 @@ function parseProjectMappingFromTags(tags) {
|
|
|
32
37
|
}
|
|
33
38
|
return { legacyIds, projectMapping };
|
|
34
39
|
}
|
|
35
|
-
/** Matches "(Qase ID: 123)" or "(Qase PROJ1: 123,124)" — optional space after "Qase". */
|
|
36
|
-
const QASE_MARKER_REGEXP = /\(Qase\s+([A-Za-z0-9_]+):\s*([
|
|
40
|
+
/** Matches "(Qase ID: 123)" or "(Qase PROJ1: 123,124)" — optional space after "Qase". Allows negative numbers. */
|
|
41
|
+
const QASE_MARKER_REGEXP = /\(Qase\s+([A-Za-z0-9_]+):\s*([-\d,]+)\)/gi;
|
|
37
42
|
/**
|
|
38
43
|
* Parse multi-project and legacy Qase ID markers from a test title.
|
|
39
44
|
* - "(Qase ID: 123)" or "(Qase ID: 123,124)" → legacyIds, single-project.
|
|
@@ -42,7 +47,7 @@ const QASE_MARKER_REGEXP = /\(Qase\s+([A-Za-z0-9_]+):\s*([\d,]+)\)/gi;
|
|
|
42
47
|
* @param title — test title that may contain "(Qase ID: …)" or "(Qase PROJECT_CODE: …)".
|
|
43
48
|
* @returns legacyIds, projectMapping, and cleanedTitle with all markers stripped.
|
|
44
49
|
*/
|
|
45
|
-
function parseProjectMappingFromTitle(title) {
|
|
50
|
+
function parseProjectMappingFromTitle(title, logger) {
|
|
46
51
|
const legacyIds = [];
|
|
47
52
|
const projectMapping = {};
|
|
48
53
|
let cleanedTitle = title;
|
|
@@ -51,7 +56,11 @@ function parseProjectMappingFromTitle(title) {
|
|
|
51
56
|
while ((m = re.exec(title)) !== null) {
|
|
52
57
|
const projectCode = m[1] ?? '';
|
|
53
58
|
const idsStr = m[2] ?? '';
|
|
54
|
-
const
|
|
59
|
+
const rawIds = idsStr
|
|
60
|
+
.split(',')
|
|
61
|
+
.map((s) => parseInt(s, 10))
|
|
62
|
+
.filter((n) => !Number.isNaN(n));
|
|
63
|
+
const ids = (0, filter_positive_ids_1.filterPositiveIds)(rawIds, logger);
|
|
55
64
|
if (projectCode.toUpperCase() === 'ID') {
|
|
56
65
|
legacyIds.push(...ids);
|
|
57
66
|
}
|