testit-js-commons 5.0.5 → 5.0.6
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/lib/adapters-api/dist/api/CustomAttributesApi.js +201 -0
- package/lib/adapters-api/dist/index.js +77 -0
- package/lib/adapters-api/dist/model/AutoTestApiResult.js +15 -0
- package/lib/adapters-api/dist/model/AutoTestCreateApiModel.js +15 -0
- package/lib/adapters-api/dist/model/AutoTestUpdateApiModel.js +30 -4
- package/lib/adapters-api/dist/model/CustomAttributeApiResult.js +54 -4
- package/lib/adapters-api/dist/model/CustomAttributeOptionPostApiModel.js +98 -0
- package/lib/adapters-api/dist/model/CustomAttributeOptionUpdateApiModel.js +124 -0
- package/lib/adapters-api/dist/model/CustomAttributeSearchApiModel.js +137 -0
- package/lib/adapters-api/dist/model/CustomAttributeSearchApiResult.js +281 -0
- package/lib/adapters-api/dist/model/GlobalCustomAttributePostApiModel.js +141 -0
- package/lib/adapters-api/dist/model/GlobalCustomAttributeUpdateApiModel.js +129 -0
- package/lib/adapters-api/dist/model/LayerApiModel.js +102 -0
- package/lib/adapters-api/dist/model/LayerApiResult.js +102 -0
- package/lib/adapters-api/dist/model/LayerSource.js +61 -0
- package/lib/adapters-api/dist/model/ProjectShortestApiResult.js +138 -0
- package/lib/adapters-api/dist/model/ProjectsFilterModel.js +13 -13
- package/lib/adapters-api/dist/model/TestResultShortResponse.js +15 -4
- package/lib/adapters-api/dist/model/TestResultsFilterApiModel.js +14 -0
- package/lib/adapters-api/dist/model/TestRunApiResult.js +45 -4
- package/lib/adapters-api/index.d.ts +718 -8
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.js +1 -0
- package/lib/common/test-layers.d.ts +11 -0
- package/lib/common/test-layers.js +13 -0
- package/lib/common/types/common.type.d.ts +2 -0
- package/lib/services/autotests/autotests.converter.d.ts +6 -2
- package/lib/services/autotests/autotests.converter.js +41 -16
- package/lib/services/autotests/autotests.converter.test.d.ts +1 -0
- package/lib/services/autotests/autotests.converter.test.js +39 -0
- package/lib/services/autotests/autotests.service.js +3 -3
- package/lib/services/autotests/autotests.type.d.ts +2 -0
- package/package.json +1 -1
package/lib/common/index.d.ts
CHANGED
package/lib/common/index.js
CHANGED
|
@@ -16,5 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./types"), exports);
|
|
18
18
|
__exportStar(require("./utils"), exports);
|
|
19
|
+
__exportStar(require("./test-layers"), exports);
|
|
19
20
|
__exportStar(require("./base.converter"), exports);
|
|
20
21
|
__exportStar(require("./base.service"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Recommended autotest pyramid layer names (not enforced). */
|
|
2
|
+
export declare const TestLayers: {
|
|
3
|
+
readonly E2E: "E2E";
|
|
4
|
+
readonly UI: "UI";
|
|
5
|
+
readonly API: "API";
|
|
6
|
+
readonly CONTRACT: "Contract";
|
|
7
|
+
readonly INTEGRATION: "Integration";
|
|
8
|
+
readonly COMPONENT: "Component";
|
|
9
|
+
readonly UNIT: "Unit";
|
|
10
|
+
};
|
|
11
|
+
export type TestLayerName = (typeof TestLayers)[keyof typeof TestLayers] | string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TestLayers = void 0;
|
|
4
|
+
/** Recommended autotest pyramid layer names (not enforced). */
|
|
5
|
+
exports.TestLayers = {
|
|
6
|
+
E2E: "E2E",
|
|
7
|
+
UI: "UI",
|
|
8
|
+
API: "API",
|
|
9
|
+
CONTRACT: "Contract",
|
|
10
|
+
INTEGRATION: "Integration",
|
|
11
|
+
COMPONENT: "Component",
|
|
12
|
+
UNIT: "Unit",
|
|
13
|
+
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { BaseConverter, AdapterConfig } from "../../common";
|
|
2
2
|
import { AutotestGet, AutotestPost } from "./autotests.type";
|
|
3
3
|
export interface IAutotestConverter {
|
|
4
|
-
|
|
4
|
+
toOriginAutotestCreate(autotest: AutotestPost): any;
|
|
5
|
+
toOriginAutotestUpdate(autotest: AutotestPost): any;
|
|
5
6
|
toLocalAutotest(autotest: any): AutotestGet;
|
|
6
7
|
}
|
|
7
8
|
export declare class AutotestConverter extends BaseConverter implements IAutotestConverter {
|
|
8
9
|
constructor(config: AdapterConfig);
|
|
9
|
-
|
|
10
|
+
toOriginAutotestCreate(autotest: AutotestPost): any;
|
|
11
|
+
toOriginAutotestUpdate(autotest: AutotestPost): any;
|
|
10
12
|
toLocalAutotest(autotest: any): AutotestGet;
|
|
13
|
+
private baseAutotestFields;
|
|
14
|
+
private layerToApiModel;
|
|
11
15
|
}
|
|
@@ -2,11 +2,45 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AutotestConverter = void 0;
|
|
4
4
|
const common_1 = require("../../common");
|
|
5
|
+
const LAYER_SOURCE_RUN = "Run";
|
|
5
6
|
class AutotestConverter extends common_1.BaseConverter {
|
|
6
7
|
constructor(config) {
|
|
7
8
|
super(config);
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
toOriginAutotestCreate(autotest) {
|
|
11
|
+
const model = this.baseAutotestFields(autotest);
|
|
12
|
+
const layer = this.layerToApiModel(autotest.layer);
|
|
13
|
+
if (layer) {
|
|
14
|
+
model.layer = layer;
|
|
15
|
+
}
|
|
16
|
+
return model;
|
|
17
|
+
}
|
|
18
|
+
toOriginAutotestUpdate(autotest) {
|
|
19
|
+
const model = Object.assign(Object.assign({}, this.baseAutotestFields(autotest)), { resetLayer: false });
|
|
20
|
+
const layer = this.layerToApiModel(autotest.layer);
|
|
21
|
+
if (layer) {
|
|
22
|
+
model.layer = layer;
|
|
23
|
+
}
|
|
24
|
+
return model;
|
|
25
|
+
}
|
|
26
|
+
toLocalAutotest(autotest) {
|
|
27
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
28
|
+
return {
|
|
29
|
+
id: autotest.id,
|
|
30
|
+
name: (_a = autotest.name) !== null && _a !== void 0 ? _a : undefined,
|
|
31
|
+
externalId: (_b = autotest.externalId) !== null && _b !== void 0 ? _b : undefined,
|
|
32
|
+
links: (_c = autotest.links) === null || _c === void 0 ? void 0 : _c.map((link) => this.toLocalLink(link)),
|
|
33
|
+
namespace: (_d = autotest.namespace) !== null && _d !== void 0 ? _d : undefined,
|
|
34
|
+
classname: (_e = autotest.classname) !== null && _e !== void 0 ? _e : undefined,
|
|
35
|
+
steps: (_f = autotest.steps) === null || _f === void 0 ? void 0 : _f.map((step) => this.toLocalShortStep(step)),
|
|
36
|
+
setup: (_g = autotest.setup) === null || _g === void 0 ? void 0 : _g.map((step) => this.toLocalShortStep(step)),
|
|
37
|
+
teardown: (_h = autotest.teardown) === null || _h === void 0 ? void 0 : _h.map((step) => this.toLocalShortStep(step)),
|
|
38
|
+
labels: (_j = autotest.labels) !== null && _j !== void 0 ? _j : undefined,
|
|
39
|
+
tags: (_k = autotest.tags) !== null && _k !== void 0 ? _k : undefined,
|
|
40
|
+
layer: (_m = (_l = autotest.layer) === null || _l === void 0 ? void 0 : _l.name) !== null && _m !== void 0 ? _m : undefined,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
baseAutotestFields(autotest) {
|
|
10
44
|
return {
|
|
11
45
|
externalId: autotest.externalId,
|
|
12
46
|
name: autotest.name,
|
|
@@ -26,21 +60,12 @@ class AutotestConverter extends common_1.BaseConverter {
|
|
|
26
60
|
shouldCreateWorkItem: this.config.automaticCreationTestCases,
|
|
27
61
|
};
|
|
28
62
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
links: (_c = autotest.links) === null || _c === void 0 ? void 0 : _c.map((link) => this.toLocalLink(link)),
|
|
36
|
-
namespace: (_d = autotest.namespace) !== null && _d !== void 0 ? _d : undefined,
|
|
37
|
-
classname: (_e = autotest.classname) !== null && _e !== void 0 ? _e : undefined,
|
|
38
|
-
steps: (_f = autotest.steps) === null || _f === void 0 ? void 0 : _f.map((step) => this.toLocalShortStep(step)),
|
|
39
|
-
setup: (_g = autotest.setup) === null || _g === void 0 ? void 0 : _g.map((step) => this.toLocalShortStep(step)),
|
|
40
|
-
teardown: (_h = autotest.teardown) === null || _h === void 0 ? void 0 : _h.map((step) => this.toLocalShortStep(step)),
|
|
41
|
-
labels: (_j = autotest.labels) !== null && _j !== void 0 ? _j : undefined,
|
|
42
|
-
tags: (_k = autotest.tags) !== null && _k !== void 0 ? _k : undefined,
|
|
43
|
-
};
|
|
63
|
+
layerToApiModel(layer) {
|
|
64
|
+
const name = layer === null || layer === void 0 ? void 0 : layer.trim();
|
|
65
|
+
if (!name) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
return { name, source: LAYER_SOURCE_RUN };
|
|
44
69
|
}
|
|
45
70
|
}
|
|
46
71
|
exports.AutotestConverter = AutotestConverter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const autotests_converter_1 = require("./autotests.converter");
|
|
4
|
+
function makeConfig() {
|
|
5
|
+
return {
|
|
6
|
+
url: "http://localhost:8080",
|
|
7
|
+
privateToken: "token",
|
|
8
|
+
projectId: "11111111-1111-1111-1111-111111111111",
|
|
9
|
+
configurationId: "22222222-2222-2222-2222-222222222222",
|
|
10
|
+
testRunId: "33333333-3333-3333-3333-333333333333",
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function makeAutotest(overrides = {}) {
|
|
14
|
+
return Object.assign({ externalId: "ext-1", name: "test name" }, overrides);
|
|
15
|
+
}
|
|
16
|
+
describe("AutotestConverter layer", () => {
|
|
17
|
+
const converter = new autotests_converter_1.AutotestConverter(makeConfig());
|
|
18
|
+
it("create: includes layer when set", () => {
|
|
19
|
+
const model = converter.toOriginAutotestCreate(makeAutotest({ layer: "API" }));
|
|
20
|
+
expect(model.layer).toEqual({ name: "API", source: "Run" });
|
|
21
|
+
expect(model.resetLayer).toBeUndefined();
|
|
22
|
+
});
|
|
23
|
+
it("create: omits layer when not set", () => {
|
|
24
|
+
const model = converter.toOriginAutotestCreate(makeAutotest());
|
|
25
|
+
expect(model.layer).toBeUndefined();
|
|
26
|
+
});
|
|
27
|
+
it("create: accepts custom layer string", () => {
|
|
28
|
+
const model = converter.toOriginAutotestCreate(makeAutotest({ layer: "my-custom-layer" }));
|
|
29
|
+
expect(model.layer).toEqual({ name: "my-custom-layer", source: "Run" });
|
|
30
|
+
});
|
|
31
|
+
it("update: always resetLayer false, layer only when set", () => {
|
|
32
|
+
const withLayer = converter.toOriginAutotestUpdate(makeAutotest({ layer: "E2E" }));
|
|
33
|
+
expect(withLayer.resetLayer).toBe(false);
|
|
34
|
+
expect(withLayer.layer).toEqual({ name: "E2E", source: "Run" });
|
|
35
|
+
const withoutLayer = converter.toOriginAutotestUpdate(makeAutotest());
|
|
36
|
+
expect(withoutLayer.resetLayer).toBe(false);
|
|
37
|
+
expect(withoutLayer.layer).toBeUndefined();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -28,7 +28,7 @@ class AutotestsService extends common_1.BaseService {
|
|
|
28
28
|
}
|
|
29
29
|
createAutotest(autotest) {
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
const autotestPost = this._converter.
|
|
31
|
+
const autotestPost = this._converter.toOriginAutotestCreate(autotest);
|
|
32
32
|
(0, common_1.escapeHtmlInObject)(autotestPost);
|
|
33
33
|
logger_1.default.debug("[autotests] createAutoTest", { externalId: autotest.externalId, name: autotest.name });
|
|
34
34
|
try {
|
|
@@ -51,7 +51,7 @@ class AutotestsService extends common_1.BaseService {
|
|
|
51
51
|
}
|
|
52
52
|
updateAutotest(autotest) {
|
|
53
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
const autotestPost = this._converter.
|
|
54
|
+
const autotestPost = this._converter.toOriginAutotestUpdate(autotest);
|
|
55
55
|
(0, common_1.escapeHtmlInObject)(autotestPost);
|
|
56
56
|
logger_1.default.debug("[autotests] updateAutoTest", { externalId: autotest.externalId, name: autotest.name });
|
|
57
57
|
yield (0, common_1.withHttpRetry)(() => this._client
|
|
@@ -103,7 +103,7 @@ class AutotestsService extends common_1.BaseService {
|
|
|
103
103
|
updateAutotestFromFailed(originAutotest, autotest) {
|
|
104
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
105
|
var _a, _b, _c, _d;
|
|
106
|
-
yield this.updateAutotest(Object.assign(Object.assign({}, originAutotest), { externalId: (_a = originAutotest === null || originAutotest === void 0 ? void 0 : originAutotest.externalId) !== null && _a !== void 0 ? _a : autotest.externalId, name: (_b = originAutotest === null || originAutotest === void 0 ? void 0 : originAutotest.name) !== null && _b !== void 0 ? _b : autotest.name, links: autotest.links, externalKey: autotest.externalKey, steps: autotest.steps, setup: autotest.setup, teardown: autotest.teardown, title: autotest.title, description: autotest.description, namespace: (_c = autotest.namespace) !== null && _c !== void 0 ? _c : originAutotest.namespace, classname: (_d = autotest.classname) !== null && _d !== void 0 ? _d : originAutotest.classname, labels: autotest.labels, tags: autotest.tags, workItemIds: autotest.workItemIds, isFlaky: autotest.isFlaky, shouldCreateWorkItem: autotest.shouldCreateWorkItem }));
|
|
106
|
+
yield this.updateAutotest(Object.assign(Object.assign({}, originAutotest), { externalId: (_a = originAutotest === null || originAutotest === void 0 ? void 0 : originAutotest.externalId) !== null && _a !== void 0 ? _a : autotest.externalId, name: (_b = originAutotest === null || originAutotest === void 0 ? void 0 : originAutotest.name) !== null && _b !== void 0 ? _b : autotest.name, links: autotest.links, externalKey: autotest.externalKey, steps: autotest.steps, setup: autotest.setup, teardown: autotest.teardown, title: autotest.title, description: autotest.description, namespace: (_c = autotest.namespace) !== null && _c !== void 0 ? _c : originAutotest.namespace, classname: (_d = autotest.classname) !== null && _d !== void 0 ? _d : originAutotest.classname, labels: autotest.labels, tags: autotest.tags, layer: autotest.layer, workItemIds: autotest.workItemIds, isFlaky: autotest.isFlaky, shouldCreateWorkItem: autotest.shouldCreateWorkItem }));
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
linkToWorkItems(internalId, workItemIds) {
|
|
@@ -25,6 +25,8 @@ interface AutotestBase {
|
|
|
25
25
|
labels?: Array<Label>;
|
|
26
26
|
tags?: Array<string>;
|
|
27
27
|
externalKey?: string;
|
|
28
|
+
/** Test pyramid layer name from test code annotation (source Run is set by converter). */
|
|
29
|
+
layer?: string;
|
|
28
30
|
}
|
|
29
31
|
export interface AutotestPost extends AutotestBase {
|
|
30
32
|
externalId: string;
|