@charcuterie/ui 4.22.1 → 4.23.0
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/README.md +13 -0
- package/dist/GroupedList/GroupedList.d.ts +105 -0
- package/dist/GroupedList/GroupedList.d.ts.map +1 -0
- package/dist/GroupedList/GroupedList.js +63 -0
- package/dist/GroupedList/GroupedList.js.map +1 -0
- package/dist/GroupedList/GroupedListRow.d.ts +29 -0
- package/dist/GroupedList/GroupedListRow.d.ts.map +1 -0
- package/dist/GroupedList/GroupedListRow.js +38 -0
- package/dist/GroupedList/GroupedListRow.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/GroupedList/GroupedList.mdx +67 -0
- package/src/GroupedList/GroupedList.stories.tsx +474 -0
- package/src/GroupedList/GroupedList.test.tsx +271 -0
- package/src/GroupedList/GroupedList.tsx +200 -0
- package/src/GroupedList/GroupedListRow.tsx +117 -0
- package/src/index.ts +8 -0
- package/src/sourceRules.test.ts +4 -1
- package/src/Button/Button.test.tsx +0 -114
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
composeStories,
|
|
3
|
-
composeStory,
|
|
4
|
-
} from "@storybook/react"
|
|
5
|
-
import { expect, fn, userEvent } from "storybook/test"
|
|
6
|
-
import { test } from "vitest"
|
|
7
|
-
|
|
8
|
-
import { mountStory } from "../mountStory.testHelpers.ts"
|
|
9
|
-
import { expectAgentDrivable } from "../testing/index.ts"
|
|
10
|
-
import meta, * as stories from "./Button.stories.tsx"
|
|
11
|
-
|
|
12
|
-
const { AllStates, Playground, Loading } =
|
|
13
|
-
composeStories(stories)
|
|
14
|
-
|
|
15
|
-
test("is drivable by role and name", async () => {
|
|
16
|
-
const { canvas } = await mountStory(Playground)
|
|
17
|
-
|
|
18
|
-
expectAgentDrivable(canvas, {
|
|
19
|
-
name: "Start rip",
|
|
20
|
-
role: "button",
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The keyboard contract, asserted rather than assumed: Tab reaches
|
|
26
|
-
* it, Enter activates, Space activates. Every hand-rolled
|
|
27
|
-
* `<div onClick>` in the fleet fails all three.
|
|
28
|
-
*/
|
|
29
|
-
test("Tab reaches it, and Enter and Space both activate", async () => {
|
|
30
|
-
const onClick = fn()
|
|
31
|
-
|
|
32
|
-
const { canvas } = await mountStory(
|
|
33
|
-
composeStory(
|
|
34
|
-
{ args: { children: "Start rip", onClick } },
|
|
35
|
-
meta,
|
|
36
|
-
),
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
const button = expectAgentDrivable(canvas, {
|
|
40
|
-
name: "Start rip",
|
|
41
|
-
role: "button",
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
await userEvent.tab()
|
|
45
|
-
|
|
46
|
-
await expect(button).toHaveFocus()
|
|
47
|
-
|
|
48
|
-
await userEvent.keyboard("{Enter}")
|
|
49
|
-
|
|
50
|
-
await expect(onClick).toHaveBeenCalledTimes(1)
|
|
51
|
-
|
|
52
|
-
await userEvent.keyboard(" ")
|
|
53
|
-
|
|
54
|
-
await expect(onClick).toHaveBeenCalledTimes(2)
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
test("a disabled button is skipped by Tab and ignores a click", async () => {
|
|
58
|
-
const onClick = fn()
|
|
59
|
-
|
|
60
|
-
const { canvas } = await mountStory(
|
|
61
|
-
composeStory(
|
|
62
|
-
{
|
|
63
|
-
args: {
|
|
64
|
-
children: "Start rip",
|
|
65
|
-
isDisabled: true,
|
|
66
|
-
onClick,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
meta,
|
|
70
|
-
),
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
const button = canvas.getByRole("button", {
|
|
74
|
-
name: "Start rip",
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
await userEvent.click(button)
|
|
78
|
-
|
|
79
|
-
// A `<div role="button">` with a guard clause looks the same and
|
|
80
|
-
// is not the same: a real `disabled` is skipped by Tab, ignored
|
|
81
|
-
// by click, and reported to AT.
|
|
82
|
-
await expect(onClick).not.toHaveBeenCalled()
|
|
83
|
-
await expect(button).toBeDisabled()
|
|
84
|
-
|
|
85
|
-
await userEvent.tab()
|
|
86
|
-
|
|
87
|
-
await expect(button).not.toHaveFocus()
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
test("loading disables the button and announces the work", async () => {
|
|
91
|
-
const { canvas } = await mountStory(Loading)
|
|
92
|
-
|
|
93
|
-
const button = expectAgentDrivable(canvas, {
|
|
94
|
-
name: /Ripping disc 3/,
|
|
95
|
-
role: "button",
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
await expect(button).toBeDisabled()
|
|
99
|
-
await expect(button).toHaveAttribute("aria-busy", "true")
|
|
100
|
-
|
|
101
|
-
// The spinner's label lives in a `role="status"`, so a screen
|
|
102
|
-
// reader hears the work start rather than only seeing it.
|
|
103
|
-
await expect(
|
|
104
|
-
canvas.getByRole("status"),
|
|
105
|
-
).toBeInTheDocument()
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
test("the states board really renders a busy button", async () => {
|
|
109
|
-
const { canvas } = await mountStory(AllStates)
|
|
110
|
-
|
|
111
|
-
await expect(
|
|
112
|
-
canvas.getByRole("button", { name: /loading/i }),
|
|
113
|
-
).toHaveAttribute("aria-busy", "true")
|
|
114
|
-
})
|