testit-adapter-codecept 1.1.5 → 2.0.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/.prettierrc +9 -0
- package/README.md +8 -13
- package/build/bootstrap.js +13 -18
- package/build/builders/index.d.ts +2 -0
- package/build/builders/index.js +7 -0
- package/build/builders/run.builder.d.ts +9 -0
- package/build/builders/run.builder.js +53 -0
- package/build/{services/tests.builder.d.ts → builders/test.builder.d.ts} +3 -4
- package/build/{services/tests.builder.js → builders/test.builder.js} +12 -28
- package/build/common/classes/index.d.ts +2 -0
- package/build/common/classes/index.js +7 -0
- package/build/common/classes/logger.class.d.ts +2 -2
- package/build/common/classes/logger.class.js +6 -1
- package/build/common/types/index.d.ts +1 -0
- package/build/common/types/index.js +2 -0
- package/build/common/utils/index.d.ts +5 -0
- package/build/common/utils/index.js +21 -0
- package/build/common/{functions/is-passed.function.d.ts → utils/is-passed.util.d.ts} +1 -1
- package/build/common/{functions/is-passed.function.js → utils/is-passed.util.js} +1 -1
- package/build/common/{functions/use-hash.function.d.ts → utils/use-hash.util.d.ts} +1 -1
- package/build/common/{functions/use-hash.function.js → utils/use-hash.util.js} +3 -3
- package/build/helper.d.ts +4 -4
- package/build/helper.js +7 -5
- package/build/strategies/base.strategy.d.ts +17 -0
- package/build/strategies/base.strategy.js +40 -0
- package/build/strategies/default.strategy.d.ts +14 -0
- package/build/strategies/{default-strategy.class.js → default.strategy.js} +13 -11
- package/build/strategies/index.d.ts +5 -0
- package/build/strategies/index.js +13 -0
- package/build/strategies/partial.strategy.d.ts +18 -0
- package/build/strategies/partial.strategy.js +77 -0
- package/build/strategies/scratch.strategy.d.ts +16 -0
- package/build/strategies/scratch.strategy.js +46 -0
- package/build/strategies/strategy.factory.d.ts +4 -5
- package/build/strategies/strategy.factory.js +6 -6
- package/build/types/codecept.type.d.ts +1 -1
- package/build/types/index.d.ts +3 -0
- package/build/types/index.js +19 -0
- package/build/types/origin.type.d.ts +6 -28
- package/build/types/strategy.type.d.ts +3 -3
- package/package.json +5 -15
- package/build/common/__tests/box.class.spec.d.ts +0 -1
- package/build/common/__tests/box.class.spec.js +0 -15
- package/build/common/__tests/test.utils.d.ts +0 -4
- package/build/common/__tests/test.utils.js +0 -71
- package/build/common/classes/config.class.d.ts +0 -6
- package/build/common/classes/config.class.js +0 -67
- package/build/common/classes/outcome.factory.d.ts +0 -7
- package/build/common/classes/outcome.factory.js +0 -19
- package/build/common/functions/to-iso-string.function.d.ts +0 -1
- package/build/common/functions/to-iso-string.function.js +0 -10
- package/build/http/default-http-client.class.d.ts +0 -22
- package/build/http/default-http-client.class.js +0 -123
- package/build/http/http-client.errors.d.ts +0 -7
- package/build/http/http-client.errors.js +0 -18
- package/build/jest.config.d.ts +0 -7
- package/build/jest.config.js +0 -12
- package/build/services/__tests/attachments.class.spec.d.ts +0 -1
- package/build/services/__tests/attachments.class.spec.js +0 -23
- package/build/services/__tests/runs.builder.spec.d.ts +0 -1
- package/build/services/__tests/runs.builder.spec.js +0 -79
- package/build/services/__tests/tests.builder.spec.d.ts +0 -1
- package/build/services/__tests/tests.builder.spec.js +0 -32
- package/build/services/attachments.service.d.ts +0 -11
- package/build/services/attachments.service.js +0 -28
- package/build/services/runs.builder.d.ts +0 -10
- package/build/services/runs.builder.js +0 -65
- package/build/strategies/base-strategy.class.d.ts +0 -24
- package/build/strategies/base-strategy.class.js +0 -66
- package/build/strategies/default-strategy.class.d.ts +0 -16
- package/build/strategies/partial-startegy.class.d.ts +0 -20
- package/build/strategies/partial-startegy.class.js +0 -72
- package/build/strategies/scratch-strategy.class.d.ts +0 -18
- package/build/strategies/scratch-strategy.class.js +0 -49
- /package/build/common/{functions/compose.function.d.ts → utils/compose.util.d.ts} +0 -0
- /package/build/common/{functions/compose.function.js → utils/compose.util.js} +0 -0
- /package/build/common/{functions/hash.function.d.ts → utils/hash.util.d.ts} +0 -0
- /package/build/common/{functions/hash.function.js → utils/hash.util.js} +0 -0
- /package/build/common/{functions/humanize.function.d.ts → utils/humanize.util.d.ts} +0 -0
- /package/build/common/{functions/humanize.function.js → utils/humanize.util.js} +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PartialStrategy = void 0;
|
|
4
|
+
const utils_1 = require("../common/utils");
|
|
5
|
+
const base_strategy_1 = require("./base.strategy");
|
|
6
|
+
// Adapter mode 0
|
|
7
|
+
class PartialStrategy extends base_strategy_1.BaseStrategy {
|
|
8
|
+
constructor(http, logger, config) {
|
|
9
|
+
super(http, logger, config);
|
|
10
|
+
this.http = http;
|
|
11
|
+
this.logger = logger;
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.testsInRun = this.http.testRuns.getAutotests(this.config.testRunId);
|
|
14
|
+
}
|
|
15
|
+
async bootstrap() {
|
|
16
|
+
if (!this.config.testRunId) {
|
|
17
|
+
this.logger.error("Test run id is required when adapter mode is 0");
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
await this.http.testRuns.startTestRun(this.config.testRunId);
|
|
21
|
+
}
|
|
22
|
+
async teardown() {
|
|
23
|
+
await this.http.testRuns.completeTestRun(this.config.testRunId);
|
|
24
|
+
}
|
|
25
|
+
async getTestsIdsInRun() {
|
|
26
|
+
const tests = await this.testsInRun;
|
|
27
|
+
return tests === null || tests === void 0 ? void 0 : tests.map((test) => test.autoTest.externalId);
|
|
28
|
+
}
|
|
29
|
+
async beforeTest(test) {
|
|
30
|
+
var _a;
|
|
31
|
+
const tests = await this.getTestsIdsInRun();
|
|
32
|
+
const hash = (_a = (0, utils_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, utils_1.useCompositeHash)(test);
|
|
33
|
+
if (!tests.includes(hash.toString())) {
|
|
34
|
+
test.run = () => test.skip();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async transferRunsToSystem(suite) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
const tests = await this.getTestsIdsInRun();
|
|
40
|
+
const data = await Promise.all((_b = (_a = suite.tests) === null || _a === void 0 ? void 0 : _a.filter((test) => {
|
|
41
|
+
var _a;
|
|
42
|
+
const hash = (_a = (0, utils_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, utils_1.useCompositeHash)(test);
|
|
43
|
+
return tests.includes(hash.toString());
|
|
44
|
+
})) === null || _b === void 0 ? void 0 : _b.map(async (test) => {
|
|
45
|
+
var _a, _b, _c;
|
|
46
|
+
const config = this.box.get(test.id);
|
|
47
|
+
const screenshot = (_a = test.artifacts) === null || _a === void 0 ? void 0 : _a.screenshot;
|
|
48
|
+
const clientUrls = (_b = config === null || config === void 0 ? void 0 : config.attachments) !== null && _b !== void 0 ? _b : [];
|
|
49
|
+
if (screenshot) {
|
|
50
|
+
clientUrls.push(screenshot);
|
|
51
|
+
}
|
|
52
|
+
const attachments = await this.http.attachments.uploadAttachments(clientUrls);
|
|
53
|
+
if (config === null || config === void 0 ? void 0 : config.text) {
|
|
54
|
+
const attach = await this.http.attachments.uploadTextAttachment(config.text.content, (_c = config.text) === null || _c === void 0 ? void 0 : _c.name);
|
|
55
|
+
attachments.push(...attach);
|
|
56
|
+
}
|
|
57
|
+
return this.runsBuilder.build(test, config, attachments);
|
|
58
|
+
}));
|
|
59
|
+
if (data.length) {
|
|
60
|
+
await this.http.testRuns.loadAutotests(this.config.testRunId, data);
|
|
61
|
+
this.logger.log(`Test run - ${this.config.testRunId} transferred to remote system`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async transferTestsToSystem(suite) {
|
|
65
|
+
const tests = await this.testsInRun;
|
|
66
|
+
const suiteWithNeededTests = {
|
|
67
|
+
...suite,
|
|
68
|
+
tests: suite.tests.filter((test) => {
|
|
69
|
+
var _a;
|
|
70
|
+
const hash = (_a = (0, utils_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, utils_1.useCompositeHash)(test);
|
|
71
|
+
return tests.includes(hash.toString());
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
await this.createOrUpdateTests(suiteWithNeededTests);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.PartialStrategy = PartialStrategy;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="codeceptjs" />
|
|
2
|
+
import { AdapterConfig, IClient } from "testit-js-commons";
|
|
3
|
+
import { BaseStrategy } from "./base.strategy";
|
|
4
|
+
import { Logger } from "../common/classes";
|
|
5
|
+
import { Strategy } from "../types";
|
|
6
|
+
export declare class ScratchStrategy extends BaseStrategy implements Strategy {
|
|
7
|
+
protected readonly http: IClient;
|
|
8
|
+
protected readonly logger: Logger;
|
|
9
|
+
protected readonly config: AdapterConfig;
|
|
10
|
+
private testRunId;
|
|
11
|
+
constructor(http: IClient, logger: Logger, config: AdapterConfig);
|
|
12
|
+
bootstrap(): Promise<void>;
|
|
13
|
+
teardown(): Promise<void>;
|
|
14
|
+
transferTestsToSystem(suite: Mocha.Suite): Promise<void>;
|
|
15
|
+
transferRunsToSystem(suite: any): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScratchStrategy = void 0;
|
|
4
|
+
const base_strategy_1 = require("./base.strategy");
|
|
5
|
+
// Adapter mode 2
|
|
6
|
+
class ScratchStrategy extends base_strategy_1.BaseStrategy {
|
|
7
|
+
constructor(http, logger, config) {
|
|
8
|
+
super(http, logger, config);
|
|
9
|
+
this.http = http;
|
|
10
|
+
this.logger = logger;
|
|
11
|
+
this.config = config;
|
|
12
|
+
}
|
|
13
|
+
async bootstrap() {
|
|
14
|
+
this.testRunId = await this.http.testRuns.createTestRun();
|
|
15
|
+
await this.http.testRuns.startTestRun(this.testRunId);
|
|
16
|
+
}
|
|
17
|
+
async teardown() {
|
|
18
|
+
await this.http.testRuns.completeTestRun(this.testRunId);
|
|
19
|
+
}
|
|
20
|
+
async transferTestsToSystem(suite) {
|
|
21
|
+
await this.createOrUpdateTests(suite);
|
|
22
|
+
}
|
|
23
|
+
async transferRunsToSystem(suite) {
|
|
24
|
+
var _a, _b, _c;
|
|
25
|
+
for (const test of suite.tests) {
|
|
26
|
+
const config = this.box.get(test.id);
|
|
27
|
+
const screenshot = (_a = test.artifacts) === null || _a === void 0 ? void 0 : _a.screenshot;
|
|
28
|
+
const clientUrls = (_b = config === null || config === void 0 ? void 0 : config.attachments) !== null && _b !== void 0 ? _b : [];
|
|
29
|
+
if (screenshot) {
|
|
30
|
+
clientUrls.push(screenshot);
|
|
31
|
+
}
|
|
32
|
+
const attachments = await this.http.attachments.uploadAttachments(clientUrls);
|
|
33
|
+
if (config === null || config === void 0 ? void 0 : config.text) {
|
|
34
|
+
const attach = await this.http.attachments.uploadTextAttachment(config.text.content, (_c = config.text) === null || _c === void 0 ? void 0 : _c.name);
|
|
35
|
+
attachments.push(...attach);
|
|
36
|
+
}
|
|
37
|
+
const autotestResult = this.runsBuilder.build(test, config, attachments);
|
|
38
|
+
await this.http.testRuns.loadAutotests(this.testRunId, [autotestResult]).catch((e) => {
|
|
39
|
+
console.log("Error load test run.");
|
|
40
|
+
console.log(e);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
this.logger.log(`Test run - ${this.testRunId} transferred to remote system`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.ScratchStrategy = ScratchStrategy;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Strategy } from
|
|
4
|
-
import { Origin } from '../types/origin.type';
|
|
1
|
+
import { AdapterConfig, IClient } from "testit-js-commons";
|
|
2
|
+
import { Logger } from "../common/classes";
|
|
3
|
+
import { Strategy } from "../types";
|
|
5
4
|
export type AdapterMode = 0 | 1 | 2;
|
|
6
5
|
export declare class StrategyFactory {
|
|
7
|
-
static create(http:
|
|
6
|
+
static create(http: IClient, logger: Logger, config: AdapterConfig): Strategy;
|
|
8
7
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StrategyFactory = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const default_strategy_1 = require("./default.strategy");
|
|
5
|
+
const partial_strategy_1 = require("./partial.strategy");
|
|
6
|
+
const scratch_strategy_1 = require("./scratch.strategy");
|
|
7
7
|
class StrategyFactory {
|
|
8
8
|
static create(http, logger, config) {
|
|
9
9
|
var _a;
|
|
10
10
|
const strategies = {
|
|
11
|
-
0: () => new
|
|
12
|
-
1: () => new
|
|
13
|
-
2: () => new
|
|
11
|
+
0: () => new partial_strategy_1.PartialStrategy(http, logger, config),
|
|
12
|
+
1: () => new default_strategy_1.DefaultStrategy(http, logger, config),
|
|
13
|
+
2: () => new scratch_strategy_1.ScratchStrategy(http, logger, config),
|
|
14
14
|
};
|
|
15
15
|
if (!strategies[config === null || config === void 0 ? void 0 : config.adapterMode]) {
|
|
16
16
|
logger.warn(`This mode ${config === null || config === void 0 ? void 0 : config.adapterMode} is invalid. Use mode 0, 1, 2`);
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./strategy.type"), exports);
|
|
18
|
+
__exportStar(require("./origin.type"), exports);
|
|
19
|
+
__exportStar(require("./codecept.type"), exports);
|
|
@@ -1,46 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AdapterMode } from '../strategies/strategy.factory';
|
|
1
|
+
import { Link } from "testit-js-commons";
|
|
3
2
|
export declare namespace Origin {
|
|
4
3
|
interface TestConfig {
|
|
5
4
|
title?: string;
|
|
6
5
|
displayName?: string;
|
|
7
6
|
description?: string;
|
|
8
7
|
externalId?: string;
|
|
9
|
-
links:
|
|
8
|
+
links: Link[];
|
|
10
9
|
labels?: string[];
|
|
11
|
-
|
|
10
|
+
workItemIds?: [];
|
|
11
|
+
classname?: string;
|
|
12
|
+
namespace?: string;
|
|
12
13
|
}
|
|
13
14
|
interface TestText {
|
|
14
15
|
name: string;
|
|
15
16
|
content: string;
|
|
16
17
|
}
|
|
17
18
|
interface TestMetadata {
|
|
18
|
-
links?:
|
|
19
|
+
links?: Link[];
|
|
19
20
|
attachments?: string[];
|
|
20
21
|
message?: string;
|
|
21
22
|
text?: TestText;
|
|
22
23
|
}
|
|
23
|
-
interface Config {
|
|
24
|
-
url?: string;
|
|
25
|
-
privateToken?: string;
|
|
26
|
-
projectId?: string;
|
|
27
|
-
configurationId?: string;
|
|
28
|
-
testRunId?: string;
|
|
29
|
-
testRunName?: string;
|
|
30
|
-
adapterMode?: AdapterMode;
|
|
31
|
-
automaticCreationTestCases?: boolean;
|
|
32
|
-
configFile?: string;
|
|
33
|
-
__DEV?: boolean;
|
|
34
|
-
}
|
|
35
|
-
type EnvironmentsConfig = Partial<{
|
|
36
|
-
TMS_URL: string;
|
|
37
|
-
TMS_PRIVATE_TOKEN: string;
|
|
38
|
-
TMS_PROJECT_ID: string;
|
|
39
|
-
TMS_CONFIGURATION_ID: string;
|
|
40
|
-
TMS_TEST_RUN_ID: string;
|
|
41
|
-
TMS_TEST_RUN_NAME: string;
|
|
42
|
-
TMS_ADAPTER_MODE: AdapterMode;
|
|
43
|
-
TMS_AUTOMATIC_CREATION_TEST_CASES: boolean;
|
|
44
|
-
TMS_CONFIG_FILE: string;
|
|
45
|
-
}>;
|
|
46
24
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="codeceptjs" />
|
|
2
|
-
import { Origin } from
|
|
2
|
+
import { Origin } from "./origin.type";
|
|
3
3
|
export interface Strategy {
|
|
4
|
-
bootstrap(): Promise<
|
|
5
|
-
teardown(): Promise<
|
|
4
|
+
bootstrap(): Promise<void>;
|
|
5
|
+
teardown(): Promise<void>;
|
|
6
6
|
beforeTest(test: Mocha.Test): Promise<void>;
|
|
7
7
|
transferTestsToSystem(suite: {
|
|
8
8
|
tests: Mocha.Test[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testit-adapter-codecept",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Codecept adapter for Test IT",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": {
|
|
@@ -10,33 +10,23 @@
|
|
|
10
10
|
"main": "build/index.js",
|
|
11
11
|
"types": "build/index.d.ts",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "
|
|
14
|
-
"
|
|
15
|
-
"build:dev": "tsc -p tsconfig.json",
|
|
16
|
-
"publish:local": "npm run build:main && npm pack --pack-destination ~/Packages",
|
|
17
|
-
"watch:dev": "tsc -p tsconfig.publish.json -w",
|
|
18
|
-
"test": "jest"
|
|
13
|
+
"build": "tsc -p tsconfig.json",
|
|
14
|
+
"watch": "tsc -p tsconfig.json -w"
|
|
19
15
|
},
|
|
20
16
|
"dependencies": {
|
|
21
|
-
"
|
|
22
|
-
"npm-run-all": "^4.1.5",
|
|
23
|
-
"testit-api-client": "^1.0.8"
|
|
17
|
+
"testit-js-commons": "^2.0.0"
|
|
24
18
|
},
|
|
25
19
|
"devDependencies": {
|
|
26
20
|
"@codeceptjs/configure": "^0.10.0",
|
|
27
21
|
"@codeceptjs/examples": "^1.2.1",
|
|
28
22
|
"@codeceptjs/ui": "^0.4.7",
|
|
29
|
-
"@types/jest": "^29.2.2",
|
|
30
23
|
"@types/node": "^18.11.9",
|
|
31
24
|
"@typescript-eslint/eslint-plugin": "^5.42.0",
|
|
32
25
|
"@typescript-eslint/parser": "^5.42.0",
|
|
33
|
-
"codeceptjs": "^3.
|
|
26
|
+
"codeceptjs": "^3.5.4",
|
|
34
27
|
"eslint": "^8.27.0",
|
|
35
|
-
"jest": "^29.2.2",
|
|
36
28
|
"playwright": "^1.27.1",
|
|
37
29
|
"prettier": "2.7.1",
|
|
38
|
-
"ts-jest": "^29.0.3",
|
|
39
|
-
"ts-node": "^10.9.1",
|
|
40
30
|
"typescript": "^4.8.4"
|
|
41
31
|
},
|
|
42
32
|
"bugs": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
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;
|
|
@@ -1,67 +0,0 @@
|
|
|
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;
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function safetyUseISOString(date: number | null): string;
|
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
}
|