@zohodesk/testinglibrary 0.4.97-n18-experimental → 0.4.98-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/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/custom-commands.js +1 -1
- package/build/core/playwright/env-initializer.js +9 -4
- package/build/core/playwright/helpers/auth/getUsers.js +14 -16
- package/build/core/playwright/helpers/configFileNameProvider.js +13 -7
- package/build/core/playwright/helpers/resolvePropertiesFile.js +29 -0
- package/build/core/playwright/helpers/resolveStageConfigPath.js +18 -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__/getUsers_ListOfActors.test.js +29 -26
- package/build/test/core/playwright/helpers/__tests__/resolvePropertiesFile.test.js +58 -0
- package/build/test/core/playwright/helpers/__tests__/resolveStageConfigPath.test.js +44 -0
- package/npm-shrinkwrap.json +471 -368
- package/package.json +5 -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 _resolveStageConfigPath = require("../../../../../core/playwright/helpers/resolveStageConfigPath");
|
|
7
8
|
jest.mock('fs');
|
|
8
|
-
jest.mock('path')
|
|
9
|
+
jest.mock('path', () => ({
|
|
10
|
+
resolve: jest.fn()
|
|
11
|
+
}));
|
|
12
|
+
jest.mock("../../../../../core/playwright/helpers/resolveStageConfigPath", () => ({
|
|
13
|
+
resolveStageConfigPath: 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
|
+
_resolveStageConfigPath.resolveStageConfigPath.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(_resolveStageConfigPath.resolveStageConfigPath).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
|
+
_resolveStageConfigPath.resolveStageConfigPath.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
|
+
_resolveStageConfigPath.resolveStageConfigPath.mockReturnValue('uat/conf');
|
|
63
|
+
_fs.existsSync.mockReturnValue(true);
|
|
64
|
+
const result = (0, _configFileNameProvider.getEnvConfigFilePath)('uat', 'cd');
|
|
65
|
+
expect(_resolveStageConfigPath.resolveStageConfigPath).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
|
+
_resolveStageConfigPath.resolveStageConfigPath.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
|
});
|
|
@@ -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 _resolveStageConfigPath = require("../../../../../core/playwright/helpers/resolveStageConfigPath");
|
|
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/resolveStageConfigPath', () => ({
|
|
11
|
+
resolveStageConfigPath: 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
|
+
_resolveStageConfigPath.resolveStageConfigPath.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
|
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
5
|
+
var _path = _interopRequireDefault(require("path"));
|
|
6
|
+
var _resolvePropertiesFile = require("../../../../../core/playwright/helpers/resolvePropertiesFile");
|
|
7
|
+
jest.mock('fs');
|
|
8
|
+
jest.mock('path');
|
|
9
|
+
describe('readPropertiesFile', () => {
|
|
10
|
+
const mockCwd = '/mock/current/directory';
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
jest.clearAllMocks();
|
|
13
|
+
process.cwd = jest.fn(() => mockCwd);
|
|
14
|
+
_path.default.resolve.mockImplementation((...args) => args.join('/'));
|
|
15
|
+
});
|
|
16
|
+
test('should return default object when file does not exist', () => {
|
|
17
|
+
_fs.default.existsSync.mockReturnValue(false);
|
|
18
|
+
const result = (0, _resolvePropertiesFile.readPropertiesFile)('uat/conf/config.properties');
|
|
19
|
+
expect(_fs.default.existsSync).toHaveBeenCalledWith(`${mockCwd}/uat/conf/config.properties`);
|
|
20
|
+
expect(result).toEqual({
|
|
21
|
+
uat: 'uat/conf'
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
test('should parse valid properties file correctly', () => {
|
|
25
|
+
_fs.default.existsSync.mockReturnValue(true);
|
|
26
|
+
_fs.default.readFileSync.mockReturnValue(`uat=uat/conf\ne2e=testingSlices/e2e/conf`);
|
|
27
|
+
const result = (0, _resolvePropertiesFile.readPropertiesFile)('uat/conf/config.properties');
|
|
28
|
+
expect(result).toEqual({
|
|
29
|
+
uat: 'uat/conf',
|
|
30
|
+
e2e: 'testingSlices/e2e/conf'
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
test('should ignore invalid or empty lines', () => {
|
|
34
|
+
_fs.default.existsSync.mockReturnValue(true);
|
|
35
|
+
_fs.default.readFileSync.mockReturnValue(`
|
|
36
|
+
uat=uat/conf
|
|
37
|
+
invalidLineWithoutEquals
|
|
38
|
+
e2e = testingSlices/e2e/conf
|
|
39
|
+
`);
|
|
40
|
+
const result = (0, _resolvePropertiesFile.readPropertiesFile)('uat/conf/config.properties');
|
|
41
|
+
expect(result).toEqual({
|
|
42
|
+
uat: 'uat/conf',
|
|
43
|
+
e2e: 'testingSlices/e2e/conf'
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
test('should trim spaces around keys and values', () => {
|
|
47
|
+
_fs.default.existsSync.mockReturnValue(true);
|
|
48
|
+
_fs.default.readFileSync.mockReturnValue(`
|
|
49
|
+
uat = uat/conf
|
|
50
|
+
e2e = testingSlices/e2e/conf
|
|
51
|
+
`);
|
|
52
|
+
const result = (0, _resolvePropertiesFile.readPropertiesFile)('uat/conf/config.properties');
|
|
53
|
+
expect(result).toEqual({
|
|
54
|
+
uat: 'uat/conf',
|
|
55
|
+
e2e: 'testingSlices/e2e/conf'
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _resolveStageConfigPath = require("../../../../../core/playwright/helpers/resolveStageConfigPath");
|
|
4
|
+
var _resolvePropertiesFile = require("../../../../../core/playwright/helpers/resolvePropertiesFile");
|
|
5
|
+
var _logger = require("../../../../../utils/logger");
|
|
6
|
+
jest.mock('../../../../../utils/logger', () => ({
|
|
7
|
+
Logger: {
|
|
8
|
+
log: jest.fn(),
|
|
9
|
+
FAILURE_TYPE: 'FAILURE'
|
|
10
|
+
}
|
|
11
|
+
}));
|
|
12
|
+
jest.mock("../../../../../core/playwright/helpers/resolvePropertiesFile", () => ({
|
|
13
|
+
readPropertiesFile: jest.fn()
|
|
14
|
+
}));
|
|
15
|
+
describe('resolveStageConfigPath', () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
jest.clearAllMocks();
|
|
18
|
+
});
|
|
19
|
+
test('should return correct stageConfig when mapping exists', () => {
|
|
20
|
+
const mockProps = {
|
|
21
|
+
uat: 'uat/conf',
|
|
22
|
+
e2e: 'testingSlices/e2e/conf'
|
|
23
|
+
};
|
|
24
|
+
_resolvePropertiesFile.readPropertiesFile.mockReturnValue(mockProps);
|
|
25
|
+
const result = (0, _resolveStageConfigPath.resolveStageConfigPath)('uat');
|
|
26
|
+
expect(_resolvePropertiesFile.readPropertiesFile).toHaveBeenCalledWith('uat/conf-path-map.properties');
|
|
27
|
+
expect(result).toEqual('uat/conf');
|
|
28
|
+
expect(_logger.Logger.log).not.toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
test('should log failure when stage mapping does not exist', () => {
|
|
31
|
+
_resolvePropertiesFile.readPropertiesFile.mockReturnValue({
|
|
32
|
+
uat: 'uat/conf'
|
|
33
|
+
});
|
|
34
|
+
const result = (0, _resolveStageConfigPath.resolveStageConfigPath)('e2e');
|
|
35
|
+
expect(result).toEqual(undefined);
|
|
36
|
+
expect(_logger.Logger.log).toHaveBeenCalledWith('FAILURE', 'No config mapping found for stage: "e2e"');
|
|
37
|
+
});
|
|
38
|
+
test('should handle empty properties object gracefully', () => {
|
|
39
|
+
_resolvePropertiesFile.readPropertiesFile.mockReturnValue({});
|
|
40
|
+
const result = (0, _resolveStageConfigPath.resolveStageConfigPath)('uat');
|
|
41
|
+
expect(result).toEqual(undefined);
|
|
42
|
+
expect(_logger.Logger.log).toHaveBeenCalledWith('FAILURE', 'No config mapping found for stage: "uat"');
|
|
43
|
+
});
|
|
44
|
+
});
|