@pega/custom-dx-components 0.25.3 → 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.
- package/package.json +1 -1
- package/src/tasks/create/templates/Constellation/Field/Date/demo.test.tsx.mustache +52 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/demo.test.tsx.mustache +72 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/demo.test.tsx.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.test.tsx.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/demo.stories.tsx.mustache +2 -0
- package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/demo.test.tsx.mustache +27 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/demo.test.tsx.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/demo.test.tsx.mustache +25 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/demo.test.tsx.mustache +32 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist-RadioButtons/demo.test.tsx.mustache +29 -0
- package/src/tasks/create/templates/Constellation/Field/Text/demo.test.tsx.mustache +19 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.test.tsx.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.test.tsx.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.test.tsx.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.test.tsx.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.test.tsx.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.test.tsx.mustache +33 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.tsx.mustache +3 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.test.tsx.mustache +47 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.tsx.mustache +3 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.test.tsx.mustache +58 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/demo.test.tsx.mustache +40 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.test.tsx.mustache +56 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.tsx.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/demo.test.tsx.mustache +24 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.tsx.mustache +5 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/demo.test.tsx.mustache +28 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.tsx.mustache +4 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.test.tsx.mustache +36 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.tsx.mustache +4 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.tsx.mustache +4 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.test.tsx.mustache +29 -0
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/demo.stories.tsx.mustache +3 -0
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/demo.test.tsx.mustache +27 -0
- package/src/tasks/create/templates/Launchpad/Widget/CASE/demo.stories.tsx.mustache +5 -0
- package/src/tasks/create/templates/Launchpad/Widget/CASE/demo.test.tsx.mustache +28 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/demo.stories.tsx.mustache +4 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/demo.test.tsx.mustache +36 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/demo.stories.tsx.mustache +4 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/demo.test.tsx.mustache +19 -0
- package/src/tasks/init/template/jest.config.cjs +3 -2
- package/src/tasks/init/template/package.json.mustache +1 -1
- package/src/tasks/init/template/setupFiles.ts +5 -0
- package/src/tasks/init/template/setupTests.ts +99 -0
|
@@ -0,0 +1,40 @@
|
|
|
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('Form template')).toBeVisible();
|
|
13
|
+
|
|
14
|
+
// labels
|
|
15
|
+
expect(await screen.findByText('First Name')).toBeVisible();
|
|
16
|
+
expect(await screen.findByText('Middle Name')).toBeVisible();
|
|
17
|
+
expect(await screen.findByText('Last Name')).toBeVisible();
|
|
18
|
+
expect(await screen.findByText('Email')).toBeVisible();
|
|
19
|
+
expect(await screen.findByText('Phone Number')).toBeVisible();
|
|
20
|
+
expect(await screen.findByText('Service Date')).toBeVisible();
|
|
21
|
+
|
|
22
|
+
const inputElements = screen.getAllByTestId(':input:control');
|
|
23
|
+
expect((inputElements[0] as HTMLInputElement).value).toBe('John');
|
|
24
|
+
expect((inputElements[1] as HTMLInputElement).value).toBe('');
|
|
25
|
+
expect((inputElements[2] as HTMLInputElement).value).toBe('Doe');
|
|
26
|
+
expect((inputElements[3] as HTMLInputElement).value).toBe('John@doe.com');
|
|
27
|
+
|
|
28
|
+
const myPhone = (screen.getByTestId(':phone-input:control') as HTMLInputElement).value;
|
|
29
|
+
expect(myPhone).toContain('(639) 797-5093');
|
|
30
|
+
|
|
31
|
+
const myClearMonth = (screen.getByTestId(':date-input:control-month') as HTMLInputElement).value;
|
|
32
|
+
expect(myClearMonth).toContain('01');
|
|
33
|
+
|
|
34
|
+
const myClearDay = (screen.getByTestId(':date-input:control-day') as HTMLInputElement).value;
|
|
35
|
+
expect(myClearDay).toContain('25');
|
|
36
|
+
|
|
37
|
+
const myClearYear = (screen.getByTestId(':date-input:control-year') as HTMLInputElement).value;
|
|
38
|
+
expect(myClearYear).toContain('2023');
|
|
39
|
+
|
|
40
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
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('Form Region template')).toBeVisible();
|
|
13
|
+
|
|
14
|
+
// labels
|
|
15
|
+
expect(await screen.findByText('First Name')).toBeVisible();
|
|
16
|
+
expect(await screen.findByText('Middle Name')).toBeVisible();
|
|
17
|
+
expect(await screen.findByText('Last Name')).toBeVisible();
|
|
18
|
+
expect(await screen.findByText('Email')).toBeVisible();
|
|
19
|
+
expect(await screen.findByText('Phone Number')).toBeVisible();
|
|
20
|
+
expect(await screen.findByText('Service Date')).toBeVisible();
|
|
21
|
+
|
|
22
|
+
const inputElements = screen.getAllByTestId(':input:control');
|
|
23
|
+
expect((inputElements[0] as HTMLInputElement).value).toBe('John');
|
|
24
|
+
expect((inputElements[1] as HTMLInputElement).value).toBe('');
|
|
25
|
+
expect((inputElements[2] as HTMLInputElement).value).toBe('Doe');
|
|
26
|
+
expect((inputElements[3] as HTMLInputElement).value).toBe('John@doe.com');
|
|
27
|
+
|
|
28
|
+
const myPhone = (screen.getByTestId(':phone-input:control') as HTMLInputElement).value;
|
|
29
|
+
expect(myPhone).toContain('(639) 797-5093');
|
|
30
|
+
|
|
31
|
+
const myClearMonth = (screen.getByTestId(':date-input:control-month') as HTMLInputElement).value;
|
|
32
|
+
expect(myClearMonth).toContain('01');
|
|
33
|
+
|
|
34
|
+
const myClearDay = (screen.getByTestId(':date-input:control-day') as HTMLInputElement).value;
|
|
35
|
+
expect(myClearDay).toContain('25');
|
|
36
|
+
|
|
37
|
+
const myClearYear = (screen.getByTestId(':date-input:control-year') as HTMLInputElement).value;
|
|
38
|
+
expect(myClearYear).toContain('2023');
|
|
39
|
+
|
|
40
|
+
// verify 2 columns
|
|
41
|
+
const fieldSet = screen.getByRole('group');
|
|
42
|
+
|
|
43
|
+
// <fieldset>
|
|
44
|
+
// <legend></legend>
|
|
45
|
+
// <div>
|
|
46
|
+
// <div>
|
|
47
|
+
// <div> 2 divs (columns) </div>
|
|
48
|
+
// </div>
|
|
49
|
+
// </div>
|
|
50
|
+
// </fieldset>
|
|
51
|
+
|
|
52
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
53
|
+
expect(fieldSet.children[1].children[0].children[0].children).toHaveLength(2);
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
});
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
5
|
|
|
6
6
|
import { AppAnnouncement as PegaAppAnnouncement } from '@pega/cosmos-react-work';
|
|
7
|
+
import { useRef } from 'react';
|
|
7
8
|
|
|
8
9
|
import {{COMPONENT_CLASS_NAME}} from './index';
|
|
9
10
|
import { pyHome1Resolved, pyHome1Raw } from './mock';
|
|
@@ -19,9 +20,11 @@ type Story = StoryObj<typeof {{COMPONENT_CLASS_NAME}}>;
|
|
|
19
20
|
|
|
20
21
|
export const Base{{COMPONENT_CLASS_NAME}}: Story = (args: any) => {
|
|
21
22
|
if (!window.PCore) {
|
|
23
|
+
// @ts-ignore
|
|
22
24
|
window.PCore = {};
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
// @ts-ignore
|
|
25
28
|
window.PCore.getLocaleUtils = () => {
|
|
26
29
|
return {
|
|
27
30
|
getLocaleValue: (val: any) => {
|
|
@@ -32,6 +35,8 @@ export const Base{{COMPONENT_CLASS_NAME}}: Story = (args: any) => {
|
|
|
32
35
|
|
|
33
36
|
const configProps = pyHome1Resolved.children[0].children[0].config;
|
|
34
37
|
|
|
38
|
+
const myRef = useRef(null);
|
|
39
|
+
|
|
35
40
|
const props = {
|
|
36
41
|
useConfigurableLayout: false,
|
|
37
42
|
icon: pyHome1Raw.config.icon,
|
|
@@ -82,6 +87,7 @@ export const Base{{COMPONENT_CLASS_NAME}}: Story = (args: any) => {
|
|
|
82
87
|
}
|
|
83
88
|
};
|
|
84
89
|
}}
|
|
90
|
+
ref={myRef}
|
|
85
91
|
/>
|
|
86
92
|
);
|
|
87
93
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
|
|
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('Page Template')).toBeVisible();
|
|
15
|
+
expect(await screen.findByText('Announcements')).toBeVisible();
|
|
16
|
+
expect(await screen.findByText('Get next work')).toBeVisible();
|
|
17
|
+
expect(await screen.findByText("We've launched a brand new experience to accelerate your workflow. Check out the guides to help you get the most of Cosmos.")).toBeVisible();
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
});
|
|
@@ -15,11 +15,13 @@ 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
|
|
|
21
22
|
export const Base{{COMPONENT_CLASS_NAME}}: Story = (args: any) => {
|
|
22
23
|
|
|
24
|
+
// @ts-ignore
|
|
23
25
|
window.PCore.getConstants = () => {
|
|
24
26
|
return {
|
|
25
27
|
CASE_INFO: {
|
|
@@ -28,6 +30,7 @@ export const Base{{COMPONENT_CLASS_NAME}}: Story = (args: any) => {
|
|
|
28
30
|
};
|
|
29
31
|
};
|
|
30
32
|
|
|
33
|
+
// @ts-ignore
|
|
31
34
|
window.PCore.getLocaleUtils = () => {
|
|
32
35
|
return {
|
|
33
36
|
getLocaleValue: (value: any) => {
|
|
@@ -36,10 +39,12 @@ export const Base{{COMPONENT_CLASS_NAME}}: Story = (args: any) => {
|
|
|
36
39
|
};
|
|
37
40
|
};
|
|
38
41
|
|
|
42
|
+
// @ts-ignore
|
|
39
43
|
window.PCore.getDataApiUtils = () => {
|
|
40
44
|
return {
|
|
41
45
|
getData: () => {
|
|
42
46
|
return new Promise(resolve => {
|
|
47
|
+
// @ts-ignore
|
|
43
48
|
resolve(historyData);
|
|
44
49
|
});
|
|
45
50
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
|
|
15
|
+
const caseHistoryArr = await screen.findAllByText('Case history');
|
|
16
|
+
expect(caseHistoryArr[0]).toBeVisible();
|
|
17
|
+
expect(caseHistoryArr[1]).toBeVisible();
|
|
18
|
+
|
|
19
|
+
expect(await screen.findByText('Date')).toBeVisible();
|
|
20
|
+
expect(await screen.findByText('Description')).toBeVisible();
|
|
21
|
+
expect(await screen.findByText('Performed by')).toBeVisible();
|
|
22
|
+
|
|
23
|
+
const peformedArr = await screen.findAllByText('User DigV2');
|
|
24
|
+
expect(peformedArr[0]).toBeVisible();
|
|
25
|
+
expect(peformedArr[1]).toBeVisible();
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
});
|
|
@@ -17,6 +17,7 @@ export default meta;
|
|
|
17
17
|
type Story = StoryObj<typeof {{COMPONENT_CLASS_NAME}}>;
|
|
18
18
|
|
|
19
19
|
if (!window.PCore) {
|
|
20
|
+
// @ts-ignore
|
|
20
21
|
window.PCore = {};
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -47,15 +48,18 @@ const worklistData = {
|
|
|
47
48
|
|
|
48
49
|
export const Base{{COMPONENT_CLASS_NAME}}: Story = (args: any) => {
|
|
49
50
|
|
|
51
|
+
// @ts-ignore
|
|
50
52
|
window.PCore.getDataApiUtils = () => {
|
|
51
53
|
return {
|
|
52
54
|
getData: () => {
|
|
53
55
|
return new Promise(resolve => {
|
|
56
|
+
// @ts-ignore
|
|
54
57
|
resolve(worklistData);
|
|
55
58
|
});
|
|
56
59
|
},
|
|
57
60
|
getDataAsync: () => {
|
|
58
61
|
return new Promise(resolve => {
|
|
62
|
+
// @ts-ignore
|
|
59
63
|
resolve(worklistData);
|
|
60
64
|
});
|
|
61
65
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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('Announcements')).toBeVisible();
|
|
15
|
+
expect(await screen.findByText("See what's new")).toBeVisible();
|
|
16
|
+
expect(
|
|
17
|
+
await screen.findByText('Welcome to MediaCo Application for testing SDK frameworks.')
|
|
18
|
+
).toBeVisible();
|
|
19
|
+
|
|
20
|
+
const workListArr = screen.getAllByText('Work list');
|
|
21
|
+
expect(workListArr[0]).toBeVisible();
|
|
22
|
+
expect(workListArr[1]).toBeInTheDocument();
|
|
23
|
+
|
|
24
|
+
expect(await screen.findByText('Case type')).toBeVisible();
|
|
25
|
+
expect(await screen.findByText('Key')).toBeVisible();
|
|
26
|
+
expect(await screen.findByText('Status')).toBeVisible();
|
|
27
|
+
expect(await screen.findByText('Stage')).toBeVisible();
|
|
28
|
+
|
|
29
|
+
expect(await screen.findByText('A-8002')).toBeVisible();
|
|
30
|
+
expect(await screen.findByText('A-7001')).toBeVisible();
|
|
31
|
+
expect(await screen.findByText('A-9000')).toBeVisible();
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
1
|
+
import { useEffect, useState, useRef } from 'react';
|
|
2
2
|
import { withConfiguration, Table } from '@pega/cosmos-react-core';
|
|
3
3
|
import { AppAnnouncement as PegaAppAnnouncement } from '@pega/cosmos-react-work';
|
|
4
4
|
import type { PConnFieldProps } from './PConnProps';
|
|
@@ -42,6 +42,8 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
|
|
|
42
42
|
{ renderer: 'stage', label: PConnect.getLocalizedValue('Stage', '', '') }
|
|
43
43
|
];
|
|
44
44
|
|
|
45
|
+
const myRef = useRef(null);
|
|
46
|
+
|
|
45
47
|
// going to get data for worklist to put into a table
|
|
46
48
|
// data comes from calling a PCore function to get
|
|
47
49
|
// get data from a data page and a PConnect function
|
|
@@ -90,6 +92,7 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
|
|
|
90
92
|
details={details}
|
|
91
93
|
whatsNewLink={whatsnewlink}
|
|
92
94
|
image={image.replace(/ /g, '+')}
|
|
95
|
+
ref={myRef}
|
|
93
96
|
/>
|
|
94
97
|
<br />
|
|
95
98
|
<Table
|
|
@@ -15,9 +15,11 @@ 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
|
|
|
22
|
+
// @ts-ignore
|
|
21
23
|
window.PCore.getLocaleUtils = () => {
|
|
22
24
|
return {
|
|
23
25
|
getLocaleValue: (value: any) => {
|
|
@@ -26,10 +28,12 @@ window.PCore.getLocaleUtils = () => {
|
|
|
26
28
|
};
|
|
27
29
|
};
|
|
28
30
|
|
|
31
|
+
// @ts-ignore
|
|
29
32
|
window.PCore.getUserApi = () => {
|
|
30
33
|
return {
|
|
31
34
|
getOperatorDetails: () => {
|
|
32
35
|
return new Promise(resolve => {
|
|
36
|
+
// @ts-ignore
|
|
33
37
|
resolve(operatorDetails);
|
|
34
38
|
});
|
|
35
39
|
}
|
|
@@ -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
|
+
|
|
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('Create operator')).toBeVisible();
|
|
15
|
+
// expect(await screen.findByText('last year')).toBeVisible();
|
|
16
|
+
|
|
17
|
+
const frenchBefore = screen.queryByText('french DigV2');
|
|
18
|
+
expect(frenchBefore).not.toBeInTheDocument();
|
|
19
|
+
|
|
20
|
+
// admin button
|
|
21
|
+
const adminButton = screen.getByRole('button');
|
|
22
|
+
fireEvent.click(adminButton);
|
|
23
|
+
|
|
24
|
+
const frenchArr = await screen.findAllByText('french DigV2');
|
|
25
|
+
expect(frenchArr[0]).toBeVisible();
|
|
26
|
+
expect(frenchArr[1]).toBeVisible();
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
});
|
package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/demo.stories.tsx.mustache
CHANGED
|
@@ -14,7 +14,9 @@ const meta: Meta<typeof {{COMPONENT_CLASS_NAME}}> = {
|
|
|
14
14
|
export default meta;
|
|
15
15
|
type Story = StoryObj<typeof {{COMPONENT_CLASS_NAME}}>;
|
|
16
16
|
|
|
17
|
+
|
|
17
18
|
if (!window.PCore) {
|
|
19
|
+
// @ts-ignore
|
|
18
20
|
window.PCore = {};
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -35,6 +37,7 @@ const countrylistData = {
|
|
|
35
37
|
]
|
|
36
38
|
};
|
|
37
39
|
|
|
40
|
+
// @ts-ignore
|
|
38
41
|
window.PCore.getDataPageUtils = () => {
|
|
39
42
|
return {
|
|
40
43
|
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('List of countries')).toBeVisible();
|
|
13
|
+
|
|
14
|
+
expect(screen.queryByText('United States of America')).not.toBeInTheDocument();
|
|
15
|
+
expect(screen.queryByText('Canada')).not.toBeInTheDocument();
|
|
16
|
+
expect(screen.queryByText('Mexico')).not.toBeInTheDocument();
|
|
17
|
+
|
|
18
|
+
const iconButton = screen.getByRole('button');
|
|
19
|
+
fireEvent.click(iconButton);
|
|
20
|
+
|
|
21
|
+
expect(await screen.findByText('United States of America')).toBeVisible();
|
|
22
|
+
expect(await screen.findByText('Canada')).toBeVisible();
|
|
23
|
+
expect(await screen.findByText('Mexico')).toBeVisible();
|
|
24
|
+
|
|
25
|
+
const iconLink = screen.getByRole('link');
|
|
26
|
+
expect(iconLink).toHaveAttribute('href', 'about:blank');
|
|
27
|
+
});
|
|
@@ -15,9 +15,11 @@ 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
|
|
|
22
|
+
// @ts-ignore
|
|
21
23
|
window.PCore.getConstants = () => {
|
|
22
24
|
return {
|
|
23
25
|
CASE_INFO: {
|
|
@@ -26,6 +28,7 @@ window.PCore.getConstants = () => {
|
|
|
26
28
|
};
|
|
27
29
|
};
|
|
28
30
|
|
|
31
|
+
// @ts-ignore
|
|
29
32
|
window.PCore.getLocaleUtils = () => {
|
|
30
33
|
return {
|
|
31
34
|
getLocaleValue: (value: any) => {
|
|
@@ -34,10 +37,12 @@ window.PCore.getLocaleUtils = () => {
|
|
|
34
37
|
};
|
|
35
38
|
};
|
|
36
39
|
|
|
40
|
+
// @ts-ignore
|
|
37
41
|
window.PCore.getDataApiUtils = () => {
|
|
38
42
|
return {
|
|
39
43
|
getData: () => {
|
|
40
44
|
return new Promise(resolve => {
|
|
45
|
+
// @ts-ignore
|
|
41
46
|
resolve(historyData);
|
|
42
47
|
});
|
|
43
48
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
|
|
15
|
+
const caseHistoryArr = await screen.findAllByText('Case history');
|
|
16
|
+
expect(caseHistoryArr[0]).toBeVisible();
|
|
17
|
+
expect(caseHistoryArr[1]).toBeVisible();
|
|
18
|
+
|
|
19
|
+
expect(await screen.findByText('Date')).toBeVisible();
|
|
20
|
+
expect(await screen.findByText('Description')).toBeVisible();
|
|
21
|
+
expect(await screen.findByText('Performed by')).toBeVisible();
|
|
22
|
+
|
|
23
|
+
const peformedArr = await screen.findAllByText('User DigV2');
|
|
24
|
+
expect(peformedArr[0]).toBeVisible();
|
|
25
|
+
expect(peformedArr[1]).toBeVisible();
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
});
|
|
@@ -16,6 +16,7 @@ export default meta;
|
|
|
16
16
|
type Story = StoryObj<typeof {{COMPONENT_CLASS_NAME}}>;
|
|
17
17
|
|
|
18
18
|
if (!window.PCore) {
|
|
19
|
+
// @ts-ignore
|
|
19
20
|
window.PCore = {};
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -45,15 +46,18 @@ const worklistData = {
|
|
|
45
46
|
|
|
46
47
|
};
|
|
47
48
|
|
|
49
|
+
// @ts-ignore
|
|
48
50
|
window.PCore.getDataApiUtils = () => {
|
|
49
51
|
return {
|
|
50
52
|
getData: () => {
|
|
51
53
|
return new Promise(resolve => {
|
|
54
|
+
// @ts-ignore
|
|
52
55
|
resolve(worklistData);
|
|
53
56
|
});
|
|
54
57
|
},
|
|
55
58
|
getDataAsync: () => {
|
|
56
59
|
return new Promise(resolve => {
|
|
60
|
+
// @ts-ignore
|
|
57
61
|
resolve(worklistData);
|
|
58
62
|
});
|
|
59
63
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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('Announcements')).toBeVisible();
|
|
15
|
+
expect(await screen.findByText("See what's new")).toBeVisible();
|
|
16
|
+
expect(
|
|
17
|
+
await screen.findByText('Welcome to MediaCo Application for testing SDK frameworks.')
|
|
18
|
+
).toBeVisible();
|
|
19
|
+
|
|
20
|
+
const workListArr = screen.getAllByText('Work list');
|
|
21
|
+
expect(workListArr[0]).toBeVisible();
|
|
22
|
+
expect(workListArr[1]).toBeInTheDocument();
|
|
23
|
+
|
|
24
|
+
expect(await screen.findByText('Case type')).toBeVisible();
|
|
25
|
+
expect(await screen.findByText('Key')).toBeVisible();
|
|
26
|
+
expect(await screen.findByText('Status')).toBeVisible();
|
|
27
|
+
expect(await screen.findByText('Stage')).toBeVisible();
|
|
28
|
+
|
|
29
|
+
expect(await screen.findByText('A-8002')).toBeVisible();
|
|
30
|
+
expect(await screen.findByText('A-7001')).toBeVisible();
|
|
31
|
+
expect(await screen.findByText('A-9000')).toBeVisible();
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
});
|
|
@@ -15,9 +15,11 @@ 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
|
|
|
22
|
+
// @ts-ignore
|
|
21
23
|
window.PCore.getLocaleUtils = () => {
|
|
22
24
|
return {
|
|
23
25
|
getLocaleValue: (value: any) => {
|
|
@@ -26,10 +28,12 @@ window.PCore.getLocaleUtils = () => {
|
|
|
26
28
|
};
|
|
27
29
|
};
|
|
28
30
|
|
|
31
|
+
// @ts-ignore
|
|
29
32
|
window.PCore.getUserApi = () => {
|
|
30
33
|
return {
|
|
31
34
|
getOperatorDetails: () => {
|
|
32
35
|
return new Promise(resolve => {
|
|
36
|
+
// @ts-ignore
|
|
33
37
|
resolve(operatorDetails);
|
|
34
38
|
});
|
|
35
39
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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('Create operator')).toBeVisible();
|
|
15
|
+
expect(await screen.findByText('Created')).toBeVisible();
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const packagesToTranspile = [
|
|
2
|
+
'@pega/cosmos-react-condition-builder',
|
|
2
3
|
'@pega/cosmos-react-core',
|
|
3
4
|
'@pega/cosmos-react-social',
|
|
4
5
|
'@pega/cosmos-react-rte',
|
|
@@ -26,8 +27,8 @@ module.exports = {
|
|
|
26
27
|
transformIgnorePatterns: [],
|
|
27
28
|
modulePathIgnorePatterns: [],
|
|
28
29
|
coveragePathIgnorePatterns: [],
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
setupFiles: ['./setupFiles.ts'],
|
|
31
|
+
setupFilesAfterEnv: ['./setupTests.ts'],
|
|
31
32
|
collectCoverageFrom: [
|
|
32
33
|
'./node_modules/@pega/custom-dx-components/src/*.js',
|
|
33
34
|
'!**/*.(test|stories).{ts,tsx,js,jsx}'
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"@babel/preset-react": "^7.25.7",
|
|
107
107
|
"@babel/preset-typescript": "^7.25.7",
|
|
108
108
|
"@pega/configs": "^0.15.1",
|
|
109
|
-
"@pega/custom-dx-components": "~0.25.
|
|
109
|
+
"@pega/custom-dx-components": "~0.25.4",
|
|
110
110
|
"@pega/pcore-pconnect-typedefs": "^4.1.0-alpha.1",
|
|
111
111
|
"@storybook/addon-actions": "^7.6.19",
|
|
112
112
|
"@storybook/addon-essentials": "^7.6.19",
|