@kaizen/components 1.61.1 → 1.61.3
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/codemods/utils/__snapshots__/transformSource.spec.ts.snap +2 -2
- package/dist/cjs/RichTextEditor/RichTextContent/RichTextContent.cjs +10 -1
- package/dist/cjs/__future__/Select/Select.cjs +1 -6
- package/dist/cjs/__future__/Select/subcomponents/ListBox/ListBox.cjs +1 -2
- package/dist/cjs/__future__/Select/subcomponents/ListBox/ListBox.module.scss.cjs +1 -2
- package/dist/esm/RichTextEditor/RichTextContent/RichTextContent.mjs +11 -2
- package/dist/esm/__future__/Select/Select.mjs +1 -6
- package/dist/esm/__future__/Select/subcomponents/ListBox/ListBox.mjs +1 -2
- package/dist/esm/__future__/Select/subcomponents/ListBox/ListBox.module.scss.mjs +1 -2
- package/dist/styles.css +46 -44
- package/package.json +6 -5
- package/src/Avatar/Avatar.spec.tsx +1 -1
- package/src/Calendar/utils/setFocusInCalendar.spec.tsx +2 -2
- package/src/Checkbox/Checkbox/Checkbox.spec.tsx +2 -2
- package/src/Collapsible/Collapsible/Collapsible.spec.tsx +2 -14
- package/src/Collapsible/Collapsible/_docs/Collapsible.mdx +0 -2
- package/src/Collapsible/Collapsible/_docs/Collapsible.stickersheet.stories.tsx +49 -0
- package/src/Collapsible/Collapsible/_docs/Collapsible.stories.tsx +0 -11
- package/src/DateInput/DateInputDescription/DateInputDescription.spec.tsx +5 -6
- package/src/DateInput/DateInputWithIconButton/DateInputWithIconButton.spec.tsx +4 -6
- package/src/DatePicker/DatePicker.spec.tsx +32 -36
- package/src/DatePicker/subcomponents/DateInputField/DateInputField.spec.tsx +13 -13
- package/src/DatePicker/utils/validateDate.spec.ts +5 -6
- package/src/EmptyState/EmptyState.spec.tsx +1 -1
- package/src/ErrorPage/ErrorPage.spec.tsx +19 -19
- package/src/Filter/FilterBar/FilterBar.spec.tsx +26 -26
- package/src/Filter/FilterBar/context/utils/updateDependentFilters.spec.ts +2 -4
- package/src/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.spec.tsx +3 -4
- package/src/Filter/FilterBar/subcomponents/FilterBarButton/FilterBarButton.spec.tsx +3 -6
- package/src/Filter/FilterBar/subcomponents/FilterBarDatePicker/FilterBarDatePicker.spec.tsx +10 -12
- package/src/Filter/FilterBar/subcomponents/FilterBarDateRangePicker/FilterBarDateRangePicker.spec.tsx +9 -10
- package/src/Filter/FilterBar/subcomponents/FilterBarMultiSelect/FilterBarMultiSelect.spec.tsx +12 -14
- package/src/Filter/FilterBar/subcomponents/FilterBarSelect/FilterBarSelect.spec.tsx +11 -13
- package/src/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.spec.tsx +5 -5
- package/src/Filter/FilterDatePicker/FilterDatePicker.spec.tsx +12 -15
- package/src/Filter/FilterDatePicker/hooks/useDateInputHandlers.spec.ts +12 -15
- package/src/Filter/FilterDatePicker/hooks/useDateValidation.spec.ts +3 -5
- package/src/Filter/FilterDatePicker/subcomponents/FilterDatePickerField/FilterDatePickerField.spec.tsx +23 -28
- package/src/Filter/FilterDatePicker/utils/getDateValidationHandler.spec.tsx +2 -6
- package/src/Filter/FilterDatePicker/utils/validateDate.spec.ts +5 -6
- package/src/Filter/FilterDateRangePicker/FilterDateRangePicker.spec.tsx +2 -3
- package/src/Filter/FilterDateRangePicker/_docs/FilterDateRangePicker.stickersheet.stories.tsx +27 -0
- package/src/Filter/FilterDateRangePicker/subcomponents/DateRangeInputField/DateRangeInputField.spec.tsx +9 -11
- package/src/Filter/FilterDateRangePicker/subcomponents/DateRangeValidationMessage/DateRangeValidationMessage.spec.tsx +1 -63
- package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/FilterDateRangePickerField.spec.tsx +32 -32
- package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/useEndDateValidation.spec.ts +3 -8
- package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/useStartDateValidation.spec.ts +2 -5
- package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/utils/validateEndDateBeforeStartDate.spec.ts +2 -3
- package/src/Filter/FilterMultiSelect/FilterMultiSelect.spec.tsx +9 -10
- package/src/Filter/FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.spec.tsx +2 -1
- package/src/Filter/FilterMultiSelect/context/SelectionProvider/SelectionProvider.spec.tsx +32 -32
- package/src/Filter/FilterMultiSelect/subcomponents/MultiSelectOption/MultiSelectOption.spec.tsx +9 -7
- package/src/Filter/FilterMultiSelect/subcomponents/SearchInput/SearchInput.spec.tsx +12 -12
- package/src/Filter/FilterMultiSelect/subcomponents/SelectionControlButton/ClearButton/ClearButton.spec.tsx +7 -7
- package/src/Filter/FilterMultiSelect/subcomponents/SelectionControlButton/SelectAllButton/SelectAllButton.spec.tsx +9 -9
- package/src/Filter/FilterSelect/FilterSelect.spec.tsx +3 -5
- package/src/Heading/Heading.spec.tsx +1 -31
- package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.spec.tsx +43 -97
- package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.stickersheet.stories.tsx +68 -0
- package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.stories.tsx +37 -0
- package/src/Input/InputRange/InputRange.spec.tsx +2 -2
- package/src/Input/InputSearch/InputSearch.spec.tsx +3 -5
- package/src/KaizenProvider/KaizenProvider.spec.tsx +2 -2
- package/src/KaizenProvider/subcomponents/OptionalIntlProvider/OptionalIntlProvider.spec.tsx +2 -3
- package/src/Modal/ConfirmationModal/ConfirmationModal.spec.tsx +7 -7
- package/src/Modal/ContextModal/ContextModal.spec.tsx +5 -5
- package/src/Modal/GenericModal/GenericModal.spec.tsx +4 -4
- package/src/Modal/InputEditModal/InputEditModal.spec.tsx +7 -7
- package/src/MultiSelect/subcomponents/MultiSelectOptionField/MultiSelectOptionField.spec.tsx +3 -3
- package/src/MultiSelect/subcomponents/MultiSelectOptions/MultiSelectOptions.spec.tsx +3 -3
- package/src/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.spec.tsx +2 -2
- package/src/MultiSelect/subcomponents/Popover/Popover.module.scss +1 -0
- package/src/Notification/subcomponents/GenericNotification/GenericNotification.stories.tsx +60 -0
- package/src/Pagination/Pagination.spec.tsx +2 -2
- package/src/RichTextEditor/EditableRichTextContent/EditableRichTextContent.spec.tsx +4 -4
- package/src/RichTextEditor/RichTextContent/RichTextContent.tsx +11 -2
- package/src/RichTextEditor/utils/commands/addMark.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/fixtures/helpers.ts +4 -3
- package/src/RichTextEditor/utils/commands/getMarkAttrs.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/getMarkRange.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/listIsActive.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/markContainsSelection.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/markIsActive.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/removeMark.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/updateMark.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/validateAndRemoveMarks.spec.ts +3 -3
- package/src/RichTextEditor/utils/core/createRichTextEditor.spec.ts +11 -11
- package/src/RichTextEditor/utils/core/hooks/useRichTextEditor.spec.tsx +2 -2
- package/src/SplitButton/SplitButton.spec.tsx +5 -5
- package/src/SplitButton/subcomponents/DropdownButton/DropdownButton.spec.tsx +3 -4
- package/src/Text/Text.spec.tsx +1 -57
- package/src/TextArea/TextArea.spec.tsx +2 -2
- package/src/TimeField/TimeField.spec.tsx +2 -2
- package/src/TitleBlockZen/TitleBlockZen.spec.tsx +36 -68
- package/src/TitleBlockZen/_docs/TitleBlockZen.stories.tsx +78 -8
- package/src/TitleBlockZen/subcomponents/MobileActions.spec.tsx +2 -2
- package/src/TitleBlockZen/subcomponents/NavigationTabs.spec.tsx +8 -2
- package/src/ToggleSwitch/ToggleSwitch/ToggleSwitch.spec.tsx +2 -2
- package/src/__actions__/Menu/v1/Menu.spec.tsx +2 -2
- package/src/__containers__/GuidanceBlock/v1/GuidanceBlock.spec.tsx +5 -5
- package/src/__containers__/GuidanceBlock/v2/GuidanceBlock.spec.tsx +5 -5
- package/src/__future__/Select/Select.spec.tsx +8 -8
- package/src/__future__/Select/Select.tsx +1 -10
- package/src/__future__/Select/subcomponents/ListBox/ListBox.module.scss +3 -3
- package/src/__future__/Select/subcomponents/ListBox/ListBox.tsx +1 -1
- package/src/__overlays__/Tooltip/v1/Tooltip.spec.tsx +1 -1
- package/src/__overlays__/Tooltip/v1/utils/isSemanticElement.spec.tsx +4 -9
- package/src/utils/useMediaQueries.spec.tsx +7 -7
- package/src/Heading/__snapshots__/Heading.spec.tsx.snap +0 -85
- package/src/Illustration/utils/usePausePlay.spec.tsx +0 -85
- package/src/Notification/subcomponents/GenericNotification/GenericNotification.spec.tsx +0 -76
- package/src/Text/__snapshots__/Text.spec.tsx.snap +0 -49
- package/src/__overlays__/Tooltip/v1/subcomponents/AppearanceAnim.spec.tsx +0 -39
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { render, screen } from "@testing-library/react"
|
|
3
3
|
import { IntlProvider } from "react-intl"
|
|
4
|
+
import { vi } from "vitest"
|
|
4
5
|
import { OptionalIntlProvider } from "."
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
vi.mock("@cultureamp/i18n-react-intl", () => ({
|
|
7
8
|
StaticIntlProvider: ({ children }: { children: React.ReactElement }) => (
|
|
8
9
|
<div data-testid="mockedIntlProvider">{children}</div>
|
|
9
10
|
),
|
|
@@ -35,5 +36,3 @@ describe("<OptionalIntlProvider>", () => {
|
|
|
35
36
|
expect(childrenResult).toBeInTheDocument()
|
|
36
37
|
})
|
|
37
38
|
})
|
|
38
|
-
|
|
39
|
-
/* eslint-enable jest/expect-expect */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { render, waitFor } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
+
import { vi } from "vitest"
|
|
4
5
|
import { mockMatchMedia } from "~components/utils/useMediaQueries.spec"
|
|
5
6
|
import { ConfirmationModal, ConfirmationModalProps } from "./ConfirmationModal"
|
|
6
|
-
|
|
7
7
|
const user = userEvent.setup()
|
|
8
8
|
|
|
9
9
|
const ConfirmationModalWrapper = ({
|
|
@@ -28,8 +28,8 @@ describe("<ConfirmationModal />", () => {
|
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
it("supports a dismiss action when dismiss button is pressed", async () => {
|
|
31
|
-
const handleConfirm =
|
|
32
|
-
const handleDismiss =
|
|
31
|
+
const handleConfirm = vi.fn()
|
|
32
|
+
const handleDismiss = vi.fn()
|
|
33
33
|
const { getByLabelText } = render(
|
|
34
34
|
<ConfirmationModalWrapper
|
|
35
35
|
onConfirm={handleConfirm}
|
|
@@ -46,8 +46,8 @@ describe("<ConfirmationModal />", () => {
|
|
|
46
46
|
})
|
|
47
47
|
|
|
48
48
|
it("supports a dismiss action when cancel button is pressed", async () => {
|
|
49
|
-
const handleConfirm =
|
|
50
|
-
const handleDismiss =
|
|
49
|
+
const handleConfirm = vi.fn()
|
|
50
|
+
const handleDismiss = vi.fn()
|
|
51
51
|
const { getByText } = render(
|
|
52
52
|
<ConfirmationModalWrapper
|
|
53
53
|
onDismiss={handleDismiss}
|
|
@@ -64,8 +64,8 @@ describe("<ConfirmationModal />", () => {
|
|
|
64
64
|
})
|
|
65
65
|
|
|
66
66
|
it("supports a confirm action when confirm button is pressed", async () => {
|
|
67
|
-
const handleConfirm =
|
|
68
|
-
const handleDismiss =
|
|
67
|
+
const handleConfirm = vi.fn()
|
|
68
|
+
const handleDismiss = vi.fn()
|
|
69
69
|
const { getByText } = render(
|
|
70
70
|
<ConfirmationModalWrapper
|
|
71
71
|
onDismiss={handleDismiss}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { render, waitFor } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
+
import { vi } from "vitest"
|
|
4
5
|
import { mockMatchMedia } from "~components/utils/useMediaQueries.spec"
|
|
5
6
|
import { ContextModal, ContextModalProps } from "./ContextModal"
|
|
6
|
-
|
|
7
7
|
const user = userEvent.setup()
|
|
8
8
|
|
|
9
9
|
const ContextModalWrapper = ({
|
|
@@ -29,8 +29,8 @@ describe("<ContextModal />", () => {
|
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
it("supports a dismiss action when dismiss button is pressed", async () => {
|
|
32
|
-
const handleConfirm =
|
|
33
|
-
const handleDismiss =
|
|
32
|
+
const handleConfirm = vi.fn()
|
|
33
|
+
const handleDismiss = vi.fn()
|
|
34
34
|
const { getByLabelText } = render(
|
|
35
35
|
<ContextModalWrapper onConfirm={handleConfirm} onDismiss={handleDismiss}>
|
|
36
36
|
Example modal body
|
|
@@ -44,8 +44,8 @@ describe("<ContextModal />", () => {
|
|
|
44
44
|
})
|
|
45
45
|
|
|
46
46
|
it("supports a confirm action when confirm button is pressed", async () => {
|
|
47
|
-
const handleConfirm =
|
|
48
|
-
const handleDismiss =
|
|
47
|
+
const handleConfirm = vi.fn()
|
|
48
|
+
const handleDismiss = vi.fn()
|
|
49
49
|
const { getByText } = render(
|
|
50
50
|
<ContextModalWrapper onDismiss={handleDismiss} onConfirm={handleConfirm}>
|
|
51
51
|
Example modal body
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { render, screen, waitFor } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
+
import { vi } from "vitest"
|
|
4
5
|
import { GenericModal, GenericModalProps } from "./GenericModal"
|
|
5
6
|
import { ModalAccessibleLabel } from "./subcomponents/ModalAccessibleLabel"
|
|
6
7
|
import { ModalBody } from "./subcomponents/ModalBody"
|
|
7
8
|
import { ModalHeader } from "./subcomponents/ModalHeader"
|
|
8
|
-
|
|
9
9
|
const user = userEvent.setup()
|
|
10
10
|
|
|
11
11
|
const GenericModalWrapper = ({
|
|
@@ -50,7 +50,7 @@ describe("<GenericModal />", () => {
|
|
|
50
50
|
})
|
|
51
51
|
|
|
52
52
|
it("closes the modal when escape key is pressed", async () => {
|
|
53
|
-
const handleDismiss =
|
|
53
|
+
const handleDismiss = vi.fn()
|
|
54
54
|
|
|
55
55
|
render(<GenericModalWrapper onEscapeKeyup={handleDismiss} />)
|
|
56
56
|
|
|
@@ -70,7 +70,7 @@ describe("<GenericModal />", () => {
|
|
|
70
70
|
})
|
|
71
71
|
|
|
72
72
|
it("closes the modal when a click is outside of the modal content", async () => {
|
|
73
|
-
const handleDismiss =
|
|
73
|
+
const handleDismiss = vi.fn()
|
|
74
74
|
render(<GenericModalWrapper onOutsideModalClick={handleDismiss} />)
|
|
75
75
|
|
|
76
76
|
await user.click(screen.getByTestId("GenericModalTestId-scrollLayer"))
|
|
@@ -80,7 +80,7 @@ describe("<GenericModal />", () => {
|
|
|
80
80
|
})
|
|
81
81
|
|
|
82
82
|
it("calls onAfterLeave after it closes", async () => {
|
|
83
|
-
const mockOnAfterLeave =
|
|
83
|
+
const mockOnAfterLeave = vi.fn()
|
|
84
84
|
render(<GenericModalWrapper onAfterLeave={mockOnAfterLeave} />)
|
|
85
85
|
|
|
86
86
|
await user.click(screen.getByTestId("GenericModalTestId-scrollLayer"))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { render, waitFor } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
+
import { vi } from "vitest"
|
|
4
5
|
import { mockMatchMedia } from "~components/utils/useMediaQueries.spec"
|
|
5
6
|
import { InputEditModal, InputEditModalProps } from "./InputEditModal"
|
|
6
|
-
|
|
7
7
|
const user = userEvent.setup()
|
|
8
8
|
|
|
9
9
|
const InputEditModalWrapper = ({
|
|
@@ -28,8 +28,8 @@ describe("<InputEditModal />", () => {
|
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
it("supports a dismiss action when dismiss button is pressed", async () => {
|
|
31
|
-
const handleSubmit =
|
|
32
|
-
const handleDismiss =
|
|
31
|
+
const handleSubmit = vi.fn()
|
|
32
|
+
const handleDismiss = vi.fn()
|
|
33
33
|
const { getByLabelText } = render(
|
|
34
34
|
<InputEditModalWrapper onSubmit={handleSubmit} onDismiss={handleDismiss}>
|
|
35
35
|
Example modal body
|
|
@@ -43,8 +43,8 @@ describe("<InputEditModal />", () => {
|
|
|
43
43
|
})
|
|
44
44
|
|
|
45
45
|
it("supports a dismiss action when cancel button is pressed", async () => {
|
|
46
|
-
const handleSubmit =
|
|
47
|
-
const handleDismiss =
|
|
46
|
+
const handleSubmit = vi.fn()
|
|
47
|
+
const handleDismiss = vi.fn()
|
|
48
48
|
const { getByText } = render(
|
|
49
49
|
<InputEditModalWrapper onDismiss={handleDismiss} onSubmit={handleSubmit}>
|
|
50
50
|
Example modal body
|
|
@@ -58,8 +58,8 @@ describe("<InputEditModal />", () => {
|
|
|
58
58
|
})
|
|
59
59
|
|
|
60
60
|
it("supports a Submit action when Submit button is pressed", async () => {
|
|
61
|
-
const handleSubmit =
|
|
62
|
-
const handleDismiss =
|
|
61
|
+
const handleSubmit = vi.fn()
|
|
62
|
+
const handleDismiss = vi.fn()
|
|
63
63
|
const { getByText } = render(
|
|
64
64
|
<InputEditModalWrapper onDismiss={handleDismiss} onSubmit={handleSubmit}>
|
|
65
65
|
Example modal body
|
package/src/MultiSelect/subcomponents/MultiSelectOptionField/MultiSelectOptionField.spec.tsx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React, { useState } from "react"
|
|
2
2
|
import { render, waitFor } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
+
import { vi } from "vitest"
|
|
4
5
|
import { CheckboxProps } from "../Checkbox"
|
|
5
6
|
import {
|
|
6
7
|
MultiSelectOptionField,
|
|
7
8
|
MultiSelectOptionFieldProps,
|
|
8
9
|
} from "./MultiSelectOptionField"
|
|
9
|
-
|
|
10
10
|
const user = userEvent.setup()
|
|
11
11
|
|
|
12
|
-
const onChange =
|
|
12
|
+
const onChange = vi.fn()
|
|
13
13
|
|
|
14
14
|
const MultiSelectOptionFieldWrapper = (
|
|
15
15
|
customProps?: Partial<MultiSelectOptionFieldProps>
|
|
@@ -42,7 +42,7 @@ const MultiSelectOptionFieldWrapper = (
|
|
|
42
42
|
|
|
43
43
|
describe("<MultiSelectOptionField />", () => {
|
|
44
44
|
afterEach(() => {
|
|
45
|
-
|
|
45
|
+
vi.clearAllMocks()
|
|
46
46
|
})
|
|
47
47
|
|
|
48
48
|
it("has an accessible name", () => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React, { useState } from "react"
|
|
2
2
|
import { render, waitFor } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
+
import { vi } from "vitest"
|
|
4
5
|
import {
|
|
5
6
|
MultiSelectOptions,
|
|
6
7
|
MultiSelectOptionsProps,
|
|
7
8
|
} from "./MultiSelectOptions"
|
|
8
|
-
|
|
9
9
|
const user = userEvent.setup()
|
|
10
10
|
|
|
11
|
-
const onChange =
|
|
11
|
+
const onChange = vi.fn()
|
|
12
12
|
const testOptions = [
|
|
13
13
|
{
|
|
14
14
|
label: "Pancakes",
|
|
@@ -46,7 +46,7 @@ const MultiSelectOptionsWrapper = (
|
|
|
46
46
|
|
|
47
47
|
describe("<MultiSelectOptions />", () => {
|
|
48
48
|
afterEach(() => {
|
|
49
|
-
|
|
49
|
+
vi.clearAllMocks()
|
|
50
50
|
})
|
|
51
51
|
|
|
52
52
|
it("contains the number of options available in the accessible description", () => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { render, waitFor } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
+
import { vi } from "vitest"
|
|
4
5
|
import { MultiSelectToggle, MultiSelectToggleProps } from "./MultiSelectToggle"
|
|
5
|
-
|
|
6
6
|
const user = userEvent.setup()
|
|
7
7
|
|
|
8
|
-
const onClick =
|
|
8
|
+
const onClick = vi.fn()
|
|
9
9
|
|
|
10
10
|
const MultiSelectToggleWrapper = (
|
|
11
11
|
customProps?: Partial<MultiSelectToggleProps>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { useState } from "react"
|
|
2
|
+
import { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import { userEvent, within, expect, waitFor } from "@storybook/test"
|
|
4
|
+
import { GenericNotification } from "./index"
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Components/Notifications/GenericNotification",
|
|
8
|
+
component: GenericNotification,
|
|
9
|
+
args: {
|
|
10
|
+
variant: "success",
|
|
11
|
+
style: "inline",
|
|
12
|
+
title: "Success",
|
|
13
|
+
children: "This is my positive notification",
|
|
14
|
+
},
|
|
15
|
+
} satisfies Meta<typeof GenericNotification>
|
|
16
|
+
|
|
17
|
+
export default meta
|
|
18
|
+
|
|
19
|
+
type Story = StoryObj<typeof meta>
|
|
20
|
+
|
|
21
|
+
export const GenericNotificationTest: Story = {
|
|
22
|
+
render: () => {
|
|
23
|
+
const [isHidden, setIsHidden] = useState<boolean>(false)
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div>
|
|
27
|
+
<span data-testid="hidden-state">{isHidden ? "Hidden" : "Shown"}</span>
|
|
28
|
+
<GenericNotification
|
|
29
|
+
variant="success"
|
|
30
|
+
style="inline"
|
|
31
|
+
title="Success"
|
|
32
|
+
data-testid="generic-notification"
|
|
33
|
+
onHide={() => setIsHidden(true)}
|
|
34
|
+
>
|
|
35
|
+
This is my positive notification
|
|
36
|
+
</GenericNotification>
|
|
37
|
+
</div>
|
|
38
|
+
)
|
|
39
|
+
},
|
|
40
|
+
name: "Test: Closes when close button is clicked and onHide is called",
|
|
41
|
+
play: async ({ canvasElement }) => {
|
|
42
|
+
const canvas = within(canvasElement)
|
|
43
|
+
const element = canvas.getByTestId("generic-notification")
|
|
44
|
+
const hiddenState = canvas.getByTestId("hidden-state")
|
|
45
|
+
|
|
46
|
+
await waitFor(() => {
|
|
47
|
+
expect(element).toBeInTheDocument()
|
|
48
|
+
expect(hiddenState).toHaveTextContent("Shown")
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
await userEvent.click(canvas.getByTestId("close-button"))
|
|
52
|
+
|
|
53
|
+
await waitFor(() => {
|
|
54
|
+
setTimeout(() => {
|
|
55
|
+
expect(hiddenState).toHaveTextContent("Hidden")
|
|
56
|
+
expect(element).not.toBeInTheDocument()
|
|
57
|
+
}, 1000)
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
}
|
|
@@ -11,12 +11,12 @@ const defaultProps = {
|
|
|
11
11
|
ariaLabelNextPage: "Next page",
|
|
12
12
|
ariaLabelPreviousPage: "Previous page",
|
|
13
13
|
ariaLabelPage: "Page",
|
|
14
|
-
onPageChange:
|
|
14
|
+
onPageChange: vi.fn(),
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
describe("<Pagination />", () => {
|
|
18
18
|
it("calls onPageChange when clicking page number", async () => {
|
|
19
|
-
const onPageChange =
|
|
19
|
+
const onPageChange = vi.fn()
|
|
20
20
|
|
|
21
21
|
render(<Pagination {...defaultProps} onPageChange={onPageChange} />)
|
|
22
22
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { render } from "@testing-library/react"
|
|
3
|
+
import { vi } from "vitest"
|
|
3
4
|
import { RichTextContentProps } from "../RichTextContent"
|
|
4
5
|
import { EditableRichTextContent } from "./EditableRichTextContent"
|
|
6
|
+
const mockFn = vi.fn()
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
jest.mock("../RichTextContent", () => ({
|
|
8
|
+
vi.mock("../RichTextContent", () => ({
|
|
9
9
|
__esModule: true,
|
|
10
10
|
RichTextContent: (props: RichTextContentProps): JSX.Element => {
|
|
11
11
|
mockFn(props)
|
|
@@ -26,7 +26,7 @@ describe("Content props are passed", () => {
|
|
|
26
26
|
<EditableRichTextContent
|
|
27
27
|
content={content}
|
|
28
28
|
labelText=""
|
|
29
|
-
onClick={
|
|
29
|
+
onClick={vi.fn()}
|
|
30
30
|
contentProps={{ id: "sampleId" }}
|
|
31
31
|
/>
|
|
32
32
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, HTMLAttributes } from "react"
|
|
1
|
+
import React, { useState, HTMLAttributes, useId, useEffect } from "react"
|
|
2
2
|
import classnames from "classnames"
|
|
3
3
|
import { OverrideClassName } from "~components/types/OverrideClassName"
|
|
4
4
|
import { createSchemaWithAll } from "../RichTextEditor/schema"
|
|
@@ -14,6 +14,13 @@ export type RichTextContentProps = {
|
|
|
14
14
|
export const RichTextContent = (props: RichTextContentProps): JSX.Element => {
|
|
15
15
|
const { content, classNameOverride, ...restProps } = props
|
|
16
16
|
const [schema] = useState<ProseMirrorModel.Schema>(createSchemaWithAll())
|
|
17
|
+
const editorId = useId()
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
// prosemirror only allows us to set this to false (which has caused a strange bug in the platform)
|
|
21
|
+
// so we have to hack a bit to remove the attribute completely
|
|
22
|
+
document.getElementById(editorId)?.removeAttribute("contenteditable")
|
|
23
|
+
}, [])
|
|
17
24
|
|
|
18
25
|
const [editorRef] = useRichTextEditor(
|
|
19
26
|
ProseMirrorState.EditorState.create({
|
|
@@ -23,7 +30,9 @@ export const RichTextContent = (props: RichTextContentProps): JSX.Element => {
|
|
|
23
30
|
}),
|
|
24
31
|
schema,
|
|
25
32
|
}),
|
|
26
|
-
|
|
33
|
+
{
|
|
34
|
+
id: editorId,
|
|
35
|
+
},
|
|
27
36
|
{
|
|
28
37
|
editable: false,
|
|
29
38
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { findByText, waitFor } from "@testing-library/dom"
|
|
2
|
+
import { vi } from "vitest"
|
|
2
3
|
import { createRichTextEditor } from "../core"
|
|
3
4
|
import { addMark } from "./addMark"
|
|
4
5
|
import {
|
|
@@ -7,9 +8,8 @@ import {
|
|
|
7
8
|
simulateTextInsert,
|
|
8
9
|
} from "./fixtures/helpers"
|
|
9
10
|
import { testEditorState, testSchema } from "./fixtures/test-state"
|
|
10
|
-
|
|
11
11
|
describe("addMark()", () => {
|
|
12
|
-
const onChange =
|
|
12
|
+
const onChange = vi.fn()
|
|
13
13
|
const attributes = { "aria-labelledby": "label-text-123" }
|
|
14
14
|
|
|
15
15
|
it("creates an empty wrapper of the given Mark type if no selection is provided", async () => {
|
|
@@ -5,14 +5,15 @@ import {
|
|
|
5
5
|
Transaction,
|
|
6
6
|
} from "prosemirror-state"
|
|
7
7
|
import { findChildrenByType } from "prosemirror-utils"
|
|
8
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
9
|
+
import { vi } from "vitest"
|
|
8
10
|
import { ProseMirrorModel } from "../../prosemirror"
|
|
9
|
-
|
|
10
11
|
/*
|
|
11
12
|
** This is used handle the JSDom type error issue you may encounter in testing
|
|
12
13
|
** See https://github.com/jsdom/jsdom/issues/3002
|
|
13
14
|
*/
|
|
14
15
|
export const mockRangeForBoundingRect = (): void => {
|
|
15
|
-
|
|
16
|
+
vi.spyOn(document, "createRange").mockImplementation(() => {
|
|
16
17
|
const range = new Range()
|
|
17
18
|
|
|
18
19
|
range.getBoundingClientRect = () => ({
|
|
@@ -30,7 +31,7 @@ export const mockRangeForBoundingRect = (): void => {
|
|
|
30
31
|
range.getClientRects = () => ({
|
|
31
32
|
item: () => null,
|
|
32
33
|
length: 0,
|
|
33
|
-
[Symbol.iterator]:
|
|
34
|
+
[Symbol.iterator]: vi.fn(),
|
|
34
35
|
})
|
|
35
36
|
|
|
36
37
|
return range
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { waitFor } from "@testing-library/dom"
|
|
2
2
|
import { EditorState } from "prosemirror-state"
|
|
3
|
+
import { vi } from "vitest"
|
|
3
4
|
import { createRichTextEditor } from "../core"
|
|
4
5
|
import { simulateSelectionByText } from "./fixtures/helpers"
|
|
5
6
|
import { testEditorStateWithMarks, testSchema } from "./fixtures/test-state"
|
|
6
7
|
import { getMarkAttrs } from "./getMarkAttrs"
|
|
7
|
-
|
|
8
8
|
describe("getMarkAttrs()", () => {
|
|
9
|
-
const onChange =
|
|
9
|
+
const onChange = vi.fn()
|
|
10
10
|
const attributes = { "aria-labelledby": "label-text-123" }
|
|
11
11
|
|
|
12
12
|
it("returns an empty object if the selected Mark has no attributes", async () => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { waitFor } from "@testing-library/dom"
|
|
2
2
|
import { EditorState } from "prosemirror-state"
|
|
3
|
+
import { vi } from "vitest"
|
|
3
4
|
import { createRichTextEditor } from "../core"
|
|
4
5
|
import { simulateSelectionByText } from "./fixtures/helpers"
|
|
5
6
|
import { testEditorStateWithMarks } from "./fixtures/test-state"
|
|
6
7
|
import { getMarkRange } from "./getMarkRange"
|
|
7
|
-
|
|
8
8
|
describe("getMarkRange()", () => {
|
|
9
|
-
const onChange =
|
|
9
|
+
const onChange = vi.fn()
|
|
10
10
|
const attributes = { "aria-labelledby": "label-text-123" }
|
|
11
11
|
|
|
12
12
|
it("returns the entire range of the Mark provided from a resolved position", async () => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { waitFor } from "@testing-library/dom"
|
|
2
2
|
import { EditorState } from "prosemirror-state"
|
|
3
|
+
import { vi } from "vitest"
|
|
3
4
|
import { createRichTextEditor } from "../core"
|
|
4
5
|
import { simulateSelectionByText } from "./fixtures/helpers"
|
|
5
6
|
import { testEditorStateWitList, testSchema } from "./fixtures/test-state"
|
|
6
7
|
import { listIsActive } from "./listIsActive"
|
|
7
|
-
|
|
8
8
|
describe("listIsActive()", () => {
|
|
9
|
-
const onChange =
|
|
9
|
+
const onChange = vi.fn()
|
|
10
10
|
const attributes = { "aria-labelledby": "label-text-123" }
|
|
11
11
|
const listNodes = [testSchema.nodes.bulletList, testSchema.nodes.orderedList]
|
|
12
12
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { waitFor } from "@testing-library/dom"
|
|
2
2
|
import { EditorState } from "prosemirror-state"
|
|
3
|
+
import { vi } from "vitest"
|
|
3
4
|
import { createRichTextEditor } from "../core"
|
|
4
5
|
import { simulateSelectionByText } from "./fixtures/helpers"
|
|
5
6
|
import { testEditorStateWithMarks, testSchema } from "./fixtures/test-state"
|
|
6
7
|
import { markContainsSelection } from "./markContainsSelection"
|
|
7
|
-
|
|
8
8
|
describe("markContainsSelection()", () => {
|
|
9
|
-
const onChange =
|
|
9
|
+
const onChange = vi.fn()
|
|
10
10
|
const attributes = { "aria-labelledby": "label-text-123" }
|
|
11
11
|
|
|
12
12
|
it("will return true if the current select contains the provided Mark", async () => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { waitFor } from "@testing-library/dom"
|
|
2
2
|
import { EditorState } from "prosemirror-state"
|
|
3
|
+
import { vi } from "vitest"
|
|
3
4
|
import { createRichTextEditor } from "../core"
|
|
4
5
|
import {
|
|
5
6
|
simulateRangeSelection,
|
|
@@ -7,9 +8,8 @@ import {
|
|
|
7
8
|
} from "./fixtures/helpers"
|
|
8
9
|
import { testEditorStateWithMarks, testSchema } from "./fixtures/test-state"
|
|
9
10
|
import { markIsActive } from "./markIsActive"
|
|
10
|
-
|
|
11
11
|
describe("markIsActive()", () => {
|
|
12
|
-
const onChange =
|
|
12
|
+
const onChange = vi.fn()
|
|
13
13
|
const attributes = { "aria-labelledby": "label-text-123" }
|
|
14
14
|
|
|
15
15
|
it("returns true if the provided Mark Type matches the current selection", async () => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { findByText, getByText, waitFor } from "@testing-library/dom"
|
|
2
|
+
import { vi } from "vitest"
|
|
2
3
|
import { createRichTextEditor } from "../core"
|
|
3
4
|
import { simulateSelectionByText } from "./fixtures/helpers"
|
|
4
5
|
import { testEditorStateWithMarks, testSchema } from "./fixtures/test-state"
|
|
5
6
|
import { removeMark } from "./removeMark"
|
|
6
|
-
|
|
7
7
|
describe("removeMark()", () => {
|
|
8
|
-
const onChange =
|
|
8
|
+
const onChange = vi.fn()
|
|
9
9
|
const attributes = { "aria-labelledby": "label-text-123" }
|
|
10
10
|
|
|
11
11
|
it("removes the given <strong> Mark from a paragraph in the document", async () => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getByRole, getByText, waitFor } from "@testing-library/dom"
|
|
2
|
+
import { vi } from "vitest"
|
|
2
3
|
import { createRichTextEditor } from "../core"
|
|
3
4
|
import { simulateSelectionByText } from "./fixtures/helpers"
|
|
4
5
|
import { testEditorStateWithMarks, testSchema } from "./fixtures/test-state"
|
|
5
6
|
import { updateMark } from "./updateMark"
|
|
6
|
-
|
|
7
7
|
describe("updateMark()", () => {
|
|
8
|
-
const onChange =
|
|
8
|
+
const onChange = vi.fn()
|
|
9
9
|
const attributes = { "aria-labelledby": "label-text-123" }
|
|
10
10
|
|
|
11
11
|
it("can update existing Mark with a nested Mark", async () => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { findByText, waitFor } from "@testing-library/dom"
|
|
2
|
+
import { vi } from "vitest"
|
|
2
3
|
import { createRichTextEditor } from "../core"
|
|
3
4
|
import { testEditorStateWithMarks, testSchema } from "./fixtures/test-state"
|
|
4
5
|
import { validateAndRemoveMarks } from "./validateAndRemoveMarks"
|
|
5
|
-
|
|
6
6
|
describe("validateAndRemoveMarks()", () => {
|
|
7
|
-
const onChange =
|
|
7
|
+
const onChange = vi.fn()
|
|
8
8
|
const attributes = { "aria-labelledby": "label-text-123" }
|
|
9
9
|
|
|
10
10
|
it("removes all Marks of the given type that fail the validator method", async () => {
|
|
@@ -16,7 +16,7 @@ describe("validateAndRemoveMarks()", () => {
|
|
|
16
16
|
initialEditorState: testEditorStateWithMarks,
|
|
17
17
|
})
|
|
18
18
|
// The current mockData will always return true so using the mock to represent bad attributes
|
|
19
|
-
const failingValidatorMethod =
|
|
19
|
+
const failingValidatorMethod = vi.fn().mockImplementation(() => false)
|
|
20
20
|
|
|
21
21
|
expect(node.querySelectorAll("a").length).toBeGreaterThan(0)
|
|
22
22
|
|