@kaizen/components 1.61.0 → 1.61.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/codemods/utils/__snapshots__/transformSource.spec.ts.snap +2 -2
  2. package/dist/cjs/RichTextEditor/RichTextContent/RichTextContent.cjs +10 -1
  3. package/dist/esm/RichTextEditor/RichTextContent/RichTextContent.mjs +11 -2
  4. package/dist/styles.css +115 -114
  5. package/package.json +5 -4
  6. package/src/Avatar/Avatar.spec.tsx +1 -1
  7. package/src/Calendar/utils/setFocusInCalendar.spec.tsx +2 -2
  8. package/src/Checkbox/Checkbox/Checkbox.spec.tsx +2 -2
  9. package/src/Collapsible/Collapsible/Collapsible.spec.tsx +2 -14
  10. package/src/Collapsible/Collapsible/_docs/Collapsible.stickersheet.stories.tsx +49 -0
  11. package/src/Collapsible/Collapsible/_docs/Collapsible.stories.tsx +0 -11
  12. package/src/DateInput/DateInputDescription/DateInputDescription.spec.tsx +5 -6
  13. package/src/DateInput/DateInputWithIconButton/DateInputWithIconButton.spec.tsx +4 -6
  14. package/src/DatePicker/DatePicker.spec.tsx +32 -36
  15. package/src/DatePicker/subcomponents/DateInputField/DateInputField.spec.tsx +13 -13
  16. package/src/DatePicker/utils/validateDate.spec.ts +5 -6
  17. package/src/EmptyState/EmptyState.spec.tsx +1 -1
  18. package/src/ErrorPage/ErrorPage.spec.tsx +19 -19
  19. package/src/Filter/FilterBar/FilterBar.spec.tsx +26 -26
  20. package/src/Filter/FilterBar/context/utils/updateDependentFilters.spec.ts +2 -4
  21. package/src/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.spec.tsx +3 -4
  22. package/src/Filter/FilterBar/subcomponents/FilterBarButton/FilterBarButton.spec.tsx +3 -6
  23. package/src/Filter/FilterBar/subcomponents/FilterBarDatePicker/FilterBarDatePicker.spec.tsx +10 -12
  24. package/src/Filter/FilterBar/subcomponents/FilterBarDateRangePicker/FilterBarDateRangePicker.spec.tsx +9 -10
  25. package/src/Filter/FilterBar/subcomponents/FilterBarMultiSelect/FilterBarMultiSelect.spec.tsx +12 -14
  26. package/src/Filter/FilterBar/subcomponents/FilterBarSelect/FilterBarSelect.spec.tsx +11 -13
  27. package/src/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.spec.tsx +5 -5
  28. package/src/Filter/FilterDatePicker/FilterDatePicker.spec.tsx +12 -15
  29. package/src/Filter/FilterDatePicker/hooks/useDateInputHandlers.spec.ts +12 -15
  30. package/src/Filter/FilterDatePicker/hooks/useDateValidation.spec.ts +3 -5
  31. package/src/Filter/FilterDatePicker/subcomponents/FilterDatePickerField/FilterDatePickerField.spec.tsx +23 -28
  32. package/src/Filter/FilterDatePicker/utils/getDateValidationHandler.spec.tsx +2 -6
  33. package/src/Filter/FilterDatePicker/utils/validateDate.spec.ts +5 -6
  34. package/src/Filter/FilterDateRangePicker/FilterDateRangePicker.spec.tsx +2 -3
  35. package/src/Filter/FilterDateRangePicker/_docs/FilterDateRangePicker.stickersheet.stories.tsx +27 -0
  36. package/src/Filter/FilterDateRangePicker/subcomponents/DateRangeInputField/DateRangeInputField.spec.tsx +9 -11
  37. package/src/Filter/FilterDateRangePicker/subcomponents/DateRangeValidationMessage/DateRangeValidationMessage.spec.tsx +1 -63
  38. package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/FilterDateRangePickerField.spec.tsx +32 -32
  39. package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/useEndDateValidation.spec.ts +3 -8
  40. package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/useStartDateValidation.spec.ts +2 -5
  41. package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/utils/validateEndDateBeforeStartDate.spec.ts +2 -3
  42. package/src/Filter/FilterMultiSelect/FilterMultiSelect.spec.tsx +9 -10
  43. package/src/Filter/FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.spec.tsx +2 -1
  44. package/src/Filter/FilterMultiSelect/context/SelectionProvider/SelectionProvider.spec.tsx +32 -32
  45. package/src/Filter/FilterMultiSelect/subcomponents/MultiSelectOption/MultiSelectOption.spec.tsx +9 -7
  46. package/src/Filter/FilterMultiSelect/subcomponents/SearchInput/SearchInput.spec.tsx +12 -12
  47. package/src/Filter/FilterMultiSelect/subcomponents/SelectionControlButton/ClearButton/ClearButton.spec.tsx +7 -7
  48. package/src/Filter/FilterMultiSelect/subcomponents/SelectionControlButton/SelectAllButton/SelectAllButton.spec.tsx +9 -9
  49. package/src/Filter/FilterSelect/FilterSelect.spec.tsx +2 -2
  50. package/src/Heading/Heading.spec.tsx +1 -31
  51. package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.spec.tsx +43 -97
  52. package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.stickersheet.stories.tsx +68 -0
  53. package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.stories.tsx +37 -0
  54. package/src/Input/InputRange/InputRange.spec.tsx +2 -2
  55. package/src/Input/InputSearch/InputSearch.spec.tsx +3 -5
  56. package/src/KaizenProvider/KaizenProvider.spec.tsx +2 -2
  57. package/src/KaizenProvider/subcomponents/OptionalIntlProvider/OptionalIntlProvider.spec.tsx +2 -3
  58. package/src/Modal/ConfirmationModal/ConfirmationModal.spec.tsx +7 -7
  59. package/src/Modal/ContextModal/ContextModal.spec.tsx +5 -5
  60. package/src/Modal/GenericModal/GenericModal.spec.tsx +4 -4
  61. package/src/Modal/InputEditModal/InputEditModal.spec.tsx +7 -7
  62. package/src/MultiSelect/subcomponents/MultiSelectOptionField/MultiSelectOptionField.spec.tsx +3 -3
  63. package/src/MultiSelect/subcomponents/MultiSelectOptions/MultiSelectOptions.spec.tsx +3 -3
  64. package/src/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.spec.tsx +2 -2
  65. package/src/Notification/subcomponents/GenericNotification/GenericNotification.stories.tsx +60 -0
  66. package/src/Pagination/Pagination.spec.tsx +2 -2
  67. package/src/RichTextEditor/EditableRichTextContent/EditableRichTextContent.spec.tsx +4 -4
  68. package/src/RichTextEditor/RichTextContent/RichTextContent.tsx +11 -2
  69. package/src/RichTextEditor/utils/commands/addMark.spec.ts +2 -2
  70. package/src/RichTextEditor/utils/commands/fixtures/helpers.ts +4 -3
  71. package/src/RichTextEditor/utils/commands/getMarkAttrs.spec.ts +2 -2
  72. package/src/RichTextEditor/utils/commands/getMarkRange.spec.ts +2 -2
  73. package/src/RichTextEditor/utils/commands/listIsActive.spec.ts +2 -2
  74. package/src/RichTextEditor/utils/commands/markContainsSelection.spec.ts +2 -2
  75. package/src/RichTextEditor/utils/commands/markIsActive.spec.ts +2 -2
  76. package/src/RichTextEditor/utils/commands/removeMark.spec.ts +2 -2
  77. package/src/RichTextEditor/utils/commands/updateMark.spec.ts +2 -2
  78. package/src/RichTextEditor/utils/commands/validateAndRemoveMarks.spec.ts +3 -3
  79. package/src/RichTextEditor/utils/core/createRichTextEditor.spec.ts +11 -11
  80. package/src/RichTextEditor/utils/core/hooks/useRichTextEditor.spec.tsx +2 -2
  81. package/src/SplitButton/SplitButton.spec.tsx +5 -5
  82. package/src/SplitButton/subcomponents/DropdownButton/DropdownButton.spec.tsx +3 -4
  83. package/src/Text/Text.spec.tsx +1 -57
  84. package/src/TextArea/TextArea.spec.tsx +2 -2
  85. package/src/TimeField/TimeField.spec.tsx +2 -2
  86. package/src/TitleBlockZen/TitleBlockZen.spec.tsx +36 -68
  87. package/src/TitleBlockZen/_docs/TitleBlockZen.stories.tsx +78 -8
  88. package/src/TitleBlockZen/subcomponents/MobileActions.spec.tsx +2 -2
  89. package/src/TitleBlockZen/subcomponents/NavigationTabs.spec.tsx +8 -2
  90. package/src/ToggleSwitch/ToggleSwitch/ToggleSwitch.spec.tsx +2 -2
  91. package/src/__actions__/Menu/v1/Menu.spec.tsx +2 -2
  92. package/src/__containers__/GuidanceBlock/v1/GuidanceBlock.spec.tsx +5 -5
  93. package/src/__containers__/GuidanceBlock/v2/GuidanceBlock.spec.tsx +5 -5
  94. package/src/__future__/Select/Select.spec.tsx +4 -4
  95. package/src/__layout__/Workflow/v3/_docs/Workflow.stories.tsx +8 -2
  96. package/src/__layout__/Workflow/v3/subcomponents/Footer/components/Root/FooterRoot.module.css +1 -0
  97. package/src/__layout__/Workflow/v3/subcomponents/Header/components/Root/Root.module.css +1 -1
  98. package/src/__overlays__/Tooltip/v1/Tooltip.spec.tsx +1 -1
  99. package/src/__overlays__/Tooltip/v1/utils/isSemanticElement.spec.tsx +4 -9
  100. package/src/utils/useMediaQueries.spec.tsx +7 -7
  101. package/src/Heading/__snapshots__/Heading.spec.tsx.snap +0 -85
  102. package/src/Illustration/utils/usePausePlay.spec.tsx +0 -85
  103. package/src/Notification/subcomponents/GenericNotification/GenericNotification.spec.tsx +0 -76
  104. package/src/Text/__snapshots__/Text.spec.tsx.snap +0 -49
  105. package/src/__overlays__/Tooltip/v1/subcomponents/AppearanceAnim.spec.tsx +0 -39
@@ -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 = jest.fn()
32
- const handleDismiss = jest.fn()
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 = jest.fn()
50
- const handleDismiss = jest.fn()
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 = jest.fn()
68
- const handleDismiss = jest.fn()
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 = jest.fn()
33
- const handleDismiss = jest.fn()
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 = jest.fn()
48
- const handleDismiss = jest.fn()
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 = jest.fn()
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 = jest.fn()
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 = jest.fn()
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 = jest.fn()
32
- const handleDismiss = jest.fn()
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 = jest.fn()
47
- const handleDismiss = jest.fn()
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 = jest.fn()
62
- const handleDismiss = jest.fn()
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
@@ -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 = jest.fn()
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
- jest.clearAllMocks()
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 = jest.fn()
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
- jest.clearAllMocks()
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 = jest.fn()
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: jest.fn<void, [number]>(),
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 = jest.fn<void, [number]>()
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
- const mockFn = jest.fn()
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={jest.fn()}
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
- undefined,
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 = jest.fn()
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
- jest.spyOn(document, "createRange").mockImplementation(() => {
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]: jest.fn(),
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 = jest.fn()
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 = jest.fn()
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 = jest.fn()
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 = jest.fn()
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 = jest.fn()
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 = jest.fn()
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 = jest.fn()
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 = jest.fn()
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 = jest.fn().mockImplementation(() => false)
19
+ const failingValidatorMethod = vi.fn().mockImplementation(() => false)
20
20
 
21
21
  expect(node.querySelectorAll("a").length).toBeGreaterThan(0)
22
22
 
@@ -1,14 +1,14 @@
1
1
  import { findByText, queryByText, getByText } from "@testing-library/dom"
2
2
  import { Command, EditorState } from "prosemirror-state"
3
+ import { vi } from "vitest"
3
4
  import { createRichTextEditor } from "./createRichTextEditor"
4
5
  import { testEditorState } from "./fixtures/testState"
5
-
6
6
  describe("createRichTextEditor()", () => {
7
7
  const attributes = { "aria-labelledby": "label-text-123" }
8
8
 
9
9
  it("initializes an editor with the correct content", async () => {
10
10
  const node = document.createElement("div")
11
- const onChange = jest.fn()
11
+ const onChange = vi.fn()
12
12
 
13
13
  createRichTextEditor({
14
14
  node,
@@ -23,7 +23,7 @@ describe("createRichTextEditor()", () => {
23
23
 
24
24
  it("returns the expected API shape", async () => {
25
25
  const node = document.createElement("div")
26
- const onChange = jest.fn()
26
+ const onChange = vi.fn()
27
27
 
28
28
  const returnValue = createRichTextEditor({
29
29
  node,
@@ -39,7 +39,7 @@ describe("createRichTextEditor()", () => {
39
39
 
40
40
  it("destroys the instance", async () => {
41
41
  const node = document.createElement("div")
42
- const onChange = jest.fn()
42
+ const onChange = vi.fn()
43
43
 
44
44
  const { destroy } = createRichTextEditor({
45
45
  node,
@@ -58,7 +58,7 @@ describe("createRichTextEditor()", () => {
58
58
 
59
59
  it("updates the DOM when commands are dispatched", async () => {
60
60
  const node = document.createElement("div")
61
- const onChange = jest.fn()
61
+ const onChange = vi.fn()
62
62
 
63
63
  const command: Command = (state, dispatch) => {
64
64
  // Insert text at the current selection point, which is the start because
@@ -87,7 +87,7 @@ describe("createRichTextEditor()", () => {
87
87
 
88
88
  it("calls onChange when the editor state changes", async () => {
89
89
  const node = document.createElement("div")
90
- const onChange = jest.fn()
90
+ const onChange = vi.fn()
91
91
  const command: Command = (state, dispatch) => {
92
92
  if (!dispatch) return false
93
93
  dispatch(state.tr.insertText("Prepended content. "))
@@ -110,7 +110,7 @@ describe("createRichTextEditor()", () => {
110
110
 
111
111
  it("calls onChange with the updated state", async () => {
112
112
  const node = document.createElement("div")
113
- const onChange = jest.fn()
113
+ const onChange = vi.fn()
114
114
  const command: Command = (state, dispatch) => {
115
115
  if (!dispatch) return false
116
116
  dispatch(state.tr.insertText("Prepended content. "))
@@ -155,7 +155,7 @@ describe("createRichTextEditor()", () => {
155
155
 
156
156
  it("defaults to editable", async () => {
157
157
  const node = document.createElement("div")
158
- const onChange = jest.fn()
158
+ const onChange = vi.fn()
159
159
 
160
160
  createRichTextEditor({
161
161
  node,
@@ -169,7 +169,7 @@ describe("createRichTextEditor()", () => {
169
169
 
170
170
  it("respects initial isEditable value", async () => {
171
171
  const node = document.createElement("div")
172
- const onChange = jest.fn()
172
+ const onChange = vi.fn()
173
173
 
174
174
  createRichTextEditor({
175
175
  node,
@@ -185,7 +185,7 @@ describe("createRichTextEditor()", () => {
185
185
  it("updates editable status", async () => {
186
186
  let editable = true
187
187
  const node = document.createElement("div")
188
- const onChange = jest.fn()
188
+ const onChange = vi.fn()
189
189
  const noopCommand: Command = (state, dispatch) => {
190
190
  if (!dispatch) return false
191
191
  dispatch(state.tr)
@@ -211,7 +211,7 @@ describe("createRichTextEditor()", () => {
211
211
  it("aria-labelledby is present", async () => {
212
212
  const editable = true
213
213
  const node = document.createElement("div")
214
- const onChange = jest.fn()
214
+ const onChange = vi.fn()
215
215
  const noopCommand: Command = (state, dispatch) => {
216
216
  if (!dispatch) return false
217
217
  dispatch(state.tr)
@@ -2,9 +2,9 @@ import React, { useEffect } from "react"
2
2
  import { render, screen, waitFor } from "@testing-library/react"
3
3
  import userEvent from "@testing-library/user-event"
4
4
  import { Command, EditorState } from "prosemirror-state"
5
+ import { vi } from "vitest"
5
6
  import { testEditorState } from "../fixtures/testState"
6
7
  import { useRichTextEditor } from "./useRichTextEditor"
7
-
8
8
  const user = userEvent.setup()
9
9
 
10
10
  const Scenario = ({
@@ -76,7 +76,7 @@ describe("useRichTextEditor()", () => {
76
76
  })
77
77
 
78
78
  it("updates the editorState when commands are dispatched", async () => {
79
- const onChange = jest.fn()
79
+ const onChange = vi.fn()
80
80
  render(<Scenario onChange={onChange} />)
81
81
 
82
82
  await waitFor(() => {