@zohodesk/testinglibrary 0.4.43-experimental → 0.4.45-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.
Files changed (36) hide show
  1. package/.gitlab-ci.yml +20 -12
  2. package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +1 -1
  3. package/build/bdd-framework/reporter/cucumber/json.js +1 -1
  4. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +1 -1
  5. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +1 -1
  6. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +1 -1
  7. package/build/core/playwright/builtInFixtures/page.js +64 -46
  8. package/build/core/playwright/constants/fileMutexConfig.js +3 -4
  9. package/build/core/playwright/custom-commands.js +1 -1
  10. package/build/core/playwright/helpers/auth/loginSteps.js +26 -18
  11. package/build/core/playwright/helpers/fileMutex.js +13 -11
  12. package/build/core/playwright/tagProcessor.js +32 -24
  13. package/build/core/playwright/test-runner.js +1 -1
  14. package/build/test/core/playwright/__tests__/tagProcessor.test.js +18 -19
  15. package/nobdd/README.md +1 -0
  16. package/nobdd/package.json +17 -0
  17. package/nobdd/src/App.js +7 -0
  18. package/nobdd/uat/conf/default/actors/editions/enterprise.json +24 -0
  19. package/nobdd/uat/conf/default/actors/editions/index.js +4 -0
  20. package/nobdd/uat/conf/default/actors/index.js +2 -0
  21. package/nobdd/uat/conf/default/settings.json +6 -0
  22. package/nobdd/uat/conf/nobdd/uat.config.js +36 -0
  23. package/nobdd/uat/env-config.json +20 -0
  24. package/nobdd/uat/fixtures/auth.setup.js +44 -0
  25. package/nobdd/uat/fixtures/setup.teardown.js +33 -0
  26. package/nobdd/uat/modules/nobdd/steps/VerifyNoBDD.feature.spec.js +16 -0
  27. package/nobdd/uat/shared/commands/_index-custom-fixtures.js +9 -0
  28. package/nobdd/uat/shared/commands/i18n.js +25 -0
  29. package/nobdd/uat/shared/commands/unauthenticatedPage.js +8 -0
  30. package/nobdd/uat/shared/index.js +7 -0
  31. package/nobdd/uat/shared/onboardings/onboardingUpdate.js +44 -0
  32. package/nobdd/uat/shared/url-helpers/getUrlOrigin.js +6 -0
  33. package/nobdd/uat.config.js +37 -0
  34. package/npm-shrinkwrap.json +1305 -1470
  35. package/package.json +5 -6
  36. package/unit_reports/unit-report.html +0 -260
@@ -2,7 +2,6 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  var _tagProcessor = _interopRequireDefault(require("../../../../../src/core/playwright/tagProcessor"));
5
- var _Configuration = _interopRequireDefault(require("../../../../../src/core/playwright/configuration/Configuration.js"));
6
5
  var _logger = require("../../../../utils/logger");
7
6
  jest.mock('../../../../utils/logger');
8
7
  describe('TagProcessor', () => {
@@ -12,83 +11,83 @@ describe('TagProcessor', () => {
12
11
  });
13
12
  test('should return tagArgs if no edition is provided', () => {
14
13
  const tagProcessor = new _tagProcessor.default(editionOrder);
15
- const userArgs = new _Configuration.default({
14
+ const userArgs = {
16
15
  tags: 'tag1',
17
16
  edition: null
18
- });
17
+ };
19
18
  const result = tagProcessor.processTags(userArgs);
20
19
  expect(result).toBe('tag1');
21
20
  });
22
21
  test('should handle a single edition with <= operator', () => {
23
22
  const tagProcessor = new _tagProcessor.default(editionOrder);
24
- const userArgs = new _Configuration.default({
23
+ const userArgs = {
25
24
  tags: 'tag1',
26
25
  edition: '<=edition2'
27
- });
26
+ };
28
27
  const result = tagProcessor.processTags(userArgs);
29
28
  expect(result).toBe('tag1 and not (@edition_edition3 or @edition_edition4)');
30
29
  });
31
30
  test('should handle a single edition with >= operator', () => {
32
31
  const tagProcessor = new _tagProcessor.default(editionOrder);
33
- const userArgs = new _Configuration.default({
32
+ const userArgs = {
34
33
  tags: 'tag1',
35
34
  edition: '>=edition2'
36
- });
35
+ };
37
36
  const result = tagProcessor.processTags(userArgs);
38
37
  expect(result).toBe('tag1 and not (@edition_edition1)');
39
38
  });
40
39
  test('should handle a single edition with < operator', () => {
41
40
  const tagProcessor = new _tagProcessor.default(editionOrder);
42
- const userArgs = new _Configuration.default({
41
+ const userArgs = {
43
42
  tags: 'tag1',
44
43
  edition: '<edition3'
45
- });
44
+ };
46
45
  const result = tagProcessor.processTags(userArgs);
47
46
  expect(result).toBe('tag1 and not (@edition_edition3 or @edition_edition4)');
48
47
  });
49
48
  test('should handle a single edition with > operator', () => {
50
49
  const tagProcessor = new _tagProcessor.default(editionOrder);
51
- const userArgs = new _Configuration.default({
50
+ const userArgs = {
52
51
  tags: 'tag1',
53
52
  edition: '>edition1'
54
- });
53
+ };
55
54
  const result = tagProcessor.processTags(userArgs);
56
55
  expect(result).toBe('tag1 and not (@edition_edition1)');
57
56
  });
58
57
  test('should handle a single edition with no operator', () => {
59
58
  const tagProcessor = new _tagProcessor.default(editionOrder);
60
- const userArgs = new _Configuration.default({
59
+ const userArgs = {
61
60
  tags: 'tag1',
62
61
  edition: 'edition2'
63
- });
62
+ };
64
63
  const result = tagProcessor.processTags(userArgs);
65
64
  expect(result).toBe('tag1 and not (@edition_edition1 or @edition_edition3 or @edition_edition4)');
66
65
  });
67
66
  test('should log a message if edition is not found', () => {
68
67
  const tagProcessor = new _tagProcessor.default(editionOrder);
69
- const userArgs = new _Configuration.default({
68
+ const userArgs = {
70
69
  tags: 'tag1',
71
70
  edition: 'nonexistentEdition'
72
- });
71
+ };
73
72
  const result = tagProcessor.processTags(userArgs);
74
73
  expect(result).toBe('tag1');
75
74
  expect(_logger.Logger.log).toHaveBeenCalledWith(_logger.Logger.INFO_TYPE, expect.stringContaining('No matching editions for nonexistentEdition found.'));
76
75
  });
77
76
  test('should handle multiple editions', () => {
78
77
  const tagProcessor = new _tagProcessor.default(editionOrder);
79
- const userArgs = new _Configuration.default({
78
+ const userArgs = {
80
79
  tags: 'tag1',
81
80
  edition: 'edition1,edition3'
82
- });
81
+ };
83
82
  const result = tagProcessor.processTags(userArgs);
84
83
  expect(result).toBe('tag1 and not (@edition_edition2 or @edition_edition4)');
85
84
  });
86
85
  test('should build tags correctly when tags are empty', () => {
87
86
  const tagProcessor = new _tagProcessor.default(editionOrder);
88
- const userArgs = new _Configuration.default({
87
+ const userArgs = {
89
88
  tags: '',
90
89
  edition: 'edition1'
91
- });
90
+ };
92
91
  const result = tagProcessor.processTags(userArgs);
93
92
  expect(result).toBe('not (@edition_edition2 or @edition_edition3 or @edition_edition4)');
94
93
  });
@@ -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
+ }
@@ -0,0 +1,7 @@
1
+ export function add(a, b) {
2
+ return a + b;
3
+ }
4
+
5
+ export function greet(name) {
6
+ return `Hello, ${name}!`;
7
+ }
@@ -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,4 @@
1
+ const enterprise = require('./enterprise.json');
2
+ const editions = {enterprise};
3
+
4
+ module.exports = editions;
@@ -0,0 +1,2 @@
1
+ const editions = require('./editions/index');
2
+ module.exports = { editions }
@@ -0,0 +1,6 @@
1
+ {
2
+ "environment": "ci",
3
+ "edition": "enterprise",
4
+ "profile": "admin",
5
+ "domain": "https://zdesk-devops16.csez.zohocorpin.com:31025/agent"
6
+ }
@@ -0,0 +1,36 @@
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: false,
16
+ retries:1,
17
+ openReportOn: 'never',
18
+ browsers: ['Chrome'],
19
+ isAuthMode: true,
20
+ authFilePath: getPrimaryCookiePath(),
21
+ trace: 'retain-on-failure',
22
+ video: 'retain-on-failure',
23
+ retries:1,
24
+ bddMode: false,
25
+ expectTimeout: 10 * 1000,
26
+ testTimeout: 60 * 1000,
27
+ globalTimeout: 2 * 60 * 60 * 1000,
28
+ featureFilesFolder: 'feature-files',
29
+ stepDefinitionsFolder: 'steps',
30
+ viewport: { width: 1280, height: 720 },
31
+ testIdAttribute: 'data-id',
32
+ editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise'],
33
+ additionalPages: {
34
+ ...customFixtures
35
+ }
36
+ };
@@ -0,0 +1,20 @@
1
+ {
2
+ "dev": {
3
+ "domain": "https://zdesk-devops16.csez.zohocorpin.com:31025/agent",
4
+ "orgName": "org-name",
5
+ "deptName": "dept-name",
6
+ "moduleName": "module-name"
7
+ },
8
+ "prod": {
9
+ "domain": "https://zdesk-devops16.csez.zohocorpin.com:31025/agent",
10
+ "orgName": "sangeetha.t@zohocorp.com",
11
+ "deptName": "sangeethat",
12
+ "moduleName": "sangeethat"
13
+ },
14
+ "ci": {
15
+ "domain": "https://zdesk-devops16.csez.zohocorpin.com:31025/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,33 @@
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
+ const logoutURL = `${domainOrigin}/support/logout.sas`;
25
+ await page.goto(logoutURL);
26
+ await page.waitForNavigation();
27
+ await expect(page.locator('[id="signin_flow"]')).toBeVisible();
28
+ await fs.rmSync(authFilePath);
29
+ });
30
+
31
+ await Promise.all(promises);
32
+ });
33
+ }
@@ -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(process.env.domain);
8
+
9
+ await page.waitForSelector('#login');
10
+
11
+ const isLoggedIn = await page.isVisible('#login');
12
+ expect(isLoggedIn).toBe(true);
13
+
14
+ });
15
+
16
+ });
@@ -0,0 +1,9 @@
1
+ const i18n = require('./i18n');
2
+ const unAuthenticatedPage = require('./unauthenticatedPage');
3
+
4
+ const customFixtures = {
5
+ ...i18n,
6
+ ...unAuthenticatedPage
7
+ };
8
+
9
+ module.exports = customFixtures;
@@ -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,8 @@
1
+ module.exports = {
2
+ unauthenticatedPage: async ({ browser }, use) => {
3
+ const context = await browser.newContext({ storageState: null });
4
+ const unauthenticatedPage = await context.newPage();
5
+ await use(unauthenticatedPage);
6
+ await context.close();
7
+ }
8
+ }
@@ -0,0 +1,7 @@
1
+ const completeOnboardings = require("./onboardings/onboardingUpdate")
2
+
3
+
4
+
5
+ module.exports = {
6
+ completeOnboardings
7
+ }
@@ -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,6 @@
1
+ function getUrlOrigin(url) {
2
+ const { origin } = new URL(url);
3
+ return origin;
4
+ }
5
+
6
+ module.exports = getUrlOrigin;
@@ -0,0 +1,37 @@
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
+ retries:1,
17
+ openReportOn: 'never',
18
+ browsers: ['Chrome'],
19
+ isAuthMode: true,
20
+ authFilePath: getPrimaryCookiePath(),
21
+ trace: 'retain-on-failure',
22
+ video: 'retain-on-failure',
23
+ retries:1,
24
+ bddMode: false,
25
+ expectTimeout: 10 * 1000,
26
+ testTimeout: 60 * 1000,
27
+ globalTimeout: 2 * 60 * 60 * 1000,
28
+ featureFilesFolder: 'feature-files',
29
+ stepDefinitionsFolder: 'steps',
30
+ viewport: { width: 1280, height: 720 },
31
+ testIdAttribute: 'data-id',
32
+ editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise'],
33
+ additionalPages: {
34
+ ...customFixtures
35
+ },
36
+ url:""
37
+ };