@zohodesk/testinglibrary 0.0.66-n20-experimental → 0.0.68-n20-experimental
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/build/common/data-generator/steps/DataGenerator.spec.js +4 -8
- package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +2 -2
- package/build/core/dataGenerator/DataGenerator.js +4 -9
- package/build/core/playwright/builtInFixtures/caseTimeout.js +20 -0
- package/build/core/playwright/builtInFixtures/index.js +3 -1
- package/build/core/playwright/helpers/browserTimeoutFactor.js +16 -0
- package/build/core/playwright/helpers/caseTimeoutResolver.js +37 -0
- package/build/core/playwright/readConfigFile.js +1 -1
- package/build/core/playwright/setup/config-utils.js +7 -4
- package/build/core/playwright/types.js +1 -1
- package/build/setup-folder-structure/samples/uat-config-sample.js +1 -1
- package/build/test/core/playwright/buildInFixtures/__tests__/caseTimeout.test.js +96 -0
- package/jest.config.js +1 -1
- package/npm-shrinkwrap.json +1726 -2785
- package/package.json +1 -1
- package/unit_reports/unit-report.html +1 -1
- package/build/core/dataGenerator/authenticator/Authenticator.js +0 -35
- package/build/core/dataGenerator/authenticator/CookieAuthenticator.js +0 -41
- package/build/core/dataGenerator/authenticator/JWTauthenticator.js +0 -71
- package/build/core/dataGenerator/authenticator/OAuthAuthenticator.js +0 -31
- package/build/core/dataGenerator/authenticator/OrgOAuthAuthenticator.js +0 -29
- package/build/test/core/dataGenerator/authenticator/__test__/Authenticator.test.js +0 -89
- package/build/test/core/dataGenerator/authenticator/__test__/JWTauthenticator.test.js +0 -134
- package/build/test/core/dataGenerator/authenticator/__test__/OAuthAuthenticator.test.js +0 -46
- package/build/test/core/dataGenerator/authenticator/__test__/OrgOAuthAuthenticator.test.js +0 -46
- package/build/test/core/dataGenerator/authenticator/__tests__/JWTauthenticator.test.js +0 -165
|
@@ -4,20 +4,16 @@ import { generateAndCacheTestData } from './DataGeneratorStepsHelper';
|
|
|
4
4
|
const { Given } = createBdd();
|
|
5
5
|
|
|
6
6
|
Given('generate a {string} entity {string} with generator {string}', async ({ page, context, i18N, cacheLayer, executionContext}, module, entityName, generatorName, dataTable) => {
|
|
7
|
-
await generateAndCacheTestData(executionContext, "template", generatorName, dataTable, cacheLayer, entityName
|
|
7
|
+
await generateAndCacheTestData(executionContext, "template", generatorName, dataTable, cacheLayer, entityName);
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
Given('generate a {string} entity {string} with API {string}', async ({ page, context, i18N, cacheLayer, executionContext}, module, entityName, operationId, dataTable) => {
|
|
11
|
-
await generateAndCacheTestData(executionContext, "API", operationId, dataTable, cacheLayer, entityName
|
|
11
|
+
await generateAndCacheTestData(executionContext, "API", operationId, dataTable, cacheLayer, entityName);
|
|
12
12
|
});
|
|
13
13
|
Given('generate a {string} entity {string} with generator {string} using {string} profile', async ({ page, context, i18N, cacheLayer, executionContext}, module, entityName, generatorName, profile, dataTable) => {
|
|
14
|
-
await generateAndCacheTestData(executionContext, "template", generatorName, dataTable, cacheLayer, entityName, profile
|
|
14
|
+
await generateAndCacheTestData(executionContext, "template", generatorName, dataTable, cacheLayer, entityName, profile);
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
Given('generate a {string} entity {string} with API {string} using {string} profile', async ({ page, context, i18N, cacheLayer, executionContext}, module, entityName, operationId, profile, dataTable) => {
|
|
18
|
-
await generateAndCacheTestData(executionContext, "API", operationId, dataTable, cacheLayer, entityName, profile
|
|
18
|
+
await generateAndCacheTestData(executionContext, "API", operationId, dataTable, cacheLayer, entityName, profile);
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
Given('generate a {string} entity {string} with API {string} using {string} profile', async ({ page, context, i18N, cacheLayer, executionContext}, module, entityName, operationId, profile, dataTable) => {
|
|
22
|
-
await generateAndCacheTestData(executionContext, "API", operationId, dataTable, cacheLayer, entityName, profile, page);
|
|
23
|
-
});
|
|
@@ -4,7 +4,7 @@ import DataGenerator from '@zohodesk/testinglibrary/DataGenerator';
|
|
|
4
4
|
|
|
5
5
|
const dataGenerator = new DataGenerator();
|
|
6
6
|
|
|
7
|
-
export async function generateAndCacheTestData(executionContext, type, identifier, dataTable, cacheLayer, entityName, profile = null
|
|
7
|
+
export async function generateAndCacheTestData(executionContext, type, identifier, dataTable, cacheLayer, entityName, profile = null) {
|
|
8
8
|
let actorInfo;
|
|
9
9
|
const testInfo = test.info();
|
|
10
10
|
const scenarioName = testInfo.title.split('/').pop() || 'Unknown Scenario';
|
|
@@ -16,6 +16,6 @@ export async function generateAndCacheTestData(executionContext, type, identifie
|
|
|
16
16
|
actorInfo = executionContext.actorInfo;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const generatedData = await dataGenerator.generate(testInfo, actorInfo, type, identifier, scenarioName, dataTable ? dataTable.hashes() : []
|
|
19
|
+
const generatedData = await dataGenerator.generate(testInfo, actorInfo, type, identifier, scenarioName, dataTable ? dataTable.hashes() : []);
|
|
20
20
|
await cacheLayer.set(entityName, generatedData.data);
|
|
21
21
|
}
|
|
@@ -9,7 +9,6 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
9
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
10
10
|
var _logger = require("../../utils/logger");
|
|
11
11
|
var _DataGeneratorHelper = require("./DataGeneratorHelper");
|
|
12
|
-
var _Authenticator = _interopRequireDefault(require("./authenticator/Authenticator.js"));
|
|
13
12
|
var _helpers = require("@zohodesk/testinglibrary/helpers");
|
|
14
13
|
var _DataGeneratorError = require("./DataGeneratorError");
|
|
15
14
|
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
@@ -20,7 +19,7 @@ class DataGenerator {
|
|
|
20
19
|
constructor() {
|
|
21
20
|
_classPrivateMethodInitSpec(this, _DataGenerator_brand);
|
|
22
21
|
}
|
|
23
|
-
async generate(testInfo, actorInfo, generatorType, generatorName, scenarioName, dataTable
|
|
22
|
+
async generate(testInfo, actorInfo, generatorType, generatorName, scenarioName, dataTable) {
|
|
24
23
|
try {
|
|
25
24
|
let generators;
|
|
26
25
|
if (generatorType === 'API') {
|
|
@@ -29,7 +28,7 @@ class DataGenerator {
|
|
|
29
28
|
generators = await _assertClassBrand(_DataGenerator_brand, this, _getGenerator).call(this, testInfo, generatorName);
|
|
30
29
|
}
|
|
31
30
|
const processedGenerators = await (0, _DataGeneratorHelper.processGenerator)(generators, dataTable);
|
|
32
|
-
const apiPayload = await _assertClassBrand(_DataGenerator_brand, this, _constructApiPayload).call(this, scenarioName, processedGenerators, actorInfo
|
|
31
|
+
const apiPayload = await _assertClassBrand(_DataGenerator_brand, this, _constructApiPayload).call(this, scenarioName, processedGenerators, actorInfo);
|
|
33
32
|
const response = await (0, _DataGeneratorHelper.makeRequest)(process.env.DG_SERVICE_DOMAIN + process.env.DG_SERVICE_API_PATH, apiPayload);
|
|
34
33
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Generated response for the generator: ${generatorName} for scenario: ${scenarioName}, Response: ${JSON.stringify(response)}`);
|
|
35
34
|
return response;
|
|
@@ -73,12 +72,12 @@ async function _generateAPIGenerator(operationId) {
|
|
|
73
72
|
name: operationId
|
|
74
73
|
}];
|
|
75
74
|
}
|
|
76
|
-
async function _constructApiPayload(scenarioName, processedGenerators, actorInfo
|
|
75
|
+
async function _constructApiPayload(scenarioName, processedGenerators, actorInfo) {
|
|
77
76
|
const dataGeneratorObj = actorInfo['data-generator'];
|
|
78
77
|
if (!dataGeneratorObj) {
|
|
79
78
|
throw new _DataGeneratorError.DataGeneratorConfigurationError(`Data Generator configuration is missing for the profile: ${actorInfo['profile']}`);
|
|
80
79
|
}
|
|
81
|
-
|
|
80
|
+
const apiPayload = {
|
|
82
81
|
scenario_name: scenarioName,
|
|
83
82
|
data_generation_templates: processedGenerators,
|
|
84
83
|
...dataGeneratorObj
|
|
@@ -95,10 +94,6 @@ async function _constructApiPayload(scenarioName, processedGenerators, actorInfo
|
|
|
95
94
|
environmentDetails.host = domainUrl.origin;
|
|
96
95
|
}
|
|
97
96
|
apiPayload.environmentDetails = environmentDetails;
|
|
98
|
-
|
|
99
|
-
// Only perform auth augmentation via Authenticator
|
|
100
|
-
apiPayload = await new _Authenticator.default().constructPayload(apiPayload, actorInfo, page);
|
|
101
|
-
console.log("Final API Payload after authentication augmentation: ", JSON.stringify(apiPayload));
|
|
102
97
|
return apiPayload;
|
|
103
98
|
}
|
|
104
99
|
var _default = exports.default = DataGenerator;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _caseTimeoutResolver = require("../helpers/caseTimeoutResolver");
|
|
8
|
+
var _default = exports.default = {
|
|
9
|
+
caseTimeout: [async ({
|
|
10
|
+
$tags
|
|
11
|
+
}, use, testInfo) => {
|
|
12
|
+
const timeoutMs = (0, _caseTimeoutResolver.resolveCaseTimeoutMs)($tags, testInfo.project.name);
|
|
13
|
+
if (timeoutMs !== null) {
|
|
14
|
+
testInfo.setTimeout(timeoutMs);
|
|
15
|
+
}
|
|
16
|
+
await use();
|
|
17
|
+
}, {
|
|
18
|
+
auto: true
|
|
19
|
+
}]
|
|
20
|
+
};
|
|
@@ -9,6 +9,7 @@ var _page = _interopRequireDefault(require("./page"));
|
|
|
9
9
|
var _context = _interopRequireDefault(require("./context"));
|
|
10
10
|
var _cacheLayer = _interopRequireDefault(require("./cacheLayer"));
|
|
11
11
|
var _addTags = _interopRequireDefault(require("./addTags"));
|
|
12
|
+
var _caseTimeout = _interopRequireDefault(require("./caseTimeout"));
|
|
12
13
|
var _i18N = _interopRequireDefault(require("./i18N"));
|
|
13
14
|
var _unauthenticatedPage = _interopRequireDefault(require("./unauthenticatedPage"));
|
|
14
15
|
var _executionContext = _interopRequireDefault(require("./executionContext"));
|
|
@@ -24,7 +25,8 @@ function getBuiltInFixtures(bddMode) {
|
|
|
24
25
|
..._cacheLayer.default,
|
|
25
26
|
..._i18N.default,
|
|
26
27
|
..._unauthenticatedPage.default,
|
|
27
|
-
..._executionContext.default
|
|
28
|
+
..._executionContext.default,
|
|
29
|
+
..._caseTimeout.default
|
|
28
30
|
};
|
|
29
31
|
if (bddMode) {
|
|
30
32
|
builtInFixtures = {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBrowserTimeoutFactor = getBrowserTimeoutFactor;
|
|
7
|
+
var _browserTypes = require("../constants/browserTypes");
|
|
8
|
+
function getBrowserTimeoutFactor(projectName) {
|
|
9
|
+
if (projectName === _browserTypes.BROWSER_PROJECT_MAPPING.FIREFOX) {
|
|
10
|
+
return 2;
|
|
11
|
+
}
|
|
12
|
+
if (projectName === _browserTypes.BROWSER_PROJECT_MAPPING.SAFARI) {
|
|
13
|
+
return 4;
|
|
14
|
+
}
|
|
15
|
+
return 1;
|
|
16
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TIMEOUT_TAG_PATTERN = void 0;
|
|
7
|
+
exports.findTimeoutTags = findTimeoutTags;
|
|
8
|
+
exports.parseTimeoutSeconds = parseTimeoutSeconds;
|
|
9
|
+
exports.resolveCaseTimeoutMs = resolveCaseTimeoutMs;
|
|
10
|
+
var _logger = require("../../../utils/logger");
|
|
11
|
+
var _browserTimeoutFactor = require("./browserTimeoutFactor");
|
|
12
|
+
const TIMEOUT_TAG_PATTERN = exports.TIMEOUT_TAG_PATTERN = /^@timeout_(\d+)$/;
|
|
13
|
+
function findTimeoutTags(tags) {
|
|
14
|
+
if (!Array.isArray(tags)) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
return tags.filter(tag => typeof tag === 'string' && TIMEOUT_TAG_PATTERN.test(tag));
|
|
18
|
+
}
|
|
19
|
+
function parseTimeoutSeconds(tag) {
|
|
20
|
+
const match = tag.match(TIMEOUT_TAG_PATTERN);
|
|
21
|
+
return match ? Number(match[1]) : null;
|
|
22
|
+
}
|
|
23
|
+
function resolveCaseTimeoutMs(tags, projectName) {
|
|
24
|
+
const matched = findTimeoutTags(tags);
|
|
25
|
+
if (matched.length === 0) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (matched.length > 1) {
|
|
29
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Multiple @timeout_* tags found (${matched.join(', ')}). Using the first one: ${matched[0]}`);
|
|
30
|
+
}
|
|
31
|
+
const seconds = parseTimeoutSeconds(matched[0]);
|
|
32
|
+
if (seconds === 0) {
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
const factor = (0, _browserTimeoutFactor.getBrowserTimeoutFactor)(projectName);
|
|
36
|
+
return seconds * 1000 * factor;
|
|
37
|
+
}
|
|
@@ -105,7 +105,7 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
105
105
|
* @property {any} reportPath : directory where report is generate
|
|
106
106
|
* @property {boolean} bddMode: Feature files needs to be processed
|
|
107
107
|
* @property {number} expectTimeout: time in milliseconds which the expect condition should fail
|
|
108
|
-
* @property {number} testTimeout: time in milliseconds which the test should fail
|
|
108
|
+
* @property {number} testTimeout: time in milliseconds which the test should fail. Can be overridden per-scenario by tagging the scenario with `@timeout_<seconds>` (e.g. `@timeout_180`). `@timeout_0` disables the timeout. Browser scaling (Firefox 2x, Safari 4x) is preserved.
|
|
109
109
|
* @property {Object} additionalPages: custom pages configuration
|
|
110
110
|
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
111
111
|
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
@@ -15,6 +15,7 @@ var _readConfigFile = require("../readConfigFile");
|
|
|
15
15
|
var _playwrightBdd = require("playwright-bdd");
|
|
16
16
|
var _logger = require("../../../utils/logger");
|
|
17
17
|
var _browserTypes = require("../constants/browserTypes");
|
|
18
|
+
var _browserTimeoutFactor = require("../helpers/browserTimeoutFactor");
|
|
18
19
|
var _fileUtils = require("../../../utils/fileUtils");
|
|
19
20
|
var _ConfigurationHelper = require("../configuration/ConfigurationHelper");
|
|
20
21
|
var _configConstants = _interopRequireDefault(require("../constants/configConstants"));
|
|
@@ -69,11 +70,12 @@ function getBrowserConfig({
|
|
|
69
70
|
dependencies
|
|
70
71
|
};
|
|
71
72
|
} else if (browser === 'firefox') {
|
|
73
|
+
const factor = (0, _browserTimeoutFactor.getBrowserTimeoutFactor)(_browserTypes.BROWSER_PROJECT_MAPPING.FIREFOX);
|
|
72
74
|
return {
|
|
73
75
|
name: _browserTypes.BROWSER_PROJECT_MAPPING.FIREFOX,
|
|
74
|
-
timeout:
|
|
76
|
+
timeout: factor * testTimeout,
|
|
75
77
|
expect: {
|
|
76
|
-
timeout:
|
|
78
|
+
timeout: factor * expectTimeout
|
|
77
79
|
},
|
|
78
80
|
use: {
|
|
79
81
|
..._test.devices['Desktop Firefox'],
|
|
@@ -82,11 +84,12 @@ function getBrowserConfig({
|
|
|
82
84
|
dependencies
|
|
83
85
|
};
|
|
84
86
|
} else if (browser === 'safari') {
|
|
87
|
+
const factor = (0, _browserTimeoutFactor.getBrowserTimeoutFactor)(_browserTypes.BROWSER_PROJECT_MAPPING.SAFARI);
|
|
85
88
|
return {
|
|
86
89
|
name: _browserTypes.BROWSER_PROJECT_MAPPING.SAFARI,
|
|
87
|
-
timeout:
|
|
90
|
+
timeout: factor * testTimeout,
|
|
88
91
|
expect: {
|
|
89
|
-
timeout:
|
|
92
|
+
timeout: factor * expectTimeout
|
|
90
93
|
},
|
|
91
94
|
use: {
|
|
92
95
|
..._test.devices['Desktop Safari'],
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* @property {any} reportPath : directory where report is generate
|
|
32
32
|
* @property {boolean} bddMode: Feature files needs to be processed
|
|
33
33
|
* @property {number} expectTimeout: time in milliseconds which the expect condition should fail
|
|
34
|
-
* @property {number} testTimeout: time in milliseconds which the test should fail
|
|
34
|
+
* @property {number} testTimeout: time in milliseconds which the test should fail. Can be overridden per-scenario by tagging the scenario with `@timeout_<seconds>` (e.g. `@timeout_180`). `@timeout_0` disables the timeout. Browser scaling (Firefox 2x, Safari 4x) is preserved.
|
|
35
35
|
* @property {Object} additionalPages: custom pages configuration
|
|
36
36
|
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
37
37
|
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
@@ -19,7 +19,7 @@ const testSetup = require('../../fixtures/testSetup');
|
|
|
19
19
|
* @property {any} reportPath : directory where report is generate
|
|
20
20
|
* @property {boolean} bddMode: Feature files needs to be processed
|
|
21
21
|
* @property {number} expectTimeout: time in milliseconds which the expect condition should fail
|
|
22
|
-
* @property {number} testTimeout: time in milliseconds which the test should fail
|
|
22
|
+
* @property {number} testTimeout: time in milliseconds which the test should fail. Can be overridden per-scenario by tagging the scenario with `@timeout_<seconds>` (e.g. `@timeout_180`). `@timeout_0` disables the timeout. Browser scaling (Firefox 2x, Safari 4x) is preserved.
|
|
23
23
|
* @property {Object} additionalPages: custom pages configuration
|
|
24
24
|
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
25
25
|
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _caseTimeout = _interopRequireDefault(require("../../../../../core/playwright/builtInFixtures/caseTimeout"));
|
|
5
|
+
var _caseTimeoutResolver = require("../../../../../core/playwright/helpers/caseTimeoutResolver");
|
|
6
|
+
var _browserTypes = require("../../../../../core/playwright/constants/browserTypes");
|
|
7
|
+
var _logger = require("../../../../../utils/logger");
|
|
8
|
+
jest.mock('../../../../../utils/logger');
|
|
9
|
+
describe('resolveCaseTimeoutMs', () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
jest.clearAllMocks();
|
|
12
|
+
});
|
|
13
|
+
test('returns null when no timeout tag is present', () => {
|
|
14
|
+
expect((0, _caseTimeoutResolver.resolveCaseTimeoutMs)(['@smoke', '@edition_Free'], _browserTypes.BROWSER_PROJECT_MAPPING.CHROME)).toBeNull();
|
|
15
|
+
});
|
|
16
|
+
test('returns null when tags is not an array', () => {
|
|
17
|
+
expect((0, _caseTimeoutResolver.resolveCaseTimeoutMs)(undefined, _browserTypes.BROWSER_PROJECT_MAPPING.CHROME)).toBeNull();
|
|
18
|
+
expect((0, _caseTimeoutResolver.resolveCaseTimeoutMs)(null, _browserTypes.BROWSER_PROJECT_MAPPING.CHROME)).toBeNull();
|
|
19
|
+
});
|
|
20
|
+
test('parses @timeout_<n> as seconds for Chrome (factor 1)', () => {
|
|
21
|
+
expect((0, _caseTimeoutResolver.resolveCaseTimeoutMs)(['@timeout_180'], _browserTypes.BROWSER_PROJECT_MAPPING.CHROME)).toBe(180000);
|
|
22
|
+
});
|
|
23
|
+
test('applies Firefox 2x multiplier', () => {
|
|
24
|
+
expect((0, _caseTimeoutResolver.resolveCaseTimeoutMs)(['@timeout_180'], _browserTypes.BROWSER_PROJECT_MAPPING.FIREFOX)).toBe(360000);
|
|
25
|
+
});
|
|
26
|
+
test('returns 0 (no timeout) when tag is @timeout_0, regardless of browser', () => {
|
|
27
|
+
expect((0, _caseTimeoutResolver.resolveCaseTimeoutMs)(['@timeout_0'], _browserTypes.BROWSER_PROJECT_MAPPING.CHROME)).toBe(0);
|
|
28
|
+
expect((0, _caseTimeoutResolver.resolveCaseTimeoutMs)(['@timeout_0'], _browserTypes.BROWSER_PROJECT_MAPPING.FIREFOX)).toBe(0);
|
|
29
|
+
expect((0, _caseTimeoutResolver.resolveCaseTimeoutMs)(['@timeout_0'], _browserTypes.BROWSER_PROJECT_MAPPING.SAFARI)).toBe(0);
|
|
30
|
+
});
|
|
31
|
+
test('uses the first matching tag and logs a warning when multiple are present', () => {
|
|
32
|
+
const result = (0, _caseTimeoutResolver.resolveCaseTimeoutMs)(['@timeout_120', '@timeout_300'], _browserTypes.BROWSER_PROJECT_MAPPING.CHROME);
|
|
33
|
+
expect(result).toBe(120_000);
|
|
34
|
+
expect(_logger.Logger.log).toHaveBeenCalledWith(_logger.Logger.INFO_TYPE, expect.stringContaining('Multiple @timeout_* tags found'));
|
|
35
|
+
});
|
|
36
|
+
test('ignores malformed timeout-like tags', () => {
|
|
37
|
+
expect((0, _caseTimeoutResolver.resolveCaseTimeoutMs)(['@timeout_', '@timeout_abc', '@timeout_-5', '@timeoutfoo'], _browserTypes.BROWSER_PROJECT_MAPPING.CHROME)).toBeNull();
|
|
38
|
+
});
|
|
39
|
+
test('ignores non-string entries in tags', () => {
|
|
40
|
+
expect((0, _caseTimeoutResolver.resolveCaseTimeoutMs)(['@timeout_60', null, undefined, 42], _browserTypes.BROWSER_PROJECT_MAPPING.CHROME)).toBe(60_000);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
describe('caseTimeout fixture', () => {
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
jest.clearAllMocks();
|
|
46
|
+
});
|
|
47
|
+
function getFixture() {
|
|
48
|
+
return _caseTimeout.default.caseTimeout[0];
|
|
49
|
+
}
|
|
50
|
+
test('is registered as an auto fixture', () => {
|
|
51
|
+
expect(_caseTimeout.default.caseTimeout[1]).toEqual({
|
|
52
|
+
auto: true
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
test('calls testInfo.setTimeout with scaled value when tag matches', async () => {
|
|
56
|
+
const use = jest.fn();
|
|
57
|
+
const testInfo = {
|
|
58
|
+
project: {
|
|
59
|
+
name: _browserTypes.BROWSER_PROJECT_MAPPING.FIREFOX
|
|
60
|
+
},
|
|
61
|
+
setTimeout: jest.fn()
|
|
62
|
+
};
|
|
63
|
+
await getFixture()({
|
|
64
|
+
$tags: ['@timeout_30']
|
|
65
|
+
}, use, testInfo);
|
|
66
|
+
expect(testInfo.setTimeout).toHaveBeenCalledWith(60_000);
|
|
67
|
+
expect(use).toHaveBeenCalled();
|
|
68
|
+
});
|
|
69
|
+
test('does not call testInfo.setTimeout when no tag is present', async () => {
|
|
70
|
+
const use = jest.fn();
|
|
71
|
+
const testInfo = {
|
|
72
|
+
project: {
|
|
73
|
+
name: _browserTypes.BROWSER_PROJECT_MAPPING.CHROME
|
|
74
|
+
},
|
|
75
|
+
setTimeout: jest.fn()
|
|
76
|
+
};
|
|
77
|
+
await getFixture()({
|
|
78
|
+
$tags: ['@smoke']
|
|
79
|
+
}, use, testInfo);
|
|
80
|
+
expect(testInfo.setTimeout).not.toHaveBeenCalled();
|
|
81
|
+
expect(use).toHaveBeenCalled();
|
|
82
|
+
});
|
|
83
|
+
test('passes 0 through to testInfo.setTimeout for @timeout_0', async () => {
|
|
84
|
+
const use = jest.fn();
|
|
85
|
+
const testInfo = {
|
|
86
|
+
project: {
|
|
87
|
+
name: _browserTypes.BROWSER_PROJECT_MAPPING.SAFARI
|
|
88
|
+
},
|
|
89
|
+
setTimeout: jest.fn()
|
|
90
|
+
};
|
|
91
|
+
await getFixture()({
|
|
92
|
+
$tags: ['@timeout_0']
|
|
93
|
+
}, use, testInfo);
|
|
94
|
+
expect(testInfo.setTimeout).toHaveBeenCalledWith(0);
|
|
95
|
+
});
|
|
96
|
+
});
|