testit-adapter-codecept 1.1.1 → 1.1.3
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/README.md +2 -7
- package/build/bootstrap.d.ts +1 -0
- package/build/bootstrap.js +34 -0
- package/build/common/__tests/box.class.spec.d.ts +1 -0
- package/build/common/__tests/box.class.spec.js +15 -0
- package/build/common/__tests/test.utils.d.ts +4 -0
- package/build/common/__tests/test.utils.js +71 -0
- package/build/common/classes/box.class.d.ts +5 -0
- package/build/common/classes/box.class.js +18 -0
- package/build/common/classes/config.class.d.ts +6 -0
- package/build/common/classes/config.class.js +67 -0
- package/build/common/classes/logger.class.d.ts +9 -0
- package/build/common/classes/logger.class.js +28 -0
- package/build/common/classes/outcome.factory.d.ts +7 -0
- package/build/common/classes/outcome.factory.js +19 -0
- package/build/common/functions/compose.function.d.ts +1 -0
- package/build/common/functions/compose.function.js +5 -0
- package/build/common/functions/hash.function.d.ts +1 -0
- package/build/common/functions/hash.function.js +15 -0
- package/build/common/functions/humanize.function.d.ts +1 -0
- package/build/common/functions/humanize.function.js +7 -0
- package/build/common/functions/is-passed.function.d.ts +2 -0
- package/build/common/functions/is-passed.function.js +7 -0
- package/build/common/functions/to-iso-string.function.d.ts +1 -0
- package/build/common/functions/to-iso-string.function.js +10 -0
- package/build/common/functions/use-hash.function.d.ts +9 -0
- package/build/common/functions/use-hash.function.js +13 -0
- package/build/common/types/nullable.type.d.ts +1 -0
- package/build/common/types/nullable.type.js +2 -0
- package/build/helper.d.ts +9 -0
- package/build/helper.js +37 -0
- package/build/http/default-http-client.class.d.ts +22 -0
- package/build/http/default-http-client.class.js +123 -0
- package/build/http/http-client.errors.d.ts +7 -0
- package/build/http/http-client.errors.js +18 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +18 -0
- package/build/jest.config.d.ts +7 -0
- package/build/jest.config.js +12 -0
- package/build/services/__tests/attachments.class.spec.d.ts +1 -0
- package/build/services/__tests/attachments.class.spec.js +23 -0
- package/build/services/__tests/runs.builder.spec.d.ts +1 -0
- package/build/services/__tests/runs.builder.spec.js +79 -0
- package/build/services/__tests/tests.builder.spec.d.ts +1 -0
- package/build/services/__tests/tests.builder.spec.js +32 -0
- package/build/services/attachments.service.d.ts +11 -0
- package/build/services/attachments.service.js +28 -0
- package/build/services/runs.builder.d.ts +10 -0
- package/build/services/runs.builder.js +65 -0
- package/build/services/tests.builder.d.ts +10 -0
- package/build/services/tests.builder.js +57 -0
- package/build/strategies/base-strategy.class.d.ts +24 -0
- package/build/strategies/base-strategy.class.js +66 -0
- package/build/strategies/default-strategy.class.d.ts +16 -0
- package/build/strategies/default-strategy.class.js +44 -0
- package/build/strategies/partial-startegy.class.d.ts +20 -0
- package/build/strategies/partial-startegy.class.js +72 -0
- package/build/strategies/scratch-strategy.class.d.ts +18 -0
- package/build/strategies/scratch-strategy.class.js +49 -0
- package/build/strategies/strategy.factory.d.ts +8 -0
- package/build/strategies/strategy.factory.js +21 -0
- package/build/types/codecept.type.d.ts +27 -0
- package/build/types/codecept.type.js +2 -0
- package/build/types/origin.type.d.ts +46 -0
- package/build/types/origin.type.js +2 -0
- package/build/types/strategy.type.d.ts +10 -0
- package/build/types/strategy.type.js +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,13 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
## Getting Started
|
|
5
5
|
|
|
6
|
-
### Compatibility
|
|
7
|
-
|
|
8
|
-
| Test IT | Adapter |
|
|
9
|
-
|---------|---------|
|
|
10
|
-
| 3.5 | 1.0 |
|
|
11
|
-
| 4.0 | 1.1 |
|
|
12
|
-
|
|
13
6
|
### Installation
|
|
14
7
|
```
|
|
15
8
|
npm install testit-adapter-codecept
|
|
@@ -132,6 +125,8 @@ Description of metadata methods:
|
|
|
132
125
|
- `description` - description in the autotest card
|
|
133
126
|
- `labels` - tags in the work item
|
|
134
127
|
- `link` - links in the autotest card
|
|
128
|
+
- `nameSpace` - directory in the TMS system
|
|
129
|
+
- `className` - subdirectory in the TMS system
|
|
135
130
|
|
|
136
131
|
Description of methods:
|
|
137
132
|
- `addLinks` - links in the autotest result
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const codeceptjs_1 = require("codeceptjs");
|
|
4
|
+
const config_class_1 = require("./common/classes/config.class");
|
|
5
|
+
const logger_class_1 = require("./common/classes/logger.class");
|
|
6
|
+
const default_http_client_class_1 = require("./http/default-http-client.class");
|
|
7
|
+
const strategy_factory_1 = require("./strategies/strategy.factory");
|
|
8
|
+
module.exports = async function () {
|
|
9
|
+
const config = new config_class_1.ConfigComposer().compose();
|
|
10
|
+
const logger = new logger_class_1.Logger(config.__DEV);
|
|
11
|
+
const http = new default_http_client_class_1.DefaultHttpClient(config, logger);
|
|
12
|
+
const strategy = strategy_factory_1.StrategyFactory.create(http, logger, config);
|
|
13
|
+
const helper = codeceptjs_1.container.helpers('TestITHelper');
|
|
14
|
+
await strategy.bootstrap();
|
|
15
|
+
codeceptjs_1.event.dispatcher.on(codeceptjs_1.event.test.after, (test) => {
|
|
16
|
+
strategy.collect(test.id, helper.metadata);
|
|
17
|
+
helper.metadata = {};
|
|
18
|
+
});
|
|
19
|
+
codeceptjs_1.event.dispatcher.on(codeceptjs_1.event.test.before, async (test) => {
|
|
20
|
+
await strategy.beforeTest(test);
|
|
21
|
+
});
|
|
22
|
+
codeceptjs_1.event.dispatcher.on(codeceptjs_1.event.suite.after, async (suite) => {
|
|
23
|
+
codeceptjs_1.recorder.add('transferTestAndRuns', async () => {
|
|
24
|
+
await strategy.transferTestsToSystem(suite);
|
|
25
|
+
await strategy.transferRunsToSystem(suite);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
codeceptjs_1.event.dispatcher.on(codeceptjs_1.event.all.after, async () => {
|
|
29
|
+
await strategy.teardown();
|
|
30
|
+
});
|
|
31
|
+
codeceptjs_1.event.dispatcher.on(codeceptjs_1.event.all.after, async () => {
|
|
32
|
+
await strategy.teardown();
|
|
33
|
+
});
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const box_class_1 = require("../classes/box.class");
|
|
4
|
+
describe('Box', () => {
|
|
5
|
+
const box = new box_class_1.Box();
|
|
6
|
+
it('Should append values to box and merge them', () => {
|
|
7
|
+
box.collectWithMerge('1', { a: 1 });
|
|
8
|
+
box.collectWithMerge('1', { b: 2 });
|
|
9
|
+
expect(box.get('1'))
|
|
10
|
+
.toEqual({
|
|
11
|
+
a: 1,
|
|
12
|
+
b: 2
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDefaultConfig = exports.getDefaultTest = void 0;
|
|
4
|
+
function getDefaultTest() {
|
|
5
|
+
return {
|
|
6
|
+
title: 'Test',
|
|
7
|
+
startedAt: 5634234,
|
|
8
|
+
duration: 240,
|
|
9
|
+
state: 'passed',
|
|
10
|
+
steps: [
|
|
11
|
+
{
|
|
12
|
+
name: 'Step 1',
|
|
13
|
+
args: [],
|
|
14
|
+
status: 'passed',
|
|
15
|
+
startedAt: 5634234,
|
|
16
|
+
duration: 40
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'Step 2',
|
|
20
|
+
args: [],
|
|
21
|
+
status: 'passed',
|
|
22
|
+
startedAt: 5634234,
|
|
23
|
+
duration: 200
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
parent: {
|
|
27
|
+
title: 'Suite',
|
|
28
|
+
_beforeEach: [
|
|
29
|
+
{
|
|
30
|
+
title: 'Before',
|
|
31
|
+
steps: [
|
|
32
|
+
{
|
|
33
|
+
name: 'Step Before',
|
|
34
|
+
args: [],
|
|
35
|
+
status: 'passed',
|
|
36
|
+
startedAt: 5634234,
|
|
37
|
+
duration: 40
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
_afterEach: [
|
|
43
|
+
{
|
|
44
|
+
title: 'Before',
|
|
45
|
+
steps: [
|
|
46
|
+
{
|
|
47
|
+
name: 'Step After',
|
|
48
|
+
args: [],
|
|
49
|
+
status: 'passed',
|
|
50
|
+
startedAt: 5634234,
|
|
51
|
+
duration: 40
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
exports.getDefaultTest = getDefaultTest;
|
|
60
|
+
function getDefaultConfig() {
|
|
61
|
+
return {
|
|
62
|
+
url: 'https://url.com//',
|
|
63
|
+
privateToken: 'TTBwakF34lpuQ0FyT6F21EFU',
|
|
64
|
+
projectId: '96g6d4bg-20g0-25e8-b17e-a1a34a7adf2f',
|
|
65
|
+
testRunId: '55238c45-e4cd-4328-b4d5-b0484544a640',
|
|
66
|
+
configurationId: '1c33c90c-f34c-427b-81f6-1458f5g9c072',
|
|
67
|
+
testRunName: 'Run',
|
|
68
|
+
adapterMode: 2
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
exports.getDefaultConfig = getDefaultConfig;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Box = void 0;
|
|
4
|
+
class Box {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.box = new Map;
|
|
7
|
+
}
|
|
8
|
+
collectWithMerge(id, entity) {
|
|
9
|
+
const collected = this.box.get(id);
|
|
10
|
+
this.box.set(id, collected
|
|
11
|
+
? { ...collected, ...entity }
|
|
12
|
+
: entity);
|
|
13
|
+
}
|
|
14
|
+
get(id) {
|
|
15
|
+
return this.box.get(id);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.Box = Box;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ConfigComposer = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const dotenv = __importStar(require("dotenv"));
|
|
29
|
+
const logger_class_1 = require("./logger.class");
|
|
30
|
+
const DEFAULT_CONFIG_NAME = 'testit-adapter.config.json';
|
|
31
|
+
class ConfigComposer {
|
|
32
|
+
constructor() {
|
|
33
|
+
//TODO: Поставлять логгер через зависимости
|
|
34
|
+
this.logger = new logger_class_1.Logger();
|
|
35
|
+
}
|
|
36
|
+
compose(base) {
|
|
37
|
+
var _a;
|
|
38
|
+
const environment = dotenv.config().parsed;
|
|
39
|
+
const from = (_a = environment === null || environment === void 0 ? void 0 : environment.TMS_CONFIG_FILE) !== null && _a !== void 0 ? _a : DEFAULT_CONFIG_NAME;
|
|
40
|
+
const buffer = fs
|
|
41
|
+
.readFileSync(from)
|
|
42
|
+
.toString();
|
|
43
|
+
const file = JSON.parse(buffer);
|
|
44
|
+
if ((file === null || file === void 0 ? void 0 : file.privateToken) || (base === null || base === void 0 ? void 0 : base.privateToken)) {
|
|
45
|
+
console.warn(`
|
|
46
|
+
The configuration file specifies a private token. It is not safe.
|
|
47
|
+
Use TMS_PRIVATE_TOKEN environment variable
|
|
48
|
+
`);
|
|
49
|
+
}
|
|
50
|
+
return this.merge(base, file, environment);
|
|
51
|
+
}
|
|
52
|
+
merge(base, file, environment) {
|
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
54
|
+
return {
|
|
55
|
+
url: (_b = (_a = environment === null || environment === void 0 ? void 0 : environment.TMS_URL) !== null && _a !== void 0 ? _a : file.url) !== null && _b !== void 0 ? _b : base === null || base === void 0 ? void 0 : base.url,
|
|
56
|
+
privateToken: (_d = (_c = environment === null || environment === void 0 ? void 0 : environment.TMS_PRIVATE_TOKEN) !== null && _c !== void 0 ? _c : file === null || file === void 0 ? void 0 : file.privateToken) !== null && _d !== void 0 ? _d : base === null || base === void 0 ? void 0 : base.url,
|
|
57
|
+
projectId: (_f = (_e = environment === null || environment === void 0 ? void 0 : environment.TMS_PROJECT_ID) !== null && _e !== void 0 ? _e : file === null || file === void 0 ? void 0 : file.projectId) !== null && _f !== void 0 ? _f : base === null || base === void 0 ? void 0 : base.projectId,
|
|
58
|
+
configurationId: (_h = (_g = environment === null || environment === void 0 ? void 0 : environment.TMS_CONFIGURATION_ID) !== null && _g !== void 0 ? _g : file === null || file === void 0 ? void 0 : file.configurationId) !== null && _h !== void 0 ? _h : base === null || base === void 0 ? void 0 : base.configurationId,
|
|
59
|
+
testRunId: (_k = (_j = environment === null || environment === void 0 ? void 0 : environment.TMS_TEST_RUN_ID) !== null && _j !== void 0 ? _j : file === null || file === void 0 ? void 0 : file.testRunId) !== null && _k !== void 0 ? _k : base === null || base === void 0 ? void 0 : base.testRunId,
|
|
60
|
+
testRunName: (_m = (_l = environment === null || environment === void 0 ? void 0 : environment.TMS_TEST_RUN_NAME) !== null && _l !== void 0 ? _l : file === null || file === void 0 ? void 0 : file.testRunName) !== null && _m !== void 0 ? _m : base === null || base === void 0 ? void 0 : base.testRunName,
|
|
61
|
+
adapterMode: (_q = (_p = (_o = environment === null || environment === void 0 ? void 0 : environment.TMS_ADAPTER_MODE) !== null && _o !== void 0 ? _o : file === null || file === void 0 ? void 0 : file.adapterMode) !== null && _p !== void 0 ? _p : base === null || base === void 0 ? void 0 : base.adapterMode) !== null && _q !== void 0 ? _q : 0,
|
|
62
|
+
automaticCreationTestCases: (_t = (_s = (_r = environment === null || environment === void 0 ? void 0 : environment.TMS_AUTOMATIC_CREATION_TEST_CASES) !== null && _r !== void 0 ? _r : file === null || file === void 0 ? void 0 : file.automaticCreationTestCases) !== null && _s !== void 0 ? _s : base === null || base === void 0 ? void 0 : base.automaticCreationTestCases) !== null && _t !== void 0 ? _t : false,
|
|
63
|
+
__DEV: (_u = file.__DEV) !== null && _u !== void 0 ? _u : false
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.ConfigComposer = ConfigComposer;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = void 0;
|
|
4
|
+
const codeceptjs_1 = require("codeceptjs");
|
|
5
|
+
class Logger {
|
|
6
|
+
constructor(__DEV = false) {
|
|
7
|
+
this.__DEV = __DEV;
|
|
8
|
+
this.logger = codeceptjs_1.output;
|
|
9
|
+
}
|
|
10
|
+
log(message) {
|
|
11
|
+
if (this.__DEV) {
|
|
12
|
+
this.logger.success(message);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
warn(message) {
|
|
16
|
+
this.logger.error(message);
|
|
17
|
+
}
|
|
18
|
+
error(error) {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
this.logger.error(`
|
|
21
|
+
${(_a = error.response) === null || _a === void 0 ? void 0 : _a.status},
|
|
22
|
+
${(_b = error.config) === null || _b === void 0 ? void 0 : _b.method},
|
|
23
|
+
${(_c = error.config) === null || _c === void 0 ? void 0 : _c.url},
|
|
24
|
+
${JSON.stringify((_d = error.response) === null || _d === void 0 ? void 0 : _d.data)}
|
|
25
|
+
`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.Logger = Logger;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OutcomeType } from "testit-api-client/dist/types/outcome";
|
|
2
|
+
export type SomeOutcome = 'passed' | 'failed' | 'skipped' | 'success';
|
|
3
|
+
export type Outcome = OutcomeType;
|
|
4
|
+
export declare class OutcomeFactory {
|
|
5
|
+
static create(outcome: SomeOutcome): Outcome;
|
|
6
|
+
static isSkipped(outcome: SomeOutcome): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OutcomeFactory = void 0;
|
|
4
|
+
class OutcomeFactory {
|
|
5
|
+
static create(outcome) {
|
|
6
|
+
var _a;
|
|
7
|
+
const outcomes = {
|
|
8
|
+
passed: 'Passed',
|
|
9
|
+
success: 'Passed',
|
|
10
|
+
failed: 'Failed',
|
|
11
|
+
skipped: 'Skipped'
|
|
12
|
+
};
|
|
13
|
+
return (_a = outcomes[outcome]) !== null && _a !== void 0 ? _a : 'Skipped';
|
|
14
|
+
}
|
|
15
|
+
static isSkipped(outcome) {
|
|
16
|
+
return outcome === 'skipped';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.OutcomeFactory = OutcomeFactory;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const compose: (...fns: any[]) => (x: any) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hash: (str: any, seed?: number) => number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hash = void 0;
|
|
4
|
+
const hash = (str, seed = 0) => {
|
|
5
|
+
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
|
|
6
|
+
for (let i = 0, ch; i < str.length; i++) {
|
|
7
|
+
ch = str.charCodeAt(i);
|
|
8
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
9
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
10
|
+
}
|
|
11
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
12
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
13
|
+
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
|
14
|
+
};
|
|
15
|
+
exports.hash = hash;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function humanize(args: unknown[]): unknown[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function safetyUseISOString(date: number | null): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.safetyUseISOString = void 0;
|
|
4
|
+
function safetyUseISOString(date) {
|
|
5
|
+
if (!date) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
return new Date(date).toISOString();
|
|
9
|
+
}
|
|
10
|
+
exports.safetyUseISOString = safetyUseISOString;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="codeceptjs" />
|
|
2
|
+
/// <reference types="codeceptjs" />
|
|
3
|
+
import { Codecept } from '../../types/codecept.type';
|
|
4
|
+
export declare const useCompositeKey: (test: Mocha.Test) => string;
|
|
5
|
+
export declare const useDefaultHash: (test: Codecept.Test) => any;
|
|
6
|
+
export declare const useCompositeHash: (test: Mocha.Test) => any;
|
|
7
|
+
export declare const useConfig: (test: Mocha.Test & {
|
|
8
|
+
opts: any;
|
|
9
|
+
}) => any;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useConfig = exports.useCompositeHash = exports.useDefaultHash = exports.useCompositeKey = void 0;
|
|
4
|
+
const compose_function_1 = require("./compose.function");
|
|
5
|
+
const hash_function_1 = require("./hash.function");
|
|
6
|
+
const useCompositeKey = (test) => { var _a; return `${test.title}:${(_a = test.parent) === null || _a === void 0 ? void 0 : _a.title}`; };
|
|
7
|
+
exports.useCompositeKey = useCompositeKey;
|
|
8
|
+
const useDefaultHash = (test) => { var _a; return (_a = test === null || test === void 0 ? void 0 : test.opts) === null || _a === void 0 ? void 0 : _a.externalId; };
|
|
9
|
+
exports.useDefaultHash = useDefaultHash;
|
|
10
|
+
const useCompositeHash = (test) => (0, compose_function_1.compose)(hash_function_1.hash, exports.useCompositeKey)(test);
|
|
11
|
+
exports.useCompositeHash = useCompositeHash;
|
|
12
|
+
const useConfig = (test) => test.opts;
|
|
13
|
+
exports.useConfig = useConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Nullable<T> = null | undefined | T;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LinkPost, LinkType } from 'testit-api-client';
|
|
2
|
+
import { Nullable } from './common/types/nullable.type';
|
|
3
|
+
import { Origin } from './types/origin.type';
|
|
4
|
+
export declare class TestMetadataHelper extends Helper {
|
|
5
|
+
metadata: Nullable<Origin.TestMetadata>;
|
|
6
|
+
addMessage(message: string): void;
|
|
7
|
+
addAttachments(paths: string[] | string, name?: string): void;
|
|
8
|
+
addLinks(linksOrName: LinkPost[] | string, description?: string, type?: LinkType, url?: string): void;
|
|
9
|
+
}
|
package/build/helper.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TestMetadataHelper = void 0;
|
|
4
|
+
class TestMetadataHelper extends Helper {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.metadata = {};
|
|
8
|
+
}
|
|
9
|
+
addMessage(message) {
|
|
10
|
+
this.metadata.message = message;
|
|
11
|
+
}
|
|
12
|
+
addAttachments(paths, name) {
|
|
13
|
+
if (Array.isArray(paths)) {
|
|
14
|
+
this.metadata.attachments = paths;
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
this.metadata.text = {
|
|
18
|
+
name,
|
|
19
|
+
content: paths
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
addLinks(linksOrName, description, type, url) {
|
|
23
|
+
if (typeof linksOrName !== 'string') {
|
|
24
|
+
this.metadata.links = linksOrName;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.metadata.links = [{
|
|
28
|
+
title: linksOrName,
|
|
29
|
+
url,
|
|
30
|
+
description,
|
|
31
|
+
type
|
|
32
|
+
}];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.TestMetadataHelper = TestMetadataHelper;
|
|
37
|
+
module.exports = TestMetadataHelper;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Attachment, Autotest, AutotestPost, AutotestPut, AutotestResultsForTestRun, Client, TestRunGet } from 'testit-api-client';
|
|
2
|
+
import { Logger } from '../common/classes/logger.class';
|
|
3
|
+
import { Origin } from '../types/origin.type';
|
|
4
|
+
export declare class DefaultHttpClient {
|
|
5
|
+
readonly config: Origin.Config;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
readonly http: Client;
|
|
8
|
+
constructor(config: Origin.Config, logger: Logger);
|
|
9
|
+
hasInSystem(id: string): Promise<Autotest | null>;
|
|
10
|
+
create(test: AutotestPost): Promise<Autotest | void>;
|
|
11
|
+
loadAttachment(path: string): Promise<Attachment | void>;
|
|
12
|
+
update(test: AutotestPut): Promise<void>;
|
|
13
|
+
validate(): Promise<void>;
|
|
14
|
+
updateRuns(result: AutotestResultsForTestRun, run?: string): Promise<void>;
|
|
15
|
+
updateManyRuns(result: AutotestResultsForTestRun[], run?: string): Promise<void>;
|
|
16
|
+
createEmptyRun(name?: string): Promise<void | TestRunGet>;
|
|
17
|
+
linkToWorkItem(autotestId: string, ids: string[]): Promise<void>;
|
|
18
|
+
startRunIfNeeded(id: string): Promise<void>;
|
|
19
|
+
completeRunIfNeeded(id: string): Promise<void>;
|
|
20
|
+
getRun(id: string): Promise<TestRunGet>;
|
|
21
|
+
getTestsIdsByRunId(id: string): Promise<string[]>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DefaultHttpClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const testit_api_client_1 = require("testit-api-client");
|
|
9
|
+
const http_client_errors_1 = require("./http-client.errors");
|
|
10
|
+
class DefaultHttpClient {
|
|
11
|
+
constructor(config, logger) {
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.logger = logger;
|
|
14
|
+
if (!this.config) {
|
|
15
|
+
http_client_errors_1.HttpClientErrors.throwNotFoundHttpClientConfig();
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
this.http = new testit_api_client_1.Client(this.config);
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
this.logger.warn(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
hasInSystem(id) {
|
|
25
|
+
const query = { projectId: this.config.projectId, externalId: id };
|
|
26
|
+
return this.http
|
|
27
|
+
.getAutotest(query)
|
|
28
|
+
.then(([test]) => test);
|
|
29
|
+
}
|
|
30
|
+
create(test) {
|
|
31
|
+
return this.http.createAutotest(test)
|
|
32
|
+
.catch(error => {
|
|
33
|
+
this.logger.error(error);
|
|
34
|
+
http_client_errors_1.HttpClientErrors.throwErrorAfterTestCreate(test);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
loadAttachment(path) {
|
|
38
|
+
return this.http.loadAttachment(path)
|
|
39
|
+
.catch(error => {
|
|
40
|
+
this.logger.error(error);
|
|
41
|
+
http_client_errors_1.HttpClientErrors.throwNotUploadAttachments(path);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
update(test) {
|
|
45
|
+
return this.http.updateAutotest(test)
|
|
46
|
+
.catch(error => {
|
|
47
|
+
this.logger.error(error);
|
|
48
|
+
http_client_errors_1.HttpClientErrors.throwErrorAfterTestUpdate(test);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async validate() {
|
|
52
|
+
try {
|
|
53
|
+
await this.http.checkConnection();
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
this.logger.error(e);
|
|
57
|
+
throw new Error();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async updateRuns(result, run = this.config.testRunId) {
|
|
61
|
+
await this.http.loadTestRunResults(run, [result]);
|
|
62
|
+
}
|
|
63
|
+
async updateManyRuns(result, run = this.config.testRunId) {
|
|
64
|
+
await this.http.loadTestRunResults(run, result);
|
|
65
|
+
}
|
|
66
|
+
async createEmptyRun(name = '') {
|
|
67
|
+
return this.http
|
|
68
|
+
.createTestRun({ name, projectId: this.config.projectId })
|
|
69
|
+
.catch((error) => this.logger.error(error));
|
|
70
|
+
}
|
|
71
|
+
async linkToWorkItem(autotestId, ids) {
|
|
72
|
+
for (const id of ids) {
|
|
73
|
+
try {
|
|
74
|
+
await this.http.linkToWorkItem(autotestId, { id });
|
|
75
|
+
this.logger.log(`Test - ${autotestId} linked with WI - ${ids}`);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
this.logger.error(error);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async startRunIfNeeded(id) {
|
|
83
|
+
try {
|
|
84
|
+
const run = await this.getRun(id);
|
|
85
|
+
if (run.stateName !== 'Completed') {
|
|
86
|
+
await this.http.startTestRun(id);
|
|
87
|
+
this.logger.log(`Test run - ${run.id} started`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
this.logger.error(error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async completeRunIfNeeded(id) {
|
|
95
|
+
try {
|
|
96
|
+
const run = await this.getRun(id);
|
|
97
|
+
if (run.stateName !== 'Completed') {
|
|
98
|
+
await this.http.completeTestRun(id);
|
|
99
|
+
this.logger.log(`Test run - ${run.id} completed`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
this.logger.error(e);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
getRun(id) {
|
|
107
|
+
const baseURL = new URL('/api/v2', this.config.url).toString();
|
|
108
|
+
const client = axios_1.default.create({
|
|
109
|
+
baseURL,
|
|
110
|
+
headers: {
|
|
111
|
+
Authorization: `PrivateToken ${this.config.privateToken}`
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return client.get(`testRuns/${id}`).then(response => response.data);
|
|
115
|
+
}
|
|
116
|
+
async getTestsIdsByRunId(id) {
|
|
117
|
+
const run = await this.getRun(id);
|
|
118
|
+
return run.testResults
|
|
119
|
+
.filter(test => test.configurationId === this.config.configurationId)
|
|
120
|
+
.map(test => test.autoTest.externalId);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.DefaultHttpClient = DefaultHttpClient;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AutotestPut } from 'testit-api-client';
|
|
2
|
+
export declare class HttpClientErrors {
|
|
3
|
+
static throwNotFoundHttpClientConfig(): void;
|
|
4
|
+
static throwErrorAfterTestUpdate(test: AutotestPut): void;
|
|
5
|
+
static throwErrorAfterTestCreate(test: AutotestPut): void;
|
|
6
|
+
static throwNotUploadAttachments(path: string): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpClientErrors = void 0;
|
|
4
|
+
class HttpClientErrors {
|
|
5
|
+
static throwNotFoundHttpClientConfig() {
|
|
6
|
+
throw new Error('Http client config not found');
|
|
7
|
+
}
|
|
8
|
+
static throwErrorAfterTestUpdate(test) {
|
|
9
|
+
throw new Error(`An error occurred while updating the test - ${test.name}`);
|
|
10
|
+
}
|
|
11
|
+
static throwErrorAfterTestCreate(test) {
|
|
12
|
+
throw new Error(`an error occurred while creating the test - ${test.name}`);
|
|
13
|
+
}
|
|
14
|
+
static throwNotUploadAttachments(path) {
|
|
15
|
+
throw new Error(`when loading an attachment along the path - ${path}, an error occurred`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.HttpClientErrors = HttpClientErrors;
|