@tpzdsp/next-toolkit 2.5.1 → 3.0.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/package.json +21 -12
- package/src/assets/styles/globals.css +75 -95
- package/src/assets/styles/ol.css +57 -16
- package/src/assets/styles/utils.css +80 -0
- package/src/components/Accordion/Accordion.css +85 -0
- package/src/components/Accordion/Accordion.stories.tsx +264 -0
- package/src/components/Accordion/Accordion.tsx +98 -0
- package/src/components/Alert/Alert.css +129 -0
- package/src/components/Alert/Alert.stories.tsx +291 -0
- package/src/components/Alert/Alert.tsx +76 -0
- package/src/components/BackLink/BackLink.css +12 -0
- package/src/components/BackLink/BackLink.stories.tsx +52 -0
- package/src/components/BackLink/BackLink.tsx +44 -0
- package/src/components/BackToTop/BackToTop.css +23 -0
- package/src/components/BackToTop/BackToTop.stories.tsx +41 -0
- package/src/components/BackToTop/BackToTop.tsx +48 -0
- package/src/components/Breadcrumb/Breadcrumb.css +42 -0
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +94 -0
- package/src/components/Breadcrumb/Breadcrumb.tsx +135 -0
- package/src/components/Button/Button.css +229 -0
- package/src/components/Button/Button.stories.tsx +140 -20
- package/src/components/Button/Button.tsx +53 -28
- package/src/components/Button/ButtonSkeleton.stories.tsx +50 -0
- package/src/components/Button/ButtonSkeleton.tsx +14 -0
- package/src/components/ButtonGroup/ButtonGroup.css +52 -0
- package/src/components/ButtonGroup/ButtonGroup.stories.tsx +156 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +50 -0
- package/src/components/ButtonLink/ButtonLink.css +114 -0
- package/src/components/ButtonLink/ButtonLink.stories.tsx +38 -51
- package/src/components/ButtonLink/ButtonLink.tsx +54 -23
- package/src/components/Card/Card.css +13 -0
- package/src/components/Card/Card.stories.tsx +98 -57
- package/src/components/Card/Card.tsx +4 -13
- package/src/components/CardGroup/CardGroup.css +10 -0
- package/src/components/CardGroup/CardGroup.stories.tsx +81 -0
- package/src/components/CardGroup/CardGroup.tsx +9 -0
- package/src/components/Checkbox/Checkbox.css +49 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +86 -0
- package/src/components/Checkbox/Checkbox.tsx +32 -0
- package/src/components/Chip/Chip.css +54 -0
- package/src/components/Chip/Chip.stories.tsx +94 -0
- package/src/components/Chip/Chip.tsx +34 -0
- package/src/components/CookieBanner/CookieBanner.css +19 -0
- package/src/components/CookieBanner/CookieBanner.stories.tsx +52 -0
- package/src/components/CookieBanner/CookieBanner.tsx +55 -0
- package/src/components/CopyButton/CopyButton.stories.tsx +28 -0
- package/src/components/CopyButton/CopyButton.tsx +65 -0
- package/src/components/DateInput/DateInput.css +13 -0
- package/src/components/DateInput/DateInput.stories.tsx +131 -0
- package/src/components/DateInput/DateInput.test.tsx +21 -0
- package/src/components/DateInput/DateInput.tsx +98 -0
- package/src/components/Details/Details.css +28 -0
- package/src/components/Details/Details.stories.tsx +48 -0
- package/src/components/Details/Details.tsx +41 -0
- package/src/components/Dropdown/Dropdown.css +81 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +131 -0
- package/src/components/Dropdown/Dropdown.tsx +69 -0
- package/src/components/ErrorBoundary/ErrorBoundary.stories.tsx +4 -39
- package/src/components/ErrorBoundary/ErrorBoundary.tsx +7 -4
- package/src/components/ErrorBoundary/ErrorFallback.tsx +32 -66
- package/src/components/ErrorModal/ErrorModal.css +32 -0
- package/src/components/ErrorModal/ErrorModal.stories.tsx +101 -0
- package/src/components/ErrorModal/ErrorModal.tsx +120 -0
- package/src/components/ErrorText/ErrorText.css +22 -0
- package/src/components/ErrorText/ErrorText.stories.tsx +42 -27
- package/src/components/ErrorText/ErrorText.tsx +10 -8
- package/src/components/ExternalLink/ExternalLink.css +12 -0
- package/src/components/ExternalLink/ExternalLink.stories.tsx +43 -0
- package/src/components/ExternalLink/ExternalLink.tsx +43 -0
- package/src/components/Fieldset/Fieldset.css +103 -0
- package/src/components/Fieldset/Fieldset.stories.tsx +304 -0
- package/src/components/Fieldset/Fieldset.tsx +38 -0
- package/src/components/FileUpload/FileUpload.css +85 -0
- package/src/components/FileUpload/FileUpload.stories.tsx +106 -0
- package/src/components/FileUpload/FileUpload.tsx +99 -0
- package/src/components/{layout/footer → Footer}/Copyright.tsx +4 -2
- package/src/components/Footer/Footer.stories.tsx +24 -0
- package/src/components/Footer/Footer.tsx +41 -0
- package/src/components/Footer/Licence.tsx +18 -0
- package/src/components/{layout/footer → Footer}/MetaLinks.tsx +8 -3
- package/src/components/Footer/Small/SmallFooter.tsx +43 -42
- package/src/components/Form/FormGroup.css +18 -0
- package/src/components/Form/FormGroup.stories.tsx +87 -0
- package/src/components/Form/FormGroup.tsx +16 -0
- package/src/components/{layout/header → Header}/Header.stories.tsx +26 -12
- package/src/components/Header/Header.test.tsx +87 -0
- package/src/components/Header/Header.tsx +303 -0
- package/src/components/Header/HeaderAppContent.tsx +120 -0
- package/src/components/Heading/Heading.css +40 -0
- package/src/components/Heading/Heading.stories.tsx +15 -5
- package/src/components/Heading/Heading.tsx +21 -44
- package/src/components/Heading/HeadingSkeleton.stories.tsx +30 -0
- package/src/components/Heading/HeadingSkeleton.tsx +14 -0
- package/src/components/Hero/Hero.css +19 -0
- package/src/components/Hero/Hero.stories.tsx +41 -0
- package/src/components/Hero/Hero.tsx +14 -0
- package/src/components/HintText/HintText.css +5 -0
- package/src/components/HintText/HintText.stories.tsx +29 -0
- package/src/components/HintText/HintText.tsx +13 -0
- package/src/components/InfoBox/InfoBox.css +38 -0
- package/src/components/InfoBox/InfoBox.stories.tsx +51 -403
- package/src/components/InfoBox/InfoBox.tsx +31 -158
- package/src/components/Input/Input.css +77 -0
- package/src/components/Input/Input.stories.tsx +123 -0
- package/src/components/Input/Input.tsx +74 -0
- package/src/components/InputGroup/InputGroup.css +140 -0
- package/src/components/InputGroup/InputGroup.stories.tsx +125 -0
- package/src/components/InputGroup/InputGroup.tsx +47 -0
- package/src/components/InsetText/InsetText.css +5 -0
- package/src/components/InsetText/InsetText.stories.tsx +30 -0
- package/src/components/InsetText/InsetText.tsx +9 -0
- package/src/components/Keyboard/Keyboard.css +9 -0
- package/src/components/Keyboard/Keyboard.stories.tsx +63 -0
- package/src/components/Keyboard/Keyboard.tsx +30 -0
- package/src/components/Label/Label.css +27 -0
- package/src/components/Label/Label.stories.tsx +40 -0
- package/src/components/Label/Label.tsx +17 -0
- package/src/components/LayerSwitcher/LayerSwitcher.css +59 -0
- package/src/components/LayerSwitcher/LayerSwitcher.stories.tsx +112 -0
- package/src/components/LayerSwitcher/LayerSwitcher.tsx +61 -0
- package/src/components/Layout/401/401.stories.tsx +23 -0
- package/src/components/Layout/401/401.tsx +1 -0
- package/src/components/Layout/403/403.stories.tsx +23 -0
- package/src/components/Layout/403/403.tsx +21 -0
- package/src/components/Layout/404/404.stories.tsx +23 -0
- package/src/components/Layout/404/404.tsx +28 -0
- package/src/components/Layout/500/500.stories.tsx +56 -0
- package/src/components/Layout/500/500.tsx +63 -0
- package/src/components/Layout/ButtonGroup/ButtonGroup.css +52 -0
- package/src/components/Layout/ButtonGroup/ButtonGroup.stories.tsx +156 -0
- package/src/components/Layout/ButtonGroup/ButtonGroup.tsx +50 -0
- package/src/components/Layout/HeadingGroup/HeadingGroup.css +21 -0
- package/src/components/Layout/HeadingGroup/HeadingGroup.stories.tsx +84 -0
- package/src/components/Layout/HeadingGroup/HeadingGroup.tsx +9 -0
- package/src/components/Layout/MainWrapper/MainWrapper.css +12 -0
- package/src/components/Layout/MainWrapper/MainWrapper.stories.tsx +36 -0
- package/src/components/Layout/MainWrapper/MainWrapper.tsx +14 -0
- package/src/components/Layout/PageShell/PageShell.css +42 -0
- package/src/components/Layout/PageShell/PageShell.stories.tsx +108 -0
- package/src/components/Layout/PageShell/PageShell.tsx +31 -0
- package/src/components/Layout/ParagraphGroup/ParagraphGroup.css +5 -0
- package/src/components/Layout/ParagraphGroup/ParagraphGroup.stories.tsx +34 -0
- package/src/components/Layout/ParagraphGroup/ParagraphGroup.tsx +9 -0
- package/src/components/Layout/Stack/Stack.css +29 -0
- package/src/components/Layout/Stack/Stack.stories.tsx +83 -0
- package/src/components/Layout/Stack/Stack.tsx +19 -0
- package/src/components/Layout/WidthContainer/WidthContainer.css +17 -0
- package/src/components/Layout/WidthContainer/WidthContainer.stories.tsx +59 -0
- package/src/components/Layout/WidthContainer/WidthContainer.tsx +13 -0
- package/src/components/Legend/Legend.css +95 -0
- package/src/components/Legend/Legend.stories.tsx +81 -0
- package/src/components/Legend/Legend.tsx +32 -0
- package/src/components/Legend/LegendDot.tsx +15 -0
- package/src/components/Legend/LegendPanel.stories.tsx +101 -0
- package/src/components/Legend/LegendPanel.tsx +68 -0
- package/src/components/Legend/LegendSkeleton.stories.tsx +87 -0
- package/src/components/Legend/LegendSkeleton.tsx +73 -0
- package/src/components/LegendSelect/LegendSelect.css +8 -0
- package/src/components/LegendSelect/LegendSelect.stories.tsx +80 -0
- package/src/components/LegendSelect/LegendSelect.tsx +26 -0
- package/src/components/Link/Link.css +98 -0
- package/src/components/Link/Link.stories.tsx +70 -0
- package/src/components/Link/Link.tsx +52 -0
- package/src/components/LinkButton/LinkButton.css +67 -0
- package/src/components/LinkButton/LinkButton.stories.tsx +90 -42
- package/src/components/LinkButton/LinkButton.tsx +50 -63
- package/src/components/LinkList/LinkList.css +28 -0
- package/src/components/LinkList/LinkList.stories.tsx +46 -0
- package/src/components/LinkList/LinkList.tsx +23 -0
- package/src/components/List/Li.tsx +9 -0
- package/src/components/List/List.css +9 -0
- package/src/components/List/OrderedList.stories.tsx +36 -0
- package/src/components/List/OrderedList.tsx +9 -0
- package/src/components/List/UnorderedList.stories.tsx +36 -0
- package/src/components/List/UnorderedList.tsx +9 -0
- package/src/components/LoadingBox/LoadingBox.css +27 -0
- package/src/components/LoadingBox/LoadingBox.stories.tsx +66 -0
- package/src/components/LoadingBox/LoadingBox.tsx +40 -0
- package/src/components/Modal/Modal.css +114 -0
- package/src/components/Modal/Modal.stories.tsx +41 -160
- package/src/components/Modal/Modal.tsx +132 -75
- package/src/components/NoScriptBanner/NoScriptBanner.css +17 -0
- package/src/components/NoScriptBanner/NoScriptBanner.stories.tsx +46 -0
- package/src/components/NoScriptBanner/NoScriptBanner.tsx +26 -0
- package/src/components/Paragraph/Paragraph.css +22 -0
- package/src/components/Paragraph/Paragraph.stories.tsx +1 -42
- package/src/components/Paragraph/Paragraph.tsx +4 -3
- package/src/components/Paragraph/ParagraphSkeleton.stories.tsx +44 -0
- package/src/components/Paragraph/ParagraphSkeleton.tsx +33 -0
- package/src/components/PasswordInput/PasswordInput.css +3 -0
- package/src/components/PasswordInput/PasswordInput.stories.tsx +47 -0
- package/src/components/PasswordInput/PasswordInput.tsx +45 -0
- package/src/components/PhaseBanner/PhaseBanner.css +12 -0
- package/src/components/PhaseBanner/PhaseBanner.stories.tsx +61 -0
- package/src/components/PhaseBanner/PhaseBanner.tsx +17 -0
- package/src/components/Popover/Popover.css +43 -0
- package/src/components/Popover/Popover.stories.tsx +102 -0
- package/src/components/Popover/Popover.tsx +40 -0
- package/src/components/Radio/Radio.css +69 -0
- package/src/components/Radio/Radio.stories.tsx +169 -0
- package/src/components/Radio/Radio.tsx +56 -0
- package/src/components/Resizable/Resizable.css +86 -0
- package/src/components/Resizable/Resizable.stories.tsx +123 -0
- package/src/components/Resizable/Resizable.tsx +86 -0
- package/src/components/ScrollArea/ScrollArea.css +9 -0
- package/src/components/ScrollArea/ScrollArea.stories.tsx +42 -0
- package/src/components/ScrollArea/ScrollArea.tsx +11 -0
- package/src/components/SearchBox/SearchBox.stories.tsx +88 -0
- package/src/components/SearchBox/SearchBox.tsx +36 -0
- package/src/components/Select/AsyncSelect.stories.tsx +84 -0
- package/src/components/Select/AsyncSelect.tsx +41 -0
- package/src/components/Select/Select.css +194 -0
- package/src/components/Select/Select.stories.tsx +162 -0
- package/src/components/Select/Select.test.tsx +36 -0
- package/src/components/Select/Select.tsx +291 -0
- package/src/components/Select/SelectSkeleton.stories.tsx +51 -0
- package/src/components/Select/SelectSkeleton.tsx +23 -0
- package/src/components/Separator/Separator.css +41 -0
- package/src/components/Separator/Separator.stories.tsx +63 -0
- package/src/components/Separator/Separator.tsx +42 -0
- package/src/components/Sidebar/ResizableSidebar.tsx +118 -0
- package/src/components/Sidebar/Sidebar.css +203 -0
- package/src/components/Sidebar/Sidebar.stories.tsx +438 -0
- package/src/components/Sidebar/Sidebar.tsx +225 -0
- package/src/components/Skeleton/Skeleton.css +16 -0
- package/src/components/Skeleton/Skeleton.stories.tsx +39 -0
- package/src/components/Skeleton/Skeleton.tsx +12 -0
- package/src/components/SkipLink/SkipLink.css +16 -0
- package/src/components/SkipLink/SkipLink.stories.tsx +40 -0
- package/src/components/SkipLink/SkipLink.tsx +15 -0
- package/src/components/Spinner/Spinner.css +30 -0
- package/src/components/Spinner/Spinner.stories.tsx +36 -0
- package/src/components/Spinner/Spinner.tsx +45 -0
- package/src/components/StartButton/StartButton.css +13 -0
- package/src/components/StartButton/StartButton.stories.tsx +68 -0
- package/src/components/StartButton/StartButton.tsx +50 -0
- package/src/components/SubmitButton/SubmitButton.stories.tsx +31 -0
- package/src/components/SubmitButton/SubmitButton.tsx +14 -0
- package/src/components/SummaryList/SummaryList.css +71 -0
- package/src/components/SummaryList/SummaryList.stories.tsx +211 -0
- package/src/components/SummaryList/SummaryList.tsx +41 -0
- package/src/components/SummaryList/SummaryListSkeleton.stories.tsx +67 -0
- package/src/components/SummaryList/SummaryListSkeleton.tsx +40 -0
- package/src/components/Tabs/Tabs.css +84 -0
- package/src/components/Tabs/Tabs.stories.tsx +133 -0
- package/src/components/Tabs/Tabs.tsx +66 -0
- package/src/components/Tag/Tag.css +8 -0
- package/src/components/Tag/Tag.stories.tsx +96 -0
- package/src/components/Tag/Tag.tsx +34 -0
- package/src/components/Textarea/Textarea.css +38 -0
- package/src/components/Textarea/Textarea.stories.tsx +131 -0
- package/src/components/Textarea/Textarea.tsx +50 -0
- package/src/components/TextareaCount/TextareaCount.css +17 -0
- package/src/components/TextareaCount/TextareaCount.stories.tsx +131 -0
- package/src/components/TextareaCount/TextareaCount.tsx +108 -0
- package/src/components/Tooltip/Tooltip.css +43 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +110 -0
- package/src/components/Tooltip/Tooltip.tsx +53 -0
- package/src/components/WarningText/WarningText.css +20 -0
- package/src/components/WarningText/WarningText.stories.tsx +29 -0
- package/src/components/WarningText/WarningText.tsx +17 -0
- package/src/components/index.ts +342 -61
- package/src/errors/errorDisplay.ts +70 -0
- package/src/errors/index.ts +1 -0
- package/src/http/constants.ts +1 -0
- package/src/http/fetch.ts +7 -3
- package/src/map/LayerSwitcherPanel.tsx +2 -173
- package/src/map/LegendShim.tsx +2 -0
- package/src/map/MapComponent.tsx +7 -17
- package/src/map/MapControlsOverlay.tsx +68 -175
- package/src/map/Popup.tsx +71 -24
- package/src/map/geocoder/Geocoder.test.tsx +46 -3
- package/src/map/geocoder/Geocoder.tsx +155 -278
- package/src/map/index.ts +1 -1
- package/src/types/utils.ts +0 -10
- package/src/utils/components.ts +96 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/utils.ts +0 -12
- package/src/assets/images/defra-logo.svg +0 -51
- package/src/assets/images/ea-logo.svg +0 -58
- package/src/assets/images/ogl.svg +0 -1
- package/src/components/Button/Button.test.tsx +0 -53
- package/src/components/ButtonLink/ButtonLink.test.tsx +0 -154
- package/src/components/Card/Card.test.tsx +0 -51
- package/src/components/ErrorBoundary/ErrorBoundary.test.tsx +0 -75
- package/src/components/ErrorBoundary/ErrorFallback.test.tsx +0 -107
- package/src/components/ErrorText/ErrorText.test.tsx +0 -33
- package/src/components/Heading/Heading.test.tsx +0 -22
- package/src/components/Hint/Hint.stories.tsx +0 -58
- package/src/components/Hint/Hint.test.tsx +0 -33
- package/src/components/Hint/Hint.tsx +0 -12
- package/src/components/InfoBox/InfoBox.test.tsx +0 -330
- package/src/components/InfoBox/types.ts +0 -6
- package/src/components/LinkButton/LinkButton.test.tsx +0 -177
- package/src/components/Modal/Modal.test.tsx +0 -246
- package/src/components/NotificationBanner/NotificationBanner.stories.tsx +0 -45
- package/src/components/NotificationBanner/NotificationBanner.test.tsx +0 -58
- package/src/components/NotificationBanner/NotificationBanner.tsx +0 -45
- package/src/components/Paragraph/Paragraph.test.tsx +0 -10
- package/src/components/SlidingPanel/SlidingPanel.stories.tsx +0 -129
- package/src/components/SlidingPanel/SlidingPanel.test.tsx +0 -83
- package/src/components/SlidingPanel/SlidingPanel.tsx +0 -258
- package/src/components/accordion/Accordion.stories.tsx +0 -234
- package/src/components/accordion/Accordion.test.tsx +0 -192
- package/src/components/accordion/Accordion.tsx +0 -73
- package/src/components/backToTop/BackToTop.stories.tsx +0 -407
- package/src/components/backToTop/BackToTop.test.tsx +0 -57
- package/src/components/backToTop/BackToTop.tsx +0 -134
- package/src/components/chip/Chip.stories.tsx +0 -61
- package/src/components/chip/Chip.test.tsx +0 -31
- package/src/components/chip/Chip.tsx +0 -23
- package/src/components/container/Container.tsx +0 -42
- package/src/components/cookieBanner/CookieBanner.stories.tsx +0 -257
- package/src/components/cookieBanner/CookieBanner.test.tsx +0 -68
- package/src/components/cookieBanner/CookieBanner.tsx +0 -73
- package/src/components/divider/RuleDivider.stories.tsx +0 -254
- package/src/components/divider/RuleDivider.test.tsx +0 -164
- package/src/components/divider/RuleDivider.tsx +0 -23
- package/src/components/dropdown/DropdownMenu.test.tsx +0 -211
- package/src/components/dropdown/DropdownMenu.tsx +0 -108
- package/src/components/dropdown/useDropdownMenu.ts +0 -249
- package/src/components/form/Input.stories.tsx +0 -435
- package/src/components/form/Input.test.tsx +0 -206
- package/src/components/form/Input.tsx +0 -23
- package/src/components/form/TextArea.stories.tsx +0 -464
- package/src/components/form/TextArea.test.tsx +0 -232
- package/src/components/form/TextArea.tsx +0 -23
- package/src/components/layout/footer/Footer.tsx +0 -26
- package/src/components/layout/footer/Licence.tsx +0 -19
- package/src/components/layout/header/Header.test.tsx +0 -36
- package/src/components/layout/header/Header.tsx +0 -90
- package/src/components/layout/header/HeaderAuthClient.test.tsx +0 -45
- package/src/components/layout/header/HeaderAuthClient.tsx +0 -40
- package/src/components/layout/header/HeaderNavClient.test.tsx +0 -44
- package/src/components/layout/header/HeaderNavClient.tsx +0 -67
- package/src/components/link/ExternalLink.test.tsx +0 -102
- package/src/components/link/ExternalLink.tsx +0 -29
- package/src/components/link/Link.tsx +0 -26
- package/src/components/select/Select.stories.tsx +0 -336
- package/src/components/select/Select.test.tsx +0 -474
- package/src/components/select/Select.tsx +0 -125
- package/src/components/select/SelectSkeleton.stories.tsx +0 -194
- package/src/components/select/SelectSkeleton.test.tsx +0 -104
- package/src/components/select/SelectSkeleton.tsx +0 -23
- package/src/components/select/common.ts +0 -3
- package/src/components/select/index.ts +0 -18
- package/src/components/skipLink/SkipLink.stories.tsx +0 -346
- package/src/components/skipLink/SkipLink.test.tsx +0 -22
- package/src/components/skipLink/SkipLink.tsx +0 -49
- package/src/map/LegendPanel.tsx +0 -85
- /package/src/{components → assets}/images/DefraLogo.tsx +0 -0
- /package/src/{components → assets}/images/EaLogo.tsx +0 -0
- /package/src/{components → assets}/images/OglLogo.tsx +0 -0
- /package/src/components/{googleAnalytics → GoogleAnalytics}/GlobalVars.tsx +0 -0
- /package/src/components/{googleAnalytics → GoogleAnalytics}/GoogleAnalytics.tsx +0 -0
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { ErrorFallback } from './ErrorFallback';
|
|
2
|
-
import { ApiError } from '../../errors';
|
|
3
|
-
import { HttpStatus } from '../../http';
|
|
4
|
-
import { render, screen, userEvent, within } from '../../test/renderers';
|
|
5
|
-
import { identityFn } from '../../utils/utils';
|
|
6
|
-
|
|
7
|
-
const FAKE_UUID = 'fake-uuid';
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(navigator, 'clipboard', {
|
|
10
|
-
value: {
|
|
11
|
-
writeText: vi.fn().mockResolvedValue(undefined),
|
|
12
|
-
},
|
|
13
|
-
configurable: true,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
describe('ErrorFallback', () => {
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
(navigator.clipboard.writeText as unknown) = vi.fn().mockResolvedValue(undefined);
|
|
19
|
-
vi.spyOn(crypto, 'randomUUID').mockReturnValue(FAKE_UUID);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
afterEach(() => {
|
|
23
|
-
vi.clearAllMocks();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('renders a generic error message for an unknown error type', () => {
|
|
27
|
-
render(<ErrorFallback error={{} as unknown as Error} resetErrorBoundary={identityFn} />);
|
|
28
|
-
|
|
29
|
-
const alert = screen.getByRole('alert');
|
|
30
|
-
|
|
31
|
-
expect(alert).toHaveTextContent(/something went wrong/i);
|
|
32
|
-
expect(alert).toHaveTextContent(/reason: unknown/i);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('renders message for standard Error instance', () => {
|
|
36
|
-
const error = new Error('custom error message');
|
|
37
|
-
|
|
38
|
-
render(<ErrorFallback error={error} resetErrorBoundary={identityFn} />);
|
|
39
|
-
|
|
40
|
-
expect(screen.getByRole('alert')).toHaveTextContent(/reason: custom error message/i);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('renders message, details and digest for ApiError instance', async () => {
|
|
44
|
-
const apiError = new ApiError('Fake Reason', HttpStatus.InternalServerError, 'Some details');
|
|
45
|
-
|
|
46
|
-
render(<ErrorFallback error={apiError} resetErrorBoundary={identityFn} />);
|
|
47
|
-
|
|
48
|
-
// Message shown
|
|
49
|
-
expect(screen.getByRole('alert')).toHaveTextContent(/reason: fake reason/i);
|
|
50
|
-
|
|
51
|
-
// Accordion exists but details hidden until toggled
|
|
52
|
-
const accordionButton = screen.getByRole('button', { name: /show details/i });
|
|
53
|
-
|
|
54
|
-
expect(accordionButton).toBeInTheDocument();
|
|
55
|
-
|
|
56
|
-
// Expand and check details text
|
|
57
|
-
await userEvent.click(accordionButton);
|
|
58
|
-
|
|
59
|
-
const section = screen.getByRole('region', { hidden: false });
|
|
60
|
-
|
|
61
|
-
expect(within(section).getByText(/error id:/i)).toBeInTheDocument();
|
|
62
|
-
expect(within(section).getByText(/some details/i)).toBeInTheDocument();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('renders non-string causes', () => {
|
|
66
|
-
const error = new Error('Has a cause', { cause: ['I will display'] });
|
|
67
|
-
|
|
68
|
-
render(<ErrorFallback error={error} resetErrorBoundary={identityFn} />);
|
|
69
|
-
|
|
70
|
-
expect(screen.getByRole('alert')).toHaveTextContent(/reason: has a cause/i);
|
|
71
|
-
expect(screen.queryByRole('button', { name: /show details/i })).toBeInTheDocument();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('calls resetErrorBoundary when Retry is clicked', async () => {
|
|
75
|
-
const user = userEvent.setup();
|
|
76
|
-
const resetSpy = vi.fn();
|
|
77
|
-
|
|
78
|
-
render(<ErrorFallback error={new Error('Test error')} resetErrorBoundary={resetSpy} />);
|
|
79
|
-
|
|
80
|
-
const button = screen.getByRole('button', { name: /retry/i });
|
|
81
|
-
|
|
82
|
-
await user.click(button);
|
|
83
|
-
|
|
84
|
-
expect(resetSpy).toHaveBeenCalledTimes(1);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('copies error info to clipboard when Copy is clicked', async () => {
|
|
88
|
-
const user = userEvent.setup();
|
|
89
|
-
const apiError = new ApiError('Copy Reason', HttpStatus.BadRequest, 'Some details');
|
|
90
|
-
|
|
91
|
-
render(<ErrorFallback error={apiError} resetErrorBoundary={identityFn} />);
|
|
92
|
-
|
|
93
|
-
const copyButton = screen.getByRole('button', { name: /copy/i });
|
|
94
|
-
|
|
95
|
-
await user.click(copyButton);
|
|
96
|
-
|
|
97
|
-
expect(navigator.clipboard.writeText).toHaveBeenCalledWith(
|
|
98
|
-
expect.stringContaining('App Error: Copy Reason'),
|
|
99
|
-
);
|
|
100
|
-
expect(navigator.clipboard.writeText).toHaveBeenCalledWith(
|
|
101
|
-
expect.stringContaining('Details: Some details'),
|
|
102
|
-
);
|
|
103
|
-
expect(navigator.clipboard.writeText).toHaveBeenCalledWith(
|
|
104
|
-
expect.stringContaining(`Digest: ${FAKE_UUID}`),
|
|
105
|
-
);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ErrorText } from './ErrorText';
|
|
2
|
-
import { render, screen } from '../../test/renderers';
|
|
3
|
-
|
|
4
|
-
describe('ErrorText', () => {
|
|
5
|
-
it('renders with default ErrorText', () => {
|
|
6
|
-
render(<ErrorText>Error message</ErrorText>);
|
|
7
|
-
|
|
8
|
-
expect(screen.getByRole('alert')).toHaveTextContent(/error message/i);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('renders with custom styles', () => {
|
|
12
|
-
render(<ErrorText className="bg-orange-500">Error text</ErrorText>);
|
|
13
|
-
|
|
14
|
-
const error = screen.getByRole('alert');
|
|
15
|
-
|
|
16
|
-
expect(error).toHaveClass(/bg-orange-500/i);
|
|
17
|
-
expect(error).not.toHaveClass(/bg-green-500/i);
|
|
18
|
-
expect(error).toHaveTextContent(/error text/i);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('renders with complex children', () => {
|
|
22
|
-
render(
|
|
23
|
-
<ErrorText>
|
|
24
|
-
<a href="/">Error link</a>
|
|
25
|
-
</ErrorText>,
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const linkElement = screen.getByRole('link', { name: /error link/i });
|
|
29
|
-
|
|
30
|
-
expect(linkElement).toBeInTheDocument();
|
|
31
|
-
expect(linkElement).toHaveAttribute('href', '/');
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Heading, type HeadingProps } from './Heading';
|
|
2
|
-
import { render, screen } from '../../test/renderers';
|
|
3
|
-
|
|
4
|
-
describe('Heading Component', () => {
|
|
5
|
-
const headingTypes: HeadingProps['type'][] = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
6
|
-
|
|
7
|
-
it.each(headingTypes)('renders correct HTML element for type "%s"', (type) => {
|
|
8
|
-
render(<Heading type={type}>Test {type}</Heading>);
|
|
9
|
-
|
|
10
|
-
const heading = screen.getByRole('heading', { name: `Test ${type}` });
|
|
11
|
-
|
|
12
|
-
expect(heading).toBeInTheDocument();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it.each(headingTypes)('applies correct styles for type "%s"', (type) => {
|
|
16
|
-
render(<Heading type={type}>Styled {type}</Heading>);
|
|
17
|
-
|
|
18
|
-
const heading = screen.getByText(`Styled ${type}`);
|
|
19
|
-
|
|
20
|
-
expect(heading).toHaveClass('font-bold text-text-primary');
|
|
21
|
-
});
|
|
22
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { fn } from 'storybook/test';
|
|
2
|
-
|
|
3
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
4
|
-
|
|
5
|
-
import { Hint } from './Hint';
|
|
6
|
-
import { Button } from '../Button/Button';
|
|
7
|
-
|
|
8
|
-
const meta: Meta<typeof Hint> = {
|
|
9
|
-
title: 'Components/Hint',
|
|
10
|
-
component: Hint,
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: 'padded',
|
|
13
|
-
},
|
|
14
|
-
tags: ['autodocs'],
|
|
15
|
-
argTypes: {
|
|
16
|
-
children: {
|
|
17
|
-
control: false,
|
|
18
|
-
description: 'The content to display for the hint',
|
|
19
|
-
},
|
|
20
|
-
className: {
|
|
21
|
-
control: 'text',
|
|
22
|
-
description: 'Additional TailwindCSS classes to apply to the hint container',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
args: {
|
|
26
|
-
children: 'Hint message',
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default meta;
|
|
31
|
-
|
|
32
|
-
type Story = StoryObj<typeof Hint>;
|
|
33
|
-
|
|
34
|
-
export const Default: Story = {};
|
|
35
|
-
|
|
36
|
-
export const CustomStyling: Story = {
|
|
37
|
-
args: {
|
|
38
|
-
className: 'text-3xl',
|
|
39
|
-
children: 'Hint message with extra large text',
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const ComplexChildren: Story = {
|
|
44
|
-
args: {
|
|
45
|
-
children: (
|
|
46
|
-
<div>
|
|
47
|
-
Hint message with link and button{' '}
|
|
48
|
-
<a className="underline text-link" href="/">
|
|
49
|
-
Link
|
|
50
|
-
</a>
|
|
51
|
-
{}
|
|
52
|
-
<Button variant="primary" onClick={fn()}>
|
|
53
|
-
Click
|
|
54
|
-
</Button>
|
|
55
|
-
</div>
|
|
56
|
-
),
|
|
57
|
-
},
|
|
58
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Hint } from './Hint';
|
|
2
|
-
import { render, screen } from '../../test/renderers';
|
|
3
|
-
|
|
4
|
-
describe('Hint', () => {
|
|
5
|
-
it('renders with default Hint message', () => {
|
|
6
|
-
render(<Hint>Hint text</Hint>);
|
|
7
|
-
expect(screen.getByText(/hint text/i)).toHaveTextContent(/hint text/i);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('renders with custom styles', () => {
|
|
11
|
-
render(<Hint className="bg-orange-500">hint message</Hint>);
|
|
12
|
-
|
|
13
|
-
const hintElement = screen.getByText(/hint message/i);
|
|
14
|
-
|
|
15
|
-
expect(hintElement).toHaveClass(/bg-orange-500/i);
|
|
16
|
-
expect(hintElement).not.toHaveClass(/bg-green-500/i);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('renders with complex children', () => {
|
|
20
|
-
render(
|
|
21
|
-
<Hint>
|
|
22
|
-
Some description text <a href="/">Link</a>
|
|
23
|
-
</Hint>,
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
const linkElement = screen.getByRole('link', { name: /link/i });
|
|
27
|
-
|
|
28
|
-
expect(screen.getByText(/some description text/i)).toBeInTheDocument();
|
|
29
|
-
|
|
30
|
-
expect(linkElement).toBeInTheDocument();
|
|
31
|
-
expect(linkElement).toHaveAttribute('href', '/');
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ExtendProps } from '../../types/utils';
|
|
2
|
-
import { cn } from '../../utils';
|
|
3
|
-
|
|
4
|
-
export type HintProps = ExtendProps<'div'>;
|
|
5
|
-
|
|
6
|
-
export const Hint = ({ className, children, ...props }: HintProps) => {
|
|
7
|
-
return (
|
|
8
|
-
<div className={cn('mb-2 text-lg text-text-secondary', className)} {...props}>
|
|
9
|
-
{children}
|
|
10
|
-
</div>
|
|
11
|
-
);
|
|
12
|
-
};
|
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
import { InfoBox } from './InfoBox';
|
|
2
|
-
import { render, screen, userEvent, waitFor } from '../../test/renderers';
|
|
3
|
-
|
|
4
|
-
const TEST_CONTENT = 'Test info content';
|
|
5
|
-
const TEST_TITLE = 'Test Title';
|
|
6
|
-
const ARIA_EXPANDED = 'aria-expanded';
|
|
7
|
-
|
|
8
|
-
describe('InfoBox', () => {
|
|
9
|
-
describe('rendering', () => {
|
|
10
|
-
it('should render the trigger button with info icon', () => {
|
|
11
|
-
render(
|
|
12
|
-
<InfoBox>
|
|
13
|
-
<p>{TEST_CONTENT}</p>
|
|
14
|
-
</InfoBox>,
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
const button = screen.getByRole('button', { name: /show information/i });
|
|
18
|
-
|
|
19
|
-
expect(button).toBeInTheDocument();
|
|
20
|
-
expect(button.querySelector('svg')).toBeInTheDocument();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should not render content when closed', () => {
|
|
24
|
-
render(
|
|
25
|
-
<InfoBox>
|
|
26
|
-
<p>{TEST_CONTENT}</p>
|
|
27
|
-
</InfoBox>,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
expect(screen.queryByText(TEST_CONTENT)).not.toBeInTheDocument();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should render content when defaultOpen is true', () => {
|
|
34
|
-
render(
|
|
35
|
-
<InfoBox defaultOpen>
|
|
36
|
-
<p>{TEST_CONTENT}</p>
|
|
37
|
-
</InfoBox>,
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
expect(screen.getByText(TEST_CONTENT)).toBeInTheDocument();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should render title when provided', () => {
|
|
44
|
-
render(
|
|
45
|
-
<InfoBox title={TEST_TITLE} defaultOpen>
|
|
46
|
-
<p>{TEST_CONTENT}</p>
|
|
47
|
-
</InfoBox>,
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
expect(screen.getByText(TEST_TITLE)).toBeInTheDocument();
|
|
51
|
-
expect(screen.getByRole('heading', { level: 2 })).toHaveTextContent(TEST_TITLE);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('should not render title element when not provided', () => {
|
|
55
|
-
render(
|
|
56
|
-
<InfoBox defaultOpen>
|
|
57
|
-
<p>{TEST_CONTENT}</p>
|
|
58
|
-
</InfoBox>,
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
expect(screen.queryByRole('heading')).not.toBeInTheDocument();
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe('interactions', () => {
|
|
66
|
-
it('should open content when trigger is clicked', async () => {
|
|
67
|
-
const user = userEvent.setup();
|
|
68
|
-
|
|
69
|
-
render(
|
|
70
|
-
<InfoBox>
|
|
71
|
-
<p>{TEST_CONTENT}</p>
|
|
72
|
-
</InfoBox>,
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const button = screen.getByRole('button', { name: /show information/i });
|
|
76
|
-
|
|
77
|
-
expect(screen.queryByText(TEST_CONTENT)).not.toBeInTheDocument();
|
|
78
|
-
|
|
79
|
-
await user.click(button);
|
|
80
|
-
|
|
81
|
-
expect(screen.getByText(TEST_CONTENT)).toBeInTheDocument();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('should close content when trigger is clicked while open', async () => {
|
|
85
|
-
const user = userEvent.setup();
|
|
86
|
-
|
|
87
|
-
render(
|
|
88
|
-
<InfoBox defaultOpen>
|
|
89
|
-
<p>{TEST_CONTENT}</p>
|
|
90
|
-
</InfoBox>,
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
expect(screen.getByText(TEST_CONTENT)).toBeInTheDocument();
|
|
94
|
-
|
|
95
|
-
const button = screen.getByRole('button', { name: /show information/i });
|
|
96
|
-
|
|
97
|
-
await user.click(button);
|
|
98
|
-
|
|
99
|
-
await waitFor(() => {
|
|
100
|
-
expect(screen.queryByText(TEST_CONTENT)).not.toBeInTheDocument();
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// Note: Escape key closing is handled by FocusTrap, which is mocked in tests.
|
|
105
|
-
// The real behavior is tested through FocusTrap's own test suite.
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe('accessibility', () => {
|
|
109
|
-
it('should have aria-expanded attribute that toggles correctly', async () => {
|
|
110
|
-
const user = userEvent.setup();
|
|
111
|
-
|
|
112
|
-
render(
|
|
113
|
-
<InfoBox>
|
|
114
|
-
<p>{TEST_CONTENT}</p>
|
|
115
|
-
</InfoBox>,
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
const button = screen.getByRole('button', { name: /show information/i });
|
|
119
|
-
|
|
120
|
-
expect(button).toHaveAttribute(ARIA_EXPANDED, 'false');
|
|
121
|
-
|
|
122
|
-
await user.click(button);
|
|
123
|
-
|
|
124
|
-
expect(button).toHaveAttribute(ARIA_EXPANDED, 'true');
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('should have aria-haspopup="dialog" on trigger', () => {
|
|
128
|
-
render(
|
|
129
|
-
<InfoBox>
|
|
130
|
-
<p>{TEST_CONTENT}</p>
|
|
131
|
-
</InfoBox>,
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
const button = screen.getByRole('button', { name: /show information/i });
|
|
135
|
-
|
|
136
|
-
expect(button).toHaveAttribute('aria-haspopup', 'dialog');
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('should have dialog role', async () => {
|
|
140
|
-
const user = userEvent.setup();
|
|
141
|
-
|
|
142
|
-
render(
|
|
143
|
-
<InfoBox>
|
|
144
|
-
<p>{TEST_CONTENT}</p>
|
|
145
|
-
</InfoBox>,
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
await user.click(screen.getByRole('button', { name: /show information/i }));
|
|
149
|
-
|
|
150
|
-
const dialog = screen.getByRole('dialog');
|
|
151
|
-
|
|
152
|
-
// Floating UI uses div with role="dialog"
|
|
153
|
-
expect(dialog).toBeInTheDocument();
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('should have aria-labelledby when title is provided', async () => {
|
|
157
|
-
const user = userEvent.setup();
|
|
158
|
-
|
|
159
|
-
render(
|
|
160
|
-
<InfoBox title={TEST_TITLE}>
|
|
161
|
-
<p>{TEST_CONTENT}</p>
|
|
162
|
-
</InfoBox>,
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
await user.click(screen.getByRole('button', { name: /show information/i }));
|
|
166
|
-
|
|
167
|
-
const dialog = screen.getByRole('dialog');
|
|
168
|
-
const titleId = dialog.getAttribute('aria-labelledby');
|
|
169
|
-
|
|
170
|
-
expect(titleId).toBeTruthy();
|
|
171
|
-
|
|
172
|
-
const title = screen.getByRole('heading', { level: 2 });
|
|
173
|
-
|
|
174
|
-
expect(title).toHaveAttribute('id', titleId);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('should have aria-label when title is not provided', async () => {
|
|
178
|
-
const user = userEvent.setup();
|
|
179
|
-
|
|
180
|
-
render(
|
|
181
|
-
<InfoBox>
|
|
182
|
-
<p>{TEST_CONTENT}</p>
|
|
183
|
-
</InfoBox>,
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
await user.click(screen.getByRole('button', { name: /show information/i }));
|
|
187
|
-
|
|
188
|
-
const dialog = screen.getByRole('dialog');
|
|
189
|
-
|
|
190
|
-
expect(dialog).toHaveAttribute('aria-label', 'Information');
|
|
191
|
-
expect(dialog).not.toHaveAttribute('aria-labelledby');
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('should use custom triggerLabel when provided', () => {
|
|
195
|
-
render(
|
|
196
|
-
<InfoBox triggerLabel="Learn more about this feature">
|
|
197
|
-
<p>{TEST_CONTENT}</p>
|
|
198
|
-
</InfoBox>,
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
expect(
|
|
202
|
-
screen.getByRole('button', { name: /learn more about this feature/i }),
|
|
203
|
-
).toBeInTheDocument();
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
describe('callbacks', () => {
|
|
208
|
-
it('should call onOpenChange when opening', async () => {
|
|
209
|
-
const user = userEvent.setup();
|
|
210
|
-
const onOpenChange = vi.fn();
|
|
211
|
-
|
|
212
|
-
render(
|
|
213
|
-
<InfoBox onOpenChange={onOpenChange}>
|
|
214
|
-
<p>{TEST_CONTENT}</p>
|
|
215
|
-
</InfoBox>,
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
await user.click(screen.getByRole('button', { name: /show information/i }));
|
|
219
|
-
|
|
220
|
-
expect(onOpenChange).toHaveBeenCalledWith(true);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it('should call onOpenChange when closing', async () => {
|
|
224
|
-
const user = userEvent.setup();
|
|
225
|
-
const onOpenChange = vi.fn();
|
|
226
|
-
|
|
227
|
-
render(
|
|
228
|
-
<InfoBox defaultOpen onOpenChange={onOpenChange}>
|
|
229
|
-
<p>{TEST_CONTENT}</p>
|
|
230
|
-
</InfoBox>,
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
await user.click(screen.getByRole('button', { name: /show information/i }));
|
|
234
|
-
|
|
235
|
-
await waitFor(() => {
|
|
236
|
-
expect(onOpenChange).toHaveBeenCalledWith(false);
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
describe('positioning', () => {
|
|
242
|
-
it('should accept placement prop', async () => {
|
|
243
|
-
const user = userEvent.setup();
|
|
244
|
-
|
|
245
|
-
render(
|
|
246
|
-
<InfoBox placement="top-start">
|
|
247
|
-
<p>{TEST_CONTENT}</p>
|
|
248
|
-
</InfoBox>,
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
await user.click(screen.getByRole('button', { name: /show information/i }));
|
|
252
|
-
|
|
253
|
-
const dialog = screen.getByRole('dialog');
|
|
254
|
-
|
|
255
|
-
// Floating UI handles positioning automatically
|
|
256
|
-
expect(dialog).toBeInTheDocument();
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
describe('styling', () => {
|
|
261
|
-
it('should apply maxWidth style', async () => {
|
|
262
|
-
const user = userEvent.setup();
|
|
263
|
-
|
|
264
|
-
render(
|
|
265
|
-
<InfoBox maxWidth="400px">
|
|
266
|
-
<p>{TEST_CONTENT}</p>
|
|
267
|
-
</InfoBox>,
|
|
268
|
-
);
|
|
269
|
-
|
|
270
|
-
await user.click(screen.getByRole('button', { name: /show information/i }));
|
|
271
|
-
|
|
272
|
-
const dialog = screen.getByRole('dialog');
|
|
273
|
-
|
|
274
|
-
expect(dialog).toHaveStyle({ maxWidth: 'min(400px, calc(100vw - 32px))' });
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it('should merge custom className', () => {
|
|
278
|
-
render(
|
|
279
|
-
<InfoBox className="custom-class">
|
|
280
|
-
<p>{TEST_CONTENT}</p>
|
|
281
|
-
</InfoBox>,
|
|
282
|
-
);
|
|
283
|
-
|
|
284
|
-
const container = screen.getByRole('button', { name: /show information/i }).parentElement;
|
|
285
|
-
|
|
286
|
-
expect(container).toHaveClass('custom-class');
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
it('should have correct trigger button styling', () => {
|
|
290
|
-
render(
|
|
291
|
-
<InfoBox>
|
|
292
|
-
<p>{TEST_CONTENT}</p>
|
|
293
|
-
</InfoBox>,
|
|
294
|
-
);
|
|
295
|
-
|
|
296
|
-
const button = screen.getByRole('button', { name: /show information/i });
|
|
297
|
-
|
|
298
|
-
expect(button).toHaveClass('rounded-full', 'bg-transparent');
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
describe('complex content', () => {
|
|
303
|
-
it('should render interactive content correctly', async () => {
|
|
304
|
-
const user = userEvent.setup();
|
|
305
|
-
const onButtonClick = vi.fn();
|
|
306
|
-
|
|
307
|
-
render(
|
|
308
|
-
<InfoBox defaultOpen>
|
|
309
|
-
<div>
|
|
310
|
-
<p>Description text</p>
|
|
311
|
-
|
|
312
|
-
<input type="text" placeholder="Enter text" />
|
|
313
|
-
|
|
314
|
-
<button onClick={onButtonClick}>Action</button>
|
|
315
|
-
</div>
|
|
316
|
-
</InfoBox>,
|
|
317
|
-
);
|
|
318
|
-
|
|
319
|
-
expect(screen.getByText('Description text')).toBeInTheDocument();
|
|
320
|
-
expect(screen.getByPlaceholderText('Enter text')).toBeInTheDocument();
|
|
321
|
-
|
|
322
|
-
const actionButton = screen.getByRole('button', { name: 'Action' });
|
|
323
|
-
|
|
324
|
-
expect(actionButton).toBeInTheDocument();
|
|
325
|
-
|
|
326
|
-
await user.click(actionButton);
|
|
327
|
-
expect(onButtonClick).toHaveBeenCalled();
|
|
328
|
-
});
|
|
329
|
-
});
|
|
330
|
-
});
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type Position = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
2
|
-
|
|
3
|
-
export const POSITION_TOP_LEFT: Position = 'top-left';
|
|
4
|
-
export const POSITION_TOP_RIGHT: Position = 'top-right';
|
|
5
|
-
export const POSITION_BOTTOM_LEFT: Position = 'bottom-left';
|
|
6
|
-
export const POSITION_BOTTOM_RIGHT: Position = 'bottom-right';
|