@pega/custom-dx-components 0.25.2 → 0.25.4

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 (51) hide show
  1. package/package.json +1 -1
  2. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.test.tsx.mustache +19 -0
  3. package/src/tasks/create/templates/Constellation/Field/Date/demo.test.tsx.mustache +52 -0
  4. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.tsx.mustache +1 -0
  5. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.test.tsx.mustache +72 -0
  6. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.test.tsx.mustache +21 -0
  7. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.test.tsx.mustache +23 -0
  8. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.test.tsx.mustache +18 -0
  9. package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/demo.stories.tsx.mustache +2 -0
  10. package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/demo.test.tsx.mustache +27 -0
  11. package/src/tasks/create/templates/Constellation/Field/Integer/demo.test.tsx.mustache +18 -0
  12. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.test.tsx.mustache +25 -0
  13. package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/demo.test.tsx.mustache +32 -0
  14. package/src/tasks/create/templates/Constellation/Field/Picklist-RadioButtons/demo.test.tsx.mustache +29 -0
  15. package/src/tasks/create/templates/Constellation/Field/Text/demo.test.tsx.mustache +19 -0
  16. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.test.tsx.mustache +20 -0
  17. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.test.tsx.mustache +20 -0
  18. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.test.tsx.mustache +21 -0
  19. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.test.tsx.mustache +23 -0
  20. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.test.tsx.mustache +20 -0
  21. package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.test.tsx.mustache +33 -0
  22. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.tsx.mustache +3 -0
  23. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.test.tsx.mustache +47 -0
  24. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.tsx.mustache +3 -0
  25. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.test.tsx.mustache +58 -0
  26. package/src/tasks/create/templates/Constellation/Template/FORM/demo.test.tsx.mustache +40 -0
  27. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.test.tsx.mustache +56 -0
  28. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.tsx.mustache +6 -0
  29. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.test.tsx.mustache +24 -0
  30. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.tsx.mustache +5 -0
  31. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.test.tsx.mustache +28 -0
  32. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.tsx.mustache +4 -0
  33. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.test.tsx.mustache +36 -0
  34. package/src/tasks/create/templates/Constellation/Widget/PAGE/index.tsx.mustache +4 -1
  35. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.tsx.mustache +4 -0
  36. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.test.tsx.mustache +29 -0
  37. package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/demo.stories.tsx.mustache +3 -0
  38. package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/demo.test.tsx.mustache +27 -0
  39. package/src/tasks/create/templates/Launchpad/Widget/CASE/demo.stories.tsx.mustache +5 -0
  40. package/src/tasks/create/templates/Launchpad/Widget/CASE/demo.test.tsx.mustache +28 -0
  41. package/src/tasks/create/templates/Launchpad/Widget/PAGE/demo.stories.tsx.mustache +4 -0
  42. package/src/tasks/create/templates/Launchpad/Widget/PAGE/demo.test.tsx.mustache +36 -0
  43. package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/demo.stories.tsx.mustache +4 -0
  44. package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/demo.test.tsx.mustache +19 -0
  45. package/src/tasks/create-lib/index.js +1 -1
  46. package/src/tasks/init/template/babel.config.cjs +18 -9
  47. package/src/tasks/init/template/jest.config.cjs +29 -4
  48. package/src/tasks/init/template/package.json.mustache +16 -1
  49. package/src/tasks/init/template/setupFiles.ts +5 -0
  50. package/src/tasks/init/template/setupTests.ts +99 -0
  51. package/src/tasks/init/template/tsconfig.json +4 -1
@@ -1,13 +1,22 @@
1
- module.exports = {
2
- presets: [
1
+ module.exports = function (api) {
2
+ api.cache(true);
3
+ const presets = [
3
4
  [
4
- '@babel/preset-typescript',
5
+ '@babel/preset-env',
5
6
  {
6
- onlyRemoveTypeImports: true,
7
- allExtensions: true,
8
- isTSX: true
7
+ targets: {
8
+ esmodules: true,
9
+ node: true
10
+ }
9
11
  }
10
- ]
11
- ],
12
- sourceType: 'unambiguous'
12
+ ],
13
+ '@babel/preset-typescript',
14
+ ['@babel/preset-react', { runtime: 'automatic' }]
15
+ ];
16
+ const plugins = [];
17
+
18
+ return {
19
+ presets,
20
+ plugins
21
+ };
13
22
  };
@@ -1,15 +1,38 @@
1
+ const packagesToTranspile = [
2
+ '@pega/cosmos-react-condition-builder',
3
+ '@pega/cosmos-react-core',
4
+ '@pega/cosmos-react-social',
5
+ '@pega/cosmos-react-rte',
6
+ '@pega/cosmos-react-work',
7
+ 'shortcuts',
8
+ 'preact'
9
+ ];
10
+ const packagesToTranspileStr = packagesToTranspile.map(p => `${p}`).join('|');
11
+
1
12
  module.exports = {
2
13
  verbose: true,
14
+ // preset: 'ts-jest/presets/default-esm',
15
+ preset: 'ts-jest',
16
+ extensionsToTreatAsEsm: ['.ts', '.tsx'],
3
17
  moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
4
18
  transform: {
5
- '^.+\\.[t|j]sx?$': 'babel-jest'
19
+ '^.+\\.(js|jsx|ts|tsx)?$': ['ts-jest', { useESM: true }]
6
20
  },
21
+ moduleNameMapper: {
22
+ shortcuts: '<rootDir>/node_modules/shortcuts/dist/index.js'
23
+ },
24
+ moduleDirectories: ['node_modules', 'src'],
7
25
  collectCoverage: true,
8
- testPathIgnorePatterns: [],
26
+ testPathIgnorePatterns: ['./dist'],
9
27
  transformIgnorePatterns: [],
10
28
  modulePathIgnorePatterns: [],
11
29
  coveragePathIgnorePatterns: [],
12
- collectCoverageFrom: ['./node_modules/@pega/custom-dx-components/src/*.js'],
30
+ setupFiles: ['./setupFiles.ts'],
31
+ setupFilesAfterEnv: ['./setupTests.ts'],
32
+ collectCoverageFrom: [
33
+ './node_modules/@pega/custom-dx-components/src/*.js',
34
+ '!**/*.(test|stories).{ts,tsx,js,jsx}'
35
+ ],
13
36
  coverageThreshold: {
14
37
  global: {
15
38
  statements: 79,
@@ -17,5 +40,7 @@ module.exports = {
17
40
  functions: 81,
18
41
  lines: 80
19
42
  }
20
- }
43
+ },
44
+ testEnvironment: 'jsdom',
45
+ transformIgnorePatterns: [`node_modules/(?!(${packagesToTranspileStr}))`]
21
46
  };
@@ -7,6 +7,8 @@
7
7
  "type": "module",
8
8
  "scripts": {
9
9
  "_***Component_and_Library_mode***": "Component and library mode commands",
10
+ "test": "jest",
11
+ "coverage": "jest --coverage --coverageReporters=html",
10
12
  "startStorybook": "storybook dev --port 6040 --quiet",
11
13
  "lint": "eslint .",
12
14
  "authenticate": "custom-dx-components authenticate",
@@ -100,17 +102,26 @@
100
102
  "ts-loader": "^9.5.1"
101
103
  },
102
104
  "devDependencies": {
105
+ "@babel/preset-env": "^7.25.8",
106
+ "@babel/preset-react": "^7.25.7",
107
+ "@babel/preset-typescript": "^7.25.7",
103
108
  "@pega/configs": "^0.15.1",
104
- "@pega/custom-dx-components": "~0.25.2",
109
+ "@pega/custom-dx-components": "~0.25.4",
105
110
  "@pega/pcore-pconnect-typedefs": "^4.1.0-alpha.1",
106
111
  "@storybook/addon-actions": "^7.6.19",
107
112
  "@storybook/addon-essentials": "^7.6.19",
108
113
  "@storybook/addon-links": "^7.6.19",
109
114
  "@storybook/addon-storysource": "^7.6.19",
115
+ "@storybook/manager-api": "^7.6.19",
110
116
  "@storybook/react": "^7.6.19",
111
117
  "@storybook/react-webpack5": "^7.6.19",
118
+ "@storybook/test-runner": "^0.16.0",
112
119
  "@storybook/theming": "^7.6.19",
120
+ "@testing-library/dom": "^10.4.0",
121
+ "@testing-library/jest-dom": "^6.4.5",
122
+ "@testing-library/react": "^12.1.5",
113
123
  "@types/emoji-mart": "^3.0.14",
124
+ "@types/jest": "^29.5.14",
114
125
  "@types/lodash.get": "^4.4.9",
115
126
  "@types/react": "^17.0.80",
116
127
  "@types/react-color": "^3.0.12",
@@ -118,6 +129,7 @@
118
129
  "@types/styled-components": "^5.1.34",
119
130
  "@typescript-eslint/eslint-plugin": "^5.62.0",
120
131
  "babel-loader": "^9.1.3",
132
+ "core-js": "^3.25.5",
121
133
  "eslint": "^8.57.0",
122
134
  "eslint-plugin-import": "^2.31.0",
123
135
  "eslint-plugin-jest": "^28.8.3",
@@ -128,7 +140,9 @@
128
140
  "eslint-plugin-react-hooks": "^4.6.2",
129
141
  "eslint-plugin-sonarjs": "^0.23.0",
130
142
  "eslint-plugin-storybook": "^0.6.15",
143
+ "esm": "^3.2.25",
131
144
  "jest": "^29.7.0",
145
+ "jest-canvas-mock": "^2.5.2",
132
146
  "jest-environment-jsdom": "^29.7.0",
133
147
  "jest-junit": "^16.0.0",
134
148
  "jwt-decode": "^4.0.0",
@@ -136,6 +150,7 @@
136
150
  "prettier": "3.3.3",
137
151
  "storybook": "^7.6.19",
138
152
  "stylelint": "^16.10.0",
153
+ "ts-jest": "^29.2.5",
139
154
  "typescript": "~5.3.3"
140
155
  }
141
156
  }
@@ -0,0 +1,5 @@
1
+ // setup.js (for jest)
2
+ // import { setProjectAnnotations } from '@storybook/react';
3
+ // import projectAnnotations from './.storybook/preview';
4
+
5
+ // setProjectAnnotations(projectAnnotations);
@@ -0,0 +1,99 @@
1
+ import { configure } from '@testing-library/react';
2
+ import '@testing-library/jest-dom';
3
+ import 'jest-canvas-mock';
4
+
5
+ // Wait time needed
6
+ const TIMEOUT = 300000;
7
+
8
+ // mocks open
9
+ global.open = jest.fn();
10
+
11
+ global.fetch = jest.fn(() =>
12
+ Promise.resolve({
13
+ json: () => Promise.resolve(() => 'xxx'),
14
+ arrayBuffer: () => Promise.resolve(() => 'yyy')
15
+ })
16
+ ) as jest.Mock;
17
+
18
+ window.URL.createObjectURL = jest.fn();
19
+
20
+ // mocks ResizeObserver
21
+ window.ResizeObserver = jest.fn(() => ({
22
+ observe: () => {},
23
+ unobserve: () => {},
24
+ disconnect: () => {}
25
+ }));
26
+
27
+ // mocks IntersectionObserver
28
+ window.IntersectionObserver = jest.fn(() => ({
29
+ root: null,
30
+ rootMargin: '0',
31
+ thresholds: [],
32
+ takeRecords: () => [],
33
+ observe: () => {},
34
+ unobserve: () => {},
35
+ disconnect: () => {}
36
+ }));
37
+
38
+ Object.defineProperty(window, 'matchMedia', {
39
+ writable: true,
40
+ value: jest.fn().mockImplementation(query => ({
41
+ matches: false,
42
+ media: query,
43
+ onchange: null,
44
+ addListener: jest.fn(), // Deprecated
45
+ removeListener: jest.fn(), // Deprecated
46
+ addEventListener: jest.fn(),
47
+ removeEventListener: jest.fn(),
48
+ dispatchEvent: jest.fn()
49
+ }))
50
+ });
51
+
52
+ // // mocks createSVGPoint
53
+ // Object.defineProperty(global.SVGSVGElement.prototype, 'createSVGPoint', {
54
+ // writable: true,
55
+ // value: jest.fn().mockImplementation(() => ({
56
+ // x: 0,
57
+ // y: 0,
58
+ // matrixTransform: jest.fn().mockImplementation(() => ({
59
+ // x: 0,
60
+ // y: 0
61
+ // }))
62
+ // }))
63
+ // });
64
+
65
+ // // mocks getBBox on SVGTextElement
66
+ // (global.SVGElement.prototype as any).getBBox = () => {
67
+ // return {
68
+ // x: 0,
69
+ // y: 0,
70
+ // width: 30,
71
+ // height: 15,
72
+ // bottom: 0,
73
+ // left: 0,
74
+ // right: 0,
75
+ // top: 0,
76
+ // toJSON: () => ''
77
+ // };
78
+ // };
79
+
80
+ // // Mocks the window.matchMedia function used in useBreakpoint hook
81
+ // Object.defineProperty(window, 'matchMedia', {
82
+ // writable: true,
83
+ // value: jest.fn().mockImplementation(query => ({
84
+ // matches: false,
85
+ // media: query,
86
+ // onchange: null,
87
+ // addListener: jest.fn(),
88
+ // removeListener: jest.fn(),
89
+ // addEventListener: jest.fn(),
90
+ // removeEventListener: jest.fn(),
91
+ // dispatchEvent: jest.fn()
92
+ // }))
93
+ // });
94
+
95
+ // jest.setTimeout(TIMEOUT);
96
+
97
+ // // speeds up *ByRole queries a bit
98
+ // // https://github.com/testing-library/dom-testing-library/issues/552
99
+ // configure({ defaultHidden: true });
@@ -9,6 +9,9 @@
9
9
  "baseUrl": "./",
10
10
  "paths": {
11
11
  "@pega/pcore-pconnect-typedefs/*": ["node_modules/@pega/pcore-pconnect-typedefs/*"]
12
- }
12
+ },
13
+ "esModuleInterop": true,
14
+ "types": ["jest", "node", "@types/jest"],
15
+ "verbatimModuleSyntax": false
13
16
  }
14
17
  }