@zohodesk/testinglibrary 0.4.85-n18-experimental → 0.4.87-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.4.85-n18-experimental",
3
+ "version": "0.4.87-n18-experimental",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -8,6 +8,7 @@
8
8
  "test": "jest",
9
9
  "clean": "rm -rf build && mkdir build",
10
10
  "build-babel": "babel -d ./build ./src --copy-files",
11
+ "copy-common": "cp -r src/common build/",
11
12
  "build": "npm run clean && npm run build-babel",
12
13
  "prepare": "npm run build",
13
14
  "lint": "eslint src/* --fix"
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- var _testinglibrary = require("@zohodesk/testinglibrary");
4
- const {
5
- BeforeScenario,
6
- Given
7
- } = (0, _testinglibrary.createBdd)();
8
- BeforeScenario(async function ({
9
- actorCtx,
10
- page,
11
- context,
12
- browser,
13
- executionContext
14
- }) {
15
- // This will run before each scenario and set all the fixtures into this context
16
- this.page = page;
17
- this.context = context;
18
- this.browser = browser;
19
- this.executionContext = executionContext;
20
- this.setActor = async role => {
21
- const userPage = actorCtx.userPages.find(up => up.role === role);
22
- if (userPage) {
23
- this.page = userPage.page;
24
- this.context = userPage.context;
25
- this.browser = userPage.browser;
26
- this.executionContext = userPage.actorInfo;
27
- } else {
28
- throw new Error(`Actor ${role} not found`);
29
- }
30
- };
31
- });
32
- Given("access the {string} profile page", async function ({
33
- page
34
- }, userRole) {
35
- await this.setActor(userRole);
36
- });
@@ -1,89 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _logger = require("../../../utils/logger");
8
- var _customFixturesHelper = require("../helpers/customFixturesHelper");
9
- class actorContext {
10
- constructor() {
11
- this.page = null;
12
- this.browser = null;
13
- this.context = null;
14
- this.actorInfo = null;
15
- this.userPages = [];
16
- this.actorsList = {};
17
- }
18
- async setupAdditionalActors(browser, $tags, testInfo, defaultPage, defaultContext) {
19
- const actorInfoMap = (0, _customFixturesHelper.getCustomAccountDetails)($tags);
20
- const currentActor = actorInfoMap.additional;
21
- await Promise.all(Object.entries(currentActor).map(async ([role, actorInfo], index) => {
22
- let context, page;
23
- if (index === 0) {
24
- context = defaultContext;
25
- page = defaultPage;
26
- } else {
27
- context = await browser.newContext();
28
- page = await context.newPage();
29
- }
30
- let ctxTestDetails = {
31
- page,
32
- $tags,
33
- context,
34
- ...actorInfo
35
- };
36
- await (0, _customFixturesHelper.executeDefaultLoginSteps)(context, testInfo, ctxTestDetails, actorInfo);
37
- this.actorsList[role] = {
38
- role,
39
- browser,
40
- context,
41
- page,
42
- actorInfo,
43
- isPrimary: index === 0
44
- };
45
- await this.addUserPage(role, browser, page, context, actorInfo);
46
- }));
47
- for (const actorObj of Object.values(this.actorsList)) {
48
- await (0, _customFixturesHelper.performDefaultPageSteps)({
49
- context: actorObj.context,
50
- page: actorObj.page,
51
- $tags,
52
- ...actorObj.actorInfo
53
- });
54
- }
55
- }
56
- async addUserPage(role, browser, page, context, actorInfo) {
57
- this.userPages.push({
58
- role,
59
- browser,
60
- page,
61
- context,
62
- actorInfo
63
- });
64
- }
65
- async cleanup() {
66
- for (const actor of Object.values(this.actorsList)) {
67
- if (!actor.isPrimary && actor.context) {
68
- try {
69
- await actor.context.close();
70
- } catch (error) {
71
- _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Failed to close context for actor ${actor.role}:`, error);
72
- }
73
- }
74
- }
75
- }
76
- }
77
- var _default = exports.default = {
78
- actorCtx: async ({
79
- $tags,
80
- browser,
81
- context,
82
- page
83
- }, use, testInfo) => {
84
- const ctxObject = new actorContext();
85
- await ctxObject.setupAdditionalActors(browser, $tags, testInfo, page, context);
86
- await use(ctxObject);
87
- await ctxObject.cleanup();
88
- }
89
- };
@@ -1,90 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.executeDefaultLoginSteps = executeDefaultLoginSteps;
7
- exports.getCustomAccountDetails = getCustomAccountDetails;
8
- exports.loginSteps = loginSteps;
9
- exports.performDefaultPageSteps = performDefaultPageSteps;
10
- exports.verifyPageIsLoaded = verifyPageIsLoaded;
11
- var _auth = require("../helpers/auth");
12
- var _additionalProfiles = require("../helpers/additionalProfiles");
13
- var _readConfigFile = require("../readConfigFile");
14
- var _logger = require("../../../utils/logger");
15
- /* eslint-disable global-require */
16
-
17
- let {
18
- testSetup,
19
- isAuthMode
20
- } = (0, _readConfigFile.generateConfigFromFile)();
21
- function getTagInputFromSelectedTags(tags, inputString) {
22
- const selectedTag = [...tags].reverse().find(tag => tag.startsWith(inputString));
23
- let tagInput = null;
24
- if (selectedTag) {
25
- tagInput = selectedTag.split(`${inputString}_`).pop().toLowerCase();
26
- }
27
- return tagInput;
28
- }
29
- function getCustomAccountDetails(tags) {
30
- try {
31
- const tagsTobeFiltered = ['@profile', '@edition', '@beta', '@portal', '@additional_profile'];
32
- const filteredTags = tags.filter(tag => tagsTobeFiltered.some(prefix => tag.startsWith(prefix)));
33
- if (filteredTags && filteredTags.length > 0) {
34
- const portalInfo = getTagInputFromSelectedTags(filteredTags, '@portal');
35
- const betaFeature = getTagInputFromSelectedTags(filteredTags, '@beta');
36
- const profileInfo = getTagInputFromSelectedTags(filteredTags, '@profile');
37
- const editionInfo = getTagInputFromSelectedTags(filteredTags, '@edition');
38
- const mainActor = (0, _auth.getUserForSelectedEditionAndProfile)(editionInfo, profileInfo, betaFeature, portalInfo);
39
- const additionalActors = (0, _additionalProfiles.additionProfiles)(tags, editionInfo, betaFeature, portalInfo);
40
- return {
41
- main: mainActor,
42
- additional: additionalActors
43
- };
44
- }
45
- return {
46
- main: (0, _auth.getDefaultActor)(),
47
- additional: {}
48
- };
49
- } catch (err) {
50
- _logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Error while getting custom account details:', err);
51
- }
52
- }
53
- async function loginSteps(pageDetail) {
54
- const {
55
- page
56
- } = pageDetail;
57
- if (testSetup.loginSteps && typeof testSetup.loginSteps === 'function') {
58
- return await testSetup.loginSteps(pageDetail);
59
- } else {
60
- await page.goto(process.env.domain);
61
- }
62
- }
63
- async function performDefaultPageSteps(testInfo) {
64
- if (testSetup.page && typeof testSetup.page === 'function') {
65
- await testSetup.page(testInfo);
66
- }
67
- }
68
- async function verifyPageIsLoaded(testInfo) {
69
- if (testSetup.validateLogin && typeof testSetup.validateLogin === 'function') {
70
- return await testSetup.validateLogin(testInfo);
71
- }
72
- return true;
73
- }
74
- async function executeDefaultLoginSteps(context, testInfo, testDetails, testPortalDetails) {
75
- if (!isAuthMode) {
76
- return;
77
- }
78
- try {
79
- const projectName = testInfo.project.name;
80
- if (testPortalDetails && projectName !== 'setup' && projectName !== 'cleanup') {
81
- await context.clearCookies();
82
- await (0, _auth.performLoginSteps)(testDetails, async testInfo => {
83
- return await verifyPageIsLoaded(testInfo);
84
- }, loginSteps);
85
- process.env.actorInfo = JSON.stringify(testPortalDetails);
86
- }
87
- } catch (error) {
88
- _logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Error while executing the default login steps:', error);
89
- }
90
- }
@@ -1,4 +0,0 @@
1
- {
2
- "status": "passed",
3
- "failedTests": []
4
- }
@@ -1,260 +0,0 @@
1
- <html><head><meta charset="utf-8"/><title>Unit Report</title><style type="text/css">html,
2
- body {
3
- font-family: Arial, Helvetica, sans-serif;
4
- font-size: 1rem;
5
- margin: 0;
6
- padding: 0;
7
- color: #333;
8
- }
9
- body {
10
- padding: 2rem 1rem;
11
- font-size: 0.85rem;
12
- }
13
- .jesthtml-content {
14
- margin: 0 auto;
15
- max-width: 70rem;
16
- }
17
- header {
18
- display: flex;
19
- align-items: center;
20
- }
21
- #title {
22
- margin: 0;
23
- flex-grow: 1;
24
- }
25
- #logo {
26
- height: 4rem;
27
- }
28
- #timestamp {
29
- color: #777;
30
- margin-top: 0.5rem;
31
- }
32
-
33
- /** SUMMARY */
34
- #summary {
35
- color: #333;
36
- margin: 2rem 0;
37
- display: flex;
38
- font-family: monospace;
39
- font-size: 1rem;
40
- }
41
- #summary > div {
42
- margin-right: 2rem;
43
- background: #eee;
44
- padding: 1rem;
45
- min-width: 15rem;
46
- }
47
- #summary > div:last-child {
48
- margin-right: 0;
49
- }
50
- @media only screen and (max-width: 720px) {
51
- #summary {
52
- flex-direction: column;
53
- }
54
- #summary > div {
55
- margin-right: 0;
56
- margin-top: 2rem;
57
- }
58
- #summary > div:first-child {
59
- margin-top: 0;
60
- }
61
- }
62
-
63
- .summary-total {
64
- font-weight: bold;
65
- margin-bottom: 0.5rem;
66
- }
67
- .summary-passed {
68
- color: #4f8a10;
69
- border-left: 0.4rem solid #4f8a10;
70
- padding-left: 0.5rem;
71
- }
72
- .summary-failed,
73
- .summary-obsolete-snapshots {
74
- color: #d8000c;
75
- border-left: 0.4rem solid #d8000c;
76
- padding-left: 0.5rem;
77
- }
78
- .summary-pending {
79
- color: #9f6000;
80
- border-left: 0.4rem solid #9f6000;
81
- padding-left: 0.5rem;
82
- }
83
- .summary-empty {
84
- color: #999;
85
- border-left: 0.4rem solid #999;
86
- }
87
-
88
- .test-result {
89
- padding: 1rem;
90
- margin-bottom: 0.25rem;
91
- }
92
- .test-result:last-child {
93
- border: 0;
94
- }
95
- .test-result.passed {
96
- background-color: #dff2bf;
97
- color: #4f8a10;
98
- }
99
- .test-result.failed {
100
- background-color: #ffbaba;
101
- color: #d8000c;
102
- }
103
- .test-result.pending {
104
- background-color: #ffdf61;
105
- color: #9f6000;
106
- }
107
-
108
- .test-info {
109
- display: flex;
110
- justify-content: space-between;
111
- }
112
- .test-suitename {
113
- width: 20%;
114
- text-align: left;
115
- font-weight: bold;
116
- word-break: break-word;
117
- }
118
- .test-title {
119
- width: 40%;
120
- text-align: left;
121
- font-style: italic;
122
- }
123
- .test-status {
124
- width: 20%;
125
- text-align: right;
126
- }
127
- .test-duration {
128
- width: 10%;
129
- text-align: right;
130
- font-size: 0.75rem;
131
- }
132
-
133
- .failureMessages {
134
- padding: 0 1rem;
135
- margin-top: 1rem;
136
- border-top: 1px dashed #d8000c;
137
- }
138
- .failureMessages.suiteFailure {
139
- border-top: none;
140
- }
141
- .failureMsg {
142
- white-space: pre-wrap;
143
- white-space: -moz-pre-wrap;
144
- white-space: -pre-wrap;
145
- white-space: -o-pre-wrap;
146
- word-wrap: break-word;
147
- }
148
-
149
- .suite-container {
150
- margin-bottom: 2rem;
151
- }
152
- .suite-container > input[type="checkbox"] {
153
- position: absolute;
154
- left: -100vw;
155
- }
156
- .suite-container label {
157
- display: block;
158
- }
159
- .suite-container .suite-tests {
160
- overflow-y: hidden;
161
- height: 0;
162
- }
163
- .suite-container > input[type="checkbox"]:checked ~ .suite-tests {
164
- height: auto;
165
- overflow: visible;
166
- }
167
- .suite-info {
168
- padding: 1rem;
169
- background-color: #eee;
170
- color: #777;
171
- display: flex;
172
- align-items: center;
173
- margin-bottom: 0.25rem;
174
- }
175
- .suite-info:hover {
176
- background-color: #ddd;
177
- cursor: pointer;
178
- }
179
- .suite-info .suite-path {
180
- word-break: break-all;
181
- flex-grow: 1;
182
- font-family: monospace;
183
- font-size: 1rem;
184
- }
185
- .suite-info .suite-time {
186
- margin-left: 0.5rem;
187
- padding: 0.2rem 0.3rem;
188
- font-size: 0.75rem;
189
- }
190
- .suite-info .suite-time.warn {
191
- background-color: #d8000c;
192
- color: #fff;
193
- }
194
- .suite-info:before {
195
- content: "\2303";
196
- display: inline-block;
197
- margin-right: 0.5rem;
198
- transform: rotate(0deg);
199
- }
200
- .suite-container > input[type="checkbox"]:checked ~ label .suite-info:before {
201
- transform: rotate(180deg);
202
- }
203
-
204
- /* CONSOLE LOGS */
205
- .suite-consolelog {
206
- margin-bottom: 0.25rem;
207
- padding: 1rem;
208
- background-color: #efefef;
209
- }
210
- .suite-consolelog-header {
211
- font-weight: bold;
212
- }
213
- .suite-consolelog-item {
214
- padding: 0.5rem;
215
- }
216
- .suite-consolelog-item pre {
217
- margin: 0.5rem 0;
218
- white-space: pre-wrap;
219
- white-space: -moz-pre-wrap;
220
- white-space: -pre-wrap;
221
- white-space: -o-pre-wrap;
222
- word-wrap: break-word;
223
- }
224
- .suite-consolelog-item-origin {
225
- color: #777;
226
- font-weight: bold;
227
- }
228
- .suite-consolelog-item-message {
229
- color: #000;
230
- font-size: 1rem;
231
- padding: 0 0.5rem;
232
- }
233
-
234
- /* OBSOLETE SNAPSHOTS */
235
- .suite-obsolete-snapshots {
236
- margin-bottom: 0.25rem;
237
- padding: 1rem;
238
- background-color: #ffbaba;
239
- color: #d8000c;
240
- }
241
- .suite-obsolete-snapshots-header {
242
- font-weight: bold;
243
- }
244
- .suite-obsolete-snapshots-item {
245
- padding: 0.5rem;
246
- }
247
- .suite-obsolete-snapshots-item pre {
248
- margin: 0.5rem 0;
249
- white-space: pre-wrap;
250
- white-space: -moz-pre-wrap;
251
- white-space: -pre-wrap;
252
- white-space: -o-pre-wrap;
253
- word-wrap: break-word;
254
- }
255
- .suite-obsolete-snapshots-item-message {
256
- color: #000;
257
- font-size: 1rem;
258
- padding: 0 0.5rem;
259
- }
260
- </style></head><body><div class="jesthtml-content"><header><h1 id="title">Unit Report</h1></header><div id="metadata-container"><div id="timestamp">Started: 2025-09-03 08:57:31</div><div id="summary"><div id="suite-summary"><div class="summary-total">Suites (1)</div><div class="summary-passed ">1 passed</div><div class="summary-failed summary-empty">0 failed</div><div class="summary-pending summary-empty">0 pending</div></div><div id="test-summary"><div class="summary-total">Tests (1)</div><div class="summary-passed ">1 passed</div><div class="summary-failed summary-empty">0 failed</div><div class="summary-pending summary-empty">0 pending</div></div></div></div><div id="suite-1" class="suite-container"><input id="collapsible-0" type="checkbox" class="toggle" checked="checked"/><label for="collapsible-0"><div class="suite-info"><div class="suite-path">/Users/muthu-19817/git/testing-framework/src/test/core/playwright/buildInFixtures/__tests__/executionContext.test.js</div><div class="suite-time">0.851s</div></div></label><div class="suite-tests"><div class="test-result passed"><div class="test-info"><div class="test-suitename">executionContext</div><div class="test-title">should pass actorInfo with details from getCustomAccountDetails to use</div><div class="test-status">passed</div><div class="test-duration">0.004s</div></div></div></div></div></div></body></html>