@pega/custom-dx-components 0.25.1 → 0.25.3

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": "@pega/custom-dx-components",
3
- "version": "0.25.1",
3
+ "version": "0.25.3",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -0,0 +1,19 @@
1
+ // import { expect, test } from '@jest/globals';
2
+ import { render, screen, fireEvent } from '@testing-library/react';
3
+ import { composeStories } from '@storybook/react';
4
+ import '@testing-library/jest-dom';
5
+
6
+ import * as DemoStories from './demo.stories';
7
+
8
+ const { Base{{COMPONENT_CLASS_NAME}} } = composeStories(DemoStories);
9
+
10
+ test('renders {{COMPONENT_CLASS_NAME}}', async () => {
11
+ render(<Base{{COMPONENT_CLASS_NAME}} />);
12
+ expect(await screen.findByText('Boolean caption')).toBeVisible();
13
+ expect(await screen.findByText('Boolean label')).toBeVisible();
14
+ expect(await screen.findByText('Test helper text')).toBeVisible();
15
+ const checkboxElement = screen.getByRole('checkbox');
16
+ expect(checkboxElement).toBeChecked();
17
+ fireEvent.click(checkboxElement);
18
+ expect(checkboxElement).not.toBeChecked();
19
+ });
@@ -0,0 +1,23 @@
1
+ // import { expect, test } from '@jest/globals';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { composeStories } from '@storybook/react';
4
+ import '@testing-library/jest-dom';
5
+
6
+ import * as DemoStories from './demo.stories';
7
+
8
+ const { Base{{COMPONENT_CLASS_NAME}} } = composeStories(DemoStories);
9
+
10
+ test('renders {{COMPONENT_CLASS_NAME}}', async () => {
11
+ render(<Base{{COMPONENT_CLASS_NAME}} />);
12
+ expect(await screen.findByText('Currency Sample')).toBeVisible();
13
+ expect(await screen.findByText('Currency Helper Text')).toBeVisible();
14
+
15
+ const currencyElement = screen.getByRole('textbox');
16
+ // for some odd reason, checking the full string of "USD 0.00" doesn't pass
17
+ // expect(currencyElement).toHaveValue('USD 0.00');
18
+ const myTextAreaVal = (screen.getByRole('textbox') as HTMLInputElement).value;
19
+ expect(myTextAreaVal).toContain('USD');
20
+ expect(myTextAreaVal).toContain('0.00');
21
+
22
+ expect(currencyElement).toHaveAttribute('placeholder', 'Currency Placeholder');
23
+ });
@@ -115,7 +115,7 @@ addDebugLog("createLibrary", "", "+");
115
115
  const currAnswers = await inquirer.prompt(curOrgQuestion);
116
116
  ({ currentOrOriginal } = currAnswers);
117
117
  }
118
- else {
118
+ else if (!hasArch && currentOrOriginal === "") {
119
119
  currentOrOriginal = 'Original';
120
120
  }
121
121
 
@@ -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,37 @@
1
+ const packagesToTranspile = [
2
+ '@pega/cosmos-react-core',
3
+ '@pega/cosmos-react-social',
4
+ '@pega/cosmos-react-rte',
5
+ '@pega/cosmos-react-work',
6
+ 'shortcuts',
7
+ 'preact'
8
+ ];
9
+ const packagesToTranspileStr = packagesToTranspile.map(p => `${p}`).join('|');
10
+
1
11
  module.exports = {
2
12
  verbose: true,
13
+ // preset: 'ts-jest/presets/default-esm',
14
+ preset: 'ts-jest',
15
+ extensionsToTreatAsEsm: ['.ts', '.tsx'],
3
16
  moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
4
17
  transform: {
5
- '^.+\\.[t|j]sx?$': 'babel-jest'
18
+ '^.+\\.(js|jsx|ts|tsx)?$': ['ts-jest', { useESM: true }]
6
19
  },
20
+ moduleNameMapper: {
21
+ shortcuts: '<rootDir>/node_modules/shortcuts/dist/index.js'
22
+ },
23
+ moduleDirectories: ['node_modules', 'src'],
7
24
  collectCoverage: true,
8
- testPathIgnorePatterns: [],
25
+ testPathIgnorePatterns: ['./dist'],
9
26
  transformIgnorePatterns: [],
10
27
  modulePathIgnorePatterns: [],
11
28
  coveragePathIgnorePatterns: [],
12
- collectCoverageFrom: ['./node_modules/@pega/custom-dx-components/src/*.js'],
29
+ // setupFiles: ['./setupFiles.ts'],
30
+ // setupFilesAfterEnv: ['./setupTests.ts'],
31
+ collectCoverageFrom: [
32
+ './node_modules/@pega/custom-dx-components/src/*.js',
33
+ '!**/*.(test|stories).{ts,tsx,js,jsx}'
34
+ ],
13
35
  coverageThreshold: {
14
36
  global: {
15
37
  statements: 79,
@@ -17,5 +39,7 @@ module.exports = {
17
39
  functions: 81,
18
40
  lines: 80
19
41
  }
20
- }
42
+ },
43
+ testEnvironment: 'jsdom',
44
+ transformIgnorePatterns: [`node_modules/(?!(${packagesToTranspileStr}))`]
21
45
  };
@@ -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",
@@ -78,9 +80,9 @@
78
80
  "author": "",
79
81
  "license": "Enter License",
80
82
  "dependencies": {
81
- "@pega/cosmos-react-condition-builder": "~8.0.0-build.11.0",
82
- "@pega/cosmos-react-core": "~8.0.0-build.11.0",
83
- "@pega/cosmos-react-work": "~8.0.0-build.11.0",
83
+ "@pega/cosmos-react-condition-builder": "^8.0.0-build.13.2",
84
+ "@pega/cosmos-react-core": "^8.0.0-build.13.2",
85
+ "@pega/cosmos-react-work": "^8.0.0-build.13.2",
84
86
  "@pega/eslint-config": "^0.10.2",
85
87
  "@pega/tsconfig": "^0.15.1",
86
88
  "babel-loader": "^9.1.3",
@@ -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.1",
105
- "@pega/pcore-pconnect-typedefs": "3.2.1",
109
+ "@pega/custom-dx-components": "~0.25.3",
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
  }
@@ -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
  }