@patternfly/react-core 4.244.1 → 4.245.0
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 +24 -0
- package/dist/esm/components/Alert/Alert.d.ts +4 -0
- package/dist/esm/components/Alert/Alert.d.ts.map +1 -1
- package/dist/esm/components/Alert/Alert.js.map +1 -1
- package/dist/esm/components/Alert/AlertActionCloseButton.js +2 -4
- package/dist/esm/components/Alert/AlertActionCloseButton.js.map +1 -1
- package/dist/esm/components/Alert/AlertToggleExpandButton.js +1 -1
- package/dist/esm/components/Alert/AlertToggleExpandButton.js.map +1 -1
- package/dist/esm/components/Breadcrumb/Breadcrumb.d.ts +4 -0
- package/dist/esm/components/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/esm/components/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/esm/components/Button/Button.d.ts +4 -0
- package/dist/esm/components/Button/Button.d.ts.map +1 -1
- package/dist/esm/components/Button/Button.js.map +1 -1
- package/dist/esm/components/Card/Card.d.ts +4 -0
- package/dist/esm/components/Card/Card.d.ts.map +1 -1
- package/dist/esm/components/Card/Card.js.map +1 -1
- package/dist/esm/components/Checkbox/Checkbox.d.ts +4 -0
- package/dist/esm/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/esm/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/esm/components/Chip/Chip.d.ts +2 -0
- package/dist/esm/components/Chip/Chip.d.ts.map +1 -1
- package/dist/esm/components/Chip/Chip.js.map +1 -1
- package/dist/esm/components/ChipGroup/ChipGroup.d.ts +2 -0
- package/dist/esm/components/ChipGroup/ChipGroup.d.ts.map +1 -1
- package/dist/esm/components/ChipGroup/ChipGroup.js.map +1 -1
- package/dist/esm/components/ContextSelector/ContextSelector.d.ts +4 -0
- package/dist/esm/components/ContextSelector/ContextSelector.d.ts.map +1 -1
- package/dist/esm/components/ContextSelector/ContextSelector.js.map +1 -1
- package/dist/esm/components/Dropdown/Dropdown.d.ts +4 -0
- package/dist/esm/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/esm/components/Dropdown/DropdownItem.d.ts +4 -0
- package/dist/esm/components/Dropdown/DropdownItem.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/DropdownItem.js.map +1 -1
- package/dist/esm/components/Dropdown/DropdownSeparator.d.ts +4 -0
- package/dist/esm/components/Dropdown/DropdownSeparator.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/DropdownSeparator.js.map +1 -1
- package/dist/esm/components/Dropdown/DropdownToggle.d.ts +4 -0
- package/dist/esm/components/Dropdown/DropdownToggle.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/DropdownToggle.js.map +1 -1
- package/dist/esm/components/Dropdown/DropdownToggleCheckbox.d.ts +4 -0
- package/dist/esm/components/Dropdown/DropdownToggleCheckbox.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/DropdownToggleCheckbox.js.map +1 -1
- package/dist/esm/components/Form/Form.d.ts +4 -2
- package/dist/esm/components/Form/Form.d.ts.map +1 -1
- package/dist/esm/components/Form/Form.js +4 -3
- package/dist/esm/components/Form/Form.js.map +1 -1
- package/dist/esm/components/FormSelect/FormSelect.d.ts +4 -0
- package/dist/esm/components/FormSelect/FormSelect.d.ts.map +1 -1
- package/dist/esm/components/FormSelect/FormSelect.js.map +1 -1
- package/dist/esm/components/LoginPage/LoginForm.d.ts +1 -1
- package/dist/esm/components/LoginPage/LoginForm.d.ts.map +1 -1
- package/dist/esm/components/Menu/Menu.d.ts +4 -0
- package/dist/esm/components/Menu/Menu.d.ts.map +1 -1
- package/dist/esm/components/Menu/Menu.js.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggleCheckbox.d.ts +4 -0
- package/dist/esm/components/MenuToggle/MenuToggleCheckbox.d.ts.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggleCheckbox.js.map +1 -1
- package/dist/esm/components/Modal/Modal.d.ts +4 -0
- package/dist/esm/components/Modal/Modal.d.ts.map +1 -1
- package/dist/esm/components/Modal/Modal.js.map +1 -1
- package/dist/esm/components/Modal/ModalBoxCloseButton.d.ts +2 -0
- package/dist/esm/components/Modal/ModalBoxCloseButton.d.ts.map +1 -1
- package/dist/esm/components/Modal/ModalBoxCloseButton.js.map +1 -1
- package/dist/esm/components/Modal/ModalContent.d.ts +4 -0
- package/dist/esm/components/Modal/ModalContent.d.ts.map +1 -1
- package/dist/esm/components/Modal/ModalContent.js.map +1 -1
- package/dist/esm/components/Nav/Nav.d.ts +4 -0
- package/dist/esm/components/Nav/Nav.d.ts.map +1 -1
- package/dist/esm/components/Nav/Nav.js.map +1 -1
- package/dist/esm/components/Nav/NavExpandable.d.ts +2 -0
- package/dist/esm/components/Nav/NavExpandable.d.ts.map +1 -1
- package/dist/esm/components/Nav/NavExpandable.js.map +1 -1
- package/dist/esm/components/Nav/NavItem.d.ts +4 -0
- package/dist/esm/components/Nav/NavItem.d.ts.map +1 -1
- package/dist/esm/components/Nav/NavItem.js.map +1 -1
- package/dist/esm/components/OptionsMenu/OptionsMenu.d.ts +4 -0
- package/dist/esm/components/OptionsMenu/OptionsMenu.d.ts.map +1 -1
- package/dist/esm/components/OptionsMenu/OptionsMenu.js.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenu.d.ts +7 -1
- package/dist/esm/components/OverflowMenu/OverflowMenu.d.ts.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenu.js +36 -23
- package/dist/esm/components/OverflowMenu/OverflowMenu.js.map +1 -1
- package/dist/esm/components/Pagination/Pagination.d.ts +4 -0
- package/dist/esm/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/esm/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/Radio/Radio.d.ts +4 -0
- package/dist/esm/components/Radio/Radio.d.ts.map +1 -1
- package/dist/esm/components/Radio/Radio.js.map +1 -1
- package/dist/esm/components/Select/Select.d.ts +4 -0
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Switch/Switch.d.ts +4 -0
- package/dist/esm/components/Switch/Switch.d.ts.map +1 -1
- package/dist/esm/components/Switch/Switch.js.map +1 -1
- package/dist/esm/components/Tabs/Tab.d.ts +2 -0
- package/dist/esm/components/Tabs/Tab.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tab.js.map +1 -1
- package/dist/esm/components/Tabs/TabContent.d.ts +4 -0
- package/dist/esm/components/Tabs/TabContent.d.ts.map +1 -1
- package/dist/esm/components/Tabs/TabContent.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts +4 -0
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/components/Text/Text.d.ts +4 -0
- package/dist/esm/components/Text/Text.d.ts.map +1 -1
- package/dist/esm/components/Text/Text.js.map +1 -1
- package/dist/esm/components/TextInput/TextInput.d.ts +4 -0
- package/dist/esm/components/TextInput/TextInput.d.ts.map +1 -1
- package/dist/esm/components/TextInput/TextInput.js.map +1 -1
- package/dist/esm/components/Title/Title.d.ts +4 -0
- package/dist/esm/components/Title/Title.d.ts.map +1 -1
- package/dist/esm/components/Title/Title.js.map +1 -1
- package/dist/esm/components/Toolbar/Toolbar.d.ts +4 -0
- package/dist/esm/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/js/components/Alert/Alert.d.ts +4 -0
- package/dist/js/components/Alert/Alert.d.ts.map +1 -1
- package/dist/js/components/Alert/Alert.js.map +1 -1
- package/dist/js/components/Alert/AlertActionCloseButton.js +2 -4
- package/dist/js/components/Alert/AlertActionCloseButton.js.map +1 -1
- package/dist/js/components/Alert/AlertToggleExpandButton.js +1 -1
- package/dist/js/components/Alert/AlertToggleExpandButton.js.map +1 -1
- package/dist/js/components/Breadcrumb/Breadcrumb.d.ts +4 -0
- package/dist/js/components/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/js/components/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/js/components/Button/Button.d.ts +4 -0
- package/dist/js/components/Button/Button.d.ts.map +1 -1
- package/dist/js/components/Button/Button.js.map +1 -1
- package/dist/js/components/Card/Card.d.ts +4 -0
- package/dist/js/components/Card/Card.d.ts.map +1 -1
- package/dist/js/components/Card/Card.js.map +1 -1
- package/dist/js/components/Checkbox/Checkbox.d.ts +4 -0
- package/dist/js/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/js/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/js/components/Chip/Chip.d.ts +2 -0
- package/dist/js/components/Chip/Chip.d.ts.map +1 -1
- package/dist/js/components/Chip/Chip.js.map +1 -1
- package/dist/js/components/ChipGroup/ChipGroup.d.ts +2 -0
- package/dist/js/components/ChipGroup/ChipGroup.d.ts.map +1 -1
- package/dist/js/components/ChipGroup/ChipGroup.js.map +1 -1
- package/dist/js/components/ContextSelector/ContextSelector.d.ts +4 -0
- package/dist/js/components/ContextSelector/ContextSelector.d.ts.map +1 -1
- package/dist/js/components/ContextSelector/ContextSelector.js.map +1 -1
- package/dist/js/components/Dropdown/Dropdown.d.ts +4 -0
- package/dist/js/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/js/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/js/components/Dropdown/DropdownItem.d.ts +4 -0
- package/dist/js/components/Dropdown/DropdownItem.d.ts.map +1 -1
- package/dist/js/components/Dropdown/DropdownItem.js.map +1 -1
- package/dist/js/components/Dropdown/DropdownSeparator.d.ts +4 -0
- package/dist/js/components/Dropdown/DropdownSeparator.d.ts.map +1 -1
- package/dist/js/components/Dropdown/DropdownSeparator.js.map +1 -1
- package/dist/js/components/Dropdown/DropdownToggle.d.ts +4 -0
- package/dist/js/components/Dropdown/DropdownToggle.d.ts.map +1 -1
- package/dist/js/components/Dropdown/DropdownToggle.js.map +1 -1
- package/dist/js/components/Dropdown/DropdownToggleCheckbox.d.ts +4 -0
- package/dist/js/components/Dropdown/DropdownToggleCheckbox.d.ts.map +1 -1
- package/dist/js/components/Dropdown/DropdownToggleCheckbox.js.map +1 -1
- package/dist/js/components/Form/Form.d.ts +4 -2
- package/dist/js/components/Form/Form.d.ts.map +1 -1
- package/dist/js/components/Form/Form.js +4 -4
- package/dist/js/components/Form/Form.js.map +1 -1
- package/dist/js/components/FormSelect/FormSelect.d.ts +4 -0
- package/dist/js/components/FormSelect/FormSelect.d.ts.map +1 -1
- package/dist/js/components/FormSelect/FormSelect.js.map +1 -1
- package/dist/js/components/LoginPage/LoginForm.d.ts +1 -1
- package/dist/js/components/LoginPage/LoginForm.d.ts.map +1 -1
- package/dist/js/components/Menu/Menu.d.ts +4 -0
- package/dist/js/components/Menu/Menu.d.ts.map +1 -1
- package/dist/js/components/Menu/Menu.js.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggleCheckbox.d.ts +4 -0
- package/dist/js/components/MenuToggle/MenuToggleCheckbox.d.ts.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggleCheckbox.js.map +1 -1
- package/dist/js/components/Modal/Modal.d.ts +4 -0
- package/dist/js/components/Modal/Modal.d.ts.map +1 -1
- package/dist/js/components/Modal/Modal.js.map +1 -1
- package/dist/js/components/Modal/ModalBoxCloseButton.d.ts +2 -0
- package/dist/js/components/Modal/ModalBoxCloseButton.d.ts.map +1 -1
- package/dist/js/components/Modal/ModalBoxCloseButton.js.map +1 -1
- package/dist/js/components/Modal/ModalContent.d.ts +4 -0
- package/dist/js/components/Modal/ModalContent.d.ts.map +1 -1
- package/dist/js/components/Modal/ModalContent.js.map +1 -1
- package/dist/js/components/Nav/Nav.d.ts +4 -0
- package/dist/js/components/Nav/Nav.d.ts.map +1 -1
- package/dist/js/components/Nav/Nav.js.map +1 -1
- package/dist/js/components/Nav/NavExpandable.d.ts +2 -0
- package/dist/js/components/Nav/NavExpandable.d.ts.map +1 -1
- package/dist/js/components/Nav/NavExpandable.js.map +1 -1
- package/dist/js/components/Nav/NavItem.d.ts +4 -0
- package/dist/js/components/Nav/NavItem.d.ts.map +1 -1
- package/dist/js/components/Nav/NavItem.js.map +1 -1
- package/dist/js/components/OptionsMenu/OptionsMenu.d.ts +4 -0
- package/dist/js/components/OptionsMenu/OptionsMenu.d.ts.map +1 -1
- package/dist/js/components/OptionsMenu/OptionsMenu.js.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenu.d.ts +7 -1
- package/dist/js/components/OverflowMenu/OverflowMenu.d.ts.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenu.js +35 -22
- package/dist/js/components/OverflowMenu/OverflowMenu.js.map +1 -1
- package/dist/js/components/Pagination/Pagination.d.ts +4 -0
- package/dist/js/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/js/components/Pagination/Pagination.js.map +1 -1
- package/dist/js/components/Radio/Radio.d.ts +4 -0
- package/dist/js/components/Radio/Radio.d.ts.map +1 -1
- package/dist/js/components/Radio/Radio.js.map +1 -1
- package/dist/js/components/Select/Select.d.ts +4 -0
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/Switch/Switch.d.ts +4 -0
- package/dist/js/components/Switch/Switch.d.ts.map +1 -1
- package/dist/js/components/Switch/Switch.js.map +1 -1
- package/dist/js/components/Tabs/Tab.d.ts +2 -0
- package/dist/js/components/Tabs/Tab.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tab.js.map +1 -1
- package/dist/js/components/Tabs/TabContent.d.ts +4 -0
- package/dist/js/components/Tabs/TabContent.d.ts.map +1 -1
- package/dist/js/components/Tabs/TabContent.js.map +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts +4 -0
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.js.map +1 -1
- package/dist/js/components/Text/Text.d.ts +4 -0
- package/dist/js/components/Text/Text.d.ts.map +1 -1
- package/dist/js/components/Text/Text.js.map +1 -1
- package/dist/js/components/TextInput/TextInput.d.ts +4 -0
- package/dist/js/components/TextInput/TextInput.d.ts.map +1 -1
- package/dist/js/components/TextInput/TextInput.js.map +1 -1
- package/dist/js/components/Title/Title.d.ts +4 -0
- package/dist/js/components/Title/Title.d.ts.map +1 -1
- package/dist/js/components/Title/Title.js.map +1 -1
- package/dist/js/components/Toolbar/Toolbar.d.ts +4 -0
- package/dist/js/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/js/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +2 -2
- package/src/components/Alert/Alert.tsx +4 -0
- package/src/components/Alert/AlertActionCloseButton.tsx +2 -2
- package/src/components/Alert/AlertToggleExpandButton.tsx +2 -2
- package/src/components/Alert/__tests__/Alert.test.tsx +713 -199
- package/src/components/Alert/__tests__/AlertActionCloseButton.test.tsx +125 -0
- package/src/components/Alert/__tests__/AlertActionLink.test.tsx +59 -0
- package/src/components/Alert/__tests__/AlertIcon.test.tsx +83 -0
- package/src/components/Alert/__tests__/AlertToggleExpandButton.test.tsx +150 -0
- package/src/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +12 -2569
- package/src/components/Alert/__tests__/__snapshots__/AlertActionCloseButton.test.tsx.snap +31 -0
- package/src/components/Alert/__tests__/__snapshots__/AlertActionLink.test.tsx.snap +17 -0
- package/src/components/Alert/__tests__/__snapshots__/AlertIcon.test.tsx.snap +11 -0
- package/src/components/Alert/__tests__/__snapshots__/AlertToggleExpandButton.test.tsx.snap +24 -0
- package/src/components/Breadcrumb/Breadcrumb.tsx +4 -0
- package/src/components/Button/Button.tsx +4 -0
- package/src/components/Card/Card.tsx +4 -0
- package/src/components/Checkbox/Checkbox.tsx +4 -0
- package/src/components/Chip/Chip.tsx +2 -0
- package/src/components/ChipGroup/ChipGroup.tsx +2 -0
- package/src/components/ContextSelector/ContextSelector.tsx +4 -0
- package/src/components/Dropdown/Dropdown.tsx +4 -0
- package/src/components/Dropdown/DropdownItem.tsx +4 -0
- package/src/components/Dropdown/DropdownSeparator.tsx +4 -0
- package/src/components/Dropdown/DropdownToggle.tsx +4 -0
- package/src/components/Dropdown/DropdownToggleCheckbox.tsx +4 -0
- package/src/components/Dropdown/examples/Dropdown.md +1 -1
- package/src/components/Form/Form.tsx +9 -2
- package/src/components/FormSelect/FormSelect.tsx +4 -0
- package/src/components/LoginPage/LoginForm.tsx +1 -1
- package/src/components/Menu/Menu.tsx +4 -0
- package/src/components/MenuToggle/MenuToggleCheckbox.tsx +4 -0
- package/src/components/Modal/Modal.tsx +4 -0
- package/src/components/Modal/ModalBoxCloseButton.tsx +2 -0
- package/src/components/Modal/ModalContent.tsx +4 -0
- package/src/components/Nav/Nav.tsx +4 -0
- package/src/components/Nav/NavExpandable.tsx +2 -0
- package/src/components/Nav/NavItem.tsx +4 -0
- package/src/components/OptionsMenu/OptionsMenu.tsx +4 -0
- package/src/components/OverflowMenu/OverflowMenu.tsx +46 -25
- package/src/components/OverflowMenu/__tests__/OverflowMenu.test.tsx +38 -0
- package/src/components/OverflowMenu/examples/OverflowMenu.md +127 -35
- package/src/components/OverflowMenu/examples/OverflowMenuBreakpointOnContainer.tsx +100 -0
- package/src/components/Pagination/Pagination.tsx +4 -0
- package/src/components/Radio/Radio.tsx +4 -0
- package/src/components/Select/Select.tsx +4 -0
- package/src/components/Switch/Switch.tsx +4 -0
- package/src/components/Tabs/Tab.tsx +2 -0
- package/src/components/Tabs/TabContent.tsx +4 -0
- package/src/components/Tabs/Tabs.tsx +4 -0
- package/src/components/Text/Text.tsx +4 -0
- package/src/components/TextInput/TextInput.tsx +4 -0
- package/src/components/Title/Title.tsx +4 -0
- package/src/components/Toolbar/Toolbar.tsx +4 -0
- package/src/demos/examples/DashboardHeader.js +35 -6
- package/src/helpers/OUIA/OUIA.md +1 -1
|
@@ -1,210 +1,724 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
2
|
import { render, screen } from '@testing-library/react';
|
|
4
3
|
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { act } from 'react-dom/test-utils';
|
|
5
5
|
|
|
6
6
|
import { Alert, AlertVariant } from '../Alert';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
<p>{description}</p>
|
|
124
|
-
</Alert>
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
expect(screen.queryByText(description)).toBeNull();
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
test('Toast alerts match snapsnot', () => {
|
|
131
|
-
const { asFragment } = render(
|
|
132
|
-
<Alert isLiveRegion={true} variant={variant} aria-label={`${variant} toast alert`} title="Some title">
|
|
133
|
-
Some toast alert
|
|
134
|
-
</Alert>
|
|
135
|
-
);
|
|
136
|
-
expect(asFragment()).toMatchSnapshot();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
test('Toast alerts contain default live region', () => {
|
|
140
|
-
const ariaLabel = `${variant} toast alert`;
|
|
141
|
-
|
|
142
|
-
render(
|
|
143
|
-
<Alert isLiveRegion={true} variant={variant} aria-label={ariaLabel} title="Some title">
|
|
144
|
-
Some toast alert
|
|
145
|
-
</Alert>
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
expect(screen.getByLabelText(ariaLabel)).toHaveAttribute('aria-live', 'polite');
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
test('Toast alert live regions are not atomic', () => {
|
|
152
|
-
const ariaLabel = `${variant} toast alert`;
|
|
153
|
-
|
|
154
|
-
render(
|
|
155
|
-
<Alert isLiveRegion={true} variant={variant} aria-label={ariaLabel} title="Some title">
|
|
156
|
-
Some toast alert
|
|
157
|
-
</Alert>
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
expect(screen.getByLabelText(ariaLabel)).toHaveAttribute('aria-atomic', 'false');
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
test('Non-toast alerts can have custom live region settings', () => {
|
|
164
|
-
const ariaLabel = `${variant} toast alert`;
|
|
165
|
-
|
|
166
|
-
render(
|
|
167
|
-
<Alert
|
|
168
|
-
aria-live="assertive"
|
|
169
|
-
aria-relevant="all"
|
|
170
|
-
aria-atomic="true"
|
|
171
|
-
variant={variant}
|
|
172
|
-
aria-label={ariaLabel}
|
|
173
|
-
title="Some title"
|
|
174
|
-
>
|
|
175
|
-
Some noisy alert
|
|
176
|
-
</Alert>
|
|
177
|
-
);
|
|
178
|
-
const alert = screen.getByLabelText(ariaLabel);
|
|
179
|
-
|
|
180
|
-
expect(alert).toHaveAttribute('aria-live', 'assertive');
|
|
181
|
-
expect(alert).toHaveAttribute('aria-relevant', 'all');
|
|
182
|
-
expect(alert).toHaveAttribute('aria-atomic', 'true');
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
test('Custom icon', () => {
|
|
186
|
-
const { asFragment } = render(
|
|
187
|
-
<Alert
|
|
188
|
-
customIcon={<UsersIcon />}
|
|
189
|
-
variant={variant}
|
|
190
|
-
aria-label={`${variant} custom icon alert`}
|
|
191
|
-
title="custom icon alert title"
|
|
192
|
-
>
|
|
193
|
-
Some noisy alert
|
|
194
|
-
</Alert>
|
|
195
|
-
);
|
|
196
|
-
expect(asFragment()).toMatchSnapshot();
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
test('Alert truncate title', () => {
|
|
7
|
+
import { AlertContext } from '../AlertContext';
|
|
8
|
+
import { capitalize } from '../../../helpers';
|
|
9
|
+
|
|
10
|
+
jest.mock('../AlertToggleExpandButton', () => ({
|
|
11
|
+
AlertToggleExpandButton: ({ isExpanded, onToggleExpand, ...props }) => (
|
|
12
|
+
<button onClick={onToggleExpand} {...props}>
|
|
13
|
+
isExpanded: {`${isExpanded}`}
|
|
14
|
+
</button>
|
|
15
|
+
)
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
jest.mock('../AlertIcon', () => ({
|
|
19
|
+
AlertIcon: ({ variant, className, customIcon, ...props }) => (
|
|
20
|
+
<div {...props} className={className}>
|
|
21
|
+
<p>custom icon: {customIcon}</p>
|
|
22
|
+
<p>variant: {variant}</p>
|
|
23
|
+
</div>
|
|
24
|
+
)
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
test('Renders without children', () => {
|
|
28
|
+
render(
|
|
29
|
+
<div data-testid="container">
|
|
30
|
+
<Alert title="Some title" />
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
expect(screen.getByTestId('container').firstChild).toBeVisible();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('Renders with class pf-c-alert on the containing div', () => {
|
|
38
|
+
render(
|
|
39
|
+
<Alert title="Some title" data-testid="Alert-test-id">
|
|
40
|
+
Some alert
|
|
41
|
+
</Alert>
|
|
42
|
+
);
|
|
43
|
+
expect(screen.getByTestId('Alert-test-id')).toHaveClass('pf-c-alert');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('Renders with class pf-c-alert__title on the div containing the title', () => {
|
|
47
|
+
render(<Alert title="Some title">Some alert</Alert>);
|
|
48
|
+
expect(screen.getByRole('heading', { name: 'Default alert: Some title' })).toHaveClass('pf-c-alert__title');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('Renders with a default aria label of Default Alert', () => {
|
|
52
|
+
render(
|
|
53
|
+
<Alert title="Some title" data-testid="Alert-test-id">
|
|
54
|
+
Some alert
|
|
55
|
+
</Alert>
|
|
56
|
+
);
|
|
57
|
+
expect(screen.getByTestId('Alert-test-id')).toHaveAccessibleName('Default Alert');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
['success', 'danger', 'warning', 'info'].forEach(variant => {
|
|
61
|
+
test(`Does not render with class pf-m-${variant} by default`, () => {
|
|
62
|
+
render(
|
|
63
|
+
<Alert title="Some title" data-testid="Alert-test-id">
|
|
64
|
+
Some alert
|
|
65
|
+
</Alert>
|
|
66
|
+
);
|
|
67
|
+
expect(screen.getByTestId('Alert-test-id')).not.toHaveClass(`pf-m-${variant}`);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test(`Renders with class pf-m-${variant} when variant = ${variant}`, () => {
|
|
71
|
+
render(
|
|
72
|
+
<Alert variant={`${variant as AlertVariant}`} title="Some title" data-testid="Alert-test-id">
|
|
73
|
+
Some alert
|
|
74
|
+
</Alert>
|
|
75
|
+
);
|
|
76
|
+
expect(screen.getByTestId('Alert-test-id')).toHaveClass(`pf-m-${variant}`);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test(`Renders with aria label ${capitalize(variant)} Alert when variant = ${variant}`, () => {
|
|
80
|
+
render(
|
|
81
|
+
<Alert variant={`${variant as AlertVariant}`} title="Some title" data-testid="Alert-test-id">
|
|
82
|
+
Some alert
|
|
83
|
+
</Alert>
|
|
84
|
+
);
|
|
85
|
+
expect(screen.getByTestId('Alert-test-id')).toHaveAccessibleName(`${capitalize(variant)} Alert`);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test(`Renders the title with an accessible name of '${capitalize(
|
|
89
|
+
variant
|
|
90
|
+
)} alert: Some title' when variant = ${variant}`, () => {
|
|
91
|
+
render(
|
|
92
|
+
<Alert variant={`${variant as AlertVariant}`} title="Some title">
|
|
93
|
+
Some alert
|
|
94
|
+
</Alert>
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
expect(screen.getByRole('heading')).toHaveAccessibleName(`${capitalize(variant)} alert: Some title`);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test(`Passes AlertToggleExpandButton an aria label of '${capitalize(
|
|
101
|
+
variant
|
|
102
|
+
)} alert details' when variant = ${variant} and it is expandable`, () => {
|
|
103
|
+
render(
|
|
104
|
+
<Alert variant={`${variant as AlertVariant}`} title="Some title" isExpandable>
|
|
105
|
+
Some alert
|
|
106
|
+
</Alert>
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expect(screen.getByRole('button')).toHaveAccessibleName(`${capitalize(variant)} alert details`);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test(`Provides a variantLabel of '${capitalize(variant)} alert:' in a context when variant = ${variant}`, () => {
|
|
113
|
+
const TestComponent: React.FunctionComponent = () => {
|
|
114
|
+
const context = React.useContext(AlertContext);
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<p data-testid="Test-component" aria-label={context.variantLabel}>
|
|
118
|
+
{context.title}
|
|
119
|
+
</p>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
202
123
|
render(
|
|
203
|
-
<Alert
|
|
204
|
-
|
|
124
|
+
<Alert
|
|
125
|
+
variant={`${variant as AlertVariant}`}
|
|
126
|
+
title="Some title"
|
|
127
|
+
data-testid="Alert-test-id"
|
|
128
|
+
actionClose={<TestComponent />}
|
|
129
|
+
>
|
|
130
|
+
Some alert
|
|
205
131
|
</Alert>
|
|
206
132
|
);
|
|
207
133
|
|
|
208
|
-
expect(screen.
|
|
134
|
+
expect(screen.getByTestId('Test-component')).toHaveAccessibleName(`${capitalize(variant)} alert:`);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('Does not render with class pf-m-inline by default', () => {
|
|
139
|
+
render(<Alert title="Some title">Some alert</Alert>);
|
|
140
|
+
expect(screen.getByLabelText('Default Alert')).not.toHaveClass('pf-m-inline');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('Renders with class pf-m-inline when isInline = true', () => {
|
|
144
|
+
render(
|
|
145
|
+
<Alert isInline title="Some title">
|
|
146
|
+
Some alert
|
|
147
|
+
</Alert>
|
|
148
|
+
);
|
|
149
|
+
expect(screen.getByLabelText('Default Alert')).toHaveClass('pf-m-inline');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('Does not render with class pf-m-plain by default', () => {
|
|
153
|
+
render(<Alert title="Some title">Some alert</Alert>);
|
|
154
|
+
expect(screen.getByLabelText('Default Alert')).not.toHaveClass('pf-m-plain');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('Renders with class pf-m-plain when isPlain = true', () => {
|
|
158
|
+
render(
|
|
159
|
+
<Alert isPlain title="Some title">
|
|
160
|
+
Some alert
|
|
161
|
+
</Alert>
|
|
162
|
+
);
|
|
163
|
+
expect(screen.getByLabelText('Default Alert')).toHaveClass('pf-m-plain');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('Renders the title', () => {
|
|
167
|
+
render(<Alert title="Some title">Some alert</Alert>);
|
|
168
|
+
|
|
169
|
+
expect(screen.getByText('Some title')).toBeVisible();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test('Renders the title as an h4 by default', () => {
|
|
173
|
+
render(<Alert title="Some title">Some alert</Alert>);
|
|
174
|
+
|
|
175
|
+
expect(screen.getByRole('heading', { level: 4, name: 'Default alert: Some title' })).toBeVisible();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test('Renders the title as other heading levels when one is passed using titleHeadingLevel', () => {
|
|
179
|
+
render(
|
|
180
|
+
<Alert title="Some title" titleHeadingLevel="h1">
|
|
181
|
+
Some alert
|
|
182
|
+
</Alert>
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
expect(screen.getByRole('heading', { level: 1, name: 'Default alert: Some title' })).toBeVisible();
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test('Renders the element passed via the actionClose prop', () => {
|
|
189
|
+
render(
|
|
190
|
+
<Alert title="Some title" actionClose={<button>Action close</button>}>
|
|
191
|
+
Some alert
|
|
192
|
+
</Alert>
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
expect(screen.getByRole('button', { name: 'Action close' })).toBeVisible();
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test('Renders the actionClose element inside pf-c-alert__action', () => {
|
|
199
|
+
render(
|
|
200
|
+
<Alert title="Some title" actionClose="Action close">
|
|
201
|
+
Some alert
|
|
202
|
+
</Alert>
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
expect(screen.getByText('Action close')).toHaveClass('pf-c-alert__action');
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
test('Provides the actionClose element access to the title via a context', () => {
|
|
209
|
+
const TestComponent: React.FunctionComponent = () => {
|
|
210
|
+
const context = React.useContext(AlertContext);
|
|
211
|
+
|
|
212
|
+
return (
|
|
213
|
+
<p data-testid="Test-component" aria-label={context.variantLabel}>
|
|
214
|
+
{context.title}
|
|
215
|
+
</p>
|
|
216
|
+
);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
render(
|
|
220
|
+
<Alert title="Some title" actionClose={<TestComponent />}>
|
|
221
|
+
Some alert
|
|
222
|
+
</Alert>
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
expect(screen.getByTestId('Test-component')).toHaveTextContent('Some title');
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
test('Renders the element passed via the actionLinks prop', () => {
|
|
229
|
+
render(
|
|
230
|
+
<Alert title="Some title" actionLinks={<button>Action link</button>}>
|
|
231
|
+
Some alert
|
|
232
|
+
</Alert>
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
expect(screen.getByRole('button', { name: 'Action link' })).toBeVisible();
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
test('Renders the actionLinks element inside pf-c-alert__action-group', () => {
|
|
239
|
+
render(
|
|
240
|
+
<Alert title="Some title" actionLinks="Action link">
|
|
241
|
+
Some alert
|
|
242
|
+
</Alert>
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
expect(screen.getByText('Action link')).toHaveClass('pf-c-alert__action-group');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
test('Renders children', () => {
|
|
249
|
+
render(<Alert title="Some title">Some alert</Alert>);
|
|
250
|
+
|
|
251
|
+
expect(screen.getByText('Some alert')).toBeVisible();
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
test('Renders children inside pf-c-alert__description', () => {
|
|
255
|
+
render(<Alert title="Some title">Some alert</Alert>);
|
|
256
|
+
|
|
257
|
+
expect(screen.getByText('Some alert')).toHaveClass('pf-c-alert__description');
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
test('Renders with the aria label passed via prop', () => {
|
|
261
|
+
render(
|
|
262
|
+
<Alert aria-label="Test label" title="Some title" data-testid="Alert-test-id">
|
|
263
|
+
Some alert
|
|
264
|
+
</Alert>
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
expect(screen.getByTestId('Alert-test-id')).toHaveAccessibleName('Test label');
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test('Renders with the variantLabel passed via prop', () => {
|
|
271
|
+
const TestComponent: React.FunctionComponent = () => {
|
|
272
|
+
const context = React.useContext(AlertContext);
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<p data-testid="Test-component" aria-label={context.variantLabel}>
|
|
276
|
+
{context.title}
|
|
277
|
+
</p>
|
|
278
|
+
);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
render(
|
|
282
|
+
<Alert variantLabel="Test label" title="Some title" data-testid="Alert-test-id" actionClose={<TestComponent />}>
|
|
283
|
+
Some alert
|
|
284
|
+
</Alert>
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
expect(screen.getByTestId('Test-component')).toHaveAccessibleName('Test label');
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
test('Renders without aria-live and aria-atomic attributes by default', () => {
|
|
291
|
+
render(
|
|
292
|
+
<Alert title="Some title" data-testid="Alert-test-id">
|
|
293
|
+
Some alert
|
|
294
|
+
</Alert>
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
const alertContainer = screen.getByTestId('Alert-test-id');
|
|
298
|
+
|
|
299
|
+
expect(alertContainer).not.toHaveAttribute('aria-live');
|
|
300
|
+
expect(alertContainer).not.toHaveAttribute('aria-atomic');
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
test('Has an aria-live value of polite and aria-atomic value of false when isLiveRegion = true', () => {
|
|
304
|
+
render(
|
|
305
|
+
<Alert title="Some title" data-testid="Alert-test-id" isLiveRegion>
|
|
306
|
+
Some alert
|
|
307
|
+
</Alert>
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
const alertContainer = screen.getByTestId('Alert-test-id');
|
|
311
|
+
|
|
312
|
+
expect(alertContainer).toHaveAttribute('aria-live', 'polite');
|
|
313
|
+
expect(alertContainer).toHaveAttribute('aria-atomic', 'false');
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
test('Renders with no timeout by default', () => {
|
|
317
|
+
jest.useFakeTimers();
|
|
318
|
+
|
|
319
|
+
render(<Alert title="Some title">Some alert</Alert>);
|
|
320
|
+
|
|
321
|
+
act(() => {
|
|
322
|
+
jest.advanceTimersByTime(8000);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
expect(screen.getByText('Some alert')).toBeVisible();
|
|
326
|
+
jest.useRealTimers();
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
test('Removes the alert after 8000ms when timeout = true', () => {
|
|
330
|
+
jest.useFakeTimers();
|
|
331
|
+
|
|
332
|
+
render(
|
|
333
|
+
<Alert title="Some title" timeout>
|
|
334
|
+
Some alert
|
|
335
|
+
</Alert>
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
act(() => {
|
|
339
|
+
jest.advanceTimersByTime(7999);
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
expect(screen.getByText('Some alert')).toBeVisible();
|
|
343
|
+
|
|
344
|
+
act(() => {
|
|
345
|
+
jest.advanceTimersByTime(1);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
expect(screen.queryByText('Some alert')).not.toBeInTheDocument();
|
|
349
|
+
jest.useRealTimers();
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
test('Removes the alert after a custom time when timeout is passed with a number', () => {
|
|
353
|
+
jest.useFakeTimers();
|
|
354
|
+
|
|
355
|
+
render(
|
|
356
|
+
<Alert title="Some title" timeout={2000}>
|
|
357
|
+
Some alert
|
|
358
|
+
</Alert>
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
act(() => {
|
|
362
|
+
jest.advanceTimersByTime(1999);
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
expect(screen.getByText('Some alert')).toBeVisible();
|
|
366
|
+
|
|
367
|
+
act(() => {
|
|
368
|
+
jest.advanceTimersByTime(1);
|
|
209
369
|
});
|
|
370
|
+
|
|
371
|
+
expect(screen.queryByText('Some alert')).not.toBeInTheDocument();
|
|
372
|
+
jest.useRealTimers();
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
test('Does not remove the alert on timeout if the user is focused on the alert', async () => {
|
|
376
|
+
const user = userEvent.setup({
|
|
377
|
+
advanceTimers: delay => jest.advanceTimersByTime(delay)
|
|
378
|
+
});
|
|
379
|
+
jest.useFakeTimers();
|
|
380
|
+
|
|
381
|
+
render(
|
|
382
|
+
<Alert title="Some title" timeout>
|
|
383
|
+
Some alert
|
|
384
|
+
</Alert>
|
|
385
|
+
);
|
|
386
|
+
|
|
387
|
+
const alert = screen.getByText('Some alert');
|
|
388
|
+
|
|
389
|
+
await user.click(alert);
|
|
390
|
+
|
|
391
|
+
act(() => {
|
|
392
|
+
jest.advanceTimersByTime(8000);
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
expect(screen.getByText('Some alert')).toBeVisible();
|
|
396
|
+
jest.useRealTimers();
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
test('Does not remove the alert on timeout if the user is hovered over the alert', async () => {
|
|
400
|
+
const user = userEvent.setup({
|
|
401
|
+
advanceTimers: delay => jest.advanceTimersByTime(delay)
|
|
402
|
+
});
|
|
403
|
+
jest.useFakeTimers();
|
|
404
|
+
|
|
405
|
+
render(
|
|
406
|
+
<Alert title="Some title" timeout>
|
|
407
|
+
Some alert
|
|
408
|
+
</Alert>
|
|
409
|
+
);
|
|
410
|
+
|
|
411
|
+
const alert = screen.getByText('Some alert');
|
|
412
|
+
|
|
413
|
+
await user.hover(alert);
|
|
414
|
+
|
|
415
|
+
act(() => {
|
|
416
|
+
jest.advanceTimersByTime(8000);
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
expect(alert).toBeVisible();
|
|
420
|
+
jest.useRealTimers();
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
test('Removes the alert after the user removes focus from the alert and 3000ms have passed', async () => {
|
|
424
|
+
const user = userEvent.setup({
|
|
425
|
+
advanceTimers: delay => jest.advanceTimersByTime(delay)
|
|
426
|
+
});
|
|
427
|
+
jest.useFakeTimers();
|
|
428
|
+
|
|
429
|
+
render(
|
|
430
|
+
<div>
|
|
431
|
+
<input />
|
|
432
|
+
<Alert title="Some title" timeout>
|
|
433
|
+
Some alert
|
|
434
|
+
</Alert>
|
|
435
|
+
</div>
|
|
436
|
+
);
|
|
437
|
+
|
|
438
|
+
const alert = screen.getByText('Some alert');
|
|
439
|
+
|
|
440
|
+
await user.click(alert);
|
|
441
|
+
|
|
442
|
+
act(() => {
|
|
443
|
+
jest.advanceTimersByTime(8000);
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
await user.click(screen.getByRole('textbox'));
|
|
447
|
+
|
|
448
|
+
act(() => {
|
|
449
|
+
jest.advanceTimersByTime(3000);
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
expect(screen.queryByText('Some alert')).not.toBeInTheDocument();
|
|
453
|
+
jest.useRealTimers();
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
test('Removes the alert after the user removes hover from the alert and 3000ms have passed', async () => {
|
|
457
|
+
const user = userEvent.setup({
|
|
458
|
+
advanceTimers: delay => jest.advanceTimersByTime(delay)
|
|
459
|
+
});
|
|
460
|
+
jest.useFakeTimers();
|
|
461
|
+
|
|
462
|
+
render(
|
|
463
|
+
<div>
|
|
464
|
+
<input />
|
|
465
|
+
<Alert title="Some title" timeout>
|
|
466
|
+
Some alert
|
|
467
|
+
</Alert>
|
|
468
|
+
</div>
|
|
469
|
+
);
|
|
470
|
+
|
|
471
|
+
const alert = screen.getByText('Some alert');
|
|
472
|
+
|
|
473
|
+
await user.hover(alert);
|
|
474
|
+
|
|
475
|
+
act(() => {
|
|
476
|
+
jest.advanceTimersByTime(8000);
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
await user.hover(screen.getByRole('textbox'));
|
|
480
|
+
|
|
481
|
+
act(() => {
|
|
482
|
+
jest.advanceTimersByTime(3000);
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
expect(screen.queryByText('Some alert')).not.toBeInTheDocument();
|
|
486
|
+
jest.useRealTimers();
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
test('Removes the alert after the user removes hover from the alert and timeoutAnimation time has passed', async () => {
|
|
490
|
+
const user = userEvent.setup({
|
|
491
|
+
advanceTimers: delay => jest.advanceTimersByTime(delay)
|
|
492
|
+
});
|
|
493
|
+
jest.useFakeTimers();
|
|
494
|
+
|
|
495
|
+
render(
|
|
496
|
+
<div>
|
|
497
|
+
<input />
|
|
498
|
+
<Alert title="Some title" timeout timeoutAnimation={1000}>
|
|
499
|
+
Some alert
|
|
500
|
+
</Alert>
|
|
501
|
+
</div>
|
|
502
|
+
);
|
|
503
|
+
|
|
504
|
+
const alert = screen.getByText('Some alert');
|
|
505
|
+
|
|
506
|
+
await user.hover(alert);
|
|
507
|
+
|
|
508
|
+
act(() => {
|
|
509
|
+
jest.advanceTimersByTime(8000);
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
await user.hover(screen.getByRole('textbox'));
|
|
513
|
+
|
|
514
|
+
act(() => {
|
|
515
|
+
jest.advanceTimersByTime(1000);
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
expect(screen.queryByText('Some alert')).not.toBeInTheDocument();
|
|
519
|
+
jest.useRealTimers();
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
test('Does not call the onTimeout callback before the timeout period has expired', () => {
|
|
523
|
+
jest.useFakeTimers();
|
|
524
|
+
const onTimeoutMock = jest.fn();
|
|
525
|
+
|
|
526
|
+
render(
|
|
527
|
+
<Alert title="Some title" timeout onTimeout={onTimeoutMock}>
|
|
528
|
+
Some alert
|
|
529
|
+
</Alert>
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
act(() => {
|
|
533
|
+
jest.advanceTimersByTime(7999);
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
expect(onTimeoutMock).not.toHaveBeenCalled();
|
|
537
|
+
jest.useRealTimers();
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
test('Calls the onTimeout callback after the timeout period has expired', () => {
|
|
541
|
+
jest.useFakeTimers();
|
|
542
|
+
const onTimeoutMock = jest.fn();
|
|
543
|
+
|
|
544
|
+
render(
|
|
545
|
+
<Alert title="Some title" timeout onTimeout={onTimeoutMock}>
|
|
546
|
+
Some alert
|
|
547
|
+
</Alert>
|
|
548
|
+
);
|
|
549
|
+
|
|
550
|
+
act(() => {
|
|
551
|
+
jest.advanceTimersByTime(8000);
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
expect(onTimeoutMock).toHaveBeenCalledTimes(1);
|
|
555
|
+
jest.useRealTimers();
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
test('Renders titles without truncation styling by default', () => {
|
|
559
|
+
render(<Alert title="Some title">Some alert</Alert>);
|
|
560
|
+
|
|
561
|
+
const title = screen.getByRole('heading');
|
|
562
|
+
|
|
563
|
+
expect(title).not.toHaveClass('pf-m-truncate');
|
|
564
|
+
expect(title).not.toHaveAttribute('style');
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
test('Renders titles with the expected truncation styling when truncateTitle is a value', () => {
|
|
568
|
+
render(
|
|
569
|
+
<Alert title="Some title" truncateTitle={3}>
|
|
570
|
+
Some alert
|
|
571
|
+
</Alert>
|
|
572
|
+
);
|
|
573
|
+
|
|
574
|
+
const title = screen.getByRole('heading');
|
|
575
|
+
|
|
576
|
+
expect(title).toHaveClass('pf-m-truncate');
|
|
577
|
+
expect(title).toHaveAttribute('style', '--pf-c-alert__title--max-lines: 3;');
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
test('Passes customIcon value to AlertIcon', () => {
|
|
581
|
+
render(
|
|
582
|
+
<Alert title="Some title" customIcon="custom-icon-test">
|
|
583
|
+
Some alert
|
|
584
|
+
</Alert>
|
|
585
|
+
);
|
|
586
|
+
|
|
587
|
+
expect(screen.getByText('custom icon: custom-icon-test')).toBeVisible();
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
test('Does not render with class pf-m-expandable by default', () => {
|
|
591
|
+
render(<Alert title="Some title">Some alert</Alert>);
|
|
592
|
+
expect(screen.getByLabelText('Default Alert')).not.toHaveClass('pf-m-expandable');
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
test('Renders with class pf-m-expandable when isExpandable = true', () => {
|
|
596
|
+
render(
|
|
597
|
+
<Alert isExpandable title="Some title">
|
|
598
|
+
Some alert
|
|
599
|
+
</Alert>
|
|
600
|
+
);
|
|
601
|
+
expect(screen.getByLabelText('Default Alert')).toHaveClass('pf-m-expandable');
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
test('Renders AlertToggleExpandButton inside pf-c-alert__toggle', () => {
|
|
605
|
+
render(
|
|
606
|
+
<Alert isExpandable title="Some title">
|
|
607
|
+
Some alert
|
|
608
|
+
</Alert>
|
|
609
|
+
);
|
|
610
|
+
|
|
611
|
+
expect(screen.getByRole('button').parentElement).toHaveClass('pf-c-alert__toggle');
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
test('Does not render with class pf-m-expanded when AlertToggleExpandButton has not been clicked', () => {
|
|
615
|
+
render(
|
|
616
|
+
<Alert isExpandable title="Some title">
|
|
617
|
+
Some alert
|
|
618
|
+
</Alert>
|
|
619
|
+
);
|
|
620
|
+
|
|
621
|
+
expect(screen.getByLabelText('Default Alert')).not.toHaveClass('pf-m-expanded');
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
test('Renders with class pf-m-expanded once the AlertToggleExpandButton is clicked', async () => {
|
|
625
|
+
const user = userEvent.setup();
|
|
626
|
+
|
|
627
|
+
render(
|
|
628
|
+
<Alert isExpandable title="Some title">
|
|
629
|
+
Some alert
|
|
630
|
+
</Alert>
|
|
631
|
+
);
|
|
632
|
+
|
|
633
|
+
await user.click(screen.getByRole('button'));
|
|
634
|
+
|
|
635
|
+
expect(screen.getByLabelText('Default Alert')).toHaveClass('pf-m-expanded');
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
test('Does not render children when isExpandable = true and AlertToggleExpandButton has not been clicked', () => {
|
|
639
|
+
render(
|
|
640
|
+
<Alert isExpandable title="Some title">
|
|
641
|
+
Some alert
|
|
642
|
+
</Alert>
|
|
643
|
+
);
|
|
644
|
+
|
|
645
|
+
expect(screen.queryByText('Some alert')).not.toBeInTheDocument();
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
test('Renders children when isExpandable = true and AlertToggleExpandButton has been clicked', async () => {
|
|
649
|
+
const user = userEvent.setup();
|
|
650
|
+
|
|
651
|
+
render(
|
|
652
|
+
<Alert isExpandable title="Some title">
|
|
653
|
+
Some alert
|
|
654
|
+
</Alert>
|
|
655
|
+
);
|
|
656
|
+
|
|
657
|
+
await user.click(screen.getByRole('button'));
|
|
658
|
+
|
|
659
|
+
expect(screen.getByText('Some alert')).toBeVisible();
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
test('Passes AlertToggleExpandButton isExpanded = false when AlertToggleExpandButton has not been clicked', () => {
|
|
663
|
+
render(
|
|
664
|
+
<Alert isExpandable title="Some title">
|
|
665
|
+
Some alert
|
|
666
|
+
</Alert>
|
|
667
|
+
);
|
|
668
|
+
|
|
669
|
+
expect(screen.getByText('isExpanded: false')).toBeVisible();
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
test('Passes AlertToggleExpandButton isExpanded = true once the AlertToggleExpandButton is clicked', async () => {
|
|
673
|
+
const user = userEvent.setup();
|
|
674
|
+
|
|
675
|
+
render(
|
|
676
|
+
<Alert isExpandable title="Some title">
|
|
677
|
+
Some alert
|
|
678
|
+
</Alert>
|
|
679
|
+
);
|
|
680
|
+
|
|
681
|
+
await user.click(screen.getByRole('button'));
|
|
682
|
+
|
|
683
|
+
expect(screen.getByText('isExpanded: true')).toBeVisible();
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
test('Passes AlertToggleExpandButton the aria label provided via toggleAriaLabel', () => {
|
|
687
|
+
render(
|
|
688
|
+
<Alert isExpandable title="Some title" toggleAriaLabel="Test label">
|
|
689
|
+
Some alert
|
|
690
|
+
</Alert>
|
|
691
|
+
);
|
|
692
|
+
|
|
693
|
+
expect(screen.getByRole('button')).toHaveAccessibleName('Test label');
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
test('Passes the id prop to the top level returned element', () => {
|
|
697
|
+
render(
|
|
698
|
+
<Alert title="Some title" aria-label="Test label" id="test-id">
|
|
699
|
+
Some alert
|
|
700
|
+
</Alert>
|
|
701
|
+
);
|
|
702
|
+
|
|
703
|
+
expect(screen.getByLabelText('Test label')).toHaveAttribute('id', 'test-id');
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
test('Renders with inherited element props spread to the component', () => {
|
|
707
|
+
render(
|
|
708
|
+
<>
|
|
709
|
+
<Alert title="Some title" aria-describedby="labelling-id" aria-label="Test label" />
|
|
710
|
+
<p id="labelling-id">Described by text</p>
|
|
711
|
+
</>
|
|
712
|
+
);
|
|
713
|
+
|
|
714
|
+
expect(screen.getByLabelText('Test label')).toHaveAccessibleDescription('Described by text');
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
test('Matches snapshot', () => {
|
|
718
|
+
const { asFragment } = render(
|
|
719
|
+
<Alert isLiveRegion={true} aria-label="Toast alert label" title="Some title" ouiaId="ouia-id">
|
|
720
|
+
Some toast alert
|
|
721
|
+
</Alert>
|
|
722
|
+
);
|
|
723
|
+
expect(asFragment()).toMatchSnapshot();
|
|
210
724
|
});
|