@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "0.25.2",
3
+ "version": "0.25.4",
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,52 @@
1
+ // import { expect, test } from '@jest/globals';
2
+ // @ts-nocheck
3
+ import { render, screen, fireEvent } from '@testing-library/react';
4
+ import { composeStories } from '@storybook/react';
5
+ import '@testing-library/jest-dom';
6
+
7
+ import * as DemoStories from './demo.stories';
8
+
9
+ const { Base{{COMPONENT_CLASS_NAME}} } = composeStories(DemoStories);
10
+
11
+ test('renders {{COMPONENT_CLASS_NAME}}', async () => {
12
+ render(<Base{{COMPONENT_CLASS_NAME}}/>);
13
+ expect(await screen.findByText('Date Label')).toBeVisible();
14
+ expect(await screen.findByText('Date helper text')).toBeVisible();
15
+
16
+ // const dateElement = screen.getByRole('textbox');
17
+ // for some odd reason, checking the full string of "USD 0.00" doesn't pass
18
+ // expect(currencyElement).toHaveValue('USD 0.00');
19
+ const myMonth = (screen.getByTestId(':date-input:control-month') as HTMLInputElement);
20
+ expect(myMonth.value).toContain('01');
21
+ expect(myMonth).toHaveAttribute('placeholder', 'MM');
22
+
23
+ const myDay = (screen.getByTestId(':date-input:control-day') as HTMLInputElement);
24
+ expect(myDay.value).toContain('31');
25
+ expect(myDay).toHaveAttribute('placeholder', 'DD');
26
+
27
+ const myYear = (screen.getByTestId(':date-input:control-year') as HTMLInputElement);
28
+ expect(myYear.value).toContain('2023');
29
+ expect(myYear).toHaveAttribute('placeholder', 'YYYY');
30
+
31
+ // press clear button
32
+ const clearX = screen.getByTestId(':date-input:clear-current-date') as HTMLButtonElement;
33
+ fireEvent.click(clearX);
34
+
35
+ const myClearMonth = (screen.getByTestId(':date-input:control-month') as HTMLInputElement).value;
36
+ expect(myClearMonth).toContain('');
37
+
38
+ const myClearDay = (screen.getByTestId(':date-input:control-day') as HTMLInputElement).value;
39
+ expect(myClearDay).toContain('');
40
+
41
+ const myClearYear = (screen.getByTestId(':date-input:control-year') as HTMLInputElement).value;
42
+ expect(myClearYear).toContain('');
43
+
44
+ // press date picker
45
+ const pickerButton = screen.getByTestId(':date-input:open-close-picker') as HTMLButtonElement;
46
+ fireEvent.click(pickerButton);
47
+
48
+ // because need to wait after button pressed before finding the data picker pop up, need to do this
49
+ // via "await" and "findByTestId" (as opposed to getByTestId)
50
+ const dataPickerPopUp = await screen.findByTestId(':date-input:clear-current-date');
51
+ expect(dataPickerPopUp).not.toBeNull();
52
+ });
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable react/jsx-no-useless-fragment */
2
+ // @ts-nocheck
2
3
  import type { Meta, StoryObj } from '@storybook/react';
3
4
  import { configProps, stateProps } from './mock';
4
5
  import {{COMPONENT_CLASS_NAME}} from './index';
@@ -0,0 +1,72 @@
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('DateTime Label')).toBeVisible();
13
+ expect(await screen.findByText('DateTime helper text')).toBeVisible();
14
+
15
+ // const dateElement = 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 myMonth = (screen.getByTestId(':date-time-input:control-month') as HTMLInputElement);
19
+ expect(myMonth.value).toContain('01');
20
+ expect(myMonth).toHaveAttribute('placeholder', 'MM');
21
+
22
+ const myDay = (screen.getByTestId(':date-time-input:control-day') as HTMLInputElement);
23
+ expect(myDay.value).toContain('24');
24
+ expect(myDay).toHaveAttribute('placeholder', 'DD');
25
+
26
+ const myYear = (screen.getByTestId(':date-time-input:control-year') as HTMLInputElement);
27
+ expect(myYear.value).toContain('2023');
28
+ expect(myYear).toHaveAttribute('placeholder', 'YYYY');
29
+
30
+ const myHour = (screen.getByTestId(':date-time-input:control-hour') as HTMLInputElement);
31
+ expect(myHour.value).toContain('04');
32
+ expect(myHour).toHaveAttribute('placeholder', 'hh');
33
+
34
+ const myMinute = (screen.getByTestId(':date-time-input:control-minute') as HTMLInputElement);
35
+ expect(myMinute.value).toContain('45');
36
+ expect(myMinute).toHaveAttribute('placeholder', 'mm');
37
+
38
+ const myPeriod = (screen.getByTestId(':date-time-input:control-period') as HTMLSelectElement).value;
39
+ expect(myPeriod).toContain('PM');
40
+
41
+
42
+ // press clear button
43
+ const clearX = screen.getByTestId(':date-time-input:clear-current-date-and-time') as HTMLButtonElement;
44
+ fireEvent.click(clearX);
45
+
46
+ const myClearMonth = (screen.getByTestId(':date-time-input:control-month') as HTMLInputElement).value;
47
+ expect(myClearMonth).toContain('');
48
+
49
+ const myClearDay = (screen.getByTestId(':date-time-input:control-day') as HTMLInputElement).value;
50
+ expect(myClearDay).toContain('');
51
+
52
+ const myClearYear = (screen.getByTestId(':date-time-input:control-year') as HTMLInputElement).value;
53
+ expect(myClearYear).toContain('');
54
+
55
+ const myClearHour = (screen.getByTestId(':date-time-input:control-hour') as HTMLInputElement).value;
56
+ expect(myClearHour).toContain('');
57
+
58
+ const myClearMinute = (screen.getByTestId(':date-time-input:control-minute') as HTMLInputElement).value;
59
+ expect(myClearMinute).toContain('');
60
+
61
+ const myClearPeriod = (screen.getByTestId(':date-time-input:control-period') as HTMLSelectElement).value;
62
+ expect(myClearPeriod).toContain('AM');
63
+
64
+ // press date picker
65
+ const pickerButton = screen.getByTestId(':date-time-input:open-close-picker') as HTMLButtonElement;
66
+ fireEvent.click(pickerButton);
67
+
68
+ // because need to wait after button pressed before finding the data picker pop up, need to do this
69
+ // via "await" and "findByTestId" (as opposed to getByTestId)
70
+ const dataPickerPopUp = await screen.findByTestId(':date-time-input:picker:date-picker:');
71
+ expect(dataPickerPopUp).not.toBeNull();
72
+ });
@@ -0,0 +1,21 @@
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('Decimal Sample')).toBeVisible();
13
+ expect(await screen.findByText('Decimal Helper Text')).toBeVisible();
14
+
15
+ const decimalElement = screen.getByRole('textbox');
16
+
17
+ const myTextAreaVal = (screen.getByRole('textbox') as HTMLInputElement).value;
18
+ expect(myTextAreaVal).toContain('');
19
+
20
+ expect(decimalElement).toHaveAttribute('placeholder', 'Decimal Placeholder');
21
+ });
@@ -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
+ });
@@ -0,0 +1,18 @@
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('Percentage Sample')).toBeVisible();
13
+ expect(await screen.findByText('Percentage Helper Text')).toBeVisible();
14
+
15
+ const percentElement = (screen.getByTestId('percentage-12345678') as HTMLInputElement);
16
+ expect(percentElement.value).toContain('%');
17
+
18
+ });
@@ -15,6 +15,7 @@ export default meta;
15
15
  type Story = StoryObj<typeof {{COMPONENT_CLASS_NAME}}>;
16
16
 
17
17
  if (!window.PCore) {
18
+ // @ts-ignore
18
19
  window.PCore = {};
19
20
  }
20
21
 
@@ -37,6 +38,7 @@ const statelistData = {
37
38
 
38
39
  export const Base{{COMPONENT_CLASS_NAME}}: Story = (args: any) => {
39
40
 
41
+ // @ts-ignore
40
42
  window.PCore.getDataPageUtils = () => {
41
43
  return {
42
44
  getData: () => {
@@ -0,0 +1,27 @@
1
+ // import { expect, test } from '@jest/globals';
2
+ import { fireEvent, 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('State list for USA')).toBeVisible();
13
+
14
+ expect(screen.queryByText('Massachusetts')).not.toBeInTheDocument();
15
+ expect(screen.queryByText('Rhode Island')).not.toBeInTheDocument();
16
+ expect(screen.queryByText('Connecticut')).not.toBeInTheDocument();
17
+
18
+ const iconButton = screen.getByRole('button');
19
+ fireEvent.click(iconButton);
20
+
21
+ expect(await screen.findByText('Massachusetts')).toBeVisible();
22
+ expect(await screen.findByText('Rhode Island')).toBeVisible();
23
+ expect(await screen.findByText('Connecticut')).toBeVisible();
24
+
25
+ const iconLink = screen.getByRole('link');
26
+ expect(iconLink).toHaveAttribute('href', 'about:blank');
27
+ });
@@ -0,0 +1,18 @@
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('Integer Sample')).toBeVisible();
13
+ expect(await screen.findByText('Integer Helper Text')).toBeVisible();
14
+
15
+ const integerElement = (screen.getByTestId('integer-12345678') as HTMLInputElement);
16
+ expect(integerElement.value).toBe('');
17
+
18
+ });
@@ -0,0 +1,25 @@
1
+ // import { expect, test } from '@jest/globals';
2
+ import { fireEvent, 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('Picklist Sample')).toBeVisible();
13
+ expect(await screen.findByText('Picklist Helper Text')).toBeVisible();
14
+
15
+ const picklistElement = (screen.getByTestId('picklist-12345678') as HTMLSelectElement);
16
+ expect(picklistElement).toHaveAttribute('label', 'Picklist Sample');
17
+ expect(picklistElement.value).toContain('');
18
+
19
+ fireEvent.click(picklistElement);
20
+
21
+ fireEvent.change(picklistElement, { target: { value: 'Option 1' } });
22
+
23
+ expect(picklistElement.value).toContain('Option 1');
24
+
25
+ });
@@ -0,0 +1,32 @@
1
+ // import { expect, test } from '@jest/globals';
2
+ import { fireEvent, 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('Picklist Sample')).toBeVisible();
13
+ expect(await screen.findByText('Picklist Helper Text')).toBeVisible();
14
+
15
+ const searchboxElement = screen.getByTestId(
16
+ 'picklist-12345678:combo-box:control'
17
+ ) as HTMLInputElement;
18
+ expect(searchboxElement).toHaveAttribute('role', 'searchbox');
19
+ expect(searchboxElement).toHaveAttribute('autocomplete', 'off');
20
+ expect(searchboxElement).toHaveAttribute('placeholder', 'Select...');
21
+ expect(searchboxElement.value).toContain('');
22
+
23
+ fireEvent.click(searchboxElement);
24
+
25
+ // because need to wait after button pressed before finding the data picker pop up, need to do this
26
+ // via "await" and "findByTestId" (as opposed to getByTestId)
27
+ const dataPickerPopUp = await screen.findByTestId(':menu:');
28
+ expect(dataPickerPopUp).not.toBeNull();
29
+
30
+
31
+
32
+ });
@@ -0,0 +1,29 @@
1
+ // import { expect, test } from '@jest/globals';
2
+ import { fireEvent, 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('Picklist Sample')).toBeVisible();
13
+ expect(await screen.findByText('Picklist Helper Text')).toBeVisible();
14
+
15
+ const radioElement = (screen.getByTestId('picklist-12345678') as HTMLSelectElement);
16
+ expect(radioElement.value).toBeUndefined();
17
+
18
+ const optionRadios = screen.getAllByRole('radio');
19
+ const option1 = optionRadios[1] as HTMLInputElement;
20
+ const option2 = optionRadios[2] as HTMLInputElement;
21
+
22
+ fireEvent.click(option1);
23
+ expect(option1).toBeChecked();
24
+
25
+ fireEvent.click(option2);
26
+ expect(option2).toBeChecked();
27
+ expect(option1).not.toBeChecked();
28
+
29
+ });
@@ -0,0 +1,19 @@
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('Text Sample')).toBeVisible();
13
+
14
+
15
+ const textElement = (screen.getByTestId('Text-12345678:input:control') as HTMLInputElement);
16
+ expect(textElement.value).toBe('');
17
+
18
+ expect(textElement).toHaveAttribute('placeholder', 'Text Placeholder');
19
+ });
@@ -0,0 +1,20 @@
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('Email Sample')).toBeVisible();
13
+ expect(await screen.findByText('Email Helper Text')).toBeVisible();
14
+
15
+
16
+ const emailElement = (screen.getByTestId('email-12345678') as HTMLInputElement);
17
+ expect(emailElement.value).toBe('');
18
+
19
+ expect(emailElement).toHaveAttribute('placeholder', 'Email Placeholder');
20
+ });
@@ -0,0 +1,20 @@
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('TextInput Sample')).toBeVisible();
13
+ expect(await screen.findByText('TextInput Helper Text')).toBeVisible();
14
+
15
+
16
+ const textInputElement = (screen.getByTestId('TextInput-12345678') as HTMLInputElement);
17
+ expect(textInputElement.value).toBe('');
18
+
19
+ expect(textInputElement).toHaveAttribute('placeholder', 'TextInput Placeholder');
20
+ });
@@ -0,0 +1,21 @@
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('Paragraph Sample')).toBeVisible();
13
+ expect(await screen.findByText('Paragraph Helper Text')).toBeVisible();
14
+
15
+
16
+ const paragraphElement = (screen.getByTestId('paragraph-12345678') as HTMLTextAreaElement);
17
+ expect(paragraphElement.value).toBe('');
18
+
19
+
20
+ expect(paragraphElement).toHaveAttribute('placeholder', 'Paragraph Placeholder');
21
+ });
@@ -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('Phone Sample')).toBeVisible();
13
+ expect(await screen.findByText('Phone Helper Text')).toBeVisible();
14
+
15
+
16
+ const phoneElement = (await screen.getByTestId('phone-12345678') as HTMLInputElement);
17
+ expect(phoneElement.value).toBe('');
18
+
19
+ expect(phoneElement).toHaveAttribute('placeholder', 'Phone Placeholder');
20
+
21
+ const countryElement = (screen.getByTestId(":phone-input:country-code") as HTMLSelectElement);
22
+ expect(countryElement.value).toContain("+1");
23
+ });
@@ -0,0 +1,20 @@
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('URL Sample')).toBeVisible();
13
+ expect(await screen.findByText('URL Helper Text')).toBeVisible();
14
+
15
+
16
+ const urlElement = (screen.getByTestId('url-12345678') as HTMLInputElement);
17
+ expect(urlElement.value).toBe('');
18
+
19
+ expect(urlElement).toHaveAttribute('placeholder', 'URL Placeholder');
20
+ });
@@ -0,0 +1,33 @@
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('TimeOfDay Label')).toBeVisible();
13
+ expect(await screen.findByText('TimeOfDay helper text')).toBeVisible();
14
+
15
+ // const dateElement = 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
+
19
+ const myHour = (screen.getByTestId(':time-input:control-hour') as HTMLInputElement);
20
+ expect(myHour.value).toContain('01');
21
+ expect(myHour).toHaveAttribute('placeholder', 'hh');
22
+
23
+ const myMinute = (screen.getByTestId(':time-input:control-minute') as HTMLInputElement);
24
+ expect(myMinute.value).toContain('30');
25
+ expect(myMinute).toHaveAttribute('placeholder', 'mm');
26
+
27
+ const myPeriod = (screen.getByTestId(':time-input:control-period') as HTMLSelectElement).value;
28
+ expect(myPeriod).toContain('PM');
29
+
30
+ // no clear button
31
+
32
+ // pressing time button, reveals a <div> that has no ID, so can't test for it.
33
+ });
@@ -21,9 +21,11 @@ export default meta;
21
21
  type Story = StoryObj<typeof {{COMPONENT_CLASS_NAME}}>;
22
22
 
23
23
  if (!window.PCore) {
24
+ // @ts-ignore
24
25
  window.PCore = {};
25
26
  }
26
27
 
28
+ // @ts-ignore
27
29
  window.PCore.getLocaleUtils = () => {
28
30
  return {
29
31
  getLocaleValue: (value: any) => {
@@ -32,6 +34,7 @@ window.PCore.getLocaleUtils = () => {
32
34
  };
33
35
  };
34
36
 
37
+ // @ts-ignore
35
38
  window.PCore.getUserApi = () => {
36
39
  return {
37
40
  getOperatorDetails: () => {
@@ -0,0 +1,47 @@
1
+ // import { expect, test } from '@jest/globals';
2
+ import { fireEvent, 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
+
9
+
10
+ const { Base{{COMPONENT_CLASS_NAME}} } = composeStories(DemoStories);
11
+
12
+ test('renders {{COMPONENT_CLASS_NAME}}', async () => {
13
+ render(<Base{{COMPONENT_CLASS_NAME}} />);
14
+ expect(await screen.findByText('Details template')).toBeVisible();
15
+ expect(await screen.findByText('Work Status')).toBeVisible();
16
+ expect(await screen.findByText('Case ID')).toBeVisible();
17
+ expect(await screen.findByText('Create date/time')).toBeVisible();
18
+ expect(await screen.findByText('Create Operator')).toBeVisible();
19
+
20
+ // expect(await screen.findByText('New')).toBeVisible();
21
+
22
+ expect(await screen.findByText('M-1002')).toBeVisible();
23
+ expect(await screen.findByText('December 11, 2022 at 8:06:27 PM')).toBeVisible();
24
+
25
+ expect(await screen.findByText('SLA Deadline')).toBeVisible();
26
+ expect(await screen.findByText('SLA Goal')).toBeVisible();
27
+ expect(await screen.findByText('SLA Start Time')).toBeVisible();
28
+
29
+ expect(await screen.findByText('Deadline')).toBeVisible();
30
+ expect(await screen.findByText('Goal')).toBeVisible();
31
+ expect(await screen.findByText('Start Time')).toBeVisible();
32
+
33
+ const frenchBefore = screen.queryByText('french DigV2');
34
+ expect(frenchBefore).not.toBeInTheDocument();
35
+
36
+ // admin button
37
+ const adminButton = screen.getByRole('button');
38
+ fireEvent.click(adminButton);
39
+
40
+ const frenchArr = await screen.findAllByText('french DigV2');
41
+ expect(frenchArr[0]).toBeVisible();
42
+ expect(frenchArr[1]).toBeVisible();
43
+
44
+
45
+
46
+
47
+ });
@@ -20,9 +20,11 @@ export default meta;
20
20
  type Story = StoryObj<typeof {{COMPONENT_CLASS_NAME}}>;
21
21
 
22
22
  if (!window.PCore) {
23
+ // @ts-ignore
23
24
  window.PCore = {};
24
25
  }
25
26
 
27
+ // @ts-ignore
26
28
  window.PCore.getLocaleUtils = () => {
27
29
  return {
28
30
  getLocaleValue: (value: any) => {
@@ -31,6 +33,7 @@ window.PCore.getLocaleUtils = () => {
31
33
  };
32
34
  };
33
35
 
36
+ // @ts-ignore
34
37
  window.PCore.getUserApi = () => {
35
38
  return {
36
39
  getOperatorDetails: () => {