@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.
- package/codemods/utils/__snapshots__/transformSource.spec.ts.snap +2 -2
- package/dist/cjs/RichTextEditor/RichTextContent/RichTextContent.cjs +10 -1
- package/dist/esm/RichTextEditor/RichTextContent/RichTextContent.mjs +11 -2
- package/dist/styles.css +220 -220
- package/package.json +5 -4
- 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.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 +2 -2
- 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/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 +4 -4
- 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,12 +1,28 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { render, waitFor, screen, within } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
-
import {
|
|
4
|
+
import { vi } from "vitest"
|
|
5
5
|
import { CustomBreadcrumbProps, SectionTitleRenderProps } from "./types"
|
|
6
6
|
import { TitleBlockZen } from "./index"
|
|
7
7
|
|
|
8
8
|
const user = userEvent.setup()
|
|
9
9
|
|
|
10
|
+
const mockMatchMedia = (matches: boolean = false): void => {
|
|
11
|
+
Object.defineProperty(window, "matchMedia", {
|
|
12
|
+
writable: true,
|
|
13
|
+
value: vi.fn().mockImplementation(query => ({
|
|
14
|
+
matches,
|
|
15
|
+
media: query,
|
|
16
|
+
onchange: null,
|
|
17
|
+
addListener: vi.fn(), // Deprecated
|
|
18
|
+
removeListener: vi.fn(), // Deprecated
|
|
19
|
+
addEventListener: vi.fn(),
|
|
20
|
+
removeEventListener: vi.fn(),
|
|
21
|
+
dispatchEvent: vi.fn(),
|
|
22
|
+
})),
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
10
26
|
describe("<TitleBlockZen />", () => {
|
|
11
27
|
beforeEach(() => {
|
|
12
28
|
mockMatchMedia()
|
|
@@ -41,7 +57,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
41
57
|
})
|
|
42
58
|
|
|
43
59
|
describe("when the primary action is a button with only an onClick", () => {
|
|
44
|
-
const testOnClickFn =
|
|
60
|
+
const testOnClickFn = vi.fn()
|
|
45
61
|
const primaryActionAsButton = {
|
|
46
62
|
label: "primaryActionLabel",
|
|
47
63
|
onClick: testOnClickFn,
|
|
@@ -84,7 +100,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
84
100
|
})
|
|
85
101
|
|
|
86
102
|
describe("when the primary action is disabled", () => {
|
|
87
|
-
const testOnClickFn =
|
|
103
|
+
const testOnClickFn = vi.fn()
|
|
88
104
|
const primaryActionAsButton = {
|
|
89
105
|
label: "primaryActionLabel",
|
|
90
106
|
onClick: testOnClickFn,
|
|
@@ -166,7 +182,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
166
182
|
})
|
|
167
183
|
|
|
168
184
|
describe("when the primary action is a button with both an href and an onClick", () => {
|
|
169
|
-
const testOnClickFn =
|
|
185
|
+
const testOnClickFn = vi.fn()
|
|
170
186
|
const primaryActionAsLinkAndOnClick = {
|
|
171
187
|
label: "primaryActionLabel",
|
|
172
188
|
href: "#primaryActionHref",
|
|
@@ -307,7 +323,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
307
323
|
})
|
|
308
324
|
|
|
309
325
|
describe("when the default action is a button with only an onClick", () => {
|
|
310
|
-
const testOnClickFn =
|
|
326
|
+
const testOnClickFn = vi.fn()
|
|
311
327
|
const defaultActionAsButton = {
|
|
312
328
|
label: "defaultActionLabel",
|
|
313
329
|
onClick: testOnClickFn,
|
|
@@ -363,7 +379,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
363
379
|
})
|
|
364
380
|
|
|
365
381
|
describe("when the default action is a button with both an href and an onClick", () => {
|
|
366
|
-
const testOnClickFn =
|
|
382
|
+
const testOnClickFn = vi.fn()
|
|
367
383
|
const defaultActionAsLinkAndOnClick = {
|
|
368
384
|
label: "defaultActionLabel",
|
|
369
385
|
href: "#defaultActionHref",
|
|
@@ -423,7 +439,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
423
439
|
})
|
|
424
440
|
|
|
425
441
|
describe("when the default action is disabled", () => {
|
|
426
|
-
const testOnClickFn =
|
|
442
|
+
const testOnClickFn = vi.fn()
|
|
427
443
|
const defaultActionAsButton = {
|
|
428
444
|
label: "defaultActionLabel",
|
|
429
445
|
onClick: testOnClickFn,
|
|
@@ -504,7 +520,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
504
520
|
})
|
|
505
521
|
|
|
506
522
|
describe("when a secondary action is passed with both an href and an onClick", () => {
|
|
507
|
-
const testOnClickFn =
|
|
523
|
+
const testOnClickFn = vi.fn()
|
|
508
524
|
const secondaryActionWithLinkAndOnClick = {
|
|
509
525
|
label: "secondaryActionLabel",
|
|
510
526
|
href: "#secondaryActionHref",
|
|
@@ -516,8 +532,8 @@ describe("<TitleBlockZen />", () => {
|
|
|
516
532
|
})
|
|
517
533
|
|
|
518
534
|
it("renders the secondary action with both the href and onClick", async () => {
|
|
519
|
-
const mockWarnFn =
|
|
520
|
-
const spy =
|
|
535
|
+
const mockWarnFn = vi.fn()
|
|
536
|
+
const spy = vi
|
|
521
537
|
.spyOn(global.console, "warn")
|
|
522
538
|
.mockImplementation(mockWarnFn)
|
|
523
539
|
const { getByTestId } = render(
|
|
@@ -543,8 +559,8 @@ describe("<TitleBlockZen />", () => {
|
|
|
543
559
|
})
|
|
544
560
|
|
|
545
561
|
it("renders the action as a single mobile actions drawer item with an onClick", async () => {
|
|
546
|
-
const mockWarnFn =
|
|
547
|
-
const spy =
|
|
562
|
+
const mockWarnFn = vi.fn()
|
|
563
|
+
const spy = vi
|
|
548
564
|
.spyOn(global.console, "warn")
|
|
549
565
|
.mockImplementation(mockWarnFn)
|
|
550
566
|
const { getAllByTestId } = render(
|
|
@@ -681,7 +697,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
681
697
|
})
|
|
682
698
|
|
|
683
699
|
describe("when a disabled secondary action is passed with only an onClick", () => {
|
|
684
|
-
const testOnClickFn =
|
|
700
|
+
const testOnClickFn = vi.fn()
|
|
685
701
|
const secondaryActionWithOnClick = {
|
|
686
702
|
label: "secondaryActionLabel",
|
|
687
703
|
onClick: testOnClickFn,
|
|
@@ -708,7 +724,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
708
724
|
})
|
|
709
725
|
|
|
710
726
|
describe("when a disabled secondary overflow menu item is passed with only an onClick for the action", () => {
|
|
711
|
-
const testOnClickFn =
|
|
727
|
+
const testOnClickFn = vi.fn()
|
|
712
728
|
const secondaryOverflowMenuItemWithOnClick = {
|
|
713
729
|
label: "secondaryActionOverflowMenuItemLabel",
|
|
714
730
|
action: testOnClickFn,
|
|
@@ -737,54 +753,6 @@ describe("<TitleBlockZen />", () => {
|
|
|
737
753
|
})
|
|
738
754
|
})
|
|
739
755
|
|
|
740
|
-
describe("survey status", () => {
|
|
741
|
-
it("doesn't render tag when field is omitted", async () => {
|
|
742
|
-
render(<TitleBlockZen title="Test Title">Example</TitleBlockZen>)
|
|
743
|
-
|
|
744
|
-
await waitFor(() => {
|
|
745
|
-
expect(
|
|
746
|
-
screen.queryByTestId("survey-status-tag")
|
|
747
|
-
).not.toBeInTheDocument()
|
|
748
|
-
})
|
|
749
|
-
})
|
|
750
|
-
|
|
751
|
-
it.each([
|
|
752
|
-
["draft", "statusDraft"],
|
|
753
|
-
["live", "statusLive"],
|
|
754
|
-
["closed", "statusClosed"],
|
|
755
|
-
["scheduled", "statusClosed"],
|
|
756
|
-
["sentimentPositive", "sentimentPositive"],
|
|
757
|
-
["default", "default"],
|
|
758
|
-
])(
|
|
759
|
-
"renders tag with correct text and variant when %s status",
|
|
760
|
-
async (status, expectedClassName) => {
|
|
761
|
-
render(
|
|
762
|
-
<TitleBlockZen
|
|
763
|
-
title="Test Title"
|
|
764
|
-
surveyStatus={{
|
|
765
|
-
text: `${status} text`,
|
|
766
|
-
status: `${status}` as
|
|
767
|
-
| "draft"
|
|
768
|
-
| "live"
|
|
769
|
-
| "scheduled"
|
|
770
|
-
| "closed"
|
|
771
|
-
| "sentimentPositive"
|
|
772
|
-
| "default",
|
|
773
|
-
}}
|
|
774
|
-
>
|
|
775
|
-
Example
|
|
776
|
-
</TitleBlockZen>
|
|
777
|
-
)
|
|
778
|
-
|
|
779
|
-
const tagElement = (await screen.findByTestId("survey-status-tag"))
|
|
780
|
-
.firstChild
|
|
781
|
-
|
|
782
|
-
expect(tagElement).toHaveTextContent(`${status} text`)
|
|
783
|
-
expect(tagElement).toHaveClass(expectedClassName)
|
|
784
|
-
}
|
|
785
|
-
)
|
|
786
|
-
})
|
|
787
|
-
|
|
788
756
|
describe("automation ID behaviour", () => {
|
|
789
757
|
describe("when default automation IDs are not provided alongside required conditional renders", () => {
|
|
790
758
|
it("renders the default automation IDs", () => {
|
|
@@ -807,7 +775,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
807
775
|
breadcrumb={{
|
|
808
776
|
text: "Test Breadcrumb",
|
|
809
777
|
path: "/",
|
|
810
|
-
handleClick:
|
|
778
|
+
handleClick: vi.fn(),
|
|
811
779
|
}}
|
|
812
780
|
sectionTitle="Test Section Title"
|
|
813
781
|
sectionTitleDescription="Test Section Title Description"
|
|
@@ -845,7 +813,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
845
813
|
breadcrumb={{
|
|
846
814
|
text: "Test Breadcrumb",
|
|
847
815
|
path: "/",
|
|
848
|
-
handleClick:
|
|
816
|
+
handleClick: vi.fn(),
|
|
849
817
|
}}
|
|
850
818
|
sectionTitle="Test Section Title"
|
|
851
819
|
sectionTitleDescription="Test Section Title Description"
|
|
@@ -909,7 +877,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
909
877
|
})
|
|
910
878
|
|
|
911
879
|
it("renders a custom component when you pass a 'render' prop", async () => {
|
|
912
|
-
const mockFn =
|
|
880
|
+
const mockFn = vi.fn()
|
|
913
881
|
|
|
914
882
|
const CustomComponent = (props: CustomBreadcrumbProps): JSX.Element => (
|
|
915
883
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
@@ -1018,7 +986,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
1018
986
|
})
|
|
1019
987
|
|
|
1020
988
|
it("will render custom button with functional onClick", async () => {
|
|
1021
|
-
const testClickFunc =
|
|
989
|
+
const testClickFunc = vi.fn()
|
|
1022
990
|
render(
|
|
1023
991
|
<TitleBlockZen
|
|
1024
992
|
title="Test Title"
|
|
@@ -1045,7 +1013,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
1045
1013
|
})
|
|
1046
1014
|
|
|
1047
1015
|
it("will render custom button with children and not label", () => {
|
|
1048
|
-
const testClickFunc =
|
|
1016
|
+
const testClickFunc = vi.fn()
|
|
1049
1017
|
render(
|
|
1050
1018
|
<TitleBlockZen
|
|
1051
1019
|
title="Test Title"
|
|
@@ -1177,7 +1145,7 @@ describe("<TitleBlockZen />", () => {
|
|
|
1177
1145
|
})
|
|
1178
1146
|
|
|
1179
1147
|
it("will render the component in the top list of the Drawer content if it is a clickable button", () => {
|
|
1180
|
-
const testClickFunc =
|
|
1148
|
+
const testClickFunc = vi.fn()
|
|
1181
1149
|
render(
|
|
1182
1150
|
<TitleBlockZen
|
|
1183
1151
|
title="Test Title"
|
|
@@ -75,13 +75,6 @@ const meta = {
|
|
|
75
75
|
<NavigationTab key="6" text="Label" href="#" />,
|
|
76
76
|
],
|
|
77
77
|
},
|
|
78
|
-
decorators: [
|
|
79
|
-
Story => (
|
|
80
|
-
<div style={{ margin: "-1rem" }}>
|
|
81
|
-
<Story />
|
|
82
|
-
</div>
|
|
83
|
-
),
|
|
84
|
-
],
|
|
85
78
|
} satisfies Meta<typeof TitleBlockZen>
|
|
86
79
|
|
|
87
80
|
export default meta
|
|
@@ -152,7 +145,7 @@ export const HasLongTitle: Story = {
|
|
|
152
145
|
args: { title: "A long title with over thirty characters" },
|
|
153
146
|
}
|
|
154
147
|
|
|
155
|
-
export const
|
|
148
|
+
export const StickerSheetBreadcrumbs: Story = {
|
|
156
149
|
parameters: {
|
|
157
150
|
docs: {
|
|
158
151
|
canvas: {
|
|
@@ -208,4 +201,81 @@ export const StickerSheetDefault: Story = {
|
|
|
208
201
|
</StickerSheet.Row>
|
|
209
202
|
</StickerSheet>
|
|
210
203
|
),
|
|
204
|
+
name: "Sticker Sheet (Breadcrumb)",
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export const StickerSheetDefault: Story = {
|
|
208
|
+
render: () => (
|
|
209
|
+
<StickerSheet title="Survey Status">
|
|
210
|
+
<StickerSheet.Body>
|
|
211
|
+
<StickerSheet.Row rowTitle="Draft">
|
|
212
|
+
<TitleBlockZen
|
|
213
|
+
title="Draft Title"
|
|
214
|
+
surveyStatus={{
|
|
215
|
+
text: "draft text",
|
|
216
|
+
status: "draft",
|
|
217
|
+
}}
|
|
218
|
+
>
|
|
219
|
+
Draft
|
|
220
|
+
</TitleBlockZen>
|
|
221
|
+
</StickerSheet.Row>
|
|
222
|
+
<StickerSheet.Row rowTitle="Default">
|
|
223
|
+
<TitleBlockZen
|
|
224
|
+
title="Default Title"
|
|
225
|
+
surveyStatus={{
|
|
226
|
+
text: "default text",
|
|
227
|
+
status: "default",
|
|
228
|
+
}}
|
|
229
|
+
>
|
|
230
|
+
Default
|
|
231
|
+
</TitleBlockZen>
|
|
232
|
+
</StickerSheet.Row>
|
|
233
|
+
<StickerSheet.Row rowTitle="Scheduled">
|
|
234
|
+
<TitleBlockZen
|
|
235
|
+
title="Scheduled Title"
|
|
236
|
+
surveyStatus={{
|
|
237
|
+
text: "scheduled text",
|
|
238
|
+
status: "scheduled",
|
|
239
|
+
}}
|
|
240
|
+
>
|
|
241
|
+
Due
|
|
242
|
+
</TitleBlockZen>
|
|
243
|
+
</StickerSheet.Row>
|
|
244
|
+
<StickerSheet.Row rowTitle="Live">
|
|
245
|
+
<TitleBlockZen
|
|
246
|
+
title="Live Title"
|
|
247
|
+
surveyStatus={{
|
|
248
|
+
text: "live text",
|
|
249
|
+
status: "live",
|
|
250
|
+
}}
|
|
251
|
+
>
|
|
252
|
+
Overdue
|
|
253
|
+
</TitleBlockZen>
|
|
254
|
+
</StickerSheet.Row>
|
|
255
|
+
<StickerSheet.Row rowTitle="Closed">
|
|
256
|
+
<TitleBlockZen
|
|
257
|
+
title="Closed Title"
|
|
258
|
+
surveyStatus={{
|
|
259
|
+
text: "closed text",
|
|
260
|
+
status: "closed",
|
|
261
|
+
}}
|
|
262
|
+
>
|
|
263
|
+
Completed
|
|
264
|
+
</TitleBlockZen>
|
|
265
|
+
</StickerSheet.Row>
|
|
266
|
+
<StickerSheet.Row rowTitle="Sentiment Positive">
|
|
267
|
+
<TitleBlockZen
|
|
268
|
+
title="Sentiment Positive Title"
|
|
269
|
+
surveyStatus={{
|
|
270
|
+
text: "sentimentPositive text",
|
|
271
|
+
status: "sentimentPositive",
|
|
272
|
+
}}
|
|
273
|
+
>
|
|
274
|
+
Completed
|
|
275
|
+
</TitleBlockZen>
|
|
276
|
+
</StickerSheet.Row>
|
|
277
|
+
</StickerSheet.Body>
|
|
278
|
+
</StickerSheet>
|
|
279
|
+
),
|
|
280
|
+
name: "Sticker Sheet (Survey Status)",
|
|
211
281
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
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 { MobileActions } from "./MobileActions"
|
|
5
|
-
|
|
6
6
|
const user = userEvent.setup()
|
|
7
7
|
|
|
8
8
|
const MENU_LINKS = [
|
|
@@ -147,7 +147,7 @@ describe("<MobileActions />", () => {
|
|
|
147
147
|
|
|
148
148
|
describe("when autoHide is true", () => {
|
|
149
149
|
beforeEach(() => {
|
|
150
|
-
window.alert =
|
|
150
|
+
window.alert = vi.fn()
|
|
151
151
|
render(
|
|
152
152
|
<MobileActions
|
|
153
153
|
primaryAction={{
|
|
@@ -1,7 +1,9 @@
|
|
|
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 { NavigationTab, CustomNavigationTabProps } from "./NavigationTabs"
|
|
6
|
+
import styles from "./NavigationTabs.module.scss"
|
|
5
7
|
|
|
6
8
|
const user = userEvent.setup()
|
|
7
9
|
|
|
@@ -33,7 +35,7 @@ describe("NavigationTabs", () => {
|
|
|
33
35
|
|
|
34
36
|
describe("with a render prop", () => {
|
|
35
37
|
it("renders the component passed with the navigation tab props", async () => {
|
|
36
|
-
const handleClick =
|
|
38
|
+
const handleClick = vi.fn()
|
|
37
39
|
const text = "I am also navigation tabs"
|
|
38
40
|
const href = "www.cultureamp.com"
|
|
39
41
|
render(
|
|
@@ -50,7 +52,11 @@ describe("NavigationTabs", () => {
|
|
|
50
52
|
const button = screen.getByRole("button", {
|
|
51
53
|
name: `${href} - ${text} - true`,
|
|
52
54
|
})
|
|
53
|
-
expect(button).toHaveClass(
|
|
55
|
+
expect(button).toHaveClass(
|
|
56
|
+
styles.linkAnchor,
|
|
57
|
+
styles.active,
|
|
58
|
+
styles.lightBackground
|
|
59
|
+
)
|
|
54
60
|
|
|
55
61
|
await user.click(button)
|
|
56
62
|
await waitFor(() => {
|
|
@@ -1,13 +1,13 @@
|
|
|
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 { ToggleSwitch, ToggleSwitchProps } from "./ToggleSwitch"
|
|
5
|
-
|
|
6
6
|
const user = userEvent.setup()
|
|
7
7
|
|
|
8
8
|
const defaultToggleSwitchProps = {
|
|
9
9
|
id: "someToggleSwitchId",
|
|
10
|
-
onToggle:
|
|
10
|
+
onToggle: vi.fn(),
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const renderToggleSwitch = (
|
|
@@ -23,7 +23,7 @@ describe("Dropdown", () => {
|
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
it("shows menu & handles onClick set by the consumer when clicking on the button", async () => {
|
|
26
|
-
const onButtonClick =
|
|
26
|
+
const onButtonClick = vi.fn()
|
|
27
27
|
|
|
28
28
|
render(
|
|
29
29
|
<Menu button={<Button label="Button" onClick={onButtonClick} />}>
|
|
@@ -42,7 +42,7 @@ describe("Dropdown", () => {
|
|
|
42
42
|
})
|
|
43
43
|
})
|
|
44
44
|
it("shows menu & handles onMouseDown set by the consumer when mousing down on the button", async () => {
|
|
45
|
-
const onMouseDown =
|
|
45
|
+
const onMouseDown = vi.fn()
|
|
46
46
|
|
|
47
47
|
render(
|
|
48
48
|
<Menu button={<Button label="Button" onMouseDown={onMouseDown} />}>
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { cleanup, render, waitFor } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
+
import { vi } from "vitest"
|
|
4
5
|
import { Informative } from "~components/Illustration"
|
|
5
6
|
import { GuidanceBlock } from "./GuidanceBlock"
|
|
6
|
-
|
|
7
7
|
const user = userEvent.setup()
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
|
|
10
|
-
window.matchMedia =
|
|
10
|
+
window.matchMedia = vi.fn().mockImplementation(() => ({
|
|
11
11
|
matches: false,
|
|
12
12
|
media: "",
|
|
13
13
|
onchange: null,
|
|
14
|
-
addListener:
|
|
15
|
-
removeListener:
|
|
14
|
+
addListener: vi.fn(),
|
|
15
|
+
removeListener: vi.fn(),
|
|
16
16
|
}))
|
|
17
17
|
|
|
18
18
|
describe("GuidanceBlock", () => {
|
|
19
19
|
afterEach(cleanup)
|
|
20
20
|
|
|
21
21
|
it("calls the action function when action button is clicked", async () => {
|
|
22
|
-
const onAction =
|
|
22
|
+
const onAction = vi.fn()
|
|
23
23
|
const { container } = render(
|
|
24
24
|
<GuidanceBlock
|
|
25
25
|
illustration={<Informative alt="" />}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { cleanup, render, waitFor } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
+
import { vi } from "vitest"
|
|
4
5
|
import { Informative } from "~components/Illustration"
|
|
5
6
|
import { GuidanceBlock } from "./GuidanceBlock"
|
|
6
|
-
|
|
7
7
|
const user = userEvent.setup()
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
|
|
10
|
-
window.matchMedia =
|
|
10
|
+
window.matchMedia = vi.fn().mockImplementation(() => ({
|
|
11
11
|
matches: false,
|
|
12
12
|
media: "",
|
|
13
13
|
onchange: null,
|
|
14
|
-
addListener:
|
|
15
|
-
removeListener:
|
|
14
|
+
addListener: vi.fn(),
|
|
15
|
+
removeListener: vi.fn(),
|
|
16
16
|
}))
|
|
17
17
|
|
|
18
18
|
describe("GuidanceBlock", () => {
|
|
19
19
|
afterEach(cleanup)
|
|
20
20
|
|
|
21
21
|
it("calls the action function when action button is clicked", async () => {
|
|
22
|
-
const onAction =
|
|
22
|
+
const onAction = vi.fn()
|
|
23
23
|
const { container } = render(
|
|
24
24
|
<GuidanceBlock
|
|
25
25
|
illustration={<Informative alt="" />}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { render, waitFor, screen, within } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
+
import { vi } from "vitest"
|
|
4
5
|
import { Select, SelectProps } from "./Select"
|
|
5
6
|
import { singleMockItems } from "./_docs/mockData"
|
|
6
|
-
|
|
7
7
|
const user = userEvent.setup()
|
|
8
8
|
|
|
9
9
|
const SelectWrapper = ({
|
|
@@ -87,7 +87,7 @@ describe("<Select />", () => {
|
|
|
87
87
|
})
|
|
88
88
|
|
|
89
89
|
it("fires the onOpenChange callback when the trigger is interacted", async () => {
|
|
90
|
-
const onOpenChange =
|
|
90
|
+
const onOpenChange = vi.fn()
|
|
91
91
|
const { getByRole } = render(
|
|
92
92
|
<SelectWrapper
|
|
93
93
|
selectedKey="batch-brew"
|
|
@@ -267,7 +267,7 @@ describe("<Select />", () => {
|
|
|
267
267
|
|
|
268
268
|
describe("Selection - Mouse interaction", () => {
|
|
269
269
|
it("fires onSelectionChange when clicks on a option", async () => {
|
|
270
|
-
const spy =
|
|
270
|
+
const spy = vi.fn()
|
|
271
271
|
const { getByRole } = render(
|
|
272
272
|
<SelectWrapper defaultOpen onSelectionChange={spy} />
|
|
273
273
|
)
|
|
@@ -335,7 +335,7 @@ describe("<Select />", () => {
|
|
|
335
335
|
})
|
|
336
336
|
|
|
337
337
|
it("fires onSelectionChange when hits enter on a option", async () => {
|
|
338
|
-
const spy =
|
|
338
|
+
const spy = vi.fn()
|
|
339
339
|
const { getByRole } = render(<SelectWrapper onSelectionChange={spy} />)
|
|
340
340
|
|
|
341
341
|
await user.tab()
|
|
@@ -48,7 +48,7 @@ describe("<Tooltip />", () => {
|
|
|
48
48
|
// Non-semantic elements without roles should not have aria-description on them.
|
|
49
49
|
// They won't read to all screen readers as expected and may be reported in Storybook's accessibility tab (which uses Axe under the hood)
|
|
50
50
|
it("doesn't add an accessible description when wrapping a non-semantic element", async () => {
|
|
51
|
-
const warn =
|
|
51
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(vi.fn())
|
|
52
52
|
|
|
53
53
|
render(
|
|
54
54
|
<Tooltip
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
+
import { vi } from "vitest"
|
|
2
3
|
import { ArrowRightIcon } from "~components/Icon"
|
|
3
4
|
import { Button, IconButton } from "~components/__actions__/v2"
|
|
4
5
|
import { isSemanticElement } from "./isSemanticElement"
|
|
5
|
-
|
|
6
6
|
describe("isSemanticElement", () => {
|
|
7
7
|
it("returns true if provided a native element with a semantic role", () => {
|
|
8
8
|
expect(
|
|
9
9
|
isSemanticElement(
|
|
10
|
-
<button onClick={
|
|
10
|
+
<button onClick={vi.fn()} type="button">
|
|
11
11
|
click
|
|
12
12
|
</button>
|
|
13
13
|
)
|
|
@@ -28,19 +28,14 @@ describe("isSemanticElement", () => {
|
|
|
28
28
|
it("will return true if provided a non-semantic element with a semantic role", () => {
|
|
29
29
|
expect(
|
|
30
30
|
isSemanticElement(
|
|
31
|
-
<span
|
|
32
|
-
tabIndex={0}
|
|
33
|
-
role="button"
|
|
34
|
-
onKeyDown={jest.fn}
|
|
35
|
-
onClick={jest.fn()}
|
|
36
|
-
>
|
|
31
|
+
<span tabIndex={0} role="button" onKeyDown={vi.fn()} onClick={vi.fn()}>
|
|
37
32
|
custom semantic el
|
|
38
33
|
</span>
|
|
39
34
|
)
|
|
40
35
|
).toBe(true)
|
|
41
36
|
expect(
|
|
42
37
|
isSemanticElement(
|
|
43
|
-
<div tabIndex={0} role="button" onKeyDown={
|
|
38
|
+
<div tabIndex={0} role="button" onKeyDown={vi.fn()} onClick={vi.fn()}>
|
|
44
39
|
custom semantic el
|
|
45
40
|
</div>
|
|
46
41
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { render, screen } from "@testing-library/react"
|
|
3
|
+
import { vi } from "vitest"
|
|
3
4
|
import { useMediaQueries, subtractOnePixel } from "./useMediaQueries"
|
|
4
|
-
|
|
5
5
|
const ExampleComponent = (): JSX.Element => {
|
|
6
6
|
const { queries, components } = useMediaQueries({
|
|
7
7
|
prefersReducedMotion: "(prefers-reduced-motion: reduce)",
|
|
@@ -27,15 +27,15 @@ const ExampleComponent = (): JSX.Element => {
|
|
|
27
27
|
export const mockMatchMedia = (matches: boolean = false): void => {
|
|
28
28
|
Object.defineProperty(window, "matchMedia", {
|
|
29
29
|
writable: true,
|
|
30
|
-
value:
|
|
30
|
+
value: vi.fn().mockImplementation(query => ({
|
|
31
31
|
matches,
|
|
32
32
|
media: query,
|
|
33
33
|
onchange: null,
|
|
34
|
-
addListener:
|
|
35
|
-
removeListener:
|
|
36
|
-
addEventListener:
|
|
37
|
-
removeEventListener:
|
|
38
|
-
dispatchEvent:
|
|
34
|
+
addListener: vi.fn(), // Deprecated
|
|
35
|
+
removeListener: vi.fn(), // Deprecated
|
|
36
|
+
addEventListener: vi.fn(),
|
|
37
|
+
removeEventListener: vi.fn(),
|
|
38
|
+
dispatchEvent: vi.fn(),
|
|
39
39
|
})),
|
|
40
40
|
})
|
|
41
41
|
}
|