@kaizen/components 1.61.1 → 1.61.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/codemods/utils/__snapshots__/transformSource.spec.ts.snap +2 -2
- package/dist/cjs/RichTextEditor/RichTextContent/RichTextContent.cjs +10 -1
- package/dist/cjs/__future__/Select/Select.cjs +1 -6
- package/dist/cjs/__future__/Select/subcomponents/ListBox/ListBox.cjs +1 -2
- package/dist/cjs/__future__/Select/subcomponents/ListBox/ListBox.module.scss.cjs +1 -2
- package/dist/esm/RichTextEditor/RichTextContent/RichTextContent.mjs +11 -2
- package/dist/esm/__future__/Select/Select.mjs +1 -6
- package/dist/esm/__future__/Select/subcomponents/ListBox/ListBox.mjs +1 -2
- package/dist/esm/__future__/Select/subcomponents/ListBox/ListBox.module.scss.mjs +1 -2
- package/dist/styles.css +46 -44
- package/package.json +6 -5
- package/src/Avatar/Avatar.spec.tsx +1 -1
- package/src/Calendar/utils/setFocusInCalendar.spec.tsx +2 -2
- package/src/Checkbox/Checkbox/Checkbox.spec.tsx +2 -2
- package/src/Collapsible/Collapsible/Collapsible.spec.tsx +2 -14
- package/src/Collapsible/Collapsible/_docs/Collapsible.mdx +0 -2
- package/src/Collapsible/Collapsible/_docs/Collapsible.stickersheet.stories.tsx +49 -0
- package/src/Collapsible/Collapsible/_docs/Collapsible.stories.tsx +0 -11
- package/src/DateInput/DateInputDescription/DateInputDescription.spec.tsx +5 -6
- package/src/DateInput/DateInputWithIconButton/DateInputWithIconButton.spec.tsx +4 -6
- package/src/DatePicker/DatePicker.spec.tsx +32 -36
- package/src/DatePicker/subcomponents/DateInputField/DateInputField.spec.tsx +13 -13
- package/src/DatePicker/utils/validateDate.spec.ts +5 -6
- package/src/EmptyState/EmptyState.spec.tsx +1 -1
- package/src/ErrorPage/ErrorPage.spec.tsx +19 -19
- package/src/Filter/FilterBar/FilterBar.spec.tsx +26 -26
- package/src/Filter/FilterBar/context/utils/updateDependentFilters.spec.ts +2 -4
- package/src/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.spec.tsx +3 -4
- package/src/Filter/FilterBar/subcomponents/FilterBarButton/FilterBarButton.spec.tsx +3 -6
- package/src/Filter/FilterBar/subcomponents/FilterBarDatePicker/FilterBarDatePicker.spec.tsx +10 -12
- package/src/Filter/FilterBar/subcomponents/FilterBarDateRangePicker/FilterBarDateRangePicker.spec.tsx +9 -10
- package/src/Filter/FilterBar/subcomponents/FilterBarMultiSelect/FilterBarMultiSelect.spec.tsx +12 -14
- package/src/Filter/FilterBar/subcomponents/FilterBarSelect/FilterBarSelect.spec.tsx +11 -13
- package/src/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.spec.tsx +5 -5
- package/src/Filter/FilterDatePicker/FilterDatePicker.spec.tsx +12 -15
- package/src/Filter/FilterDatePicker/hooks/useDateInputHandlers.spec.ts +12 -15
- package/src/Filter/FilterDatePicker/hooks/useDateValidation.spec.ts +3 -5
- package/src/Filter/FilterDatePicker/subcomponents/FilterDatePickerField/FilterDatePickerField.spec.tsx +23 -28
- package/src/Filter/FilterDatePicker/utils/getDateValidationHandler.spec.tsx +2 -6
- package/src/Filter/FilterDatePicker/utils/validateDate.spec.ts +5 -6
- package/src/Filter/FilterDateRangePicker/FilterDateRangePicker.spec.tsx +2 -3
- package/src/Filter/FilterDateRangePicker/_docs/FilterDateRangePicker.stickersheet.stories.tsx +27 -0
- package/src/Filter/FilterDateRangePicker/subcomponents/DateRangeInputField/DateRangeInputField.spec.tsx +9 -11
- package/src/Filter/FilterDateRangePicker/subcomponents/DateRangeValidationMessage/DateRangeValidationMessage.spec.tsx +1 -63
- package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/FilterDateRangePickerField.spec.tsx +32 -32
- package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/useEndDateValidation.spec.ts +3 -8
- package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/useStartDateValidation.spec.ts +2 -5
- package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/utils/validateEndDateBeforeStartDate.spec.ts +2 -3
- package/src/Filter/FilterMultiSelect/FilterMultiSelect.spec.tsx +9 -10
- package/src/Filter/FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.spec.tsx +2 -1
- package/src/Filter/FilterMultiSelect/context/SelectionProvider/SelectionProvider.spec.tsx +32 -32
- package/src/Filter/FilterMultiSelect/subcomponents/MultiSelectOption/MultiSelectOption.spec.tsx +9 -7
- package/src/Filter/FilterMultiSelect/subcomponents/SearchInput/SearchInput.spec.tsx +12 -12
- package/src/Filter/FilterMultiSelect/subcomponents/SelectionControlButton/ClearButton/ClearButton.spec.tsx +7 -7
- package/src/Filter/FilterMultiSelect/subcomponents/SelectionControlButton/SelectAllButton/SelectAllButton.spec.tsx +9 -9
- package/src/Filter/FilterSelect/FilterSelect.spec.tsx +3 -5
- package/src/Heading/Heading.spec.tsx +1 -31
- package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.spec.tsx +43 -97
- package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.stickersheet.stories.tsx +68 -0
- package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.stories.tsx +37 -0
- package/src/Input/InputRange/InputRange.spec.tsx +2 -2
- package/src/Input/InputSearch/InputSearch.spec.tsx +3 -5
- package/src/KaizenProvider/KaizenProvider.spec.tsx +2 -2
- package/src/KaizenProvider/subcomponents/OptionalIntlProvider/OptionalIntlProvider.spec.tsx +2 -3
- package/src/Modal/ConfirmationModal/ConfirmationModal.spec.tsx +7 -7
- package/src/Modal/ContextModal/ContextModal.spec.tsx +5 -5
- package/src/Modal/GenericModal/GenericModal.spec.tsx +4 -4
- package/src/Modal/InputEditModal/InputEditModal.spec.tsx +7 -7
- package/src/MultiSelect/subcomponents/MultiSelectOptionField/MultiSelectOptionField.spec.tsx +3 -3
- package/src/MultiSelect/subcomponents/MultiSelectOptions/MultiSelectOptions.spec.tsx +3 -3
- package/src/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.spec.tsx +2 -2
- package/src/MultiSelect/subcomponents/Popover/Popover.module.scss +1 -0
- package/src/Notification/subcomponents/GenericNotification/GenericNotification.stories.tsx +60 -0
- package/src/Pagination/Pagination.spec.tsx +2 -2
- package/src/RichTextEditor/EditableRichTextContent/EditableRichTextContent.spec.tsx +4 -4
- package/src/RichTextEditor/RichTextContent/RichTextContent.tsx +11 -2
- package/src/RichTextEditor/utils/commands/addMark.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/fixtures/helpers.ts +4 -3
- package/src/RichTextEditor/utils/commands/getMarkAttrs.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/getMarkRange.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/listIsActive.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/markContainsSelection.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/markIsActive.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/removeMark.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/updateMark.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/validateAndRemoveMarks.spec.ts +3 -3
- package/src/RichTextEditor/utils/core/createRichTextEditor.spec.ts +11 -11
- package/src/RichTextEditor/utils/core/hooks/useRichTextEditor.spec.tsx +2 -2
- package/src/SplitButton/SplitButton.spec.tsx +5 -5
- package/src/SplitButton/subcomponents/DropdownButton/DropdownButton.spec.tsx +3 -4
- package/src/Text/Text.spec.tsx +1 -57
- package/src/TextArea/TextArea.spec.tsx +2 -2
- package/src/TimeField/TimeField.spec.tsx +2 -2
- package/src/TitleBlockZen/TitleBlockZen.spec.tsx +36 -68
- package/src/TitleBlockZen/_docs/TitleBlockZen.stories.tsx +78 -8
- package/src/TitleBlockZen/subcomponents/MobileActions.spec.tsx +2 -2
- package/src/TitleBlockZen/subcomponents/NavigationTabs.spec.tsx +8 -2
- package/src/ToggleSwitch/ToggleSwitch/ToggleSwitch.spec.tsx +2 -2
- package/src/__actions__/Menu/v1/Menu.spec.tsx +2 -2
- package/src/__containers__/GuidanceBlock/v1/GuidanceBlock.spec.tsx +5 -5
- package/src/__containers__/GuidanceBlock/v2/GuidanceBlock.spec.tsx +5 -5
- package/src/__future__/Select/Select.spec.tsx +8 -8
- package/src/__future__/Select/Select.tsx +1 -10
- package/src/__future__/Select/subcomponents/ListBox/ListBox.module.scss +3 -3
- package/src/__future__/Select/subcomponents/ListBox/ListBox.tsx +1 -1
- package/src/__overlays__/Tooltip/v1/Tooltip.spec.tsx +1 -1
- package/src/__overlays__/Tooltip/v1/utils/isSemanticElement.spec.tsx +4 -9
- package/src/utils/useMediaQueries.spec.tsx +7 -7
- package/src/Heading/__snapshots__/Heading.spec.tsx.snap +0 -85
- package/src/Illustration/utils/usePausePlay.spec.tsx +0 -85
- package/src/Notification/subcomponents/GenericNotification/GenericNotification.spec.tsx +0 -76
- package/src/Text/__snapshots__/Text.spec.tsx.snap +0 -49
- package/src/__overlays__/Tooltip/v1/subcomponents/AppearanceAnim.spec.tsx +0 -39
|
@@ -1,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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
79
|
+
const onChange = vi.fn()
|
|
80
80
|
render(<Scenario onChange={onChange} />)
|
|
81
81
|
|
|
82
82
|
await waitFor(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
-
import { screen, waitFor } from "@testing-library/react"
|
|
2
|
+
import { screen, waitFor, render } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
-
import {
|
|
4
|
+
import { vi } from "vitest"
|
|
5
5
|
import { MenuItem, MenuList } from "~components/__actions__/v2"
|
|
6
6
|
import { SplitButton, SplitButtonProps } from "./SplitButton"
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ const SplitButtonWrapper = (
|
|
|
13
13
|
<SplitButton
|
|
14
14
|
actionButtonProps={{
|
|
15
15
|
label: "Action Text",
|
|
16
|
-
onClick:
|
|
16
|
+
onClick: vi.fn(),
|
|
17
17
|
}}
|
|
18
18
|
dropdownButtonProps={{
|
|
19
19
|
"aria-label": "Dropdown Label",
|
|
@@ -30,7 +30,7 @@ const SplitButtonWrapper = (
|
|
|
30
30
|
|
|
31
31
|
describe("<SplitButton />", () => {
|
|
32
32
|
it("renders the correct structure", async () => {
|
|
33
|
-
|
|
33
|
+
render(<SplitButtonWrapper />)
|
|
34
34
|
await waitFor(() => {
|
|
35
35
|
expect(screen.getByText("Action Text")).toBeInTheDocument()
|
|
36
36
|
})
|
|
@@ -46,7 +46,7 @@ describe("<SplitButton />", () => {
|
|
|
46
46
|
})
|
|
47
47
|
|
|
48
48
|
it("disables both buttons when disabled is true", async () => {
|
|
49
|
-
|
|
49
|
+
render(<SplitButtonWrapper disabled />)
|
|
50
50
|
await waitFor(() => {
|
|
51
51
|
expect(screen.getByText("Action Text").closest("button")).toBeDisabled()
|
|
52
52
|
})
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
-
import { screen, waitFor } from "@testing-library/react"
|
|
3
|
-
import { renderWithIntl } from "~tests"
|
|
2
|
+
import { screen, waitFor, render } from "@testing-library/react"
|
|
4
3
|
import { DropdownButton, DropdownButtonProps } from "./DropdownButton"
|
|
5
4
|
|
|
6
5
|
const DropdownButtonWrapper = (
|
|
@@ -9,7 +8,7 @@ const DropdownButtonWrapper = (
|
|
|
9
8
|
|
|
10
9
|
describe("<DropdownButton />", () => {
|
|
11
10
|
it("renders icon with default aria-label", async () => {
|
|
12
|
-
|
|
11
|
+
render(<DropdownButtonWrapper />)
|
|
13
12
|
await waitFor(() => {
|
|
14
13
|
const button = screen.getByRole("button", { name: "Additional actions" })
|
|
15
14
|
expect(button.getAttribute("aria-label")).toBe("Additional actions")
|
|
@@ -18,7 +17,7 @@ describe("<DropdownButton />", () => {
|
|
|
18
17
|
})
|
|
19
18
|
|
|
20
19
|
it("renders custom aria-label", async () => {
|
|
21
|
-
|
|
20
|
+
render(<DropdownButtonWrapper aria-label="Custom aria label" />)
|
|
22
21
|
await waitFor(() => {
|
|
23
22
|
const button = screen.getByRole("button", { name: "Custom aria label" })
|
|
24
23
|
expect(button.getAttribute("aria-label")).toBe("Custom aria label")
|
package/src/Text/Text.spec.tsx
CHANGED
|
@@ -1,30 +1,8 @@
|
|
|
1
1
|
import * as React from "react"
|
|
2
2
|
import { render } from "@testing-library/react"
|
|
3
|
-
import {
|
|
3
|
+
import { AllowedTextTags, Text, TextVariants } from "."
|
|
4
4
|
|
|
5
5
|
describe("<Text />", () => {
|
|
6
|
-
describe("renders the correct variant classes", () => {
|
|
7
|
-
const testCases: TextVariants[] = [
|
|
8
|
-
"intro-lede",
|
|
9
|
-
"body",
|
|
10
|
-
"small",
|
|
11
|
-
"extra-small",
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
testCases.forEach(variant => {
|
|
15
|
-
it(`renders the correct element for <Text variant={${variant}} />`, () => {
|
|
16
|
-
const textMock = render(
|
|
17
|
-
<Text variant={variant} tag="div">
|
|
18
|
-
Example
|
|
19
|
-
</Text>
|
|
20
|
-
)
|
|
21
|
-
const textClasslist = textMock.getByText("Example").classList
|
|
22
|
-
expect(textClasslist).toContain("text")
|
|
23
|
-
expect(textClasslist).toContain(variant)
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
|
|
28
6
|
describe("changes rendered HTML element when passed tag", () => {
|
|
29
7
|
const testCases: TextVariants[] = [
|
|
30
8
|
"intro-lede",
|
|
@@ -45,30 +23,6 @@ describe("<Text />", () => {
|
|
|
45
23
|
})
|
|
46
24
|
})
|
|
47
25
|
|
|
48
|
-
describe("renders the correct color classes", () => {
|
|
49
|
-
const testCases: AllowedTextColors[] = [
|
|
50
|
-
"dark",
|
|
51
|
-
"dark-reduced-opacity",
|
|
52
|
-
"white",
|
|
53
|
-
"white-reduced-opacity",
|
|
54
|
-
"positive",
|
|
55
|
-
"negative",
|
|
56
|
-
]
|
|
57
|
-
|
|
58
|
-
testCases.forEach(color => {
|
|
59
|
-
it(`renders the correct class for <Text color={${color}} />`, () => {
|
|
60
|
-
const textMock = render(
|
|
61
|
-
<Text variant="body" color={color} tag="div">
|
|
62
|
-
Example
|
|
63
|
-
</Text>
|
|
64
|
-
)
|
|
65
|
-
const textClasslist = textMock.getByText("Example").classList
|
|
66
|
-
expect(textClasslist).toContain("text")
|
|
67
|
-
expect(textClasslist).toContain(color)
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
|
|
72
26
|
it("passes through data attributes", () => {
|
|
73
27
|
const { getByTestId } = render(
|
|
74
28
|
<Text variant="intro-lede" data-testid="test-id">
|
|
@@ -91,17 +45,7 @@ describe("<Text />", () => {
|
|
|
91
45
|
it(`renders the correct element for <Text variant={${variant}} />`, () => {
|
|
92
46
|
const textMock = render(<Text variant={variant}>Example</Text>)
|
|
93
47
|
expect(textMock.getByText("Example").tagName.toLowerCase()).toBe(el)
|
|
94
|
-
expect(textMock.baseElement).toMatchSnapshot()
|
|
95
48
|
})
|
|
96
49
|
})
|
|
97
50
|
})
|
|
98
|
-
|
|
99
|
-
it("allows consumers to provide a className", () => {
|
|
100
|
-
const { getByText } = render(
|
|
101
|
-
<Text variant="body" classNameOverride="example-classname">
|
|
102
|
-
Example
|
|
103
|
-
</Text>
|
|
104
|
-
)
|
|
105
|
-
expect(getByText("Example").classList).toContain("example-classname")
|
|
106
|
-
})
|
|
107
51
|
})
|
|
@@ -1,8 +1,8 @@
|
|
|
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 { TextArea } from "./TextArea"
|
|
5
|
-
|
|
6
6
|
const user = userEvent.setup()
|
|
7
7
|
|
|
8
8
|
describe("<TextArea />", () => {
|
|
@@ -22,7 +22,7 @@ describe("<TextArea />", () => {
|
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
it("calls the `onChange` event when the value is updated", async () => {
|
|
25
|
-
const mockFn =
|
|
25
|
+
const mockFn = vi.fn()
|
|
26
26
|
const { getByRole } = render(<TextArea onChange={mockFn} />)
|
|
27
27
|
|
|
28
28
|
await user.type(getByRole("textbox"), "Hello")
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { useState } 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 { TimeField, TimeFieldProps } from "./TimeField"
|
|
5
6
|
import { ValueType } from "./types"
|
|
6
|
-
|
|
7
7
|
const user = userEvent.setup()
|
|
8
8
|
|
|
9
|
-
const mockOnChange =
|
|
9
|
+
const mockOnChange = vi.fn()
|
|
10
10
|
const LABEL = "Launch Time Label"
|
|
11
11
|
|
|
12
12
|
const pressArrowKey =
|
|
@@ -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(() => {
|