testit-adapter-codecept 1.1.2 → 1.1.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/README.md +180 -208
- package/build/bootstrap.d.ts +1 -1
- package/build/bootstrap.js +37 -34
- package/build/common/__tests/box.class.spec.d.ts +1 -1
- package/build/common/__tests/box.class.spec.js +15 -15
- package/build/common/__tests/test.utils.d.ts +4 -4
- package/build/common/__tests/test.utils.js +71 -71
- package/build/common/classes/box.class.d.ts +5 -5
- package/build/common/classes/box.class.js +18 -18
- package/build/common/classes/config.class.d.ts +6 -6
- package/build/common/classes/config.class.js +67 -67
- package/build/common/classes/logger.class.d.ts +9 -9
- package/build/common/classes/logger.class.js +28 -28
- package/build/common/classes/outcome.factory.d.ts +7 -7
- package/build/common/classes/outcome.factory.js +19 -19
- package/build/common/functions/compose.function.d.ts +1 -1
- package/build/common/functions/compose.function.js +5 -5
- package/build/common/functions/hash.function.d.ts +1 -1
- package/build/common/functions/hash.function.js +15 -15
- package/build/common/functions/humanize.function.d.ts +1 -1
- package/build/common/functions/humanize.function.js +7 -7
- package/build/common/functions/is-passed.function.d.ts +2 -2
- package/build/common/functions/is-passed.function.js +7 -7
- package/build/common/functions/to-iso-string.function.d.ts +1 -1
- package/build/common/functions/to-iso-string.function.js +10 -10
- package/build/common/functions/use-hash.function.d.ts +9 -9
- package/build/common/functions/use-hash.function.js +13 -13
- package/build/common/types/nullable.type.d.ts +1 -1
- package/build/common/types/nullable.type.js +2 -2
- package/build/helper.d.ts +9 -9
- package/build/helper.js +37 -37
- package/build/http/default-http-client.class.d.ts +22 -22
- package/build/http/default-http-client.class.js +123 -123
- package/build/http/http-client.errors.d.ts +7 -7
- package/build/http/http-client.errors.js +18 -18
- package/build/index.d.ts +2 -2
- package/build/index.js +18 -18
- package/build/jest.config.d.ts +7 -7
- package/build/jest.config.js +12 -12
- package/build/services/__tests/attachments.class.spec.d.ts +1 -1
- package/build/services/__tests/attachments.class.spec.js +23 -23
- package/build/services/__tests/runs.builder.spec.d.ts +1 -1
- package/build/services/__tests/runs.builder.spec.js +79 -79
- package/build/services/__tests/tests.builder.spec.d.ts +1 -1
- package/build/services/__tests/tests.builder.spec.js +32 -32
- package/build/services/attachments.service.d.ts +11 -11
- package/build/services/attachments.service.js +28 -28
- package/build/services/runs.builder.d.ts +10 -10
- package/build/services/runs.builder.js +65 -65
- package/build/services/tests.builder.d.ts +10 -10
- package/build/services/tests.builder.js +57 -55
- package/build/strategies/base-strategy.class.d.ts +24 -24
- package/build/strategies/base-strategy.class.js +66 -66
- package/build/strategies/default-strategy.class.d.ts +16 -16
- package/build/strategies/default-strategy.class.js +44 -44
- package/build/strategies/partial-startegy.class.d.ts +20 -20
- package/build/strategies/partial-startegy.class.js +72 -72
- package/build/strategies/scratch-strategy.class.d.ts +18 -18
- package/build/strategies/scratch-strategy.class.js +49 -49
- package/build/strategies/strategy.factory.d.ts +8 -8
- package/build/strategies/strategy.factory.js +21 -21
- package/build/types/codecept.type.d.ts +28 -27
- package/build/types/codecept.type.js +2 -2
- package/build/types/origin.type.d.ts +46 -46
- package/build/types/origin.type.js +2 -2
- package/build/types/strategy.type.d.ts +14 -10
- package/build/types/strategy.type.js +2 -2
- package/package.json +46 -46
- package/testit-adapter-codecept-1.1.2.tgz +0 -0
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/// <reference types="codeceptjs" />
|
|
2
|
-
import { AutotestPost } from 'testit-api-client';
|
|
3
|
-
import { Box } from '../common/classes/box.class';
|
|
4
|
-
import { Logger } from '../common/classes/logger.class';
|
|
5
|
-
import { DefaultHttpClient } from '../http/default-http-client.class';
|
|
6
|
-
import { RunsBuilder } from '../services/runs.builder';
|
|
7
|
-
import { TestsBuilder } from '../services/tests.builder';
|
|
8
|
-
import { Codecept } from '../types/codecept.type';
|
|
9
|
-
import { Origin } from '../types/origin.type';
|
|
10
|
-
export declare abstract class BaseStrategy {
|
|
11
|
-
protected readonly http: DefaultHttpClient;
|
|
12
|
-
protected readonly logger: Logger;
|
|
13
|
-
protected readonly config: Origin.Config;
|
|
14
|
-
protected readonly testsBuilder: TestsBuilder;
|
|
15
|
-
protected readonly runsBuilder: RunsBuilder;
|
|
16
|
-
protected readonly box: Box<Origin.TestMetadata>;
|
|
17
|
-
protected constructor(http: DefaultHttpClient, logger: Logger, config: Origin.Config);
|
|
18
|
-
collect(id: string, metadata: Origin.TestMetadata): void;
|
|
19
|
-
connectToTest(id: string, test: Codecept.Test): Promise<void>;
|
|
20
|
-
beforeTest(test: Mocha.Test): Promise<any>;
|
|
21
|
-
createOrUpdateTests(suite: any): Promise<void>;
|
|
22
|
-
protected createTestInOriginSystem(testToOriginSystem: AutotestPost, test: Codecept.Test): Promise<void>;
|
|
23
|
-
protected updateTestInOriginSystem(fromOriginSystem: AutotestPost, testToOriginSystem: AutotestPost, test: Codecept.Test): Promise<void>;
|
|
24
|
-
}
|
|
1
|
+
/// <reference types="codeceptjs" />
|
|
2
|
+
import { AutotestPost } from 'testit-api-client';
|
|
3
|
+
import { Box } from '../common/classes/box.class';
|
|
4
|
+
import { Logger } from '../common/classes/logger.class';
|
|
5
|
+
import { DefaultHttpClient } from '../http/default-http-client.class';
|
|
6
|
+
import { RunsBuilder } from '../services/runs.builder';
|
|
7
|
+
import { TestsBuilder } from '../services/tests.builder';
|
|
8
|
+
import { Codecept } from '../types/codecept.type';
|
|
9
|
+
import { Origin } from '../types/origin.type';
|
|
10
|
+
export declare abstract class BaseStrategy {
|
|
11
|
+
protected readonly http: DefaultHttpClient;
|
|
12
|
+
protected readonly logger: Logger;
|
|
13
|
+
protected readonly config: Origin.Config;
|
|
14
|
+
protected readonly testsBuilder: TestsBuilder;
|
|
15
|
+
protected readonly runsBuilder: RunsBuilder;
|
|
16
|
+
protected readonly box: Box<Origin.TestMetadata>;
|
|
17
|
+
protected constructor(http: DefaultHttpClient, logger: Logger, config: Origin.Config);
|
|
18
|
+
collect(id: string, metadata: Origin.TestMetadata): void;
|
|
19
|
+
connectToTest(id: string, test: Codecept.Test): Promise<void>;
|
|
20
|
+
beforeTest(test: Mocha.Test): Promise<any>;
|
|
21
|
+
createOrUpdateTests(suite: any): Promise<void>;
|
|
22
|
+
protected createTestInOriginSystem(testToOriginSystem: AutotestPost, test: Codecept.Test): Promise<void>;
|
|
23
|
+
protected updateTestInOriginSystem(fromOriginSystem: AutotestPost, testToOriginSystem: AutotestPost, test: Codecept.Test): Promise<void>;
|
|
24
|
+
}
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseStrategy = void 0;
|
|
4
|
-
const box_class_1 = require("../common/classes/box.class");
|
|
5
|
-
const is_passed_function_1 = require("../common/functions/is-passed.function");
|
|
6
|
-
const use_hash_function_1 = require("../common/functions/use-hash.function");
|
|
7
|
-
const runs_builder_1 = require("../services/runs.builder");
|
|
8
|
-
const tests_builder_1 = require("../services/tests.builder");
|
|
9
|
-
class BaseStrategy {
|
|
10
|
-
constructor(http, logger, config) {
|
|
11
|
-
this.http = http;
|
|
12
|
-
this.logger = logger;
|
|
13
|
-
this.config = config;
|
|
14
|
-
this.testsBuilder = new tests_builder_1.TestsBuilder(this.config);
|
|
15
|
-
this.runsBuilder = new runs_builder_1.RunsBuilder(this.config);
|
|
16
|
-
this.box = new box_class_1.Box();
|
|
17
|
-
}
|
|
18
|
-
collect(id, metadata) {
|
|
19
|
-
this.box.collectWithMerge(id, metadata);
|
|
20
|
-
}
|
|
21
|
-
async connectToTest(id, test) {
|
|
22
|
-
var _a;
|
|
23
|
-
const config = (0, use_hash_function_1.useConfig)(test);
|
|
24
|
-
const ids = (_a = config === null || config === void 0 ? void 0 : config.workitemIds) !== null && _a !== void 0 ? _a : [];
|
|
25
|
-
await this.http.linkToWorkItem(id, ids);
|
|
26
|
-
}
|
|
27
|
-
beforeTest(test) {
|
|
28
|
-
return Promise.resolve();
|
|
29
|
-
}
|
|
30
|
-
async createOrUpdateTests(suite) {
|
|
31
|
-
var _a;
|
|
32
|
-
for (const test of suite.tests) {
|
|
33
|
-
const testToOriginSystem = this.testsBuilder.build(test);
|
|
34
|
-
const fromOriginSystem = await this.http.hasInSystem((_a = (0, use_hash_function_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, use_hash_function_1.useCompositeHash)(test));
|
|
35
|
-
!fromOriginSystem
|
|
36
|
-
? await this.createTestInOriginSystem(testToOriginSystem, test)
|
|
37
|
-
: await this.updateTestInOriginSystem(fromOriginSystem, testToOriginSystem, test);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async createTestInOriginSystem(testToOriginSystem, test) {
|
|
41
|
-
testToOriginSystem.shouldCreateWorkItem = this.config.automaticCreationTestCases;
|
|
42
|
-
const response = await this.http.create(testToOriginSystem);
|
|
43
|
-
if (!response) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
this.logger.log(`Test - ${response.name} created in remote system`);
|
|
47
|
-
await this.connectToTest(response.id, test);
|
|
48
|
-
}
|
|
49
|
-
async updateTestInOriginSystem(fromOriginSystem, testToOriginSystem, test) {
|
|
50
|
-
var _a;
|
|
51
|
-
const hasPassedState = (0, is_passed_function_1.isPassed)(test);
|
|
52
|
-
const config = (0, use_hash_function_1.useConfig)(test);
|
|
53
|
-
if (hasPassedState) {
|
|
54
|
-
await this.http.update(testToOriginSystem);
|
|
55
|
-
await this.connectToTest(fromOriginSystem.id, test);
|
|
56
|
-
}
|
|
57
|
-
if (!hasPassedState) {
|
|
58
|
-
await this.http.update({
|
|
59
|
-
...fromOriginSystem,
|
|
60
|
-
links: (_a = config === null || config === void 0 ? void 0 : config.links) !== null && _a !== void 0 ? _a : []
|
|
61
|
-
});
|
|
62
|
-
this.logger.log(`Test - ${fromOriginSystem.name} updated in remote system`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.BaseStrategy = BaseStrategy;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseStrategy = void 0;
|
|
4
|
+
const box_class_1 = require("../common/classes/box.class");
|
|
5
|
+
const is_passed_function_1 = require("../common/functions/is-passed.function");
|
|
6
|
+
const use_hash_function_1 = require("../common/functions/use-hash.function");
|
|
7
|
+
const runs_builder_1 = require("../services/runs.builder");
|
|
8
|
+
const tests_builder_1 = require("../services/tests.builder");
|
|
9
|
+
class BaseStrategy {
|
|
10
|
+
constructor(http, logger, config) {
|
|
11
|
+
this.http = http;
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
this.config = config;
|
|
14
|
+
this.testsBuilder = new tests_builder_1.TestsBuilder(this.config);
|
|
15
|
+
this.runsBuilder = new runs_builder_1.RunsBuilder(this.config);
|
|
16
|
+
this.box = new box_class_1.Box();
|
|
17
|
+
}
|
|
18
|
+
collect(id, metadata) {
|
|
19
|
+
this.box.collectWithMerge(id, metadata);
|
|
20
|
+
}
|
|
21
|
+
async connectToTest(id, test) {
|
|
22
|
+
var _a;
|
|
23
|
+
const config = (0, use_hash_function_1.useConfig)(test);
|
|
24
|
+
const ids = (_a = config === null || config === void 0 ? void 0 : config.workitemIds) !== null && _a !== void 0 ? _a : [];
|
|
25
|
+
await this.http.linkToWorkItem(id, ids);
|
|
26
|
+
}
|
|
27
|
+
beforeTest(test) {
|
|
28
|
+
return Promise.resolve();
|
|
29
|
+
}
|
|
30
|
+
async createOrUpdateTests(suite) {
|
|
31
|
+
var _a;
|
|
32
|
+
for (const test of suite.tests) {
|
|
33
|
+
const testToOriginSystem = this.testsBuilder.build(test);
|
|
34
|
+
const fromOriginSystem = await this.http.hasInSystem((_a = (0, use_hash_function_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, use_hash_function_1.useCompositeHash)(test));
|
|
35
|
+
!fromOriginSystem
|
|
36
|
+
? await this.createTestInOriginSystem(testToOriginSystem, test)
|
|
37
|
+
: await this.updateTestInOriginSystem(fromOriginSystem, testToOriginSystem, test);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async createTestInOriginSystem(testToOriginSystem, test) {
|
|
41
|
+
testToOriginSystem.shouldCreateWorkItem = this.config.automaticCreationTestCases;
|
|
42
|
+
const response = await this.http.create(testToOriginSystem);
|
|
43
|
+
if (!response) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.logger.log(`Test - ${response.name} created in remote system`);
|
|
47
|
+
await this.connectToTest(response.id, test);
|
|
48
|
+
}
|
|
49
|
+
async updateTestInOriginSystem(fromOriginSystem, testToOriginSystem, test) {
|
|
50
|
+
var _a;
|
|
51
|
+
const hasPassedState = (0, is_passed_function_1.isPassed)(test);
|
|
52
|
+
const config = (0, use_hash_function_1.useConfig)(test);
|
|
53
|
+
if (hasPassedState) {
|
|
54
|
+
await this.http.update(testToOriginSystem);
|
|
55
|
+
await this.connectToTest(fromOriginSystem.id, test);
|
|
56
|
+
}
|
|
57
|
+
if (!hasPassedState) {
|
|
58
|
+
await this.http.update({
|
|
59
|
+
...fromOriginSystem,
|
|
60
|
+
links: (_a = config === null || config === void 0 ? void 0 : config.links) !== null && _a !== void 0 ? _a : []
|
|
61
|
+
});
|
|
62
|
+
this.logger.log(`Test - ${fromOriginSystem.name} updated in remote system`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.BaseStrategy = BaseStrategy;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Logger } from '../common/classes/logger.class';
|
|
2
|
-
import { DefaultHttpClient } from '../http/default-http-client.class';
|
|
3
|
-
import { Strategy } from '../types/strategy.type';
|
|
4
|
-
import { Origin } from '../types/origin.type';
|
|
5
|
-
import { BaseStrategy } from './base-strategy.class';
|
|
6
|
-
export declare class DefaultStrategy extends BaseStrategy implements Strategy {
|
|
7
|
-
protected readonly http: DefaultHttpClient;
|
|
8
|
-
protected readonly logger: Logger;
|
|
9
|
-
protected readonly config: Origin.Config;
|
|
10
|
-
private readonly attachments;
|
|
11
|
-
constructor(http: DefaultHttpClient, logger: Logger, config: Origin.Config);
|
|
12
|
-
bootstrap(): Promise<void>;
|
|
13
|
-
teardown(): Promise<void>;
|
|
14
|
-
transferTestsToSystem(suite: any): Promise<void>;
|
|
15
|
-
transferRunsToSystem(suite: any): Promise<void>;
|
|
16
|
-
}
|
|
1
|
+
import { Logger } from '../common/classes/logger.class';
|
|
2
|
+
import { DefaultHttpClient } from '../http/default-http-client.class';
|
|
3
|
+
import { Strategy } from '../types/strategy.type';
|
|
4
|
+
import { Origin } from '../types/origin.type';
|
|
5
|
+
import { BaseStrategy } from './base-strategy.class';
|
|
6
|
+
export declare class DefaultStrategy extends BaseStrategy implements Strategy {
|
|
7
|
+
protected readonly http: DefaultHttpClient;
|
|
8
|
+
protected readonly logger: Logger;
|
|
9
|
+
protected readonly config: Origin.Config;
|
|
10
|
+
private readonly attachments;
|
|
11
|
+
constructor(http: DefaultHttpClient, logger: Logger, config: Origin.Config);
|
|
12
|
+
bootstrap(): Promise<void>;
|
|
13
|
+
teardown(): Promise<void>;
|
|
14
|
+
transferTestsToSystem(suite: any): Promise<void>;
|
|
15
|
+
transferRunsToSystem(suite: any): Promise<void>;
|
|
16
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultStrategy = void 0;
|
|
4
|
-
const attachments_service_1 = require("../services/attachments.service");
|
|
5
|
-
const base_strategy_class_1 = require("./base-strategy.class");
|
|
6
|
-
class DefaultStrategy extends base_strategy_class_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
|
-
this.attachments = new attachments_service_1.AttachmentsService(this.http);
|
|
13
|
-
}
|
|
14
|
-
async bootstrap() {
|
|
15
|
-
await this.http.startRunIfNeeded(this.config.testRunId);
|
|
16
|
-
}
|
|
17
|
-
async teardown() {
|
|
18
|
-
await this.http.completeRunIfNeeded(this.config.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.attachments.attach(clientUrls);
|
|
33
|
-
if (config === null || config === void 0 ? void 0 : config.text) {
|
|
34
|
-
const attach = await this.attachments
|
|
35
|
-
.attachTextLikeFile(config.text.content, (_c = config.text) === null || _c === void 0 ? void 0 : _c.name);
|
|
36
|
-
attachments.push(attach);
|
|
37
|
-
}
|
|
38
|
-
const run = this.runsBuilder.build(test, config, attachments);
|
|
39
|
-
await this.http.updateRuns(run);
|
|
40
|
-
}
|
|
41
|
-
this.logger.log(`Test run - ${this.config.testRunId} transferred to remote system`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.DefaultStrategy = DefaultStrategy;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultStrategy = void 0;
|
|
4
|
+
const attachments_service_1 = require("../services/attachments.service");
|
|
5
|
+
const base_strategy_class_1 = require("./base-strategy.class");
|
|
6
|
+
class DefaultStrategy extends base_strategy_class_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
|
+
this.attachments = new attachments_service_1.AttachmentsService(this.http);
|
|
13
|
+
}
|
|
14
|
+
async bootstrap() {
|
|
15
|
+
await this.http.startRunIfNeeded(this.config.testRunId);
|
|
16
|
+
}
|
|
17
|
+
async teardown() {
|
|
18
|
+
await this.http.completeRunIfNeeded(this.config.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.attachments.attach(clientUrls);
|
|
33
|
+
if (config === null || config === void 0 ? void 0 : config.text) {
|
|
34
|
+
const attach = await this.attachments
|
|
35
|
+
.attachTextLikeFile(config.text.content, (_c = config.text) === null || _c === void 0 ? void 0 : _c.name);
|
|
36
|
+
attachments.push(attach);
|
|
37
|
+
}
|
|
38
|
+
const run = this.runsBuilder.build(test, config, attachments);
|
|
39
|
+
await this.http.updateRuns(run);
|
|
40
|
+
}
|
|
41
|
+
this.logger.log(`Test run - ${this.config.testRunId} transferred to remote system`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.DefaultStrategy = DefaultStrategy;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/// <reference types="codeceptjs" />
|
|
2
|
-
import { Logger } from '../common/classes/logger.class';
|
|
3
|
-
import { DefaultHttpClient } from '../http/default-http-client.class';
|
|
4
|
-
import { Codecept } from '../types/codecept.type';
|
|
5
|
-
import { Strategy } from '../types/strategy.type';
|
|
6
|
-
import { Origin } from '../types/origin.type';
|
|
7
|
-
import { BaseStrategy } from './base-strategy.class';
|
|
8
|
-
export declare class PartialStrategy extends BaseStrategy implements Strategy {
|
|
9
|
-
protected readonly http: DefaultHttpClient;
|
|
10
|
-
protected readonly logger: Logger;
|
|
11
|
-
protected readonly config: Origin.Config;
|
|
12
|
-
private readonly attachments;
|
|
13
|
-
private readonly testsInRun;
|
|
14
|
-
constructor(http: DefaultHttpClient, logger: Logger, config: Origin.Config);
|
|
15
|
-
bootstrap(): Promise<void>;
|
|
16
|
-
teardown(): Promise<void>;
|
|
17
|
-
beforeTest(test: Codecept.Test): Promise<void>;
|
|
18
|
-
transferRunsToSystem(suite: any): Promise<void>;
|
|
19
|
-
transferTestsToSystem(suite: Mocha.Suite): Promise<void>;
|
|
20
|
-
}
|
|
1
|
+
/// <reference types="codeceptjs" />
|
|
2
|
+
import { Logger } from '../common/classes/logger.class';
|
|
3
|
+
import { DefaultHttpClient } from '../http/default-http-client.class';
|
|
4
|
+
import { Codecept } from '../types/codecept.type';
|
|
5
|
+
import { Strategy } from '../types/strategy.type';
|
|
6
|
+
import { Origin } from '../types/origin.type';
|
|
7
|
+
import { BaseStrategy } from './base-strategy.class';
|
|
8
|
+
export declare class PartialStrategy extends BaseStrategy implements Strategy {
|
|
9
|
+
protected readonly http: DefaultHttpClient;
|
|
10
|
+
protected readonly logger: Logger;
|
|
11
|
+
protected readonly config: Origin.Config;
|
|
12
|
+
private readonly attachments;
|
|
13
|
+
private readonly testsInRun;
|
|
14
|
+
constructor(http: DefaultHttpClient, logger: Logger, config: Origin.Config);
|
|
15
|
+
bootstrap(): Promise<void>;
|
|
16
|
+
teardown(): Promise<void>;
|
|
17
|
+
beforeTest(test: Codecept.Test): Promise<void>;
|
|
18
|
+
transferRunsToSystem(suite: any): Promise<void>;
|
|
19
|
+
transferTestsToSystem(suite: Mocha.Suite): Promise<void>;
|
|
20
|
+
}
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PartialStrategy = void 0;
|
|
4
|
-
const use_hash_function_1 = require("../common/functions/use-hash.function");
|
|
5
|
-
const attachments_service_1 = require("../services/attachments.service");
|
|
6
|
-
const base_strategy_class_1 = require("./base-strategy.class");
|
|
7
|
-
class PartialStrategy extends base_strategy_class_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.attachments = new attachments_service_1.AttachmentsService(this.http);
|
|
14
|
-
this.testsInRun = this.http.getTestsIdsByRunId(this.config.testRunId);
|
|
15
|
-
}
|
|
16
|
-
async bootstrap() {
|
|
17
|
-
await this.http.startRunIfNeeded(this.config.testRunId);
|
|
18
|
-
}
|
|
19
|
-
async teardown() {
|
|
20
|
-
await this.http.completeRunIfNeeded(this.config.testRunId);
|
|
21
|
-
}
|
|
22
|
-
async beforeTest(test) {
|
|
23
|
-
var _a;
|
|
24
|
-
const tests = await this.testsInRun;
|
|
25
|
-
const hash = (_a = (0, use_hash_function_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, use_hash_function_1.useCompositeHash)(test);
|
|
26
|
-
if (!tests.includes(hash.toString())) {
|
|
27
|
-
test.run = () => test.skip();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async transferRunsToSystem(suite) {
|
|
31
|
-
const tests = await this.testsInRun;
|
|
32
|
-
const data = await Promise.all(suite.tests
|
|
33
|
-
.filter(test => {
|
|
34
|
-
var _a;
|
|
35
|
-
const hash = (_a = (0, use_hash_function_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, use_hash_function_1.useCompositeHash)(test);
|
|
36
|
-
return tests.includes(hash.toString());
|
|
37
|
-
})
|
|
38
|
-
.map(async (test) => {
|
|
39
|
-
var _a, _b, _c;
|
|
40
|
-
const config = this.box.get(test.id);
|
|
41
|
-
const screenshot = (_a = test.artifacts) === null || _a === void 0 ? void 0 : _a.screenshot;
|
|
42
|
-
const clientUrls = (_b = config === null || config === void 0 ? void 0 : config.attachments) !== null && _b !== void 0 ? _b : [];
|
|
43
|
-
if (screenshot) {
|
|
44
|
-
clientUrls.push(screenshot);
|
|
45
|
-
}
|
|
46
|
-
const attachments = await this.attachments.attach(clientUrls);
|
|
47
|
-
if (config === null || config === void 0 ? void 0 : config.text) {
|
|
48
|
-
const attach = await this.attachments
|
|
49
|
-
.attachTextLikeFile(config.text.content, (_c = config.text) === null || _c === void 0 ? void 0 : _c.name);
|
|
50
|
-
attachments.push(attach);
|
|
51
|
-
}
|
|
52
|
-
return this.runsBuilder.build(test, config, attachments);
|
|
53
|
-
}));
|
|
54
|
-
if (data.length) {
|
|
55
|
-
await this.http.updateManyRuns(data);
|
|
56
|
-
this.logger.log(`Test run - ${this.config.testRunId} transferred to remote system`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async transferTestsToSystem(suite) {
|
|
60
|
-
const tests = await this.testsInRun;
|
|
61
|
-
const suiteWithNeededTests = {
|
|
62
|
-
...suite,
|
|
63
|
-
tests: suite.tests.filter((test) => {
|
|
64
|
-
var _a;
|
|
65
|
-
const hash = (_a = (0, use_hash_function_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, use_hash_function_1.useCompositeHash)(test);
|
|
66
|
-
return tests.includes(hash.toString());
|
|
67
|
-
})
|
|
68
|
-
};
|
|
69
|
-
await this.createOrUpdateTests(suiteWithNeededTests);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.PartialStrategy = PartialStrategy;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PartialStrategy = void 0;
|
|
4
|
+
const use_hash_function_1 = require("../common/functions/use-hash.function");
|
|
5
|
+
const attachments_service_1 = require("../services/attachments.service");
|
|
6
|
+
const base_strategy_class_1 = require("./base-strategy.class");
|
|
7
|
+
class PartialStrategy extends base_strategy_class_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.attachments = new attachments_service_1.AttachmentsService(this.http);
|
|
14
|
+
this.testsInRun = this.http.getTestsIdsByRunId(this.config.testRunId);
|
|
15
|
+
}
|
|
16
|
+
async bootstrap() {
|
|
17
|
+
await this.http.startRunIfNeeded(this.config.testRunId);
|
|
18
|
+
}
|
|
19
|
+
async teardown() {
|
|
20
|
+
await this.http.completeRunIfNeeded(this.config.testRunId);
|
|
21
|
+
}
|
|
22
|
+
async beforeTest(test) {
|
|
23
|
+
var _a;
|
|
24
|
+
const tests = await this.testsInRun;
|
|
25
|
+
const hash = (_a = (0, use_hash_function_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, use_hash_function_1.useCompositeHash)(test);
|
|
26
|
+
if (!tests.includes(hash.toString())) {
|
|
27
|
+
test.run = () => test.skip();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async transferRunsToSystem(suite) {
|
|
31
|
+
const tests = await this.testsInRun;
|
|
32
|
+
const data = await Promise.all(suite.tests
|
|
33
|
+
.filter(test => {
|
|
34
|
+
var _a;
|
|
35
|
+
const hash = (_a = (0, use_hash_function_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, use_hash_function_1.useCompositeHash)(test);
|
|
36
|
+
return tests.includes(hash.toString());
|
|
37
|
+
})
|
|
38
|
+
.map(async (test) => {
|
|
39
|
+
var _a, _b, _c;
|
|
40
|
+
const config = this.box.get(test.id);
|
|
41
|
+
const screenshot = (_a = test.artifacts) === null || _a === void 0 ? void 0 : _a.screenshot;
|
|
42
|
+
const clientUrls = (_b = config === null || config === void 0 ? void 0 : config.attachments) !== null && _b !== void 0 ? _b : [];
|
|
43
|
+
if (screenshot) {
|
|
44
|
+
clientUrls.push(screenshot);
|
|
45
|
+
}
|
|
46
|
+
const attachments = await this.attachments.attach(clientUrls);
|
|
47
|
+
if (config === null || config === void 0 ? void 0 : config.text) {
|
|
48
|
+
const attach = await this.attachments
|
|
49
|
+
.attachTextLikeFile(config.text.content, (_c = config.text) === null || _c === void 0 ? void 0 : _c.name);
|
|
50
|
+
attachments.push(attach);
|
|
51
|
+
}
|
|
52
|
+
return this.runsBuilder.build(test, config, attachments);
|
|
53
|
+
}));
|
|
54
|
+
if (data.length) {
|
|
55
|
+
await this.http.updateManyRuns(data);
|
|
56
|
+
this.logger.log(`Test run - ${this.config.testRunId} transferred to remote system`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async transferTestsToSystem(suite) {
|
|
60
|
+
const tests = await this.testsInRun;
|
|
61
|
+
const suiteWithNeededTests = {
|
|
62
|
+
...suite,
|
|
63
|
+
tests: suite.tests.filter((test) => {
|
|
64
|
+
var _a;
|
|
65
|
+
const hash = (_a = (0, use_hash_function_1.useDefaultHash)(test)) !== null && _a !== void 0 ? _a : (0, use_hash_function_1.useCompositeHash)(test);
|
|
66
|
+
return tests.includes(hash.toString());
|
|
67
|
+
})
|
|
68
|
+
};
|
|
69
|
+
await this.createOrUpdateTests(suiteWithNeededTests);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.PartialStrategy = PartialStrategy;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/// <reference types="codeceptjs" />
|
|
2
|
-
import { Logger } from '../common/classes/logger.class';
|
|
3
|
-
import { DefaultHttpClient } from '../http/default-http-client.class';
|
|
4
|
-
import { Strategy } from '../types/strategy.type';
|
|
5
|
-
import { Origin } from '../types/origin.type';
|
|
6
|
-
import { BaseStrategy } from './base-strategy.class';
|
|
7
|
-
export declare class ScratchStrategy extends BaseStrategy implements Strategy {
|
|
8
|
-
protected readonly http: DefaultHttpClient;
|
|
9
|
-
protected readonly logger: Logger;
|
|
10
|
-
protected readonly config: Origin.Config;
|
|
11
|
-
private readonly attachments;
|
|
12
|
-
private run;
|
|
13
|
-
constructor(http: DefaultHttpClient, logger: Logger, config: Origin.Config);
|
|
14
|
-
bootstrap(): Promise<void>;
|
|
15
|
-
teardown(): Promise<void>;
|
|
16
|
-
transferTestsToSystem(suite: Mocha.Suite): Promise<void>;
|
|
17
|
-
transferRunsToSystem(suite: any): Promise<void>;
|
|
18
|
-
}
|
|
1
|
+
/// <reference types="codeceptjs" />
|
|
2
|
+
import { Logger } from '../common/classes/logger.class';
|
|
3
|
+
import { DefaultHttpClient } from '../http/default-http-client.class';
|
|
4
|
+
import { Strategy } from '../types/strategy.type';
|
|
5
|
+
import { Origin } from '../types/origin.type';
|
|
6
|
+
import { BaseStrategy } from './base-strategy.class';
|
|
7
|
+
export declare class ScratchStrategy extends BaseStrategy implements Strategy {
|
|
8
|
+
protected readonly http: DefaultHttpClient;
|
|
9
|
+
protected readonly logger: Logger;
|
|
10
|
+
protected readonly config: Origin.Config;
|
|
11
|
+
private readonly attachments;
|
|
12
|
+
private run;
|
|
13
|
+
constructor(http: DefaultHttpClient, logger: Logger, config: Origin.Config);
|
|
14
|
+
bootstrap(): Promise<void>;
|
|
15
|
+
teardown(): Promise<void>;
|
|
16
|
+
transferTestsToSystem(suite: Mocha.Suite): Promise<void>;
|
|
17
|
+
transferRunsToSystem(suite: any): Promise<void>;
|
|
18
|
+
}
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ScratchStrategy = void 0;
|
|
4
|
-
const attachments_service_1 = require("../services/attachments.service");
|
|
5
|
-
const base_strategy_class_1 = require("./base-strategy.class");
|
|
6
|
-
class ScratchStrategy extends base_strategy_class_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
|
-
this.attachments = new attachments_service_1.AttachmentsService(this.http);
|
|
13
|
-
}
|
|
14
|
-
async bootstrap() {
|
|
15
|
-
var _a;
|
|
16
|
-
const run = await this.http.createEmptyRun((_a = this.config.testRunName) !== null && _a !== void 0 ? _a : '');
|
|
17
|
-
if (run) {
|
|
18
|
-
await this.http.startRunIfNeeded(run.id);
|
|
19
|
-
this.run = run;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
async teardown() {
|
|
23
|
-
await this.http.completeRunIfNeeded(this.run.id);
|
|
24
|
-
}
|
|
25
|
-
async transferTestsToSystem(suite) {
|
|
26
|
-
await this.createOrUpdateTests(suite);
|
|
27
|
-
}
|
|
28
|
-
async transferRunsToSystem(suite) {
|
|
29
|
-
var _a, _b, _c;
|
|
30
|
-
for (const test of suite.tests) {
|
|
31
|
-
const config = this.box.get(test.id);
|
|
32
|
-
const screenshot = (_a = test.artifacts) === null || _a === void 0 ? void 0 : _a.screenshot;
|
|
33
|
-
const clientUrls = (_b = config === null || config === void 0 ? void 0 : config.attachments) !== null && _b !== void 0 ? _b : [];
|
|
34
|
-
if (screenshot) {
|
|
35
|
-
clientUrls.push(screenshot);
|
|
36
|
-
}
|
|
37
|
-
const attachments = await this.attachments.attach(clientUrls);
|
|
38
|
-
if (config === null || config === void 0 ? void 0 : config.text) {
|
|
39
|
-
const attach = await this.attachments
|
|
40
|
-
.attachTextLikeFile(config.text.content, (_c = config.text) === null || _c === void 0 ? void 0 : _c.name);
|
|
41
|
-
attachments.push(attach);
|
|
42
|
-
}
|
|
43
|
-
const data = this.runsBuilder.build(test, config, attachments);
|
|
44
|
-
await this.http.updateRuns(data, this.run.id);
|
|
45
|
-
}
|
|
46
|
-
this.logger.log(`Test run - ${this.run.id} transferred to remote system`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.ScratchStrategy = ScratchStrategy;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScratchStrategy = void 0;
|
|
4
|
+
const attachments_service_1 = require("../services/attachments.service");
|
|
5
|
+
const base_strategy_class_1 = require("./base-strategy.class");
|
|
6
|
+
class ScratchStrategy extends base_strategy_class_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
|
+
this.attachments = new attachments_service_1.AttachmentsService(this.http);
|
|
13
|
+
}
|
|
14
|
+
async bootstrap() {
|
|
15
|
+
var _a;
|
|
16
|
+
const run = await this.http.createEmptyRun((_a = this.config.testRunName) !== null && _a !== void 0 ? _a : '');
|
|
17
|
+
if (run) {
|
|
18
|
+
await this.http.startRunIfNeeded(run.id);
|
|
19
|
+
this.run = run;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async teardown() {
|
|
23
|
+
await this.http.completeRunIfNeeded(this.run.id);
|
|
24
|
+
}
|
|
25
|
+
async transferTestsToSystem(suite) {
|
|
26
|
+
await this.createOrUpdateTests(suite);
|
|
27
|
+
}
|
|
28
|
+
async transferRunsToSystem(suite) {
|
|
29
|
+
var _a, _b, _c;
|
|
30
|
+
for (const test of suite.tests) {
|
|
31
|
+
const config = this.box.get(test.id);
|
|
32
|
+
const screenshot = (_a = test.artifacts) === null || _a === void 0 ? void 0 : _a.screenshot;
|
|
33
|
+
const clientUrls = (_b = config === null || config === void 0 ? void 0 : config.attachments) !== null && _b !== void 0 ? _b : [];
|
|
34
|
+
if (screenshot) {
|
|
35
|
+
clientUrls.push(screenshot);
|
|
36
|
+
}
|
|
37
|
+
const attachments = await this.attachments.attach(clientUrls);
|
|
38
|
+
if (config === null || config === void 0 ? void 0 : config.text) {
|
|
39
|
+
const attach = await this.attachments
|
|
40
|
+
.attachTextLikeFile(config.text.content, (_c = config.text) === null || _c === void 0 ? void 0 : _c.name);
|
|
41
|
+
attachments.push(attach);
|
|
42
|
+
}
|
|
43
|
+
const data = this.runsBuilder.build(test, config, attachments);
|
|
44
|
+
await this.http.updateRuns(data, this.run.id);
|
|
45
|
+
}
|
|
46
|
+
this.logger.log(`Test run - ${this.run.id} transferred to remote system`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.ScratchStrategy = ScratchStrategy;
|