@kaizen/components 1.61.1 → 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 (102) 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 +220 -220
  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/__overlays__/Tooltip/v1/Tooltip.spec.tsx +1 -1
  96. package/src/__overlays__/Tooltip/v1/utils/isSemanticElement.spec.tsx +4 -9
  97. package/src/utils/useMediaQueries.spec.tsx +7 -7
  98. package/src/Heading/__snapshots__/Heading.spec.tsx.snap +0 -85
  99. package/src/Illustration/utils/usePausePlay.spec.tsx +0 -85
  100. package/src/Notification/subcomponents/GenericNotification/GenericNotification.spec.tsx +0 -76
  101. package/src/Text/__snapshots__/Text.spec.tsx.snap +0 -49
  102. package/src/__overlays__/Tooltip/v1/subcomponents/AppearanceAnim.spec.tsx +0 -39
@@ -1,15 +1,15 @@
1
1
  import React from "react"
2
2
  import { render, screen } from "@testing-library/react"
3
- import userEvent from "@testing-library/user-event"
3
+ import { vi } from "vitest"
4
4
  import { VideoPlayer } from "./VideoPlayer"
5
5
 
6
6
  const matchMedia = {
7
7
  media: "",
8
8
  onchange: null,
9
- addListener: jest.fn(),
10
- removeListener: jest.fn(),
11
- addEventListener: jest.fn(),
12
- removeEventListener: jest.fn(),
9
+ addListener: vi.fn(),
10
+ removeListener: vi.fn(),
11
+ addEventListener: vi.fn(),
12
+ removeEventListener: vi.fn(),
13
13
  }
14
14
  const mockPrefersReducedMotion = {
15
15
  matches: true,
@@ -19,35 +19,36 @@ const mockDoesNotPreferReducedMotion = {
19
19
  matches: false,
20
20
  ...matchMedia,
21
21
  }
22
- const mockPlay = jest.fn().mockResolvedValue(undefined)
23
- const mockLoad = jest.fn()
24
- const mockPause = jest.fn()
22
+ const mockPlay = vi.fn().mockResolvedValue(undefined)
23
+ const mockLoad = vi.fn()
24
+ const mockPause = vi.fn()
25
25
 
26
26
  describe("<VideoPlayer />", () => {
27
27
  beforeEach(() => {
28
28
  window.HTMLMediaElement.prototype.load = mockLoad
29
29
  window.HTMLMediaElement.prototype.play = mockPlay
30
30
  window.HTMLMediaElement.prototype.pause = mockPause
31
- window.matchMedia = jest
31
+ window.matchMedia = vi
32
32
  .fn()
33
33
  .mockImplementation(() => mockDoesNotPreferReducedMotion)
34
34
  // this will stop throwing the unstable_flushDiscreteUpdates console error cause by react bug
35
35
  // https://stackoverflow.com/a/65338472/18285270
36
36
  Object.defineProperty(HTMLMediaElement.prototype, "muted", {
37
- set: jest.fn(),
37
+ set: vi.fn(),
38
38
  })
39
39
  })
40
40
 
41
41
  afterEach(() => {
42
- jest.clearAllMocks()
42
+ vi.clearAllMocks()
43
43
  })
44
44
 
45
- it("renders a video player in the document and autoplay", async () => {
45
+ it("renders a video player in the document and autoplay", () => {
46
46
  render(
47
47
  <VideoPlayer
48
48
  autoplay
49
49
  fallback="illustrations/heart/spot/moods-cautionary.svg"
50
50
  source="illustrations/heart/spot/moods-cautionary.webm"
51
+ data-testid="kz-video-player"
51
52
  />
52
53
  )
53
54
  const videoPlayer = screen.getByTestId("kz-video-player")
@@ -55,92 +56,37 @@ describe("<VideoPlayer />", () => {
55
56
  expect(mockPlay).toHaveBeenCalled()
56
57
  })
57
58
 
58
- describe("use-reduced-motion", () => {
59
- it("respects the use-reduced-motion preferences of the user", () => {
60
- window.matchMedia = jest
61
- .fn()
62
- .mockImplementation(() => mockPrefersReducedMotion)
63
- render(
64
- <VideoPlayer
65
- autoplay
66
- fallback="illustrations/heart/spot/moods-cautionary.svg"
67
- source="illustrations/heart/spot/moods-cautionary.webm"
68
- />
69
- )
70
- const videoPlayer = screen.getByTestId("kz-video-player")
71
- expect(videoPlayer).not.toHaveAttribute("autoplay")
72
- expect(mockPause).toHaveBeenCalled()
73
- })
74
-
75
- it("defaults to autoplay when user does not set use-reduced-motion preferences", () => {
76
- window.matchMedia = jest
77
- .fn()
78
- .mockImplementation(() => mockDoesNotPreferReducedMotion)
79
- render(
80
- <VideoPlayer
81
- autoplay
82
- fallback="illustrations/heart/spot/moods-cautionary.svg"
83
- source="illustrations/heart/spot/moods-cautionary.webm"
84
- />
85
- )
86
- const videoPlayer = screen.getByTestId("kz-video-player")
87
- expect(videoPlayer).toHaveAttribute("autoplay")
88
- expect(mockPlay).toHaveBeenCalled()
89
- })
90
- })
91
-
92
- describe("when the aspect ratio is set as a prop", () => {
93
- it("has aspect ratio class", () => {
94
- window.matchMedia = jest
95
- .fn()
96
- .mockImplementation(() => mockDoesNotPreferReducedMotion)
97
- const { container } = render(
98
- <VideoPlayer
99
- aspectRatio="landscape"
100
- autoplay
101
- fallback="illustrations/heart/spot/moods-cautionary.svg"
102
- source="illustrations/heart/spot/moods-cautionary.webm"
103
- />
104
- )
105
- expect(container.querySelector(".aspectRatioWrapper")).toBeTruthy()
106
- expect(container.querySelector(".landscape")).toBeTruthy()
107
- })
108
- })
109
-
110
- describe("when the aspect ratio is not set as a prop", () => {
111
- it("does not have aspect ratio class", () => {
112
- window.matchMedia = jest
113
- .fn()
114
- .mockImplementation(() => mockDoesNotPreferReducedMotion)
115
- const { container } = render(
116
- <VideoPlayer
117
- autoplay
118
- fallback="illustrations/heart/spot/moods-cautionary.svg"
119
- source="illustrations/heart/spot/moods-cautionary.webm"
120
- />
121
- )
122
- expect(container.querySelector(".aspectRatioWrapper")).toBeFalsy()
123
- expect(container.querySelector(".landscape")).toBeFalsy()
124
- })
59
+ it("respects the use-reduced-motion preferences of the user", () => {
60
+ window.matchMedia = vi
61
+ .fn()
62
+ .mockImplementation(() => mockPrefersReducedMotion)
63
+ render(
64
+ <VideoPlayer
65
+ autoplay
66
+ fallback="illustrations/heart/spot/moods-cautionary.svg"
67
+ source="illustrations/heart/spot/moods-cautionary.webm"
68
+ data-testid="kz-video-player"
69
+ />
70
+ )
71
+ const videoPlayer = screen.getByTestId("kz-video-player")
72
+ expect(videoPlayer).not.toHaveAttribute("autoplay")
73
+ expect(mockPause).toHaveBeenCalled()
125
74
  })
126
75
 
127
- describe("Pausing/Playing animations", () => {
128
- it("restarts the animation when pause button is clicked", () => {
129
- const { container, getByRole } = render(
130
- <VideoPlayer
131
- fallback="illustrations/heart/spot/moods-cautionary.svg"
132
- source="illustrations/heart/spot/moods-cautionary.webm"
133
- />
134
- )
135
-
136
- const videoElement = container.querySelector("video")!
137
-
138
- expect(videoElement.paused).toEqual(true)
139
-
140
- const button = getByRole("button")
141
- userEvent.click(button)
142
-
143
- expect(mockPlay).toHaveBeenCalled()
144
- })
76
+ it("defaults to autoplay when user does not set use-reduced-motion preferences", () => {
77
+ window.matchMedia = vi
78
+ .fn()
79
+ .mockImplementation(() => mockDoesNotPreferReducedMotion)
80
+ render(
81
+ <VideoPlayer
82
+ autoplay
83
+ fallback="illustrations/heart/spot/moods-cautionary.svg"
84
+ source="illustrations/heart/spot/moods-cautionary.webm"
85
+ data-testid="kz-video-player"
86
+ />
87
+ )
88
+ const videoPlayer = screen.getByTestId("kz-video-player")
89
+ expect(videoPlayer).toHaveAttribute("autoplay")
90
+ expect(mockPlay).toHaveBeenCalled()
145
91
  })
146
92
  })
@@ -0,0 +1,68 @@
1
+ import React from "react"
2
+ import { Meta } from "@storybook/react"
3
+ import {
4
+ StickerSheet,
5
+ StickerSheetStory,
6
+ } from "~storybook/components/StickerSheet"
7
+ import { VideoPlayer } from "./index"
8
+
9
+ export default {
10
+ title: "Components/Illustrations/VideoPlayer",
11
+ parameters: {
12
+ controls: { disable: true },
13
+ chromatic: { disable: false },
14
+ },
15
+ } satisfies Meta
16
+
17
+ const StickerSheetTemplate: StickerSheetStory = {
18
+ render: ({ isReversed }) => (
19
+ <StickerSheet isReversed={isReversed} title="Aspect Ratio">
20
+ <StickerSheet.Body>
21
+ <StickerSheet.Row rowTitle="default">
22
+ <div className="border border-dashed border-grey-500">
23
+ <VideoPlayer
24
+ autoplay={false}
25
+ fallback="illustrations/heart/scene/brand-moments-positive-outro"
26
+ source="illustrations/heart/scene/brand-moments-positive-outro"
27
+ />
28
+ </div>
29
+ </StickerSheet.Row>
30
+ <StickerSheet.Row rowTitle="landscape">
31
+ <div className="border border-dashed border-grey-500">
32
+ <VideoPlayer
33
+ autoplay={false}
34
+ aspectRatio="landscape"
35
+ fallback="illustrations/heart/scene/brand-moments-positive-outro"
36
+ source="illustrations/heart/scene/brand-moments-positive-outro"
37
+ />
38
+ </div>
39
+ </StickerSheet.Row>
40
+ <StickerSheet.Row rowTitle="portrait">
41
+ <div className="border border-dashed border-grey-500">
42
+ <VideoPlayer
43
+ autoplay={false}
44
+ aspectRatio="portrait"
45
+ fallback="illustrations/heart/scene/brand-moments-positive-outro"
46
+ source="illustrations/heart/scene/brand-moments-positive-outro"
47
+ />
48
+ </div>
49
+ </StickerSheet.Row>
50
+ <StickerSheet.Row rowTitle="square">
51
+ <div className="border border-dashed border-grey-500">
52
+ <VideoPlayer
53
+ autoplay={false}
54
+ aspectRatio="square"
55
+ fallback="illustrations/heart/scene/brand-moments-positive-outro"
56
+ source="illustrations/heart/scene/brand-moments-positive-outro"
57
+ />
58
+ </div>
59
+ </StickerSheet.Row>
60
+ </StickerSheet.Body>
61
+ </StickerSheet>
62
+ ),
63
+ }
64
+
65
+ export const StickerSheetDefault: StickerSheetStory = {
66
+ ...StickerSheetTemplate,
67
+ name: "Sticker Sheet (Default)",
68
+ }
@@ -0,0 +1,37 @@
1
+ import React from "react"
2
+ import { Meta, StoryObj } from "@storybook/react"
3
+ import { userEvent, within, expect, waitFor } from "@storybook/test"
4
+ import { VideoPlayer } from "./index"
5
+
6
+ const meta = {
7
+ title: "Components/Illustrations/VideoPlayer",
8
+ component: VideoPlayer,
9
+ args: {
10
+ autoplay: false,
11
+ fallback: "illustrations/heart/scene/brand-moments-positive-outro",
12
+ source: "illustrations/heart/scene/brand-moments-positive-outro",
13
+ },
14
+ } satisfies Meta<typeof VideoPlayer>
15
+
16
+ export default meta
17
+
18
+ type Story = StoryObj<typeof meta>
19
+
20
+ export const PausePlay: Story = {
21
+ render: args => <VideoPlayer {...args} />,
22
+ name: "VideoPlayer: Pause/Play",
23
+ play: async ({ canvasElement }) => {
24
+ const canvas = within(canvasElement)
25
+ const element = canvas.getByRole("button")
26
+
27
+ waitFor(() => {
28
+ userEvent.click(element)
29
+ expect(element).toHaveAttribute("aria-label", "Pause animation")
30
+ })
31
+
32
+ waitFor(() => {
33
+ userEvent.click(element)
34
+ expect(element).toHaveAttribute("aria-label", "Play animation")
35
+ })
36
+ },
37
+ }
@@ -1,10 +1,10 @@
1
1
  import React from "react"
2
2
  import { render, screen, fireEvent, waitFor } from "@testing-library/react"
3
+ import { vi } from "vitest"
3
4
  import { InputRange } from "./index"
4
-
5
5
  describe("<InputRange />", () => {
6
6
  it("fires onChange after interaction", async () => {
7
- const onChange = jest.fn()
7
+ const onChange = vi.fn()
8
8
  render(
9
9
  <InputRange
10
10
  id="unique-3"
@@ -1,7 +1,7 @@
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 { renderWithIntl } from "~tests"
4
+ import { vi } from "vitest"
5
5
  import { InputSearchProps } from "./InputSearch"
6
6
  import { InputSearch } from "."
7
7
 
@@ -10,7 +10,7 @@ const user = userEvent.setup()
10
10
  const defaultInputProps = {
11
11
  id: "someInputId",
12
12
  value: "somevalue",
13
- onChange: jest.fn(),
13
+ onChange: vi.fn(),
14
14
  }
15
15
 
16
16
  const renderInput = (
@@ -18,9 +18,7 @@ const renderInput = (
18
18
  ): ReturnType<typeof render> => {
19
19
  const mergedInputProps = { ...defaultInputProps, ...props }
20
20
 
21
- return renderWithIntl(
22
- <InputSearch {...mergedInputProps} data-testid="someInputId" />
23
- )
21
+ return render(<InputSearch {...mergedInputProps} data-testid="someInputId" />)
24
22
  }
25
23
 
26
24
  describe("<InputSearch />", () => {
@@ -1,7 +1,7 @@
1
1
  import React from "react"
2
2
  import { render } from "@testing-library/react"
3
+ import { vi } from "vitest"
3
4
  import { KaizenProvider, KaizenProviderProps } from "./KaizenProvider"
4
-
5
5
  const KaizenProviderWrapper = ({
6
6
  children,
7
7
  ...restProps
@@ -9,7 +9,7 @@ const KaizenProviderWrapper = ({
9
9
  <KaizenProvider {...restProps}>{children}</KaizenProvider>
10
10
  )
11
11
 
12
- jest.mock("./subcomponents/OptionalIntlProvider", () => ({
12
+ vi.mock("./subcomponents/OptionalIntlProvider", () => ({
13
13
  OptionalIntlProvider: ({ children }: { children: React.ReactElement }) => (
14
14
  <div>{children}</div>
15
15
  ),
@@ -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
- jest.mock("@cultureamp/i18n-react-intl", () => ({
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 = 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
+ }