@zohodesk/testinglibrary 0.0.3-n20-experimental → 0.0.4-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/.babelrc +2 -1
- package/.gitlab-ci.yml +13 -1
- package/README.md +72 -2
- package/build/common/data-generator/steps/DataGenerator.spec.js +19 -0
- package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +19 -0
- package/build/common/multi-actor/steps/multiActorHandling.spec.js +26 -0
- package/build/common/searchFake/helpers/rpcRequestHelper.js +41 -0
- package/build/common/searchFake/steps/searchFake.spec.js +26 -0
- package/build/core/dataGenerator/DataGenerator.js +94 -0
- package/build/core/dataGenerator/DataGeneratorHelper.js +49 -0
- package/build/core/playwright/builtInFixtures/actorContext.js +75 -0
- package/build/core/playwright/builtInFixtures/executionContext.js +5 -5
- package/build/core/playwright/builtInFixtures/index.js +2 -0
- package/build/core/playwright/builtInFixtures/page.js +3 -66
- package/build/core/playwright/helpers/additionalProfiles.js +12 -5
- package/build/core/playwright/helpers/auth/loginDefaultStepsHelper.js +54 -0
- package/build/core/playwright/helpers/customFixturesHelper.js +58 -0
- package/build/core/playwright/runner/SpawnRunner.js +3 -0
- package/build/core/playwright/setup/config-creator.js +20 -16
- package/build/core/playwright/setup/config-utils.js +2 -3
- package/build/core/playwright/setup/qc-custom-reporter.js +1 -1
- package/build/core/playwright/test-runner.js +1 -1
- package/build/setup-folder-structure/samples/settings.json +1 -1
- package/build/test/core/playwright/buildInFixtures/__tests__/executionContext.test.js +6 -6
- package/build/test/core/playwright/helpers/__tests__/additionalProfiles.test.js +45 -0
- package/build/test/core/playwright/helpers/__tests__/customFixturesHelper.test.js +51 -0
- package/build/utils/commonUtils.js +17 -0
- package/build/utils/fileUtils.js +20 -0
- package/build/utils/logger.js +0 -29
- package/npm-shrinkwrap.json +1964 -2743
- package/package.json +20 -19
- package/test-results/.last-run.json +4 -0
- package/unit_reports/unit-report.html +260 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.executeDefaultLoginSteps = executeDefaultLoginSteps;
|
|
7
|
+
exports.loginSteps = loginSteps;
|
|
8
|
+
exports.performDefaultPageSteps = performDefaultPageSteps;
|
|
9
|
+
exports.verifyPageIsLoaded = verifyPageIsLoaded;
|
|
10
|
+
var _auth = require("../auth");
|
|
11
|
+
var _readConfigFile = require("../../readConfigFile");
|
|
12
|
+
var _logger = require("../../../../utils/logger");
|
|
13
|
+
let {
|
|
14
|
+
testSetup,
|
|
15
|
+
isAuthMode
|
|
16
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
17
|
+
async function loginSteps(pageDetail) {
|
|
18
|
+
const {
|
|
19
|
+
page
|
|
20
|
+
} = pageDetail;
|
|
21
|
+
if (testSetup.loginSteps && typeof testSetup.loginSteps === 'function') {
|
|
22
|
+
return await testSetup.loginSteps(pageDetail);
|
|
23
|
+
} else {
|
|
24
|
+
await page.goto(process.env.domain);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function performDefaultPageSteps(testInfo) {
|
|
28
|
+
if (testSetup.page && typeof testSetup.page === 'function') {
|
|
29
|
+
await testSetup.page(testInfo);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function verifyPageIsLoaded(testInfo) {
|
|
33
|
+
if (testSetup.validateLogin && typeof testSetup.validateLogin === 'function') {
|
|
34
|
+
return await testSetup.validateLogin(testInfo);
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
async function executeDefaultLoginSteps(context, testInfo, testDetails, testPortalDetails) {
|
|
39
|
+
if (!isAuthMode) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const projectName = testInfo.project.name;
|
|
44
|
+
if (testPortalDetails && projectName !== 'setup' && projectName !== 'cleanup') {
|
|
45
|
+
await context.clearCookies();
|
|
46
|
+
await (0, _auth.performLoginSteps)(testDetails, async testInfo => {
|
|
47
|
+
return await verifyPageIsLoaded(testInfo);
|
|
48
|
+
}, loginSteps);
|
|
49
|
+
process.env.actorInfo = JSON.stringify(testPortalDetails);
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Error while executing the default login steps:', error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.extractTagInfo = extractTagInfo;
|
|
7
|
+
exports.getCustomAccountDetails = getCustomAccountDetails;
|
|
8
|
+
var _auth = require("../helpers/auth");
|
|
9
|
+
var _logger = require("../../../utils/logger");
|
|
10
|
+
/* eslint-disable global-require */
|
|
11
|
+
|
|
12
|
+
function getTagInputFromSelectedTags(tags, inputString) {
|
|
13
|
+
const selectedTag = [...tags].reverse().find(tag => tag.startsWith(inputString));
|
|
14
|
+
let tagInput = null;
|
|
15
|
+
if (selectedTag) {
|
|
16
|
+
tagInput = selectedTag.split(`${inputString}_`).pop().toLowerCase();
|
|
17
|
+
}
|
|
18
|
+
return tagInput;
|
|
19
|
+
}
|
|
20
|
+
function extractTagInfo(tags) {
|
|
21
|
+
const tagsTobeFiltered = ['@profile', '@edition', '@beta', '@portal'];
|
|
22
|
+
const filteredTags = tags.filter(tag => tagsTobeFiltered.some(prefix => tag.startsWith(prefix)));
|
|
23
|
+
if (!filteredTags.length) {
|
|
24
|
+
return {
|
|
25
|
+
portalInfo: null,
|
|
26
|
+
betaFeature: null,
|
|
27
|
+
profileInfo: null,
|
|
28
|
+
editionInfo: null
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const portalInfo = getTagInputFromSelectedTags(filteredTags, '@portal');
|
|
32
|
+
const betaFeature = getTagInputFromSelectedTags(filteredTags, '@beta');
|
|
33
|
+
const profileInfo = getTagInputFromSelectedTags(filteredTags, '@profile');
|
|
34
|
+
const editionInfo = getTagInputFromSelectedTags(filteredTags, '@edition');
|
|
35
|
+
return {
|
|
36
|
+
portalInfo,
|
|
37
|
+
betaFeature,
|
|
38
|
+
profileInfo,
|
|
39
|
+
editionInfo
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function getCustomAccountDetails(tags) {
|
|
43
|
+
try {
|
|
44
|
+
const {
|
|
45
|
+
portalInfo,
|
|
46
|
+
betaFeature,
|
|
47
|
+
profileInfo,
|
|
48
|
+
editionInfo
|
|
49
|
+
} = extractTagInfo(tags);
|
|
50
|
+
if (portalInfo || betaFeature || profileInfo || editionInfo) {
|
|
51
|
+
const user = (0, _auth.getUserForSelectedEditionAndProfile)(editionInfo, profileInfo, betaFeature, portalInfo);
|
|
52
|
+
return user;
|
|
53
|
+
}
|
|
54
|
+
return (0, _auth.getDefaultActor)();
|
|
55
|
+
} catch (err) {
|
|
56
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Error while getting accounts details:', err);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -8,6 +8,7 @@ var _logger = require("../../../utils/logger");
|
|
|
8
8
|
var _child_process = require("child_process");
|
|
9
9
|
var _RunnerHelper = _interopRequireDefault(require("./RunnerHelper"));
|
|
10
10
|
var _Runner = _interopRequireDefault(require("./Runner"));
|
|
11
|
+
var _commonUtils = require("../../../utils/commonUtils");
|
|
11
12
|
class SpawnRunner extends _Runner.default {
|
|
12
13
|
constructor(runnerObj) {
|
|
13
14
|
super(runnerObj);
|
|
@@ -30,6 +31,8 @@ class SpawnRunner extends _Runner.default {
|
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
runPreprocessing() {
|
|
34
|
+
//This below functoin is called to copy the data generator spec files to the current project
|
|
35
|
+
(0, _commonUtils.copyCommonSpecs)();
|
|
33
36
|
const {
|
|
34
37
|
tagArgs
|
|
35
38
|
} = this.runnerObj;
|
|
@@ -44,12 +44,6 @@ const testDir = (0, _configUtils.getTestDir)(bddMode, {
|
|
|
44
44
|
outputDir: _path.default.join(process.cwd(), 'uat', '.features-gen'),
|
|
45
45
|
uatPath: _path.default.join(process.cwd(), 'uat')
|
|
46
46
|
});
|
|
47
|
-
const smokeTestDir = (0, _configUtils.getTestDir)(bddMode, {
|
|
48
|
-
featureFilesFolder: _path.default.join(process.cwd(), 'uat', 'smokeTest', '**', '*.feature'),
|
|
49
|
-
stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', 'smokeTest', '**', '*smokeTest.spec.js'),
|
|
50
|
-
outputDir: _path.default.join(process.cwd(), 'uat', '.features-smoke-gen'),
|
|
51
|
-
uatPath: _path.default.join(process.cwd(), 'uat')
|
|
52
|
-
});
|
|
53
47
|
const use = {
|
|
54
48
|
trace,
|
|
55
49
|
video,
|
|
@@ -77,14 +71,24 @@ function getPlaywrightConfig() {
|
|
|
77
71
|
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
|
|
78
72
|
};
|
|
79
73
|
const dependencies = isAuthMode ? ['setup'] : [];
|
|
80
|
-
const smokeTestProject =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
const smokeTestProject = isSmokeTest ? smokeTestConfig() : [];
|
|
75
|
+
function smokeTestConfig() {
|
|
76
|
+
const smokeTestDir = (0, _configUtils.getTestDir)(bddMode, {
|
|
77
|
+
featureFilesFolder: _path.default.join(process.cwd(), 'uat', 'smokeTest', '**', '*.feature'),
|
|
78
|
+
stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
|
|
79
|
+
outputDir: _path.default.join(process.cwd(), 'uat', '.features-smoke-gen'),
|
|
80
|
+
uatPath: _path.default.join(process.cwd(), 'uat', 'smokeTest')
|
|
81
|
+
});
|
|
82
|
+
return [{
|
|
83
|
+
name: 'smokeTest',
|
|
84
|
+
testDir: smokeTestDir,
|
|
85
|
+
use: {
|
|
86
|
+
...commonConfig
|
|
87
|
+
},
|
|
88
|
+
dependencies: dependencies,
|
|
89
|
+
retries: 0
|
|
90
|
+
}];
|
|
91
|
+
}
|
|
88
92
|
const playwrightConfig = {
|
|
89
93
|
testDir,
|
|
90
94
|
globalTimeout: globalTimeout || 3600000,
|
|
@@ -101,11 +105,11 @@ function getPlaywrightConfig() {
|
|
|
101
105
|
testMatch: /.*\.setup\.js/,
|
|
102
106
|
testDir: _path.default.join(process.cwd(), 'uat'),
|
|
103
107
|
teardown: 'cleanup'
|
|
104
|
-
}, ...
|
|
108
|
+
}, ...smokeTestProject, {
|
|
105
109
|
name: 'cleanup',
|
|
106
110
|
testMatch: /.*\.teardown\.js/,
|
|
107
111
|
testDir: _path.default.join(process.cwd(), 'uat')
|
|
108
|
-
}, ...projects] : [...projects, ...
|
|
112
|
+
}, ...projects] : [...projects, ...smokeTestProject],
|
|
109
113
|
...uatConfig
|
|
110
114
|
};
|
|
111
115
|
return playwrightConfig;
|
|
@@ -153,7 +153,7 @@ function getPathsForFeatureFiles(cwd) {
|
|
|
153
153
|
let moduleList = modules.split(',');
|
|
154
154
|
return getModulePathForFeatureFiles(moduleList);
|
|
155
155
|
}
|
|
156
|
-
return [_path.default.join(cwd, 'uat', '**', '*.feature')];
|
|
156
|
+
return [_path.default.join(cwd, 'uat', 'modules', '**', '*.feature')];
|
|
157
157
|
}
|
|
158
158
|
function getModulePathForFeatureFiles(moduleList) {
|
|
159
159
|
let validModuleList = [];
|
|
@@ -162,9 +162,8 @@ function getModulePathForFeatureFiles(moduleList) {
|
|
|
162
162
|
if ((0, _fileUtils.checkIfFolderExistsWithPattern)(modulePath)) {
|
|
163
163
|
validModuleList.push(_path.default.join(modulePath, '**', '*.feature'));
|
|
164
164
|
} else {
|
|
165
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Module ${moduleName} does not exist, Please check the module name`);
|
|
166
165
|
validModuleList = [];
|
|
167
|
-
|
|
166
|
+
throw new Error(`Module ${moduleName} does not exist. We have not triggered the execution for this module`);
|
|
168
167
|
}
|
|
169
168
|
});
|
|
170
169
|
return validModuleList;
|
|
@@ -102,6 +102,7 @@ const createSpecEntry = (rootDir, test, testResultsById) => ({
|
|
|
102
102
|
...(test.location && {
|
|
103
103
|
snippet: formSnippet(test.location)
|
|
104
104
|
}),
|
|
105
|
+
tags: test.tags,
|
|
105
106
|
tests: [extractTestDetails(test, testResultsById)]
|
|
106
107
|
});
|
|
107
108
|
const extractTestDetails = (test, testResultsById) => {
|
|
@@ -112,7 +113,6 @@ const extractTestDetails = (test, testResultsById) => {
|
|
|
112
113
|
expectedStatus: test.expectedStatus,
|
|
113
114
|
timeout: test.timeout,
|
|
114
115
|
retries: test.retries,
|
|
115
|
-
tags: test.tags,
|
|
116
116
|
results: testResultsById.get(key) ?? [],
|
|
117
117
|
status: test.outcome()
|
|
118
118
|
};
|
|
@@ -105,7 +105,7 @@ function main() {
|
|
|
105
105
|
//This is only used for pass the user arguments to need places in legacy code. We need to rewamp that also.
|
|
106
106
|
const userArgsObject = userArgConfig.getAll();
|
|
107
107
|
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
108
|
-
const tagArgs = tagProcessor.processTags(
|
|
108
|
+
const tagArgs = tagProcessor.processTags(uatConfig.getAll());
|
|
109
109
|
const runnerObj = new _Runner.default();
|
|
110
110
|
runnerObj.setTagArgs(tagArgs);
|
|
111
111
|
runnerObj.setUserArgs(userArgsObject);
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var
|
|
4
|
+
var _customFixturesHelper = require("../../../../../core/playwright/helpers/customFixturesHelper");
|
|
5
5
|
var _executionContext = _interopRequireDefault(require("../../../../../core/playwright/builtInFixtures/executionContext"));
|
|
6
|
-
jest.mock('../../../../../core/playwright/
|
|
6
|
+
jest.mock('../../../../../core/playwright/helpers/customFixturesHelper');
|
|
7
7
|
describe('executionContext', () => {
|
|
8
8
|
test('should pass actorInfo with details from getCustomAccountDetails to use', async () => {
|
|
9
9
|
const mockTags = ['tag1', 'tag2'];
|
|
10
|
-
const
|
|
10
|
+
const mockMainActorInfo = {
|
|
11
11
|
id: '1',
|
|
12
12
|
edition: 'enterprise',
|
|
13
13
|
orgName: 'orgName',
|
|
14
14
|
profile: 'admin',
|
|
15
15
|
email: 'xxx.x+uat@zohotest.com'
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
_customFixturesHelper.getCustomAccountDetails.mockReturnValue(mockMainActorInfo);
|
|
18
18
|
const use = jest.fn();
|
|
19
19
|
await _executionContext.default.executionContext({
|
|
20
20
|
$tags: mockTags
|
|
21
21
|
}, use);
|
|
22
|
-
expect(
|
|
22
|
+
expect(_customFixturesHelper.getCustomAccountDetails).toHaveBeenCalledWith(mockTags);
|
|
23
23
|
expect(use).toHaveBeenCalledWith({
|
|
24
|
-
actorInfo:
|
|
24
|
+
actorInfo: mockMainActorInfo
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
27
|
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _additionalProfiles = require("../../../../../core/playwright/helpers/additionalProfiles");
|
|
4
|
+
jest.mock('../../../../../core/playwright/helpers/auth/getUsers', () => ({
|
|
5
|
+
getUserForSelectedEditionAndProfile: jest.fn((edition, profile, betaFeature, portalInfo) => {
|
|
6
|
+
return {
|
|
7
|
+
email: 'manager.m@zohotest.com',
|
|
8
|
+
id: '1',
|
|
9
|
+
edition: edition || 'enterprise',
|
|
10
|
+
orgName: 'orgName',
|
|
11
|
+
profile: profile || 'admin',
|
|
12
|
+
betaFeature: betaFeature || null,
|
|
13
|
+
portalInfo: portalInfo || null
|
|
14
|
+
};
|
|
15
|
+
})
|
|
16
|
+
}));
|
|
17
|
+
const defaultTags = ['@profile_admin', '@edition_enterprise'];
|
|
18
|
+
const editionTags = ['@profile_admin', '@edition_enterprise', '@additional_profile_manager', '@additional_profile_agent'];
|
|
19
|
+
const editionAndPortalTags = ['@profile_admin', '@edition_enterprise', '@beta_parentchild', '@portal_clientuat2', '@additional_profile_manager'];
|
|
20
|
+
describe('additionalProfiles', () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
jest.clearAllMocks();
|
|
23
|
+
});
|
|
24
|
+
test('should return empty object when no additional profile tags are present', () => {
|
|
25
|
+
const result = (0, _additionalProfiles.additionProfiles)(defaultTags);
|
|
26
|
+
expect(result).toEqual({});
|
|
27
|
+
});
|
|
28
|
+
test('should return additional profile actors when additional profile tags and editionInfo are present', () => {
|
|
29
|
+
const result = (0, _additionalProfiles.additionProfiles)(editionTags);
|
|
30
|
+
expect(Object.keys(result)).toEqual(['manager', 'agent']);
|
|
31
|
+
expect(result.manager).toHaveProperty('email');
|
|
32
|
+
expect(result.agent).toHaveProperty('email');
|
|
33
|
+
expect(result.manager.profile).toBe('manager');
|
|
34
|
+
expect(result.manager.betaFeature).toBe(null);
|
|
35
|
+
expect(result.agent.portalInfo).toBe(null);
|
|
36
|
+
});
|
|
37
|
+
test('should return additional profile actors when all actor details are present', () => {
|
|
38
|
+
const result = (0, _additionalProfiles.additionProfiles)(editionAndPortalTags);
|
|
39
|
+
expect(Object.keys(result)).toEqual(['manager']);
|
|
40
|
+
expect(result.manager).toHaveProperty('email');
|
|
41
|
+
expect(result.manager.profile).toBe('manager');
|
|
42
|
+
expect(result.manager.betaFeature).toBe("parentchild");
|
|
43
|
+
expect(result.manager.portalInfo).toBe("clientuat2");
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _customFixturesHelper = require("../../../../../core/playwright/helpers/customFixturesHelper");
|
|
4
|
+
var _logger = require("../../../../../utils/logger");
|
|
5
|
+
var _getUsers = require("../../../../../core/playwright/helpers/auth/getUsers");
|
|
6
|
+
jest.mock('../../../../../core/playwright/helpers/auth/getUsers', () => ({
|
|
7
|
+
getUserForSelectedEditionAndProfile: jest.fn((edition, profile, betaFeature, portalInfo) => ({
|
|
8
|
+
email: 'manager.m@zohotest.com',
|
|
9
|
+
id: '1',
|
|
10
|
+
edition: edition || 'enterprise',
|
|
11
|
+
orgName: 'orgName',
|
|
12
|
+
profile: profile || 'admin',
|
|
13
|
+
betaFeature: betaFeature || null,
|
|
14
|
+
portalInfo: portalInfo || null
|
|
15
|
+
})),
|
|
16
|
+
getDefaultActor: jest.fn(() => ({
|
|
17
|
+
edition: 'enterprise',
|
|
18
|
+
profile: 'admin'
|
|
19
|
+
}))
|
|
20
|
+
}));
|
|
21
|
+
jest.mock('../../../../../utils/logger', () => ({
|
|
22
|
+
Logger: {
|
|
23
|
+
log: jest.fn(),
|
|
24
|
+
FAILURE_TYPE: 'FAILURE'
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
27
|
+
const mockTags = ['@profile_admin', '@edition_enterprise', '@beta_feature', '@portal_clientuat'];
|
|
28
|
+
describe('getCustomAccountDetails', () => {
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
jest.clearAllMocks();
|
|
31
|
+
});
|
|
32
|
+
test('returns selected user when any tag info is present', () => {
|
|
33
|
+
const result = (0, _customFixturesHelper.getCustomAccountDetails)(mockTags);
|
|
34
|
+
expect(_getUsers.getUserForSelectedEditionAndProfile).toHaveBeenCalledWith('enterprise', 'admin', 'feature', 'clientuat');
|
|
35
|
+
expect(result).toHaveProperty('email', 'manager.m@zohotest.com');
|
|
36
|
+
});
|
|
37
|
+
test('logs and returns undefined if getCustomAccountDetails function throws', () => {
|
|
38
|
+
const error = new Error('failed to get user');
|
|
39
|
+
_getUsers.getUserForSelectedEditionAndProfile.mockImplementation(() => {
|
|
40
|
+
throw error;
|
|
41
|
+
});
|
|
42
|
+
const result = (0, _customFixturesHelper.getCustomAccountDetails)(mockTags);
|
|
43
|
+
expect(_logger.Logger.log).toHaveBeenCalledWith(_logger.Logger.FAILURE_TYPE, 'Error while getting accounts details:', error);
|
|
44
|
+
expect(result).toBeUndefined();
|
|
45
|
+
});
|
|
46
|
+
test('returns default actor when no tag info is not provided', () => {
|
|
47
|
+
const result = (0, _customFixturesHelper.getCustomAccountDetails)([]);
|
|
48
|
+
expect(_getUsers.getDefaultActor).toHaveBeenCalledTimes(1);
|
|
49
|
+
expect(result).toEqual((0, _getUsers.getDefaultActor)());
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.copyCommonSpecs = copyCommonSpecs;
|
|
8
|
+
var _fileUtils = require("./fileUtils");
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
function copyCommonSpecs() {
|
|
11
|
+
const libraryPath = require.resolve("@zohodesk/testinglibrary");
|
|
12
|
+
// libraryPath will be build/index.js to go to the common specs we need to go one level up
|
|
13
|
+
const commonSpecPath = _path.default.resolve(libraryPath, '../', 'common');
|
|
14
|
+
const destDirectory = _path.default.resolve(process.cwd(), 'uat', 'modules', '.testingLib-common');
|
|
15
|
+
(0, _fileUtils.deleteFolder)(destDirectory);
|
|
16
|
+
(0, _fileUtils.copyDirectory)(commonSpecPath, destDirectory);
|
|
17
|
+
}
|
package/build/utils/fileUtils.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.checkIfFileExists = checkIfFileExists;
|
|
8
8
|
exports.checkIfFolderExistsWithPattern = checkIfFolderExistsWithPattern;
|
|
9
|
+
exports.copyDirectory = copyDirectory;
|
|
9
10
|
exports.deleteFile = deleteFile;
|
|
10
11
|
exports.deleteFolder = deleteFolder;
|
|
11
12
|
exports.readFileContents = readFileContents;
|
|
@@ -86,4 +87,23 @@ function checkIfFolderExistsWithPattern(folderPath) {
|
|
|
86
87
|
_logger.Logger.error(err);
|
|
87
88
|
return false;
|
|
88
89
|
}
|
|
90
|
+
}
|
|
91
|
+
function copyDirectory(src, dest) {
|
|
92
|
+
if (!_fs.default.existsSync(dest)) {
|
|
93
|
+
_fs.default.mkdirSync(dest, {
|
|
94
|
+
recursive: true
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const entries = _fs.default.readdirSync(src, {
|
|
98
|
+
withFileTypes: true
|
|
99
|
+
});
|
|
100
|
+
for (const entry of entries) {
|
|
101
|
+
const srcPath = _path.default.join(src, entry.name);
|
|
102
|
+
const destPath = _path.default.join(dest, entry.name);
|
|
103
|
+
if (entry.isDirectory()) {
|
|
104
|
+
copyDirectory(srcPath, destPath);
|
|
105
|
+
} else {
|
|
106
|
+
_fs.default.copyFileSync(srcPath, destPath);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
89
109
|
}
|
package/build/utils/logger.js
CHANGED
|
@@ -4,35 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Logger = void 0;
|
|
7
|
-
// const SUCCESS_TYPE = 'success';
|
|
8
|
-
// const FAILURE_TYPE = 'failure';
|
|
9
|
-
// const INFO_TYPE = 'info';
|
|
10
|
-
|
|
11
|
-
// function logger() {
|
|
12
|
-
// this.colors = {
|
|
13
|
-
// 'success': ['\x1b[36m', '\x1b[0m'],
|
|
14
|
-
// 'failure': ['\x1b[31m', '\x1b[0m'],
|
|
15
|
-
// 'info': ['\x1b[33m', '\x1b[0m']
|
|
16
|
-
// }
|
|
17
|
-
// this.consoleLogger = console;
|
|
18
|
-
// return {
|
|
19
|
-
// SUCCESS_TYPE,
|
|
20
|
-
// FAILURE_TYPE,
|
|
21
|
-
// INFO_TYPE,
|
|
22
|
-
// error: () => { },
|
|
23
|
-
// info: () => { },
|
|
24
|
-
// log: (type, message) => {
|
|
25
|
-
// const color = this.colors[type];
|
|
26
|
-
// console.log(type, color)
|
|
27
|
-
// this.consoleLogger.log(`${color[0]}${message}${color[1]}`)
|
|
28
|
-
// }
|
|
29
|
-
// }
|
|
30
|
-
// }
|
|
31
|
-
|
|
32
|
-
// module.exports = {
|
|
33
|
-
// Logger: logger()
|
|
34
|
-
// }
|
|
35
|
-
|
|
36
7
|
class LoggerImpl {
|
|
37
8
|
constructor() {
|
|
38
9
|
this.SUCCESS_TYPE = 'success';
|