@zohodesk/testinglibrary 0.4.4-experimental → 0.4.5-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 +80 -13
- package/README.md +6 -1
- package/build/core/playwright/helpers/auth/getUsers.js +7 -29
- package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +80 -0
- package/jest.config.js +10 -0
- package/nobdd/README.md +1 -0
- package/nobdd/package.json +17 -0
- package/nobdd/src/App.js +7 -0
- package/nobdd/uat/conf/default/actors/beta/custom-module.json +24 -0
- package/nobdd/uat/conf/default/actors/beta/index.js +6 -0
- package/nobdd/uat/conf/default/actors/beta/parent-child.json +24 -0
- package/nobdd/uat/conf/default/actors/editions/enterprise.json +24 -0
- package/nobdd/uat/conf/default/actors/editions/index.js +4 -0
- package/nobdd/uat/conf/default/actors/index.js +5 -0
- package/nobdd/uat/conf/default/settings.json +6 -0
- package/nobdd/uat/conf/nobdd/uat.config.js +28 -0
- package/nobdd/uat/env-config.json +20 -0
- package/nobdd/uat/fixtures/auth.setup.js +44 -0
- package/nobdd/uat/fixtures/setup.teardown.js +32 -0
- package/nobdd/uat/modules/nobdd/steps/VerifyNoBDD.feature.spec.js +16 -0
- package/nobdd/uat/shared/commands/_index-custom-fixtures.js +9 -0
- package/nobdd/uat/shared/commands/i18n.js +25 -0
- package/nobdd/uat/shared/commands/unauthenticatedPage.js +8 -0
- package/nobdd/uat/shared/index.js +7 -0
- package/nobdd/uat/shared/onboardings/onboardingUpdate.js +44 -0
- package/nobdd/uat/shared/url-helpers/getUrlOrigin.js +6 -0
- package/nobdd/uat.config.js +30 -0
- package/package.json +2 -1
package/.gitlab-ci.yml
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
image:
|
|
1
|
+
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
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:
|
|
15
|
+
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
16
16
|
script:
|
|
17
17
|
- npm install
|
|
18
18
|
artifacts:
|
|
@@ -23,22 +23,89 @@ build:
|
|
|
23
23
|
# Unit tests stage
|
|
24
24
|
unit:
|
|
25
25
|
stage: unit
|
|
26
|
-
image:
|
|
26
|
+
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
27
27
|
script:
|
|
28
|
-
- npm test
|
|
28
|
+
- npm run test
|
|
29
29
|
artifacts:
|
|
30
30
|
when: always
|
|
31
31
|
paths:
|
|
32
|
-
-
|
|
32
|
+
- unit_reports
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
# UAT tests stage
|
|
35
|
+
uat-auth:
|
|
35
36
|
stage: uat
|
|
36
|
-
image:
|
|
37
|
+
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
37
38
|
script:
|
|
39
|
+
- npm install
|
|
40
|
+
- npm run build
|
|
38
41
|
- cd examples
|
|
39
|
-
- npm
|
|
40
|
-
- npm run
|
|
42
|
+
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
43
|
+
- output=$(npm run uatauth)
|
|
44
|
+
- echo "$output"
|
|
45
|
+
- if [[ "$output" == *"failed"* ]]; then
|
|
46
|
+
- exit 1
|
|
47
|
+
- fi
|
|
48
|
+
|
|
41
49
|
artifacts:
|
|
42
50
|
when: always
|
|
43
51
|
paths:
|
|
44
|
-
- uat-
|
|
52
|
+
- examples/uat/playwright-report
|
|
53
|
+
|
|
54
|
+
uat-noauth:
|
|
55
|
+
stage: uat
|
|
56
|
+
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
57
|
+
script:
|
|
58
|
+
- npm install
|
|
59
|
+
- npm run build
|
|
60
|
+
- cd examples
|
|
61
|
+
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
62
|
+
- output=$(npm run uatnoauth)
|
|
63
|
+
- echo "$output"
|
|
64
|
+
- if [[ "$output" == *"failed"* ]]; then
|
|
65
|
+
- exit 1
|
|
66
|
+
- fi
|
|
67
|
+
|
|
68
|
+
artifacts:
|
|
69
|
+
when: always
|
|
70
|
+
paths:
|
|
71
|
+
- examples/uat/playwright-report
|
|
72
|
+
|
|
73
|
+
uat-profile:
|
|
74
|
+
stage: uat
|
|
75
|
+
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
76
|
+
script:
|
|
77
|
+
- npm install
|
|
78
|
+
- npm run build
|
|
79
|
+
- cd examples
|
|
80
|
+
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
81
|
+
- output=$(npm run uatprofile)
|
|
82
|
+
- echo "$output"
|
|
83
|
+
- if [[ "$output" == *"failed"* ]]; then
|
|
84
|
+
- exit 1
|
|
85
|
+
- fi
|
|
86
|
+
|
|
87
|
+
artifacts:
|
|
88
|
+
when: always
|
|
89
|
+
paths:
|
|
90
|
+
- examples/uat/playwright-report
|
|
91
|
+
|
|
92
|
+
uat-nobdd:
|
|
93
|
+
stage: uat
|
|
94
|
+
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
95
|
+
script:
|
|
96
|
+
- npm install
|
|
97
|
+
- npm run build
|
|
98
|
+
- cd nobdd
|
|
99
|
+
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
100
|
+
- output=$(npm run uatnobdd)
|
|
101
|
+
- echo "$output"
|
|
102
|
+
- if [[ "$output" == *"failed"* ]]; then
|
|
103
|
+
- exit 1
|
|
104
|
+
- fi
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
artifacts:
|
|
108
|
+
when: always
|
|
109
|
+
paths:
|
|
110
|
+
- nobdd/uat/playwright-report
|
|
111
|
+
|
package/README.md
CHANGED
|
@@ -32,4 +32,9 @@
|
|
|
32
32
|
- Added support for scenario level tag support
|
|
33
33
|
- Added a new cli optin like uat-validate to validate the feature files using playwright-bdd
|
|
34
34
|
- Mode based configuration implementations
|
|
35
|
-
- @only option enabled in dev pipeline
|
|
35
|
+
- @only option enabled in dev pipeline
|
|
36
|
+
|
|
37
|
+
### v0.3.0 - 06-11-2024
|
|
38
|
+
|
|
39
|
+
#### Enhancement
|
|
40
|
+
- Beta feature Actors and edition configurations unified
|
|
@@ -58,11 +58,16 @@ function getListOfActors(betaFeature) {
|
|
|
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";
|
|
63
65
|
}
|
|
64
66
|
if (betaFeature) {
|
|
65
|
-
configFile = _path.default.join(uatDirectory, `conf/
|
|
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
|
+
}
|
|
66
71
|
}
|
|
67
72
|
try {
|
|
68
73
|
return require(configFile);
|
|
@@ -76,39 +81,12 @@ function getUserForSelectedEditionAndProfile(preferedEdition, preferredProfile,
|
|
|
76
81
|
throw new Error("The actors data is missing.");
|
|
77
82
|
}
|
|
78
83
|
const {
|
|
79
|
-
editions: userdata
|
|
80
|
-
beta: betaPortals
|
|
84
|
+
editions: userdata
|
|
81
85
|
} = actorsData;
|
|
82
86
|
const defaultConf = getDefaultActorConf();
|
|
83
87
|
const edition = preferedEdition || defaultConf.edition;
|
|
84
88
|
const profile = preferredProfile || defaultConf.profile;
|
|
85
89
|
let selectedProfile = {};
|
|
86
|
-
// if (betaFeature && betaFeature !== null) {
|
|
87
|
-
// if (!betaPortals.hasOwnProperty(betaFeature)) {
|
|
88
|
-
// throw new Error(`There is no "${betaFeature}" beta feature configured.`);
|
|
89
|
-
// }
|
|
90
|
-
|
|
91
|
-
// const betaEdition = betaPortals[betaFeature][edition].find(
|
|
92
|
-
// portal => portal.edition === edition
|
|
93
|
-
// );
|
|
94
|
-
// if (!betaEdition) {
|
|
95
|
-
// throw new Error(
|
|
96
|
-
// `There is no "${edition}" edition configured in "${betaFeature}" beta feature.`
|
|
97
|
-
// );
|
|
98
|
-
// }
|
|
99
|
-
|
|
100
|
-
// const { profiles: betaProfiles, ...betaEditionData } = betaEdition;
|
|
101
|
-
// selectedProfile = betaProfiles.find(user => user.profile === profile);
|
|
102
|
-
// if (!selectedProfile) {
|
|
103
|
-
// throw new Error(
|
|
104
|
-
// `There is no "${profile}" configured in edition of "${edition}" in "${betaFeature}" beta features.`
|
|
105
|
-
// );
|
|
106
|
-
// }
|
|
107
|
-
// return {
|
|
108
|
-
// ...betaEditionData,
|
|
109
|
-
// ...selectedProfile
|
|
110
|
-
// };
|
|
111
|
-
// }
|
|
112
90
|
|
|
113
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
|
|
114
92
|
// For this we need to get the data from ci environment.
|
|
@@ -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
|
+
});
|
package/jest.config.js
CHANGED
|
@@ -5,6 +5,16 @@ const appPath = process.cwd();
|
|
|
5
5
|
const appGlobals = path.resolve(appPath, '__testUtils__', 'globals.js');
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
|
+
reporters: [
|
|
9
|
+
"default",
|
|
10
|
+
[
|
|
11
|
+
"jest-html-reporter",
|
|
12
|
+
{
|
|
13
|
+
outputPath: "unit_reports/unit-report.html",
|
|
14
|
+
pageTitle: "Unit Report"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
],
|
|
8
18
|
rootDir: process.cwd(),
|
|
9
19
|
testEnvironment: 'node',
|
|
10
20
|
|
package/nobdd/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm install $(npm pack ../ | tail -1)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "testingframeworknobdd",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "collection of examples that we can use for testing",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"author": "",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"uat": "ZDTestingFramework test --mode=dev --headed",
|
|
10
|
+
"uatnobdd": "ZDTestingFramework test --mode=nobdd",
|
|
11
|
+
"uat-ci": "ZDTestingFramework test --mode=ci --headed",
|
|
12
|
+
"uat-clean": "ZDTestingFramework clearCaches",
|
|
13
|
+
"uat-debug": "ZDTestingFramework test --mode=dev --debug",
|
|
14
|
+
"uat-report": "ZDTestingFramework report --port=9009",
|
|
15
|
+
"codegen": "ZDTestingFramework codegen deskclientapp.localzoho.com/agent"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/nobdd/src/App.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "1",
|
|
4
|
+
"edition": "enterprise",
|
|
5
|
+
"orgName": "custommoduleportal",
|
|
6
|
+
"profiles": [
|
|
7
|
+
{
|
|
8
|
+
"profile": "admin",
|
|
9
|
+
"email": "indragith.m+agent@zohotest.com",
|
|
10
|
+
"password": "Paara!2019"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"profile": "agent",
|
|
14
|
+
"email": "indragith.m+agent@zohotest.com",
|
|
15
|
+
"password": "Paara!2019"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"profile": "lightagent",
|
|
19
|
+
"email": "indragith.m+abc1@zohotest.com",
|
|
20
|
+
"password": "Paara!2019"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "1",
|
|
4
|
+
"edition": "enterprise",
|
|
5
|
+
"orgName": "parentchildportal",
|
|
6
|
+
"profiles": [
|
|
7
|
+
{
|
|
8
|
+
"profile": "admin",
|
|
9
|
+
"email": "indragith.m@zohocorp.com",
|
|
10
|
+
"password": "Paara!2019"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"profile": "agent",
|
|
14
|
+
"email": "indragith.m+agent@zohotest.com",
|
|
15
|
+
"password": "Paara!2019"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"profile": "lightagent",
|
|
19
|
+
"email": "indragith.m+abc1@zohotest.com",
|
|
20
|
+
"password": "Paara!2019"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "1",
|
|
4
|
+
"edition": "enterprise",
|
|
5
|
+
"orgName": "zohodeskteam",
|
|
6
|
+
"profiles": [
|
|
7
|
+
{
|
|
8
|
+
"profile": "admin",
|
|
9
|
+
"email": "solairaj.m+26jun2023@zohotest.com",
|
|
10
|
+
"password": "Demo@1201"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"profile": "agent",
|
|
14
|
+
"email": "anitha.m+agentat@zohotest.com",
|
|
15
|
+
"password": "Desk@1234"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"profile": "lightagent",
|
|
19
|
+
"email": "anitha.m+admin@zohotest.com",
|
|
20
|
+
"password": "Moon@2018"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const customFixtures = require('../../shared/commands/_index-custom-fixtures');
|
|
2
|
+
|
|
3
|
+
const { getDefaultActor } = require('@zohodesk/testinglibrary/helpers');
|
|
4
|
+
|
|
5
|
+
function getPrimaryCookiePath() {
|
|
6
|
+
const { email } = getDefaultActor();
|
|
7
|
+
return `uat/playwright/.auth/${email}-cookies.json`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents the user configuration object.
|
|
12
|
+
* @typedef {import('@zohodesk/testinglibrary').UserConfig} UserConfig
|
|
13
|
+
*/
|
|
14
|
+
module.exports = {
|
|
15
|
+
headless: true,
|
|
16
|
+
openReportOn: 'never',
|
|
17
|
+
browsers: ['Chrome'],
|
|
18
|
+
isAuthMode: false,
|
|
19
|
+
authFilePath: getPrimaryCookiePath(),
|
|
20
|
+
trace: true,
|
|
21
|
+
video: true,
|
|
22
|
+
bddMode: false,
|
|
23
|
+
viewport: { width: 1280, height: 720 },
|
|
24
|
+
testIdAttribute: 'data-id',
|
|
25
|
+
additionalPages: {
|
|
26
|
+
...customFixtures
|
|
27
|
+
}
|
|
28
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dev": {
|
|
3
|
+
"domain": "https://desk.localzoho.com/agent",
|
|
4
|
+
"orgName": "org-name",
|
|
5
|
+
"deptName": "dept-name",
|
|
6
|
+
"moduleName": "module-name"
|
|
7
|
+
},
|
|
8
|
+
"prod": {
|
|
9
|
+
"domain": "https://desk.localzoho.com/agent/",
|
|
10
|
+
"orgName": "sangeetha.t@zohocorp.com",
|
|
11
|
+
"deptName": "sangeethat",
|
|
12
|
+
"moduleName": "sangeethat"
|
|
13
|
+
},
|
|
14
|
+
"ci": {
|
|
15
|
+
"domain": "https://zdesk-devops08.csez.zohocorpin.com:31007/agent/",
|
|
16
|
+
"orgName": "clientcicdk8",
|
|
17
|
+
"deptName": "clientcicdk8",
|
|
18
|
+
"moduleName": "tickets"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import {
|
|
3
|
+
test as setup,
|
|
4
|
+
expect
|
|
5
|
+
} from '@zohodesk/testinglibrary';
|
|
6
|
+
import {
|
|
7
|
+
getDefaultActor,
|
|
8
|
+
getUserForSelectedEditionAndProfile,
|
|
9
|
+
performLoginSteps
|
|
10
|
+
} from '@zohodesk/testinglibrary/helpers'
|
|
11
|
+
import { SETUP_HOME_PAGE_SELECTORS } from '../modules/Setup/dom-selectors/SetupSelectors';
|
|
12
|
+
import getUrlOrigin from '../shared/url-helpers/getUrlOrigin';
|
|
13
|
+
|
|
14
|
+
const { edition, profile } = getDefaultActor();
|
|
15
|
+
|
|
16
|
+
const user = getUserForSelectedEditionAndProfile(edition, profile);
|
|
17
|
+
|
|
18
|
+
async function verifyPageIsLoaded(page) {
|
|
19
|
+
const urlOrigin = getUrlOrigin(page.url());
|
|
20
|
+
const domainOrigin = getUrlOrigin(process.env.domain);
|
|
21
|
+
if (urlOrigin === domainOrigin) {
|
|
22
|
+
await expect(
|
|
23
|
+
page
|
|
24
|
+
.locator('header')
|
|
25
|
+
.getByLabel(SETUP_HOME_PAGE_SELECTORS.SETUP_ICON_LABEL)
|
|
26
|
+
).toBeVisible();
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
setup(`${user.edition} - Authentication`, async ({ page }) => {
|
|
33
|
+
const { email, password } = user;
|
|
34
|
+
await performLoginSteps(
|
|
35
|
+
{
|
|
36
|
+
page,
|
|
37
|
+
authFilePrefix: email,
|
|
38
|
+
useremail: email,
|
|
39
|
+
password: password
|
|
40
|
+
},
|
|
41
|
+
verifyPageIsLoaded
|
|
42
|
+
);
|
|
43
|
+
//await completeOnboardings({ page });
|
|
44
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import {
|
|
4
|
+
test as teardown,
|
|
5
|
+
expect
|
|
6
|
+
} from '@zohodesk/testinglibrary';
|
|
7
|
+
import { isDevelopmentSetup, loadCookiesIfPresent } from '@zohodesk/testinglibrary/helpers'
|
|
8
|
+
import getUrlOrigin from '../shared/url-helpers/getUrlOrigin';
|
|
9
|
+
|
|
10
|
+
// We are adding teardown logic only in CI mode
|
|
11
|
+
if (!isDevelopmentSetup()) {
|
|
12
|
+
teardown(`Log out scenarios`, async ({ page }) => {
|
|
13
|
+
const authDirectory = path.resolve(
|
|
14
|
+
process.cwd(),
|
|
15
|
+
'uat',
|
|
16
|
+
'playwright',
|
|
17
|
+
'.auth'
|
|
18
|
+
);
|
|
19
|
+
const files = fs.readdirSync(authDirectory);
|
|
20
|
+
const promises = files.map(async file => {
|
|
21
|
+
const authFilePath = path.join(authDirectory, file);
|
|
22
|
+
await loadCookiesIfPresent(page, authFilePath);
|
|
23
|
+
const domainOrigin = getUrlOrigin(process.env.domain);
|
|
24
|
+
await page.goto(`${domainOrigin}/support/logout.sas `);
|
|
25
|
+
await page.waitForNavigation();
|
|
26
|
+
await expect(page.locator('[id="signin_flow"]')).toBeVisible();
|
|
27
|
+
await fs.rmSync(authFilePath);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
await Promise.all(promises);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { test, expect } from "@zohodesk/testinglibrary";
|
|
2
|
+
|
|
3
|
+
test.describe("Verify no authentication required @nobdd", () => {
|
|
4
|
+
|
|
5
|
+
test("Verify the page is not logged in", async ({ page }) => {
|
|
6
|
+
|
|
7
|
+
await page.goto('https://desk.localzoho.com/');
|
|
8
|
+
|
|
9
|
+
await page.waitForSelector('.zgh-accounts');
|
|
10
|
+
|
|
11
|
+
const isLoggedIn = await page.isVisible('.zgh-accounts');
|
|
12
|
+
expect(isLoggedIn).toBe(true);
|
|
13
|
+
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
|
|
3
|
+
// Note: We are duplicating below method from @zohodesk/i18n. We are not importing it as react package not yet availble in test environment.
|
|
4
|
+
function replaceI18NValuesWithRegex(i18nStr, values) {
|
|
5
|
+
if (typeof values !== 'undefined') {
|
|
6
|
+
if (Array.isArray(values)) {
|
|
7
|
+
for (let i = 0; i < values.length; i++) {
|
|
8
|
+
i18nStr = i18nStr.replace(new RegExp(`\\{${i}\\}`, 'g'), values[i]);
|
|
9
|
+
}
|
|
10
|
+
} else {
|
|
11
|
+
i18nStr = i18nStr.replace(new RegExp('\\{0\\}', 'g'), values);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return i18nStr;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
i18N: async ({ page }, use) => {
|
|
19
|
+
await use(async (key, values) => {
|
|
20
|
+
const i18nValue = await page.evaluate((i18nKey) => window.i18n[i18nKey], key);
|
|
21
|
+
const i18nStr = replaceI18NValuesWithRegex(i18nValue, values)
|
|
22
|
+
return i18nStr;
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
async function get_cookie(page) {
|
|
2
|
+
return page.evaluate(async () => {
|
|
3
|
+
const results = document.cookie.match(`crmcsr=(.*?)(;|$)`);
|
|
4
|
+
if (results) {
|
|
5
|
+
return unescape(results[1]);
|
|
6
|
+
}
|
|
7
|
+
return null;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async function getOnboardings({ page, cookieVal }) {
|
|
12
|
+
return page.evaluate(
|
|
13
|
+
async (cookieVal) =>
|
|
14
|
+
fetch('/api/v1/onboardingStatus', {
|
|
15
|
+
method: 'GET',
|
|
16
|
+
headers: {
|
|
17
|
+
orgId: window.currentOrg.id,
|
|
18
|
+
'X-ZCSRF-TOKEN': `crmcsrfparam=${cookieVal}`
|
|
19
|
+
}
|
|
20
|
+
}).then((r) => (r.ok ? r.json() : Promise.reject(r))),
|
|
21
|
+
cookieVal
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function completeOnboardings({ page }) {
|
|
26
|
+
const cookieVal = await get_cookie(page);
|
|
27
|
+
const onboardings = await getOnboardings({ page });
|
|
28
|
+
if (onboardings.pending.length) {
|
|
29
|
+
await page.evaluate(
|
|
30
|
+
async ({ cookieVal, onboardings }) =>
|
|
31
|
+
fetch('/api/v1/onboardingStatus/markComplete', {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: {
|
|
34
|
+
orgId: window.currentOrg.id,
|
|
35
|
+
'X-ZCSRF-TOKEN': `crmcsrfparam=${cookieVal}`
|
|
36
|
+
},
|
|
37
|
+
body: JSON.stringify({ items: onboardings.pending })
|
|
38
|
+
}),
|
|
39
|
+
{ cookieVal, onboardings }
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = completeOnboardings;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const customFixtures = require('./uat/shared/commands/_index-custom-fixtures');
|
|
2
|
+
|
|
3
|
+
const { getDefaultActor } = require('@zohodesk/testinglibrary/helpers');
|
|
4
|
+
|
|
5
|
+
function getPrimaryCookiePath() {
|
|
6
|
+
const { email } = getDefaultActor();
|
|
7
|
+
return `uat/playwright/.auth/${email}-cookies.json`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents the user configuration object.
|
|
12
|
+
* @typedef {import('@zohodesk/testinglibrary').UserConfig} UserConfig
|
|
13
|
+
*/
|
|
14
|
+
module.exports = {
|
|
15
|
+
headless: false,
|
|
16
|
+
openReportOn: 'never',
|
|
17
|
+
browsers: ['Chrome'],
|
|
18
|
+
isAuthMode: true,
|
|
19
|
+
authFilePath: getPrimaryCookiePath(),
|
|
20
|
+
trace: true,
|
|
21
|
+
video: true,
|
|
22
|
+
bddMode: true,
|
|
23
|
+
featureFilesFolder: 'feature-files',
|
|
24
|
+
stepDefinitionsFolder: 'steps',
|
|
25
|
+
viewport: { width: 1280, height: 720 },
|
|
26
|
+
testIdAttribute: 'data-id',
|
|
27
|
+
additionalPages: {
|
|
28
|
+
...customFixtures
|
|
29
|
+
}
|
|
30
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5-experimental",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"@babel/preset-env": "7.22.15",
|
|
54
54
|
"@babel/runtime": "7.22.15",
|
|
55
55
|
"commander": "^11.0.0",
|
|
56
|
+
"jest-html-reporter": "^3.10.2",
|
|
56
57
|
"typescript": "^5.4.2"
|
|
57
58
|
}
|
|
58
59
|
}
|