@zohodesk/testinglibrary 0.4.97-n18-experimental → 0.4.99-n18-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/.gitlab-ci.yml +13 -13
- package/README.md +14 -4
- package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +1 -3
- package/build/core/dataGenerator/DataGenerator.js +9 -0
- package/build/core/playwright/configuration/ConfigurationHelper.js +7 -5
- package/build/core/playwright/constants/configFiles.js +14 -0
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/env-initializer.js +10 -9
- package/build/core/playwright/helpers/auth/getUsers.js +15 -16
- package/build/core/playwright/helpers/configFileNameProvider.js +15 -8
- package/build/core/playwright/helpers/configPathResolver.js +36 -0
- package/build/core/playwright/readConfigFile.js +4 -2
- package/build/core/playwright/setup/Project.js +35 -0
- package/build/core/playwright/setup/ProjectConfiguration.js +80 -0
- package/build/core/playwright/setup/config-creator.js +23 -51
- package/build/core/playwright/test-runner.js +6 -2
- package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +54 -13
- package/build/test/core/playwright/helpers/__tests__/configPathResolver.test.js +42 -0
- package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +29 -26
- package/npm-shrinkwrap.json +379 -271
- package/package.json +6 -3
- package/test-results/.last-run.json +4 -0
- package/unit_reports/unit-report.html +1 -1
- package/build/test/Test.js +0 -13
|
@@ -4,31 +4,72 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
var _fs = require("fs");
|
|
5
5
|
var _path = _interopRequireDefault(require("path"));
|
|
6
6
|
var _configFileNameProvider = require("../../../../../core/playwright/helpers/configFileNameProvider");
|
|
7
|
+
var _configPathResolver = require("../../../../../core/playwright/helpers/configPathResolver");
|
|
7
8
|
jest.mock('fs');
|
|
8
|
-
jest.mock('path')
|
|
9
|
+
jest.mock('path', () => ({
|
|
10
|
+
resolve: jest.fn()
|
|
11
|
+
}));
|
|
12
|
+
jest.mock("../../../../../core/playwright/helpers/configPathResolver", () => ({
|
|
13
|
+
getConfigPath: jest.fn()
|
|
14
|
+
}));
|
|
9
15
|
const mockCwd = '/mock/current/directory';
|
|
10
16
|
_path.default.resolve = jest.fn();
|
|
11
17
|
process.cwd = jest.fn(() => mockCwd);
|
|
12
18
|
describe('getUATFileName', () => {
|
|
13
19
|
beforeEach(() => {
|
|
14
20
|
jest.clearAllMocks();
|
|
21
|
+
_path.default.resolve.mockImplementation((...segments) => segments.join('/'));
|
|
15
22
|
});
|
|
16
|
-
test('return
|
|
23
|
+
test('should return pipeline-matched config path when file exists', () => {
|
|
24
|
+
const stage = 'uat';
|
|
17
25
|
const mode = 'cd';
|
|
18
|
-
|
|
26
|
+
_configPathResolver.getConfigPath.mockReturnValue(`${stage}/conf`);
|
|
19
27
|
_fs.existsSync.mockReturnValue(true);
|
|
20
|
-
|
|
21
|
-
const result = (0, _configFileNameProvider.getUATFileName)(mode);
|
|
22
|
-
expect(
|
|
23
|
-
expect(
|
|
28
|
+
const expected = `${process.cwd()}/${stage}/conf/${mode}/uat.config.js`;
|
|
29
|
+
const result = (0, _configFileNameProvider.getUATFileName)(stage, mode);
|
|
30
|
+
expect(_configPathResolver.getConfigPath).toHaveBeenCalledWith(stage);
|
|
31
|
+
expect(_fs.existsSync).toHaveBeenCalledWith(expected);
|
|
32
|
+
expect(result).toBe(expected);
|
|
24
33
|
});
|
|
25
|
-
test('
|
|
26
|
-
const mode = '
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
test('should use default stage and mode when not provided', () => {
|
|
35
|
+
const mode = 'dev';
|
|
36
|
+
const stageConfigPath = 'uat/conf';
|
|
37
|
+
const expectedPath = `${mockCwd}/${stageConfigPath}/${mode}/uat.config.js`;
|
|
38
|
+
_fs.existsSync.mockReturnValue(true);
|
|
30
39
|
const result = (0, _configFileNameProvider.getUATFileName)(mode);
|
|
31
40
|
expect(_fs.existsSync).toHaveBeenCalledWith(`${mockCwd}/uat/conf/${mode}/uat.config.js`);
|
|
32
|
-
expect(result).toBe(
|
|
41
|
+
expect(result).toBe(expectedPath);
|
|
42
|
+
});
|
|
43
|
+
test('should return the default config files for pipeline matched files not exists', () => {
|
|
44
|
+
const mockStage = 'uat';
|
|
45
|
+
const mockMode = 'ci';
|
|
46
|
+
const stageConfigPath = 'uat/conf';
|
|
47
|
+
const nonExistingPath = `${mockCwd}/${stageConfigPath}/${mockMode}/uat.config.js`;
|
|
48
|
+
const expectedDefaultPath = `${mockCwd}/${mockStage}/conf/default/uat.config.js`;
|
|
49
|
+
_configPathResolver.getConfigPath.mockReturnValue(stageConfigPath);
|
|
50
|
+
_fs.existsSync.mockReturnValue(false);
|
|
51
|
+
const result = (0, _configFileNameProvider.getUATFileName)(mockStage, mockMode);
|
|
52
|
+
expect(_fs.existsSync).toHaveBeenCalledWith(nonExistingPath);
|
|
53
|
+
expect(result).toBe(expectedDefaultPath);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('getEnvConfigFilePath', () => {
|
|
57
|
+
beforeEach(() => {
|
|
58
|
+
jest.clearAllMocks();
|
|
59
|
+
_path.default.resolve.mockImplementation((...segments) => segments.join('/'));
|
|
60
|
+
});
|
|
61
|
+
test('should return conf file path when file exists', () => {
|
|
62
|
+
_configPathResolver.getConfigPath.mockReturnValue('uat/conf');
|
|
63
|
+
_fs.existsSync.mockReturnValue(true);
|
|
64
|
+
const result = (0, _configFileNameProvider.getEnvConfigFilePath)('uat', 'cd');
|
|
65
|
+
expect(_configPathResolver.getConfigPath).toHaveBeenCalledWith('uat');
|
|
66
|
+
expect(_fs.existsSync).toHaveBeenCalled();
|
|
67
|
+
expect(result).toBe('uat/conf/cd/settings.json');
|
|
68
|
+
});
|
|
69
|
+
test('should return default path when file does not exist', () => {
|
|
70
|
+
_configPathResolver.getConfigPath.mockReturnValue('uat/conf');
|
|
71
|
+
_fs.existsSync.mockReturnValue(false);
|
|
72
|
+
const result = (0, _configFileNameProvider.getEnvConfigFilePath)('uat', 'ci');
|
|
73
|
+
expect(result).toBe('uat/conf/default/settings.json');
|
|
33
74
|
});
|
|
34
75
|
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
5
|
+
var _propertiesReader = _interopRequireDefault(require("properties-reader"));
|
|
6
|
+
var _configPathResolver = require("../../../../../core/playwright/helpers/configPathResolver");
|
|
7
|
+
var _logger = require("../../../../../utils/logger");
|
|
8
|
+
jest.mock('../../../../../utils/logger', () => ({
|
|
9
|
+
Logger: {
|
|
10
|
+
log: jest.fn(),
|
|
11
|
+
FAILURE_TYPE: 'FAILURE'
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
jest.mock('fs');
|
|
15
|
+
jest.mock('path');
|
|
16
|
+
jest.mock('properties-reader');
|
|
17
|
+
describe('getConfigPath', () => {
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
jest.clearAllMocks();
|
|
20
|
+
});
|
|
21
|
+
test('should return correct stageConfig when mapping exists', () => {
|
|
22
|
+
const mockProps = {
|
|
23
|
+
get: jest.fn(() => 'uat/conf')
|
|
24
|
+
};
|
|
25
|
+
_propertiesReader.default.mockReturnValue(mockProps);
|
|
26
|
+
_fs.default.existsSync.mockReturnValue(true);
|
|
27
|
+
const result = (0, _configPathResolver.getConfigPath)('uat');
|
|
28
|
+
expect(mockProps.get).toHaveBeenCalledWith('uat');
|
|
29
|
+
expect(result).toBe('uat/conf');
|
|
30
|
+
expect(_logger.Logger.log).not.toHaveBeenCalled();
|
|
31
|
+
});
|
|
32
|
+
test('should log failure when stage mapping does not exist', () => {
|
|
33
|
+
const mockProps = {
|
|
34
|
+
get: jest.fn(() => undefined)
|
|
35
|
+
};
|
|
36
|
+
_propertiesReader.default.mockReturnValue(mockProps);
|
|
37
|
+
_fs.default.existsSync.mockReturnValue(true);
|
|
38
|
+
const result = (0, _configPathResolver.getConfigPath)('invalidStage');
|
|
39
|
+
expect(result).toEqual(undefined);
|
|
40
|
+
expect(_logger.Logger.log).toHaveBeenCalledWith('FAILURE', 'No config mapping found for stage: "invalidStage"');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -1,80 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _fs = require("fs");
|
|
4
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
5
5
|
var _path = _interopRequireDefault(require("path"));
|
|
6
|
+
var _getUsers = require("../../../../../core/playwright/helpers/auth/getUsers");
|
|
7
|
+
var _configPathResolver = require("../../../../../core/playwright/helpers/configPathResolver");
|
|
6
8
|
jest.mock('fs');
|
|
7
9
|
jest.mock('path');
|
|
8
|
-
jest.mock('../../../../../core/playwright/
|
|
9
|
-
|
|
10
|
-
uatDirectory: '/test/directory'
|
|
11
|
-
})),
|
|
12
|
-
getRunMode: jest.fn(() => 'dev')
|
|
10
|
+
jest.mock('../../../../../core/playwright/helpers/configPathResolver', () => ({
|
|
11
|
+
getConfigPath: jest.fn()
|
|
13
12
|
}));
|
|
14
|
-
const {
|
|
15
|
-
getListOfActors
|
|
16
|
-
} = require('../../../../../core/playwright/helpers/auth/getUsers');
|
|
17
13
|
describe('getListOfActors', () => {
|
|
14
|
+
const stageConfig = 'uat/conf';
|
|
15
|
+
const mode = 'dev';
|
|
16
|
+
const stage = 'uat';
|
|
18
17
|
beforeEach(() => {
|
|
19
18
|
jest.clearAllMocks();
|
|
20
19
|
_path.default.join.mockImplementation((...args) => args.join('/'));
|
|
20
|
+
_path.default.resolve.mockImplementation((...args) => args.join('/'));
|
|
21
|
+
_configPathResolver.getConfigPath.mockReturnValue('uat/conf');
|
|
21
22
|
});
|
|
22
23
|
test('throws an error when config file cannot be loaded', () => {
|
|
23
|
-
_fs.existsSync.mockReturnValueOnce(true);
|
|
24
|
-
|
|
25
|
-
jest.mock('/test/directory/conf/dev/actors/index.js', () => {
|
|
24
|
+
_fs.default.existsSync.mockReturnValueOnce(true);
|
|
25
|
+
jest.mock('/uat/conf/dev/actors/index.js', () => {
|
|
26
26
|
throw new Error('Loading error');
|
|
27
27
|
}, {
|
|
28
28
|
virtual: true
|
|
29
29
|
});
|
|
30
|
-
expect(() => getListOfActors()).toThrow(
|
|
30
|
+
expect(() => (0, _getUsers.getListOfActors)()).toThrow(`Error loading actor configuration from ${_path.default.join(_path.default.resolve(process.cwd(), 'uat/conf/dev/actors/index.js'))}`);
|
|
31
31
|
});
|
|
32
32
|
test('throws an error when beta feature config does not exist', () => {
|
|
33
|
-
_fs.existsSync.mockReturnValueOnce(true) // Main config file exists
|
|
33
|
+
_fs.default.existsSync.mockReturnValueOnce(true) // Main config file exists
|
|
34
34
|
.mockReturnValueOnce(false); // Beta feature config does not exist in either path
|
|
35
35
|
|
|
36
36
|
const betaFeature = 'nonExistentFeature';
|
|
37
|
-
expect(() => getListOfActors(betaFeature)).toThrow(`There is no beta feature configured with the name "${betaFeature}"`);
|
|
37
|
+
expect(() => (0, _getUsers.getListOfActors)(betaFeature)).toThrow(`There is no beta feature configured with the name "${betaFeature}"`);
|
|
38
38
|
});
|
|
39
|
-
test('loads main configuration when betaFeature is not provided and main config
|
|
40
|
-
_fs.existsSync.mockReturnValueOnce(true);
|
|
41
|
-
|
|
39
|
+
test('loads main configuration when betaFeature is not provided and main config exists', () => {
|
|
40
|
+
_fs.default.existsSync.mockReturnValueOnce(true);
|
|
41
|
+
const file = _path.default.join(_path.default.resolve(process.cwd(), `${stageConfig}/${mode}/actors/index.js`));
|
|
42
|
+
jest.doMock(file, () => ({
|
|
42
43
|
actors: []
|
|
43
44
|
}), {
|
|
44
45
|
virtual: true
|
|
45
46
|
});
|
|
46
|
-
const result = getListOfActors();
|
|
47
|
+
const result = (0, _getUsers.getListOfActors)();
|
|
47
48
|
expect(result).toEqual({
|
|
48
49
|
actors: []
|
|
49
50
|
});
|
|
50
51
|
});
|
|
51
52
|
test('falls back to default configuration if main config file does not exist', () => {
|
|
52
|
-
_fs.existsSync.mockReturnValueOnce(false)
|
|
53
|
-
|
|
53
|
+
_fs.default.existsSync.mockReturnValueOnce(false) // Main config file missing
|
|
54
|
+
.mockReturnValueOnce(true); // Beta feature config exists
|
|
55
|
+
|
|
56
|
+
const defaultConfigFile = _path.default.join(_path.default.resolve(process.cwd(), `${stage}/conf/default/actors/index.js`));
|
|
57
|
+
jest.doMock(defaultConfigFile, () => ({
|
|
54
58
|
actors: []
|
|
55
59
|
}), {
|
|
56
60
|
virtual: true
|
|
57
61
|
});
|
|
58
|
-
const result = getListOfActors();
|
|
62
|
+
const result = (0, _getUsers.getListOfActors)();
|
|
59
63
|
expect(result).toEqual({
|
|
60
64
|
actors: []
|
|
61
65
|
});
|
|
62
66
|
});
|
|
63
67
|
test('loads beta feature configuration when betaFeature is provided', () => {
|
|
64
|
-
_fs.existsSync.mockReturnValueOnce(true) // Main config file exists
|
|
68
|
+
_fs.default.existsSync.mockReturnValueOnce(true) // Main config file exists
|
|
65
69
|
.mockReturnValueOnce(true); // Beta feature config exists
|
|
66
70
|
|
|
67
71
|
const betaFeature = 'parentchild';
|
|
68
|
-
const betaFeaturePath =
|
|
72
|
+
const betaFeaturePath = _path.default.join(_path.default.resolve(process.cwd(), `${stageConfig}/${mode}/actors/beta/${betaFeature}/index.js`));
|
|
69
73
|
jest.doMock(betaFeaturePath, () => ({
|
|
70
74
|
betaActors: []
|
|
71
75
|
}), {
|
|
72
76
|
virtual: true
|
|
73
77
|
});
|
|
74
|
-
const result = getListOfActors(betaFeature);
|
|
78
|
+
const result = (0, _getUsers.getListOfActors)(betaFeature);
|
|
75
79
|
expect(result).toEqual({
|
|
76
80
|
betaActors: []
|
|
77
81
|
});
|
|
78
|
-
expect(_path.default.join).toHaveBeenCalledWith('/test/directory', `conf/dev/actors/beta/${betaFeature}/index.js`);
|
|
79
82
|
});
|
|
80
83
|
});
|