@zohodesk/testinglibrary 0.3.0 → 0.3.1

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 CHANGED
@@ -1,8 +1,8 @@
1
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
1
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
2
2
 
3
- #workflow:
4
- # rules:
5
- # - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
3
+ workflow:
4
+ rules:
5
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
6
6
 
7
7
  stages:
8
8
  - build
@@ -12,7 +12,7 @@ stages:
12
12
  # Install dependencies stage
13
13
  build:
14
14
  stage: build
15
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
15
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
16
16
  script:
17
17
  - npm install
18
18
  artifacts:
@@ -23,7 +23,7 @@ build:
23
23
  # Unit tests stage
24
24
  unit:
25
25
  stage: unit
26
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
26
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
27
27
  script:
28
28
  - npm run test
29
29
  artifacts:
@@ -34,7 +34,7 @@ unit:
34
34
  # UAT tests stage
35
35
  uat-auth:
36
36
  stage: uat
37
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
37
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
38
38
  script:
39
39
  - npm install
40
40
  - npm run build
@@ -53,7 +53,7 @@ uat-auth:
53
53
 
54
54
  uat-noauth:
55
55
  stage: uat
56
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
56
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
57
57
  script:
58
58
  - npm install
59
59
  - npm run build
@@ -72,7 +72,7 @@ uat-noauth:
72
72
 
73
73
  uat-profile:
74
74
  stage: uat
75
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
75
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
76
76
  script:
77
77
  - npm install
78
78
  - npm run build
@@ -91,7 +91,7 @@ uat-profile:
91
91
 
92
92
  uat-nobdd:
93
93
  stage: uat
94
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
94
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
95
95
  script:
96
96
  - npm install
97
97
  - npm run build
package/README.md CHANGED
@@ -53,4 +53,14 @@
53
53
 
54
54
  #### Deprecations
55
55
  - **Deprecated**: Passing `video` and `trace` as boolean (`true`/`false`) in project configuration.
56
- - **New Approach**: Use Playwright values for `video` and `trace` options, such as `'on'`, `'retain-on-failure'`, or `'off'`.
56
+ - **New Approach**: Use Playwright values for `video` and `trace` options, such as `'on'`, `'retain-on-failure'`, or `'off'`.
57
+
58
+ ### v0.3.1 - 13-11-2024
59
+
60
+ #### Issue Fix
61
+ - Adding bddmode to get the fixtures.
62
+
63
+ ### v0.2.9.1 - 14-11-2024
64
+
65
+ #### Enhancement
66
+ - Beta feature Actors and edition configurations are unified
@@ -10,7 +10,7 @@ const {
10
10
  bddMode
11
11
  } = (0, _readConfigFile.generateConfigFromFile)();
12
12
  let base = bddMode ? _playwrightBdd.test : _test.test;
13
- const buildInFixtures = (0, _builtInFixtures.default)();
13
+ const buildInFixtures = (0, _builtInFixtures.default)(bddMode);
14
14
  const buildInFixturesTest = base.extend({
15
15
  ...buildInFixtures
16
16
  });
@@ -52,14 +52,22 @@ function getDefaultActor() {
52
52
  } = getDefaultActorConf();
53
53
  return getUserForSelectedEditionAndProfile(edition, profile);
54
54
  }
55
- function getListOfActors() {
55
+ function getListOfActors(betaFeature) {
56
56
  const {
57
57
  uatDirectory
58
58
  } = (0, _readConfigFile.generateConfigFromFile)();
59
59
  const mode = getRunMode();
60
60
  let configFile = _path.default.join(uatDirectory, `conf/${mode}/actors/index.js`);
61
+ let betaReference = mode;
61
62
  if (!(0, _fs.existsSync)(configFile)) {
62
63
  configFile = _path.default.join(uatDirectory, `conf/default/actors/index.js`);
64
+ betaReference = "default";
65
+ }
66
+ if (betaFeature) {
67
+ configFile = _path.default.join(uatDirectory, `conf/${betaReference}/actors/beta/${betaFeature}/index.js`);
68
+ if (!(0, _fs.existsSync)(configFile)) {
69
+ throw new Error(`There is no beta feature configured with the name "${betaFeature}"`);
70
+ }
63
71
  }
64
72
  try {
65
73
  return require(configFile);
@@ -68,42 +76,21 @@ function getListOfActors() {
68
76
  }
69
77
  }
70
78
  function getUserForSelectedEditionAndProfile(preferedEdition, preferredProfile, betaFeature, testDataPortal = null) {
71
- const actorsData = getListOfActors();
79
+ const actorsData = getListOfActors(betaFeature);
72
80
  if (!actorsData || !actorsData.editions) {
73
81
  throw new Error("The actors data is missing.");
74
82
  }
75
83
  const {
76
- editions: userdata,
77
- beta: betaPortals
84
+ editions: userdata
78
85
  } = actorsData;
79
86
  const defaultConf = getDefaultActorConf();
80
87
  const edition = preferedEdition || defaultConf.edition;
81
88
  const profile = preferredProfile || defaultConf.profile;
82
89
  let selectedProfile = {};
83
- if (betaFeature && betaFeature !== null) {
84
- if (!betaPortals.hasOwnProperty(betaFeature)) {
85
- throw new Error(`There is no "${betaFeature}" beta feature configured.`);
86
- }
87
- const betaEdition = betaPortals[betaFeature].find(portal => portal.edition === edition);
88
- if (!betaEdition) {
89
- throw new Error(`There is no "${edition}" edition configured in "${betaFeature}" beta feature.`);
90
- }
91
- const {
92
- profiles: betaProfiles,
93
- ...betaEditionData
94
- } = betaEdition;
95
- selectedProfile = betaProfiles.find(user => user.profile === profile);
96
- if (!selectedProfile) {
97
- throw new Error(`There is no "${profile}" configured in edition of "${edition}" in "${betaFeature}" beta features.`);
98
- }
99
- return {
100
- ...betaEditionData,
101
- ...selectedProfile
102
- };
103
- }
104
90
 
105
91
  // TODO: We are returning the first data from array. We need to check the possiblity of having multiple users for same profile and possibly round robin
106
92
  // For this we need to get the data from ci environment.
93
+
107
94
  let testingPortal = null;
108
95
  if (!userdata.hasOwnProperty(edition)) {
109
96
  throw new Error(`There is no "${edition}" edition configured.`);
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _fs = require("fs");
5
+ var _path = _interopRequireDefault(require("path"));
6
+ jest.mock('fs');
7
+ jest.mock('path');
8
+ jest.mock('../../../../../core/playwright/readConfigFile', () => ({
9
+ generateConfigFromFile: jest.fn(() => ({
10
+ uatDirectory: '/test/directory'
11
+ })),
12
+ getRunMode: jest.fn(() => 'dev')
13
+ }));
14
+ const {
15
+ getListOfActors
16
+ } = require('../../../../../core/playwright/helpers/auth/getUsers');
17
+ describe('getListOfActors', () => {
18
+ beforeEach(() => {
19
+ jest.clearAllMocks();
20
+ _path.default.join.mockImplementation((...args) => args.join('/'));
21
+ });
22
+ test('throws an error when config file cannot be loaded', () => {
23
+ _fs.existsSync.mockReturnValueOnce(true); // Main config file exists
24
+
25
+ jest.mock('/test/directory/conf/dev/actors/index.js', () => {
26
+ throw new Error('Loading error');
27
+ }, {
28
+ virtual: true
29
+ });
30
+ expect(() => getListOfActors()).toThrow('Error loading actor configuration from /test/directory/conf/dev/actors/index.js');
31
+ });
32
+ test('throws an error when beta feature config does not exist', () => {
33
+ _fs.existsSync.mockReturnValueOnce(true) // Main config file exists
34
+ .mockReturnValueOnce(false); // Beta feature config does not exist in either path
35
+
36
+ const betaFeature = 'nonExistentFeature';
37
+ expect(() => getListOfActors(betaFeature)).toThrow(`There is no beta feature configured with the name "${betaFeature}"`);
38
+ });
39
+ test('loads main configuration when betaFeature is not provided and main config file exists', () => {
40
+ _fs.existsSync.mockReturnValueOnce(true);
41
+ jest.doMock('/test/directory/conf/dev/actors/index.js', () => ({
42
+ actors: []
43
+ }), {
44
+ virtual: true
45
+ });
46
+ const result = getListOfActors();
47
+ expect(result).toEqual({
48
+ actors: []
49
+ });
50
+ });
51
+ test('falls back to default configuration if main config file does not exist', () => {
52
+ _fs.existsSync.mockReturnValueOnce(false).mockReturnValueOnce(true);
53
+ jest.doMock('/test/directory/conf/default/actors/index.js', () => ({
54
+ actors: []
55
+ }), {
56
+ virtual: true
57
+ });
58
+ const result = getListOfActors();
59
+ expect(result).toEqual({
60
+ actors: []
61
+ });
62
+ });
63
+ test('loads beta feature configuration when betaFeature is provided', () => {
64
+ _fs.existsSync.mockReturnValueOnce(true) // Main config file exists
65
+ .mockReturnValueOnce(true); // Beta feature config exists
66
+
67
+ const betaFeature = 'parentchild';
68
+ const betaFeaturePath = `/test/directory/conf/dev/actors/beta/${betaFeature}/index.js`;
69
+ jest.doMock(betaFeaturePath, () => ({
70
+ betaActors: []
71
+ }), {
72
+ virtual: true
73
+ });
74
+ const result = getListOfActors(betaFeature);
75
+ expect(result).toEqual({
76
+ betaActors: []
77
+ });
78
+ expect(_path.default.join).toHaveBeenCalledWith('/test/directory', `conf/dev/actors/beta/${betaFeature}/index.js`);
79
+ });
80
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.2.8",
3
+ "version": "0.3.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {