@patternfly/react-core 4.199.5 → 4.200.2
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/CHANGELOG.md +30 -0
- package/dist/esm/components/Avatar/Avatar.d.ts +2 -0
- package/dist/esm/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/esm/components/Avatar/Avatar.js +2 -2
- package/dist/esm/components/Avatar/Avatar.js.map +1 -1
- package/dist/esm/components/FormSelect/FormSelect.d.ts +2 -0
- package/dist/esm/components/FormSelect/FormSelect.d.ts.map +1 -1
- package/dist/esm/components/FormSelect/FormSelect.js +3 -2
- package/dist/esm/components/FormSelect/FormSelect.js.map +1 -1
- package/dist/esm/components/TextArea/TextArea.d.ts +2 -0
- package/dist/esm/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/esm/components/TextArea/TextArea.js +4 -3
- package/dist/esm/components/TextArea/TextArea.js.map +1 -1
- package/dist/esm/components/TextInput/TextInput.d.ts +2 -0
- package/dist/esm/components/TextInput/TextInput.d.ts.map +1 -1
- package/dist/esm/components/TextInput/TextInput.js +3 -2
- package/dist/esm/components/TextInput/TextInput.js.map +1 -1
- package/dist/js/components/Avatar/Avatar.d.ts +2 -0
- package/dist/js/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/js/components/Avatar/Avatar.js +2 -2
- package/dist/js/components/Avatar/Avatar.js.map +1 -1
- package/dist/js/components/FormSelect/FormSelect.d.ts +2 -0
- package/dist/js/components/FormSelect/FormSelect.d.ts.map +1 -1
- package/dist/js/components/FormSelect/FormSelect.js +3 -2
- package/dist/js/components/FormSelect/FormSelect.js.map +1 -1
- package/dist/js/components/TextArea/TextArea.d.ts +2 -0
- package/dist/js/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/js/components/TextArea/TextArea.js +4 -3
- package/dist/js/components/TextArea/TextArea.js.map +1 -1
- package/dist/js/components/TextInput/TextInput.d.ts +2 -0
- package/dist/js/components/TextInput/TextInput.d.ts.map +1 -1
- package/dist/js/components/TextInput/TextInput.js +3 -2
- package/dist/js/components/TextInput/TextInput.js.map +1 -1
- package/dist/umd/react-core.js +12 -9
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +5 -5
- package/src/components/Avatar/Avatar.tsx +4 -0
- package/src/components/Avatar/examples/Avatar.md +33 -4
- package/src/components/ChipGroup/__tests__/ChipGroup.test.tsx +14 -9
- package/src/components/ClipboardCopy/__tests__/ClipboardCopyToggle.test.tsx +28 -19
- package/src/components/ClipboardCopy/__tests__/__snapshots__/ClipboardCopyToggle.test.tsx.snap +1 -1
- package/src/components/ContextSelector/__tests__/ContextSelector.test.tsx +21 -14
- package/src/components/ContextSelector/__tests__/ContextSelectorToggle.test.tsx +49 -34
- package/src/components/ContextSelector/__tests__/__snapshots__/ContextSelector.test.tsx.snap +2 -169
- package/src/components/ContextSelector/__tests__/__snapshots__/ContextSelectorToggle.test.tsx.snap +5 -247
- package/src/components/DataList/__tests__/DataList.test.tsx +49 -40
- package/src/components/DataList/__tests__/__snapshots__/DataList.test.tsx.snap +1 -9
- package/src/components/Dropdown/__tests__/Dropdown.test.tsx +54 -42
- package/src/components/Dropdown/__tests__/DropdownToggle.test.tsx +179 -177
- package/src/components/Dropdown/__tests__/DropdownToggleCheckbox.test.tsx +51 -55
- package/src/components/Dropdown/__tests__/Generated/DropdownItem.test.tsx +28 -26
- package/src/components/Dropdown/__tests__/Generated/DropdownSeparator.test.tsx +14 -15
- package/src/components/Dropdown/__tests__/Generated/InternalDropdownItem.test.tsx +39 -36
- package/src/components/Dropdown/__tests__/Generated/__snapshots__/DropdownItem.test.tsx.snap +6 -4
- package/src/components/Dropdown/__tests__/Generated/__snapshots__/DropdownSeparator.test.tsx.snap +11 -4
- package/src/components/Dropdown/__tests__/Generated/__snapshots__/InternalDropdownItem.test.tsx.snap +7 -4
- package/src/components/Dropdown/__tests__/InternalDropdownItem.test.tsx +66 -69
- package/src/components/Dropdown/__tests__/__snapshots__/Dropdown.test.tsx.snap +15 -816
- package/src/components/Dropdown/__tests__/__snapshots__/DropdownToggle.test.tsx.snap +9 -454
- package/src/components/Dropdown/__tests__/__snapshots__/DropdownToggleCheckbox.test.tsx.snap +7 -141
- package/src/components/Dropdown/__tests__/__snapshots__/InternalDropdownItem.test.tsx.snap +10 -163
- package/src/components/FormSelect/FormSelect.tsx +16 -1
- package/src/components/FormSelect/examples/FormSelect.md +58 -0
- package/src/components/Nav/__tests__/Generated/NavList.test.tsx +28 -18
- package/src/components/Nav/__tests__/Generated/__snapshots__/NavList.test.tsx.snap +8 -4
- package/src/components/OptionsMenu/__tests__/Generated/OptionsMenuItem.test.tsx +21 -19
- package/src/components/OptionsMenu/__tests__/Generated/__snapshots__/OptionsMenuItem.test.tsx.snap +20 -11
- package/src/components/OverflowMenu/__tests__/Generated/OverflowMenuDropdownItem.test.tsx +14 -10
- package/src/components/OverflowMenu/__tests__/Generated/__snapshots__/OverflowMenuDropdownItem.test.tsx.snap +18 -4
- package/src/components/Select/__tests__/Generated/SelectGroup.test.tsx +22 -10
- package/src/components/Select/__tests__/Generated/SelectMenu.test.tsx +22 -26
- package/src/components/Select/__tests__/Generated/__snapshots__/SelectGroup.test.tsx.snap +15 -4
- package/src/components/Select/__tests__/Generated/__snapshots__/SelectMenu.test.tsx.snap +7 -19
- package/src/components/Select/__tests__/SelectGroup.test.tsx +14 -7
- package/src/components/Select/__tests__/SelectOption.test.tsx +51 -30
- package/src/components/Select/__tests__/__snapshots__/SelectGroup.test.tsx.snap +1 -5
- package/src/components/Select/__tests__/__snapshots__/SelectOption.test.tsx.snap +10 -272
- package/src/components/TextArea/TextArea.tsx +5 -0
- package/src/components/TextArea/__tests__/__snapshots__/TextArea.test.tsx.snap +2 -0
- package/src/components/TextArea/examples/TextArea.md +43 -0
- package/src/components/TextInput/TextInput.tsx +5 -0
- package/src/components/TextInput/__tests__/__snapshots__/TextInput.test.tsx.snap +2 -0
- package/src/components/TextInput/examples/TextInput.md +104 -27
- package/src/components/Toolbar/__tests__/Generated/ToolbarToggleGroup.test.tsx +25 -11
- package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarToggleGroup.test.tsx.snap +26 -4
- package/src/components/Toolbar/__tests__/Toolbar.test.tsx +129 -0
- package/src/components/Toolbar/__tests__/ToolbarItem.test.tsx +19 -0
- package/src/components/Toolbar/__tests__/ToolbarToggleGroup.test.tsx +12 -135
- package/src/components/Toolbar/__tests__/__snapshots__/Toolbar.test.tsx.snap +7 -0
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.test.tsx.snap +3 -0
- package/src/components/Tooltip/examples/Tooltip.md +9 -1
- package/src/components/Tooltip/examples/TooltipExamples.css +4 -4
- package/src/components/Select/__tests__/Generated/SelectOption.test.tsx +0 -29
- package/src/components/Select/__tests__/Generated/__snapshots__/SelectOption.test.tsx.snap +0 -7
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarToggleGroup.test.tsx.snap +0 -516
- package/src/components/Wizard/__tests__/Generated/Wizard.test.tsx +0 -43
- package/src/components/Wizard/__tests__/Generated/__snapshots__/Wizard.test.tsx.snap +0 -69
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.200.2",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.
|
|
38
|
-
"@patternfly/react-styles": "^4.
|
|
39
|
-
"@patternfly/react-tokens": "^4.
|
|
37
|
+
"@patternfly/react-icons": "^4.51.2",
|
|
38
|
+
"@patternfly/react-styles": "^4.50.2",
|
|
39
|
+
"@patternfly/react-tokens": "^4.52.2",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "78e64c6891ebd263e6c35a9d70d95759aba3c7ad"
|
|
64
64
|
}
|
|
@@ -12,6 +12,8 @@ export interface AvatarProps
|
|
|
12
12
|
alt: string;
|
|
13
13
|
/** Border to add */
|
|
14
14
|
border?: 'light' | 'dark';
|
|
15
|
+
/** Size variant of avatar. */
|
|
16
|
+
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export const Avatar: React.FunctionComponent<AvatarProps> = ({
|
|
@@ -19,6 +21,7 @@ export const Avatar: React.FunctionComponent<AvatarProps> = ({
|
|
|
19
21
|
src = '',
|
|
20
22
|
alt,
|
|
21
23
|
border,
|
|
24
|
+
size,
|
|
22
25
|
...props
|
|
23
26
|
}: AvatarProps) => (
|
|
24
27
|
<img
|
|
@@ -26,6 +29,7 @@ export const Avatar: React.FunctionComponent<AvatarProps> = ({
|
|
|
26
29
|
alt={alt}
|
|
27
30
|
className={css(
|
|
28
31
|
styles.avatar,
|
|
32
|
+
styles.modifiers[size],
|
|
29
33
|
border === 'light' && styles.modifiers.light,
|
|
30
34
|
border === 'dark' && styles.modifiers.dark,
|
|
31
35
|
className
|
|
@@ -10,30 +10,59 @@ import avatarImgDark from './avatarImgDark.svg';
|
|
|
10
10
|
import './example.css';
|
|
11
11
|
|
|
12
12
|
## Examples
|
|
13
|
+
|
|
13
14
|
### Basic
|
|
15
|
+
|
|
14
16
|
```ts
|
|
15
17
|
import React from 'react';
|
|
16
18
|
import { Avatar } from '@patternfly/react-core';
|
|
17
19
|
import avatarImg from './avatarImg.svg';
|
|
18
20
|
|
|
19
|
-
<Avatar src={avatarImg} alt="avatar"
|
|
21
|
+
<Avatar src={avatarImg} alt="avatar" />;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Size variations
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import { Avatar } from '@patternfly/react-core';
|
|
29
|
+
import avatarImg from './avatarImg.svg';
|
|
30
|
+
|
|
31
|
+
<React.Fragment>
|
|
32
|
+
Small
|
|
33
|
+
<br />
|
|
34
|
+
<Avatar src={avatarImg} alt="avatar" size="sm" />
|
|
35
|
+
<br />
|
|
36
|
+
Medium
|
|
37
|
+
<br />
|
|
38
|
+
<Avatar src={avatarImg} alt="avatar" size="md" />
|
|
39
|
+
<br />
|
|
40
|
+
Large
|
|
41
|
+
<br />
|
|
42
|
+
<Avatar src={avatarImg} alt="avatar" size="lg" />
|
|
43
|
+
<br />
|
|
44
|
+
Extra Large
|
|
45
|
+
<br />
|
|
46
|
+
<Avatar src={avatarImg} alt="avatar" size="xl" />
|
|
47
|
+
</React.Fragment>;
|
|
20
48
|
```
|
|
21
49
|
|
|
22
50
|
### Bordered - light
|
|
51
|
+
|
|
23
52
|
```ts
|
|
24
53
|
import React from 'react';
|
|
25
54
|
import { Avatar } from '@patternfly/react-core';
|
|
26
55
|
import avatarImg from './img_avatar.svg';
|
|
27
56
|
|
|
28
|
-
<Avatar src={avatarImg} alt="avatar" border="light"
|
|
57
|
+
<Avatar src={avatarImg} alt="avatar" border="light" />;
|
|
29
58
|
```
|
|
30
59
|
|
|
31
60
|
### Bordered - dark
|
|
61
|
+
|
|
32
62
|
```ts
|
|
33
63
|
import React from 'react';
|
|
34
64
|
import { Avatar } from '@patternfly/react-core';
|
|
35
65
|
import avatarImgDark from './img_avatar-dark.svg';
|
|
36
66
|
|
|
37
|
-
<Avatar src={avatarImgDark} alt="avatar" border="dark"
|
|
67
|
+
<Avatar src={avatarImgDark} alt="avatar" border="dark" />;
|
|
38
68
|
```
|
|
39
|
-
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
|
|
4
7
|
import { ChipGroup } from '../index';
|
|
5
8
|
import { Chip } from '../../Chip';
|
|
6
9
|
|
|
@@ -34,7 +37,7 @@ describe('ChipGroup', () => {
|
|
|
34
37
|
});
|
|
35
38
|
|
|
36
39
|
test('chip group expanded', () => {
|
|
37
|
-
|
|
40
|
+
render(
|
|
38
41
|
<ChipGroup>
|
|
39
42
|
<Chip>1</Chip>
|
|
40
43
|
<Chip>2</Chip>
|
|
@@ -42,15 +45,17 @@ describe('ChipGroup', () => {
|
|
|
42
45
|
<Chip>4</Chip>
|
|
43
46
|
</ChipGroup>
|
|
44
47
|
);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
const moreText = screen.getByText('1 more');
|
|
50
|
+
expect(moreText).toBeInTheDocument();
|
|
51
|
+
|
|
52
|
+
userEvent.click(moreText);
|
|
53
|
+
expect(screen.getByText('Show Less')).toBeInTheDocument();
|
|
49
54
|
});
|
|
50
55
|
|
|
51
56
|
test('chip group will not render if no children passed', () => {
|
|
52
|
-
|
|
53
|
-
expect(
|
|
57
|
+
render(<ChipGroup />);
|
|
58
|
+
expect(screen.queryByRole('group')).toBeNull();
|
|
54
59
|
});
|
|
55
60
|
|
|
56
61
|
test('chip group with category and tooltip', () => {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
|
-
import {
|
|
5
|
-
import { ClipboardCopyToggle } from '../ClipboardCopyToggle';
|
|
4
|
+
import { ClipboardCopyToggle, ClipboardCopyToggleProps } from '../ClipboardCopyToggle';
|
|
6
5
|
|
|
7
|
-
const props = {
|
|
6
|
+
const props: ClipboardCopyToggleProps = {
|
|
8
7
|
id: 'my-id',
|
|
9
8
|
textId: 'my-text-id',
|
|
10
9
|
contentId: 'my-content-id',
|
|
@@ -13,23 +12,33 @@ const props = {
|
|
|
13
12
|
onClick: jest.fn()
|
|
14
13
|
};
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
15
|
+
describe('ClipboardCopyToggle', () => {
|
|
16
|
+
test('toggle button render', () => {
|
|
17
|
+
const desc = 'toggle content';
|
|
18
|
+
const view = render(<ClipboardCopyToggle {...props} aria-label={desc} />);
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
render(<ClipboardCopyToggle {...props} onClick={onclick} />);
|
|
20
|
+
expect(view.container).toMatchSnapshot();
|
|
21
|
+
});
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
23
|
+
test('toggle button onClick', () => {
|
|
24
|
+
const onclick = jest.fn();
|
|
25
|
+
render(<ClipboardCopyToggle {...props} onClick={onclick} />);
|
|
26
|
+
|
|
27
|
+
userEvent.click(screen.getByRole('button'));
|
|
28
|
+
expect(onclick).toBeCalled();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('has aria-expanded set to true when isExpanded is true', () => {
|
|
32
|
+
render(<ClipboardCopyToggle {...props} isExpanded />);
|
|
33
|
+
|
|
34
|
+
const toggleButton = screen.getByRole('button');
|
|
35
|
+
expect(toggleButton.getAttribute('aria-expanded')).toEqual('true');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('has aria-expanded set to false when isExpanded is false', () => {
|
|
39
|
+
render(<ClipboardCopyToggle {...props} />);
|
|
29
40
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
view = shallow(<ClipboardCopyToggle {...props} isExpanded={false} />);
|
|
34
|
-
expect(view.props()['aria-expanded']).toBe(false);
|
|
41
|
+
const toggleButton = screen.getByRole('button');
|
|
42
|
+
expect(toggleButton.getAttribute('aria-expanded')).toEqual('false');
|
|
43
|
+
});
|
|
35
44
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
|
|
2
3
|
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import userEvent from '@testing-library/user-event';
|
|
4
|
-
|
|
5
|
+
|
|
5
6
|
import { ContextSelector } from '../ContextSelector';
|
|
6
7
|
import { ContextSelectorItem } from '../ContextSelectorItem';
|
|
7
8
|
|
|
@@ -13,20 +14,26 @@ const items = [
|
|
|
13
14
|
<ContextSelectorItem key="4">Azure</ContextSelectorItem>
|
|
14
15
|
];
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
describe('ContextSelector', () => {
|
|
18
|
+
test('Renders ContextSelector', () => {
|
|
19
|
+
render(<ContextSelector data-testid="context-test-id">{items}</ContextSelector>);
|
|
20
|
+
expect(screen.getByTestId('context-test-id').outerHTML).toMatchSnapshot();
|
|
21
|
+
});
|
|
20
22
|
|
|
21
|
-
test('Renders ContextSelector open', () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
23
|
+
test('Renders ContextSelector open', () => {
|
|
24
|
+
render(
|
|
25
|
+
<ContextSelector isOpen data-testid="context-test-id">
|
|
26
|
+
{items}
|
|
27
|
+
</ContextSelector>
|
|
28
|
+
);
|
|
29
|
+
expect(screen.getByTestId('context-test-id').outerHTML).toMatchSnapshot();
|
|
30
|
+
});
|
|
25
31
|
|
|
26
|
-
test('Verify onToggle is called ', () => {
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
test('Verify onToggle is called ', () => {
|
|
33
|
+
const mockfn = jest.fn();
|
|
34
|
+
render(<ContextSelector onToggle={mockfn}>{items}</ContextSelector>);
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
userEvent.click(screen.getByRole('button'));
|
|
37
|
+
expect(mockfn.mock.calls).toHaveLength(1);
|
|
38
|
+
});
|
|
32
39
|
});
|
|
@@ -1,43 +1,58 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
|
|
4
6
|
import { ContextSelectorToggle } from '../ContextSelectorToggle';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
describe('ContextSelectorToggle', () => {
|
|
9
|
+
test('Renders ContextSelectorToggle', () => {
|
|
10
|
+
render(<ContextSelectorToggle id="toggle-id" />);
|
|
11
|
+
expect(screen.getByRole('button').outerHTML).toMatchSnapshot();
|
|
12
|
+
});
|
|
10
13
|
|
|
11
|
-
test('Verify onToggle is called ', () => {
|
|
12
|
-
|
|
13
|
-
const view = mount(<ContextSelectorToggle onToggle={mockfnOnToggle} id="toggle-id" />);
|
|
14
|
-
view
|
|
15
|
-
.find('button')
|
|
16
|
-
.at(0)
|
|
17
|
-
.simulate('click');
|
|
18
|
-
expect(mockfnOnToggle.mock.calls).toHaveLength(1);
|
|
19
|
-
});
|
|
14
|
+
test('Verify onToggle is called ', () => {
|
|
15
|
+
const mockfnOnToggle = jest.fn();
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
const view = mount(<ContextSelectorToggle isOpen id="toggle-id" />);
|
|
23
|
-
view.simulate('keyDown', { key: 'Escape' });
|
|
24
|
-
expect(view).toMatchSnapshot();
|
|
25
|
-
});
|
|
17
|
+
render(<ContextSelectorToggle onToggle={mockfnOnToggle} id="toggle-id" />);
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
expect(view).toMatchSnapshot();
|
|
31
|
-
});
|
|
19
|
+
userEvent.click(screen.getByRole('button'));
|
|
20
|
+
expect(mockfnOnToggle.mock.calls).toHaveLength(1);
|
|
21
|
+
});
|
|
32
22
|
|
|
33
|
-
test('Verify
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
test('Verify ESC press', () => {
|
|
24
|
+
render(<ContextSelectorToggle isOpen id="toggle-id" />);
|
|
25
|
+
|
|
26
|
+
const toggleButton = screen.getByRole('button');
|
|
27
|
+
|
|
28
|
+
userEvent.type(toggleButton, '{esc}');
|
|
29
|
+
expect(toggleButton.outerHTML).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('Verify ESC press with not isOpen', () => {
|
|
33
|
+
render(<ContextSelectorToggle onToggle={jest.fn()} id="toggle-id" />);
|
|
34
|
+
|
|
35
|
+
const toggleButton = screen.getByRole('button');
|
|
36
|
+
|
|
37
|
+
userEvent.type(screen.getByRole('button'), '{esc}');
|
|
38
|
+
expect(toggleButton.outerHTML).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('Verify keydown tab ', () => {
|
|
42
|
+
render(<ContextSelectorToggle isOpen id="toggle-id" />);
|
|
43
|
+
|
|
44
|
+
const toggleButton = screen.getByRole('button');
|
|
45
|
+
|
|
46
|
+
userEvent.type(screen.getByRole('button'), '{tab}');
|
|
47
|
+
expect(toggleButton.outerHTML).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('Verify keydown enter ', () => {
|
|
51
|
+
render(<ContextSelectorToggle onToggle={jest.fn()} onEnter={jest.fn()} id="toggle-id" />);
|
|
52
|
+
|
|
53
|
+
const toggleButton = screen.getByRole('button');
|
|
38
54
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
expect(view).toMatchSnapshot();
|
|
55
|
+
userEvent.type(screen.getByRole('button'), '{enter}');
|
|
56
|
+
expect(toggleButton.outerHTML).toMatchSnapshot();
|
|
57
|
+
});
|
|
43
58
|
});
|
package/src/components/ContextSelector/__tests__/__snapshots__/ContextSelector.test.tsx.snap
CHANGED
|
@@ -1,172 +1,5 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Renders ContextSelector 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="pf-c-context-selector"
|
|
7
|
-
data-ouia-component-id="OUIA-Generated-ContextSelector-1"
|
|
8
|
-
data-ouia-component-type="PF4/ContextSelector"
|
|
9
|
-
data-ouia-safe="true"
|
|
10
|
-
>
|
|
11
|
-
|
|
12
|
-
<button
|
|
13
|
-
aria-expanded="false"
|
|
14
|
-
aria-labelledby="pf-context-selector-label-id-0 pf-context-selector-toggle-id-0"
|
|
15
|
-
class="pf-c-context-selector__toggle"
|
|
16
|
-
id="pf-context-selector-toggle-id-0"
|
|
17
|
-
type="button"
|
|
18
|
-
>
|
|
19
|
-
<span
|
|
20
|
-
class="pf-c-context-selector__toggle-text"
|
|
21
|
-
/>
|
|
22
|
-
<span
|
|
23
|
-
class="pf-c-context-selector__toggle-icon"
|
|
24
|
-
>
|
|
25
|
-
<svg
|
|
26
|
-
aria-hidden="true"
|
|
27
|
-
fill="currentColor"
|
|
28
|
-
height="1em"
|
|
29
|
-
role="img"
|
|
30
|
-
style="vertical-align: -0.125em;"
|
|
31
|
-
viewBox="0 0 320 512"
|
|
32
|
-
width="1em"
|
|
33
|
-
>
|
|
34
|
-
<path
|
|
35
|
-
d="M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"
|
|
36
|
-
/>
|
|
37
|
-
</svg>
|
|
38
|
-
</span>
|
|
39
|
-
</button>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
`;
|
|
3
|
+
exports[`ContextSelector Renders ContextSelector 1`] = `"<div class=\\"pf-c-context-selector\\" data-ouia-component-type=\\"PF4/ContextSelector\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-ContextSelector-1\\" data-testid=\\"context-test-id\\"><button aria-labelledby=\\"pf-context-selector-label-id-0 pf-context-selector-toggle-id-0\\" id=\\"pf-context-selector-toggle-id-0\\" class=\\"pf-c-context-selector__toggle\\" type=\\"button\\" aria-expanded=\\"false\\"><span class=\\"pf-c-context-selector__toggle-text\\"></span><span class=\\"pf-c-context-selector__toggle-icon\\"><svg style=\\"vertical-align: -0.125em;\\" fill=\\"currentColor\\" height=\\"1em\\" width=\\"1em\\" viewBox=\\"0 0 320 512\\" aria-hidden=\\"true\\" role=\\"img\\"><path d=\\"M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z\\"></path></svg></span></button></div>"`;
|
|
43
4
|
|
|
44
|
-
exports[`Renders ContextSelector open 1`] = `
|
|
45
|
-
<div
|
|
46
|
-
className="pf-c-context-selector pf-m-expanded"
|
|
47
|
-
data-ouia-component-id="OUIA-Generated-ContextSelector-2"
|
|
48
|
-
data-ouia-component-type="PF4/ContextSelector"
|
|
49
|
-
data-ouia-safe={true}
|
|
50
|
-
>
|
|
51
|
-
<ContextSelectorToggle
|
|
52
|
-
aria-labelledby="pf-context-selector-label-id-0 pf-context-selector-toggle-id-0"
|
|
53
|
-
className=""
|
|
54
|
-
id="pf-context-selector-toggle-id-0"
|
|
55
|
-
isActive={false}
|
|
56
|
-
isOpen={true}
|
|
57
|
-
isPlain={false}
|
|
58
|
-
isText={false}
|
|
59
|
-
onEnter={[Function]}
|
|
60
|
-
onToggle={[Function]}
|
|
61
|
-
parentRef={null}
|
|
62
|
-
toggleText=""
|
|
63
|
-
/>
|
|
64
|
-
<div
|
|
65
|
-
className="pf-c-context-selector__menu"
|
|
66
|
-
>
|
|
67
|
-
<FocusTrap
|
|
68
|
-
active={true}
|
|
69
|
-
focusTrapOptions={
|
|
70
|
-
Object {
|
|
71
|
-
"clickOutsideDeactivates": true,
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
paused={false}
|
|
75
|
-
preventScrollOnDeactivate={false}
|
|
76
|
-
>
|
|
77
|
-
<div
|
|
78
|
-
className="pf-c-context-selector__menu-search"
|
|
79
|
-
>
|
|
80
|
-
<InputGroup>
|
|
81
|
-
<TextInput
|
|
82
|
-
aria-labelledby="pf-context-selector-search-button-id-0"
|
|
83
|
-
onChange={[Function]}
|
|
84
|
-
onKeyPress={[Function]}
|
|
85
|
-
placeholder="Search"
|
|
86
|
-
type="search"
|
|
87
|
-
value=""
|
|
88
|
-
/>
|
|
89
|
-
<Button
|
|
90
|
-
aria-label="Search menu items"
|
|
91
|
-
id="pf-context-selector-search-button-id-0"
|
|
92
|
-
onClick={[Function]}
|
|
93
|
-
variant="control"
|
|
94
|
-
>
|
|
95
|
-
<SearchIcon
|
|
96
|
-
aria-hidden="true"
|
|
97
|
-
color="currentColor"
|
|
98
|
-
noVerticalAlign={false}
|
|
99
|
-
size="sm"
|
|
100
|
-
/>
|
|
101
|
-
</Button>
|
|
102
|
-
</InputGroup>
|
|
103
|
-
</div>
|
|
104
|
-
<ContextProvider
|
|
105
|
-
value={
|
|
106
|
-
Object {
|
|
107
|
-
"onSelect": [Function],
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
>
|
|
111
|
-
<ContextSelectorMenuList
|
|
112
|
-
className=""
|
|
113
|
-
isOpen={true}
|
|
114
|
-
>
|
|
115
|
-
|
|
116
|
-
<ContextSelectorItem
|
|
117
|
-
className=""
|
|
118
|
-
href={null}
|
|
119
|
-
isDisabled={false}
|
|
120
|
-
key="0"
|
|
121
|
-
onClick={[Function]}
|
|
122
|
-
sendRef={[Function]}
|
|
123
|
-
>
|
|
124
|
-
My Project
|
|
125
|
-
</ContextSelectorItem>
|
|
126
|
-
<ContextSelectorItem
|
|
127
|
-
className=""
|
|
128
|
-
href={null}
|
|
129
|
-
isDisabled={false}
|
|
130
|
-
key="1"
|
|
131
|
-
onClick={[Function]}
|
|
132
|
-
sendRef={[Function]}
|
|
133
|
-
>
|
|
134
|
-
OpenShift Cluster
|
|
135
|
-
</ContextSelectorItem>
|
|
136
|
-
<ContextSelectorItem
|
|
137
|
-
className=""
|
|
138
|
-
href={null}
|
|
139
|
-
isDisabled={false}
|
|
140
|
-
key="2"
|
|
141
|
-
onClick={[Function]}
|
|
142
|
-
sendRef={[Function]}
|
|
143
|
-
>
|
|
144
|
-
Production Ansible
|
|
145
|
-
</ContextSelectorItem>
|
|
146
|
-
<ContextSelectorItem
|
|
147
|
-
className=""
|
|
148
|
-
href={null}
|
|
149
|
-
isDisabled={false}
|
|
150
|
-
key="3"
|
|
151
|
-
onClick={[Function]}
|
|
152
|
-
sendRef={[Function]}
|
|
153
|
-
>
|
|
154
|
-
AWS
|
|
155
|
-
</ContextSelectorItem>
|
|
156
|
-
<ContextSelectorItem
|
|
157
|
-
className=""
|
|
158
|
-
href={null}
|
|
159
|
-
isDisabled={false}
|
|
160
|
-
key="4"
|
|
161
|
-
onClick={[Function]}
|
|
162
|
-
sendRef={[Function]}
|
|
163
|
-
>
|
|
164
|
-
Azure
|
|
165
|
-
</ContextSelectorItem>
|
|
166
|
-
|
|
167
|
-
</ContextSelectorMenuList>
|
|
168
|
-
</ContextProvider>
|
|
169
|
-
</FocusTrap>
|
|
170
|
-
</div>
|
|
171
|
-
</div>
|
|
172
|
-
`;
|
|
5
|
+
exports[`ContextSelector Renders ContextSelector open 1`] = `"<div class=\\"pf-c-context-selector pf-m-expanded\\" data-ouia-component-type=\\"PF4/ContextSelector\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-ContextSelector-2\\" data-testid=\\"context-test-id\\"><button aria-labelledby=\\"pf-context-selector-label-id-0 pf-context-selector-toggle-id-0\\" id=\\"pf-context-selector-toggle-id-0\\" class=\\"pf-c-context-selector__toggle\\" type=\\"button\\" aria-expanded=\\"true\\"><span class=\\"pf-c-context-selector__toggle-text\\"></span><span class=\\"pf-c-context-selector__toggle-icon\\"><svg style=\\"vertical-align: -0.125em;\\" fill=\\"currentColor\\" height=\\"1em\\" width=\\"1em\\" viewBox=\\"0 0 320 512\\" aria-hidden=\\"true\\" role=\\"img\\"><path d=\\"M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z\\"></path></svg></span></button><div class=\\"pf-c-context-selector__menu\\"><div><div class=\\"pf-c-context-selector__menu-search\\"><div class=\\"pf-c-input-group\\"><input placeholder=\\"Search\\" aria-labelledby=\\"pf-context-selector-search-button-id-0\\" aria-describedby=\\"pf-context-selector-search-button-id-0\\" class=\\"pf-c-form-control\\" type=\\"search\\" aria-invalid=\\"false\\" data-ouia-component-type=\\"PF4/TextInput\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-TextInputBase-1\\" value=\\"\\"><button id=\\"pf-context-selector-search-button-id-0\\" aria-disabled=\\"false\\" aria-label=\\"Search menu items\\" class=\\"pf-c-button pf-m-control\\" type=\\"button\\" data-ouia-component-type=\\"PF4/Button\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Button-control-1\\"><svg style=\\"vertical-align: -0.125em;\\" fill=\\"currentColor\\" height=\\"1em\\" width=\\"1em\\" viewBox=\\"0 0 512 512\\" aria-hidden=\\"true\\" role=\\"img\\"><path d=\\"M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z\\"></path></svg></button></div></div><ul class=\\"pf-c-context-selector__menu-list\\" role=\\"menu\\"><li role=\\"none\\"><button class=\\"pf-c-context-selector__menu-list-item\\">My Project</button></li><li role=\\"none\\"><button class=\\"pf-c-context-selector__menu-list-item\\">OpenShift Cluster</button></li><li role=\\"none\\"><button class=\\"pf-c-context-selector__menu-list-item\\">Production Ansible</button></li><li role=\\"none\\"><button class=\\"pf-c-context-selector__menu-list-item\\">AWS</button></li><li role=\\"none\\"><button class=\\"pf-c-context-selector__menu-list-item\\">Azure</button></li></ul></div></div></div>"`;
|