@marktiderman/genesis-ui-native 3.10.0 → 3.12.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 +69 -0
- package/dist/{chunk-ZUR4PK77.js → chunk-47CDRP43.js} +45 -166
- package/dist/chunk-47CDRP43.js.map +1 -0
- package/dist/{chunk-SG7LYX7Z.js → chunk-BQYT6TH2.js} +14 -6
- package/dist/chunk-BQYT6TH2.js.map +1 -0
- package/dist/{chunk-EAHK7D7N.js → chunk-C2ARUGT7.js} +146 -42
- package/dist/chunk-C2ARUGT7.js.map +1 -0
- package/dist/{chunk-VEWSY4TZ.js → chunk-D4UU6KIF.js} +236 -21
- package/dist/chunk-D4UU6KIF.js.map +1 -0
- package/dist/{chunk-GGH3ZQNO.js → chunk-TUDJDIGC.js} +4 -4
- package/dist/{chunk-GGH3ZQNO.js.map → chunk-TUDJDIGC.js.map} +1 -1
- package/dist/{chunk-PMS2V46D.js → chunk-VHUUOH46.js} +2 -2
- package/dist/{chunk-PMS2V46D.js.map → chunk-VHUUOH46.js.map} +1 -1
- package/dist/{chunk-IWWXERKQ.js → chunk-X5CPLUPZ.js} +1236 -136
- package/dist/chunk-X5CPLUPZ.js.map +1 -0
- package/dist/components/index.d.ts +510 -25
- package/dist/components/index.js +5 -5
- package/dist/data/index.d.ts +176 -34
- package/dist/data/index.js +1312 -985
- package/dist/data/index.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +1 -1
- package/dist/icons/lucide.d.ts +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +7 -7
- package/dist/layouts/index.d.ts +79 -6
- package/dist/layouts/index.js +5 -5
- package/dist/{native-modules-Bkm1jHO-.d.ts → native-modules-6JnyeGR-.d.ts} +55 -1
- package/package.json +70 -4
- package/src/components/__tests__/combobox.test.tsx +20 -0
- package/src/components/__tests__/number-input.test.tsx +112 -1
- package/src/components/__tests__/parity-controls.test.tsx +366 -0
- package/src/components/__tests__/parity-display.test.tsx +295 -0
- package/src/components/__tests__/twin-props.test.tsx +114 -0
- package/src/components/badge.tsx +3 -0
- package/src/components/button-group.tsx +50 -0
- package/src/components/calendar.tsx +183 -0
- package/src/components/carousel.tsx +175 -0
- package/src/components/chart.tsx +268 -0
- package/src/components/chip-group.tsx +34 -14
- package/src/components/choice-card.tsx +56 -19
- package/src/components/combobox.tsx +6 -5
- package/src/components/empty-state.tsx +40 -0
- package/src/components/flatten-children.ts +13 -0
- package/src/components/index.ts +49 -1
- package/src/components/inline-alert.tsx +3 -1
- package/src/components/input-group.tsx +99 -0
- package/src/components/input-otp.tsx +124 -0
- package/src/components/input.tsx +40 -12
- package/src/components/list-item.tsx +20 -4
- package/src/components/number-input.tsx +45 -15
- package/src/components/radio-group.tsx +5 -0
- package/src/components/resource.tsx +227 -0
- package/src/components/settings-row.tsx +194 -0
- package/src/components/slider.tsx +3 -9
- package/src/components/sortable-list.tsx +287 -0
- package/src/components/stat-card.tsx +106 -0
- package/src/components/stepper.tsx +4 -2
- package/src/components/widget-tile.tsx +66 -0
- package/src/components/workspace-switcher.tsx +217 -0
- package/src/data/NativeCustomView.tsx +117 -0
- package/src/data/NativeFormFields.tsx +312 -0
- package/src/data/NativeRecordPeek.tsx +130 -0
- package/src/data/NativeResourceFormField.tsx +32 -0
- package/src/data/__tests__/parity-data.test.tsx +350 -0
- package/src/data/index.ts +13 -0
- package/src/data/resource-view/NativeResourceView.tsx +17 -2
- package/src/data/resource-view/__tests__/native-resource-gallery.test.tsx +8 -0
- package/src/data/resource-view/index.ts +1 -0
- package/src/data/resource-view/mapping.ts +4 -4
- package/src/layouts/__tests__/keyboard-scroll.test.tsx +58 -2
- package/src/layouts/__tests__/notifications-page.test.tsx +12 -0
- package/src/layouts/index.ts +13 -0
- package/src/layouts/keyboard.tsx +22 -2
- package/src/layouts/notifications-page.tsx +13 -35
- package/src/layouts/pages.tsx +262 -0
- package/src/native-modules.tsx +37 -0
- package/dist/chunk-EAHK7D7N.js.map +0 -1
- package/dist/chunk-IWWXERKQ.js.map +0 -1
- package/dist/chunk-SG7LYX7Z.js.map +0 -1
- package/dist/chunk-VEWSY4TZ.js.map +0 -1
- package/dist/chunk-ZUR4PK77.js.map +0 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
3
|
+
import { describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { AccessibilityInfo, PanResponder, Text } from "react-native";
|
|
5
|
+
import { NativeButton } from "../button";
|
|
6
|
+
import { NativeButtonGroup } from "../button-group";
|
|
7
|
+
import { NativeCalendar } from "../calendar";
|
|
8
|
+
import { NativeCarousel } from "../carousel";
|
|
9
|
+
import { NativeInputGroup, NativePasswordToggleField } from "../input-group";
|
|
10
|
+
import { NativeInputOTP } from "../input-otp";
|
|
11
|
+
import { NativeSortableList } from "../sortable-list";
|
|
12
|
+
|
|
13
|
+
const a11y = (el: HTMLElement, name: string) => act(() => void el.dispatchEvent(new CustomEvent("accessibilityaction", { detail: name })));
|
|
14
|
+
|
|
15
|
+
describe("NativeButtonGroup", () => {
|
|
16
|
+
it("joins its buttons: inner corners squared, one toolbar", () => {
|
|
17
|
+
render(
|
|
18
|
+
<NativeButtonGroup accessibilityLabel="Pages">
|
|
19
|
+
<NativeButton testID="a">Previous</NativeButton>
|
|
20
|
+
<NativeButton testID="b">Today</NativeButton>
|
|
21
|
+
<NativeButton testID="c">Next</NativeButton>
|
|
22
|
+
</NativeButtonGroup>,
|
|
23
|
+
);
|
|
24
|
+
expect(screen.getByRole("toolbar").getAttribute("aria-label")).toBe("Pages");
|
|
25
|
+
expect(screen.getByTestId("a").className).toContain("rounded-r-none");
|
|
26
|
+
expect(screen.getByTestId("b").className).toContain("rounded-none");
|
|
27
|
+
expect(screen.getByTestId("c").className).toContain("rounded-l-none");
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("NativeInputGroup and NativePasswordToggleField", () => {
|
|
32
|
+
it("draws a prefix and suffix inside the field", () => {
|
|
33
|
+
render(<NativeInputGroup testID="price" prefix="$" suffix="USD" value="" onChangeText={() => {}} />);
|
|
34
|
+
expect(screen.getByText("$")).toBeTruthy();
|
|
35
|
+
expect(screen.getByText("USD")).toBeTruthy();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("shows and hides the password, keeping what was typed", () => {
|
|
39
|
+
render(<NativePasswordToggleField testID="pw" value="hunter2" onChangeText={() => {}} />);
|
|
40
|
+
const toggle = screen.getByTestId("pw-toggle");
|
|
41
|
+
expect(toggle.getAttribute("aria-label")).toBe("Show password");
|
|
42
|
+
expect((screen.getByTestId("pw") as HTMLInputElement).type).toBe("password");
|
|
43
|
+
fireEvent.click(toggle);
|
|
44
|
+
expect(screen.getByTestId("pw-toggle").getAttribute("aria-label")).toBe("Hide password");
|
|
45
|
+
expect((screen.getByTestId("pw") as HTMLInputElement).value).toBe("hunter2");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("keeps the cursor where it was across a toggle, and is a plain button to a screen reader", () => {
|
|
49
|
+
render(<NativePasswordToggleField testID="pw" value="hunter2" onChangeText={() => {}} />);
|
|
50
|
+
const input = screen.getByTestId("pw") as HTMLInputElement;
|
|
51
|
+
input.setSelectionRange(3, 3);
|
|
52
|
+
fireEvent.select(input);
|
|
53
|
+
fireEvent.click(screen.getByTestId("pw-toggle"));
|
|
54
|
+
// Asked for again with the new secureTextEntry, so Android doesn't send it to the start.
|
|
55
|
+
expect(JSON.parse(screen.getByTestId("pw").dataset.selection!)).toEqual({ start: 3, end: 3 });
|
|
56
|
+
expect(screen.getByTestId("pw-toggle").getAttribute("aria-checked")).toBeNull();
|
|
57
|
+
// Typing hands the cursor back to the field.
|
|
58
|
+
fireEvent.change(screen.getByTestId("pw"), { target: { value: "hunter23" } });
|
|
59
|
+
expect(screen.getByTestId("pw").dataset.selection).toBeUndefined();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("NativeInputOTP", () => {
|
|
64
|
+
function Otp({ onComplete }: { onComplete: (v: string) => void }) {
|
|
65
|
+
const [v, setV] = useState("");
|
|
66
|
+
return <NativeInputOTP maxLength={4} value={v} onChange={setV} onComplete={onComplete} />;
|
|
67
|
+
}
|
|
68
|
+
it("fills the boxes and completes once", () => {
|
|
69
|
+
const done = vi.fn();
|
|
70
|
+
render(<Otp onComplete={done} />);
|
|
71
|
+
fireEvent.change(screen.getByTestId("native-input-otp-input"), { target: { value: "12 34" } });
|
|
72
|
+
expect(screen.getByTestId("native-input-otp-slot-3").textContent).toBe("4");
|
|
73
|
+
expect(done).toHaveBeenCalledWith("1234");
|
|
74
|
+
expect(screen.getByTestId("native-input-otp-input").getAttribute("aria-label")).toBe("One-time code");
|
|
75
|
+
});
|
|
76
|
+
it("tests the pattern against the whole code, as the web's input-otp does: a refused change keeps the code", () => {
|
|
77
|
+
const onChange = vi.fn();
|
|
78
|
+
const { rerender } = render(<NativeInputOTP maxLength={4} value="12" onChange={onChange} />);
|
|
79
|
+
fireEvent.change(screen.getByTestId("native-input-otp-input"), { target: { value: "12a" } });
|
|
80
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
81
|
+
expect(screen.getByTestId("native-input-otp-slot-1").textContent).toBe("2");
|
|
82
|
+
rerender(<NativeInputOTP maxLength={4} value="" onChange={onChange} pattern="^[A-Z0-9]+$" />);
|
|
83
|
+
fireEvent.change(screen.getByTestId("native-input-otp-input"), { target: { value: "AB1" } });
|
|
84
|
+
expect(onChange).toHaveBeenLastCalledWith("AB1");
|
|
85
|
+
});
|
|
86
|
+
it.each(["123-456", "123 456", " 12 34 56 "])("keeps a pasted or autofilled %j whole: no native cap cuts it first", (pasted) => {
|
|
87
|
+
const done = vi.fn();
|
|
88
|
+
function Six() {
|
|
89
|
+
const [v, setV] = useState("");
|
|
90
|
+
return <NativeInputOTP value={v} onChange={setV} onComplete={done} />;
|
|
91
|
+
}
|
|
92
|
+
render(<Six />);
|
|
93
|
+
const input = screen.getByTestId("native-input-otp-input");
|
|
94
|
+
// The native maxLength filter runs before onChangeText; with one, "123-456" arrived as "123-45".
|
|
95
|
+
expect(input.getAttribute("maxlength")).toBeNull();
|
|
96
|
+
fireEvent.change(input, { target: { value: pasted } });
|
|
97
|
+
expect(done).toHaveBeenCalledWith("123456");
|
|
98
|
+
});
|
|
99
|
+
it("is one labelled field VoiceOver can reach: not at 0 opacity, its text transparent", () => {
|
|
100
|
+
render(<NativeInputOTP value="12" onChange={() => {}} />);
|
|
101
|
+
const input = screen.getByTestId("native-input-otp-input");
|
|
102
|
+
expect((JSON.parse(input.dataset.style!) as { opacity: number }).opacity).toBeGreaterThan(0.01);
|
|
103
|
+
expect(input.className).not.toContain("opacity-0");
|
|
104
|
+
expect(input.className).toContain("text-transparent");
|
|
105
|
+
expect(input.dataset.caretHidden).toBe("true");
|
|
106
|
+
expect(input.getAttribute("aria-label")).toBe("One-time code");
|
|
107
|
+
// The boxes are drawing only: hidden, so the field is the one element.
|
|
108
|
+
expect(screen.getByTestId("native-input-otp-slot-0").closest("[aria-hidden='true']")).toBeTruthy();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe("NativeCalendar", () => {
|
|
113
|
+
it("picks a day, and moves between months", () => {
|
|
114
|
+
const onSelect = vi.fn();
|
|
115
|
+
render(<NativeCalendar defaultMonth={new Date(2026, 5, 1)} onSelect={onSelect} locale="en-US" today={new Date(2026, 5, 10)} />);
|
|
116
|
+
expect(screen.getByTestId("native-calendar-title").textContent).toBe("June 2026");
|
|
117
|
+
const day = screen.getByTestId("native-calendar-day-2026-06-03");
|
|
118
|
+
expect(day.getAttribute("aria-label")).toBe("Wednesday, June 3, 2026");
|
|
119
|
+
fireEvent.click(day);
|
|
120
|
+
expect(onSelect.mock.calls[0]![0]).toEqual(new Date(2026, 5, 3));
|
|
121
|
+
fireEvent.click(screen.getByTestId("native-calendar-next"));
|
|
122
|
+
expect(screen.getByTestId("native-calendar-title").textContent).toBe("July 2026");
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("picks a range in two presses", () => {
|
|
126
|
+
function Range() {
|
|
127
|
+
const [r, setR] = useState<{ from: Date | undefined; to?: Date | undefined } | undefined>();
|
|
128
|
+
return <NativeCalendar mode="range" selected={r} onSelect={setR} defaultMonth={new Date(2026, 0, 1)} />;
|
|
129
|
+
}
|
|
130
|
+
render(<Range />);
|
|
131
|
+
fireEvent.click(screen.getByTestId("native-calendar-day-2026-01-10"));
|
|
132
|
+
fireEvent.click(screen.getByTestId("native-calendar-day-2026-01-05"));
|
|
133
|
+
expect(screen.getByTestId("native-calendar-day-2026-01-07").getAttribute("aria-selected")).toBe("true");
|
|
134
|
+
expect(screen.getByTestId("native-calendar-day-2026-01-11").getAttribute("aria-selected")).toBe("false");
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("won't pick a disabled day", () => {
|
|
138
|
+
const onSelect = vi.fn();
|
|
139
|
+
render(<NativeCalendar defaultMonth={new Date(2026, 0, 1)} onSelect={onSelect} disabled={(d) => d.getDate() === 4} />);
|
|
140
|
+
const day = screen.getByTestId("native-calendar-day-2026-01-04");
|
|
141
|
+
expect(day.getAttribute("aria-disabled")).toBe("true");
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
describe("NativeCarousel", () => {
|
|
146
|
+
it("says which slide it shows, and moves with the dots and a screen reader's swipe", () => {
|
|
147
|
+
const onIndexChange = vi.fn();
|
|
148
|
+
render(
|
|
149
|
+
<NativeCarousel accessibilityLabel="Featured" onIndexChange={onIndexChange} showControls>
|
|
150
|
+
<Text>One</Text>
|
|
151
|
+
<Text>Two</Text>
|
|
152
|
+
<Text>Three</Text>
|
|
153
|
+
</NativeCarousel>,
|
|
154
|
+
);
|
|
155
|
+
const dots = screen.getByTestId("native-carousel-dots");
|
|
156
|
+
expect(dots.getAttribute("role")).toBe("adjustable");
|
|
157
|
+
expect(dots.getAttribute("aria-label")).toBe("Featured");
|
|
158
|
+
expect(dots.getAttribute("aria-valuetext")).toBe("Slide 1 of 3");
|
|
159
|
+
fireEvent.click(screen.getByTestId("native-carousel-dot-2"));
|
|
160
|
+
expect(onIndexChange).toHaveBeenLastCalledWith(2);
|
|
161
|
+
expect(screen.getByTestId("native-carousel-next").getAttribute("aria-disabled")).toBe("true");
|
|
162
|
+
a11y(dots, "decrement");
|
|
163
|
+
expect(onIndexChange).toHaveBeenLastCalledWith(1);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("leaves the slide's own buttons and the arrows reachable: the carousel isn't one element", () => {
|
|
167
|
+
render(
|
|
168
|
+
<NativeCarousel accessibilityLabel="Featured" showControls>
|
|
169
|
+
<NativeButton testID="book">Book</NativeButton>
|
|
170
|
+
<Text>Two</Text>
|
|
171
|
+
</NativeCarousel>,
|
|
172
|
+
);
|
|
173
|
+
const root = screen.getByTestId("native-carousel");
|
|
174
|
+
// No role on the container, so iOS doesn't fold the subtree into a single element.
|
|
175
|
+
expect(root.getAttribute("role")).toBeNull();
|
|
176
|
+
expect(root.getAttribute("aria-valuetext")).toBeNull();
|
|
177
|
+
expect(screen.getByTestId("book").closest("[aria-hidden='true']")).toBeNull();
|
|
178
|
+
expect(screen.getByTestId("native-carousel-next").getAttribute("role")).toBe("button");
|
|
179
|
+
// The slide off screen is hidden while dots and arrows move the pages.
|
|
180
|
+
expect(screen.getByTestId("native-carousel-slide-1").getAttribute("aria-hidden")).toBe("true");
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it("with no dots or arrows, keeps every slide reachable for the screen reader", () => {
|
|
184
|
+
render(
|
|
185
|
+
<NativeCarousel showDots={false}>
|
|
186
|
+
<Text>One</Text>
|
|
187
|
+
<Text>Two</Text>
|
|
188
|
+
</NativeCarousel>,
|
|
189
|
+
);
|
|
190
|
+
expect(screen.getByTestId("native-carousel-slide-1").getAttribute("aria-hidden")).toBeNull();
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it("slides to a dot's page without the effect cutting the animation short", () => {
|
|
194
|
+
render(
|
|
195
|
+
<NativeCarousel>
|
|
196
|
+
<Text>One</Text>
|
|
197
|
+
<Text>Two</Text>
|
|
198
|
+
<Text>Three</Text>
|
|
199
|
+
</NativeCarousel>,
|
|
200
|
+
);
|
|
201
|
+
const pages = screen.getByTestId("native-carousel-pages") as HTMLElement & { scrollTo: unknown };
|
|
202
|
+
const scrollTo = vi.fn();
|
|
203
|
+
pages.scrollTo = scrollTo;
|
|
204
|
+
act(() => void screen.getByTestId("native-carousel").dispatchEvent(new CustomEvent("layout", { detail: { width: 300, height: 100 } })));
|
|
205
|
+
expect(scrollTo).toHaveBeenLastCalledWith({ x: 0, animated: false });
|
|
206
|
+
scrollTo.mockClear();
|
|
207
|
+
fireEvent.click(screen.getByTestId("native-carousel-dot-2"));
|
|
208
|
+
expect(scrollTo.mock.calls).toEqual([[{ x: 600, animated: true }]]);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
describe("NativeSortableList", () => {
|
|
213
|
+
function List({ onReorder }: { onReorder: (from: number, to: number) => void | Promise<void> }) {
|
|
214
|
+
const [items, setItems] = useState(["Week 1", "Week 2", "Week 3"]);
|
|
215
|
+
return (
|
|
216
|
+
<NativeSortableList
|
|
217
|
+
label="Weeks"
|
|
218
|
+
items={items}
|
|
219
|
+
getKey={(i) => i}
|
|
220
|
+
getItemLabel={(i) => i}
|
|
221
|
+
onReorder={(from, to) => {
|
|
222
|
+
const next = items.slice();
|
|
223
|
+
const [x] = next.splice(from, 1);
|
|
224
|
+
next.splice(to, 0, x!);
|
|
225
|
+
setItems(next);
|
|
226
|
+
return onReorder(from, to);
|
|
227
|
+
}}
|
|
228
|
+
renderItem={(item, ctx) => (
|
|
229
|
+
<Text testID={`row-${ctx.index}`}>
|
|
230
|
+
{item}
|
|
231
|
+
</Text>
|
|
232
|
+
)}
|
|
233
|
+
/>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
it("moves an item with a screen reader's action and announces it", async () => {
|
|
238
|
+
const announce = vi.spyOn(AccessibilityInfo, "announceForAccessibility");
|
|
239
|
+
const onReorder = vi.fn();
|
|
240
|
+
render(<List onReorder={onReorder} />);
|
|
241
|
+
const first = screen.getByTestId("native-sortable-list-item-Week 1");
|
|
242
|
+
expect(first.getAttribute("data-a11y-actions")).toBe("moveDown,moveToBottom,longpress");
|
|
243
|
+
a11y(first, "moveToBottom");
|
|
244
|
+
expect(onReorder).toHaveBeenCalledWith(0, 2);
|
|
245
|
+
expect(screen.getByTestId("row-2").textContent).toBe("Week 1");
|
|
246
|
+
await act(async () => {});
|
|
247
|
+
expect(announce).toHaveBeenCalledWith("Week 1 moved to position 3 of 3.");
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("puts the order back when the move fails", async () => {
|
|
251
|
+
const announce = vi.spyOn(AccessibilityInfo, "announceForAccessibility");
|
|
252
|
+
function Failing() {
|
|
253
|
+
return (
|
|
254
|
+
<NativeSortableList
|
|
255
|
+
label="Weeks"
|
|
256
|
+
items={["A", "B"]}
|
|
257
|
+
getKey={(i) => i}
|
|
258
|
+
getItemLabel={(i) => i}
|
|
259
|
+
onReorder={() => Promise.reject(new Error("no"))}
|
|
260
|
+
renderItem={(item, ctx) => <Text testID={`row-${ctx.index}`}>{item}</Text>}
|
|
261
|
+
/>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
render(<Failing />);
|
|
265
|
+
a11y(screen.getByTestId("native-sortable-list-item-A"), "moveDown");
|
|
266
|
+
expect(screen.getByTestId("row-0").textContent).toBe("B");
|
|
267
|
+
await act(async () => {});
|
|
268
|
+
expect(screen.getByTestId("row-0").textContent).toBe("A");
|
|
269
|
+
expect(announce).toHaveBeenCalledWith("Couldn’t move A.");
|
|
270
|
+
});
|
|
271
|
+
type PanConfig = {
|
|
272
|
+
onPanResponderGrant: () => void;
|
|
273
|
+
onPanResponderMove: (e: unknown, g: { dy: number }) => void;
|
|
274
|
+
onPanResponderRelease: (e: unknown, g: { dy: number }) => void;
|
|
275
|
+
onPanResponderTerminationRequest: () => boolean;
|
|
276
|
+
onShouldBlockNativeResponder: () => boolean;
|
|
277
|
+
};
|
|
278
|
+
/** The responders built for the list's current order, one per row in order (the mock draws no gesture). */
|
|
279
|
+
function capturePans() {
|
|
280
|
+
const made: PanConfig[] = [];
|
|
281
|
+
const create = vi.spyOn(PanResponder, "create").mockImplementation((config: unknown) => {
|
|
282
|
+
made.push(config as PanConfig);
|
|
283
|
+
return { panHandlers: {} } as never;
|
|
284
|
+
});
|
|
285
|
+
return { rows: (n: number) => made.slice(-n), restore: () => create.mockRestore() };
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
it("drags a row by its handle, keeps the gesture from a parent ScrollView, and tells the screen", async () => {
|
|
289
|
+
const pans = capturePans();
|
|
290
|
+
const onReorder = vi.fn();
|
|
291
|
+
const onDragChange = vi.fn();
|
|
292
|
+
function Dragged() {
|
|
293
|
+
const [items, setItems] = useState(["A", "B", "C"]);
|
|
294
|
+
return (
|
|
295
|
+
<NativeSortableList
|
|
296
|
+
label="Weeks"
|
|
297
|
+
items={items}
|
|
298
|
+
getKey={(i) => i}
|
|
299
|
+
getItemLabel={(i) => i}
|
|
300
|
+
onDragChange={onDragChange}
|
|
301
|
+
onReorder={(from, to) => {
|
|
302
|
+
const next = items.slice();
|
|
303
|
+
const [x] = next.splice(from, 1);
|
|
304
|
+
next.splice(to, 0, x!);
|
|
305
|
+
setItems(next);
|
|
306
|
+
onReorder(from, to);
|
|
307
|
+
}}
|
|
308
|
+
renderItem={(item, ctx) => (
|
|
309
|
+
<Text testID={`row-${ctx.index}`}>
|
|
310
|
+
{item}
|
|
311
|
+
{ctx.handle}
|
|
312
|
+
</Text>
|
|
313
|
+
)}
|
|
314
|
+
/>
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
render(<Dragged />);
|
|
318
|
+
const [a] = pans.rows(3);
|
|
319
|
+
// A parent ScrollView asking for the gesture mid-drag is refused; Android's native scroll is blocked.
|
|
320
|
+
expect(a!.onPanResponderTerminationRequest()).toBe(false);
|
|
321
|
+
expect(a!.onShouldBlockNativeResponder()).toBe(true);
|
|
322
|
+
act(() => a!.onPanResponderGrant());
|
|
323
|
+
expect(onDragChange).toHaveBeenLastCalledWith(true);
|
|
324
|
+
// Two rows down (the default row height is 56).
|
|
325
|
+
act(() => a!.onPanResponderMove(null, { dy: 112 }));
|
|
326
|
+
expect(screen.getByTestId("row-2").textContent).toBe("A⋮⋮");
|
|
327
|
+
act(() => a!.onPanResponderRelease(null, { dy: 112 }));
|
|
328
|
+
expect(onDragChange).toHaveBeenLastCalledWith(false);
|
|
329
|
+
expect(onReorder).toHaveBeenCalledWith(0, 2);
|
|
330
|
+
await act(async () => {});
|
|
331
|
+
expect(screen.getByTestId("row-2").textContent).toBe("A⋮⋮");
|
|
332
|
+
pans.restore();
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it("calls the latest onReorder on a drop, not the one from when the order last changed", () => {
|
|
336
|
+
const pans = capturePans();
|
|
337
|
+
const calls: number[] = [];
|
|
338
|
+
function Counting() {
|
|
339
|
+
const [version, setVersion] = useState(1);
|
|
340
|
+
return (
|
|
341
|
+
<>
|
|
342
|
+
<Text testID="bump" onPress={() => setVersion((v) => v + 1)}>
|
|
343
|
+
bump
|
|
344
|
+
</Text>
|
|
345
|
+
<NativeSortableList
|
|
346
|
+
label="Weeks"
|
|
347
|
+
items={["A", "B"]}
|
|
348
|
+
getKey={(i) => i}
|
|
349
|
+
getItemLabel={(i) => i}
|
|
350
|
+
onReorder={() => {
|
|
351
|
+
calls.push(version);
|
|
352
|
+
}}
|
|
353
|
+
renderItem={(item) => <Text>{item}</Text>}
|
|
354
|
+
/>
|
|
355
|
+
</>
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
render(<Counting />);
|
|
359
|
+
const [a] = pans.rows(2);
|
|
360
|
+
fireEvent.click(screen.getByTestId("bump"));
|
|
361
|
+
act(() => a!.onPanResponderGrant());
|
|
362
|
+
act(() => a!.onPanResponderRelease(null, { dy: 56 }));
|
|
363
|
+
expect(calls).toEqual([2]);
|
|
364
|
+
pans.restore();
|
|
365
|
+
});
|
|
366
|
+
});
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { fireEvent, render, screen, within } from "@testing-library/react";
|
|
3
|
+
import { describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { Text } from "react-native";
|
|
5
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
6
|
+
import { WorkspaceScope } from "@marktiderman/genesis-core/hooks";
|
|
7
|
+
import type { Workspace } from "@marktiderman/genesis-core/workspaces";
|
|
8
|
+
import { GenesisModulesProvider } from "../../native-modules";
|
|
9
|
+
import { NativeChartContainer, nativeColor } from "../chart";
|
|
10
|
+
import { nativeThemeLight } from "@marktiderman/genesis-design-system/tokens";
|
|
11
|
+
import { NativeNoFeaturesFound, NativeNoFeedbackFound, NativeNoSearchResults } from "../empty-state";
|
|
12
|
+
import { NativeFollowUpList, NativeHeadlineNumbers, NativeReadinessChip, NativeResponsesToolbar, NativeSummaryCard } from "../resource";
|
|
13
|
+
import { NativeResourceSettingsPage, NativeSettingsRow, NativeToggleRow } from "../settings-row";
|
|
14
|
+
import { NativeStatCard, NativeStatusBadge, NativeUserAvatar } from "../stat-card";
|
|
15
|
+
import { NativeWorkspaceSwitcher } from "../workspace-switcher";
|
|
16
|
+
import { DashboardPage, DetailPage, DocumentPage, FormPage } from "../../layouts/pages";
|
|
17
|
+
|
|
18
|
+
describe("NativeChartContainer", () => {
|
|
19
|
+
const data = [
|
|
20
|
+
{ month: "Jan", visits: 120, signups: 12 },
|
|
21
|
+
{ month: "Feb", visits: 140, signups: 18 },
|
|
22
|
+
];
|
|
23
|
+
const config = { visits: { label: "Visits", color: "var(--chart-1)" }, signups: { label: "Signups", theme: { light: "#111111", dark: "#eeeeee" } } };
|
|
24
|
+
|
|
25
|
+
it("reads its values to a screen reader and draws a bar per value", () => {
|
|
26
|
+
render(<NativeChartContainer config={config} data={data} xKey="month" accessibilityLabel="Traffic" />);
|
|
27
|
+
expect(screen.getByRole("image").getAttribute("aria-label")).toBe("Traffic. Visits: Jan 120, Feb 140. Signups: Jan 12, Feb 18.");
|
|
28
|
+
expect(screen.getByTestId("native-chart-bar-1").children).toHaveLength(2);
|
|
29
|
+
expect(screen.getByText("Visits")).toBeTruthy(); // the legend, with two series
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("draws a theme colour that isn't a chart token from the native theme, and the foreground for one it lacks", () => {
|
|
33
|
+
const themed = {
|
|
34
|
+
a: { label: "A", color: "hsl(var(--success))" },
|
|
35
|
+
b: { label: "B", color: "var(--not-a-token)" },
|
|
36
|
+
c: { label: "C", color: "#123456" },
|
|
37
|
+
d: { label: "D", color: "hsl(var(--primary))" },
|
|
38
|
+
};
|
|
39
|
+
render(<NativeChartContainer config={themed} data={[{ month: "Jan", a: 1, b: 2, c: 3, d: 4 }]} xKey="month" />);
|
|
40
|
+
const fills = Array.from(screen.getByTestId("native-chart-bar-0").children).map(
|
|
41
|
+
(bar) => (JSON.parse((bar as HTMLElement).dataset.style!) as { backgroundColor: string }).backgroundColor,
|
|
42
|
+
);
|
|
43
|
+
expect(fills).toEqual([nativeThemeLight.success, nativeThemeLight.foreground, "#123456", nativeThemeLight.primaryText]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("reads a theme variable in linear time, however long the string", () => {
|
|
47
|
+
const evil = ["var(" + " ".repeat(50_000) + "--x", "hsl(var(--" + "a-".repeat(25_000) + ")", "var(--" + "-".repeat(50_000)];
|
|
48
|
+
nativeColor("var(--chart-1)", nativeThemeLight);
|
|
49
|
+
for (const color of evil) {
|
|
50
|
+
const start = performance.now();
|
|
51
|
+
expect(nativeColor(color, nativeThemeLight)).toBeUndefined();
|
|
52
|
+
expect(performance.now() - start).toBeLessThan(50);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("draws lines with the SVG module, and the points without it", () => {
|
|
57
|
+
const { rerender } = render(<NativeChartContainer config={config} data={data} xKey="month" type="line" />);
|
|
58
|
+
expect(screen.getByTestId("native-chart-point-visits-1")).toBeTruthy();
|
|
59
|
+
const Svg = ({ children, testID }: { children?: React.ReactNode; testID?: string }) => <svg data-testid={testID}>{children}</svg>;
|
|
60
|
+
const Path = ({ d, testID }: { d: string; testID?: string }) => <path d={d} data-testid={testID} />;
|
|
61
|
+
rerender(
|
|
62
|
+
<GenesisModulesProvider modules={{ svg: { Svg, Path } }}>
|
|
63
|
+
<NativeChartContainer config={config} data={data} xKey="month" type="area" />
|
|
64
|
+
</GenesisModulesProvider>,
|
|
65
|
+
);
|
|
66
|
+
// Width comes from layout; before it is measured the points stand in.
|
|
67
|
+
expect(screen.queryByTestId("native-chart-svg") ?? screen.getByTestId("native-chart-point-visits-0")).toBeTruthy();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("stat card, status badge, avatar", () => {
|
|
72
|
+
it("StatCard reads its label, value and trend as one, and presses", () => {
|
|
73
|
+
const onPress = vi.fn();
|
|
74
|
+
render(<NativeStatCard label="Members" value={42} trend={{ value: -3, label: "this week" }} onPress={onPress} />);
|
|
75
|
+
const button = screen.getByRole("button");
|
|
76
|
+
expect(button.getAttribute("aria-label")).toBe("Members, 42, -3% this week");
|
|
77
|
+
fireEvent.click(button);
|
|
78
|
+
expect(onPress).toHaveBeenCalled();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("StatusBadge words and tint come from the status", () => {
|
|
82
|
+
render(<NativeStatusBadge status="offTrack" />);
|
|
83
|
+
expect(screen.getByText("Off track")).toBeTruthy();
|
|
84
|
+
expect(screen.getByTestId("status-badge-offTrack").className).toContain("bg-destructive/15");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("UserAvatar names the person and shows initials", () => {
|
|
88
|
+
render(<NativeUserAvatar name="Ada Lovelace" />);
|
|
89
|
+
expect(screen.getByRole("image").getAttribute("aria-label")).toBe("Ada Lovelace");
|
|
90
|
+
expect(screen.getByText("AL")).toBeTruthy();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe("resource pieces", () => {
|
|
95
|
+
it("ReadinessChip says what's left and opens the checks", () => {
|
|
96
|
+
const onPress = vi.fn();
|
|
97
|
+
render(<NativeReadinessChip readiness={{ state: "problems", problems: 2, warnings: 0, findings: [] } as never} onPress={onPress} />);
|
|
98
|
+
fireEvent.click(screen.getByRole("button"));
|
|
99
|
+
expect(onPress).toHaveBeenCalled();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("HeadlineNumbers and SummaryCard draw their tiles", () => {
|
|
103
|
+
render(
|
|
104
|
+
<>
|
|
105
|
+
<NativeHeadlineNumbers numbers={[{ key: "n", label: "Responses", value: 24, detail: "+4", tone: "positive" }]} />
|
|
106
|
+
<NativeSummaryCard title="Q1" meta="24 responses">
|
|
107
|
+
<Text>bars</Text>
|
|
108
|
+
</NativeSummaryCard>
|
|
109
|
+
</>,
|
|
110
|
+
);
|
|
111
|
+
expect(screen.getByTestId("headline-n")).toBeTruthy();
|
|
112
|
+
expect(screen.getByText("24 responses")).toBeTruthy();
|
|
113
|
+
expect(screen.getByText("bars")).toBeTruthy();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("FollowUpList lists entries with their actions, or says there's nothing", () => {
|
|
117
|
+
const { rerender } = render(
|
|
118
|
+
<NativeFollowUpList
|
|
119
|
+
entries={[{ id: "1", name: "Leo", comment: null, rating: { value: 2, max: 5 }, tag: { label: "New lead", tone: "info" } }]}
|
|
120
|
+
actions={() => <Text>Reply</Text>}
|
|
121
|
+
/>,
|
|
122
|
+
);
|
|
123
|
+
const entry = screen.getByTestId("follow-up-1");
|
|
124
|
+
expect(within(entry).getByText("No comment")).toBeTruthy();
|
|
125
|
+
expect(within(entry).getByLabelText("Rated 2 out of 5")).toBeTruthy();
|
|
126
|
+
expect(within(entry).getByText("Reply")).toBeTruthy();
|
|
127
|
+
rerender(<NativeFollowUpList entries={[]} />);
|
|
128
|
+
expect(screen.getByText(/Nothing to follow up/)).toBeTruthy();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("ResponsesToolbar switches between summary and each response", () => {
|
|
132
|
+
const onViewChange = vi.fn();
|
|
133
|
+
render(<NativeResponsesToolbar view="summary" onViewChange={onViewChange} labels={{ each: "Each submission" }} />);
|
|
134
|
+
fireEvent.click(screen.getByText("Each submission"));
|
|
135
|
+
expect(onViewChange).toHaveBeenCalledWith("each");
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
describe("settings rows", () => {
|
|
140
|
+
it("SettingsRow shows its control; ToggleRow is one switch that flips", () => {
|
|
141
|
+
const onChange = vi.fn();
|
|
142
|
+
render(
|
|
143
|
+
<>
|
|
144
|
+
<NativeSettingsRow label="Version" description="The app's build">
|
|
145
|
+
<Text>1.2.3</Text>
|
|
146
|
+
</NativeSettingsRow>
|
|
147
|
+
<NativeToggleRow label="Email me" description="Once a week" onCheckedChange={onChange} />
|
|
148
|
+
</>,
|
|
149
|
+
);
|
|
150
|
+
expect(screen.getByText("1.2.3")).toBeTruthy();
|
|
151
|
+
const row = screen.getByTestId("toggle-row");
|
|
152
|
+
expect(row.getAttribute("role")).toBe("switch");
|
|
153
|
+
expect(row.getAttribute("aria-checked")).toBe("false");
|
|
154
|
+
fireEvent.click(row);
|
|
155
|
+
expect(onChange).toHaveBeenCalledWith(true);
|
|
156
|
+
expect(row.getAttribute("aria-checked")).toBe("true");
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("ResourceSettingsPage draws sections as cards and runs a link-only section's onSelect", () => {
|
|
160
|
+
const onSelect = vi.fn();
|
|
161
|
+
render(
|
|
162
|
+
<NativeResourceSettingsPage
|
|
163
|
+
sections={[
|
|
164
|
+
{ id: "general", title: "General", content: <NativeToggleRow label="Open" /> },
|
|
165
|
+
{ id: "danger", title: "Danger zone", onSelect },
|
|
166
|
+
]}
|
|
167
|
+
/>,
|
|
168
|
+
);
|
|
169
|
+
expect(screen.getByTestId("resource-settings-page-section-general")).toBeTruthy();
|
|
170
|
+
expect(screen.queryByTestId("resource-settings-page-section-danger")).toBeNull();
|
|
171
|
+
fireEvent.click(screen.getByTestId("resource-settings-page-link-danger"));
|
|
172
|
+
expect(onSelect).toHaveBeenCalled();
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
describe("Fragment children", () => {
|
|
177
|
+
it("counts each row inside a Fragment: a stat tile each, and dividers between settings rows", () => {
|
|
178
|
+
render(
|
|
179
|
+
<>
|
|
180
|
+
<DashboardPage
|
|
181
|
+
title="Today"
|
|
182
|
+
stats={
|
|
183
|
+
<>
|
|
184
|
+
<Text>one</Text>
|
|
185
|
+
{false}
|
|
186
|
+
<>
|
|
187
|
+
<Text>two</Text>
|
|
188
|
+
<Text>three</Text>
|
|
189
|
+
</>
|
|
190
|
+
</>
|
|
191
|
+
}
|
|
192
|
+
/>
|
|
193
|
+
<NativeResourceSettingsPage
|
|
194
|
+
sections={[
|
|
195
|
+
{
|
|
196
|
+
id: "general",
|
|
197
|
+
title: "General",
|
|
198
|
+
content: (
|
|
199
|
+
<>
|
|
200
|
+
<NativeToggleRow label="Open" rowTestID="r1" />
|
|
201
|
+
<NativeToggleRow label="Public" rowTestID="r2" />
|
|
202
|
+
<NativeToggleRow label="Listed" rowTestID="r3" />
|
|
203
|
+
</>
|
|
204
|
+
),
|
|
205
|
+
},
|
|
206
|
+
]}
|
|
207
|
+
/>
|
|
208
|
+
</>,
|
|
209
|
+
);
|
|
210
|
+
expect(screen.getByTestId("dashboard-page-stats").children).toHaveLength(3);
|
|
211
|
+
const section = screen.getByTestId("resource-settings-page-section-general");
|
|
212
|
+
expect(section.querySelectorAll(".h-px.bg-border")).toHaveLength(2);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe("empty-state presets", () => {
|
|
217
|
+
it("say the web's words", () => {
|
|
218
|
+
const onClear = vi.fn();
|
|
219
|
+
render(
|
|
220
|
+
<>
|
|
221
|
+
<NativeNoFeaturesFound />
|
|
222
|
+
<NativeNoFeedbackFound />
|
|
223
|
+
<NativeNoSearchResults query="kettle" onClear={onClear} />
|
|
224
|
+
</>,
|
|
225
|
+
);
|
|
226
|
+
expect(screen.getByText("No features found")).toBeTruthy();
|
|
227
|
+
expect(screen.getByText("No feedback yet")).toBeTruthy();
|
|
228
|
+
expect(screen.getByText('No results found for "kettle". Try a different search term.')).toBeTruthy();
|
|
229
|
+
fireEvent.click(screen.getByTestId("no-search-results-clear"));
|
|
230
|
+
expect(onClear).toHaveBeenCalled();
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
describe("page layouts", () => {
|
|
235
|
+
it("DashboardPage, DetailPage, DocumentPage and FormPage draw their title blocks and bodies", () => {
|
|
236
|
+
render(
|
|
237
|
+
<>
|
|
238
|
+
<DashboardPage title="Today" subtitle="Tuesday" stats={[<Text key="a">tile</Text>]}>
|
|
239
|
+
<Text>dash body</Text>
|
|
240
|
+
</DashboardPage>
|
|
241
|
+
<DetailPage title="Ada" breadcrumb="People" sidebar={<Text>side</Text>}>
|
|
242
|
+
<Text>detail body</Text>
|
|
243
|
+
</DetailPage>
|
|
244
|
+
<DocumentPage title="Handbook" icon="📘">
|
|
245
|
+
<Text>doc body</Text>
|
|
246
|
+
</DocumentPage>
|
|
247
|
+
<FormPage title="New class" errors="Fix the time" actions={<Text>Save</Text>}>
|
|
248
|
+
<Text>form body</Text>
|
|
249
|
+
</FormPage>
|
|
250
|
+
</>,
|
|
251
|
+
);
|
|
252
|
+
expect(screen.getAllByRole("header").map((h) => h.textContent)).toEqual(["Today", "Ada", "Handbook", "New class"]);
|
|
253
|
+
expect(screen.getByTestId("dashboard-page-stats").textContent).toBe("tile");
|
|
254
|
+
expect(screen.getByTestId("detail-page-sidebar").textContent).toBe("side");
|
|
255
|
+
expect(screen.getByTestId("document-page-icon").textContent).toBe("📘");
|
|
256
|
+
expect(screen.getByTestId("form-page-errors").textContent).toContain("Fix the time");
|
|
257
|
+
expect(screen.getByTestId("form-page-actions").textContent).toBe("Save");
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
describe("NativeWorkspaceSwitcher", () => {
|
|
262
|
+
const workspaces: Workspace[] = [
|
|
263
|
+
{ id: "me", kind: "personal", label: "Personal", path: "/me", scope: {} },
|
|
264
|
+
{ id: "acme", kind: "tenant", label: "Acme Studio", path: "/o/acme", scope: { orgId: "acme" }, badge: 3 },
|
|
265
|
+
{ id: "west", kind: "tenant", label: "West Gym", path: "/o/west", scope: { orgId: "west" } },
|
|
266
|
+
];
|
|
267
|
+
|
|
268
|
+
it("lists the scope's workspaces by kind and goes to the picked one", async () => {
|
|
269
|
+
const onSelect = vi.fn();
|
|
270
|
+
function Screen() {
|
|
271
|
+
const [open, setOpen] = useState(false);
|
|
272
|
+
return (
|
|
273
|
+
<QueryClientProvider client={new QueryClient()}>
|
|
274
|
+
<WorkspaceScope viewer="u-1" timeZone="UTC" workspaces={workspaces} pathname="/o/acme/classes">
|
|
275
|
+
<NativeWorkspaceSwitcher onSelect={onSelect} open={open} onOpenChange={setOpen} />
|
|
276
|
+
</WorkspaceScope>
|
|
277
|
+
</QueryClientProvider>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
render(<Screen />);
|
|
281
|
+
const trigger = screen.getByTestId("workspace-switcher-trigger");
|
|
282
|
+
expect(trigger.getAttribute("aria-label")).toBe("Acme Studio");
|
|
283
|
+
fireEvent.click(trigger);
|
|
284
|
+
expect(await screen.findByText("Organizations")).toBeTruthy();
|
|
285
|
+
expect(screen.getByLabelText("3 new")).toBeTruthy();
|
|
286
|
+
// Rows are radios in their group, the current one checked, and a row reads its badge.
|
|
287
|
+
const acme = screen.getByTestId("workspace-switcher-option-acme");
|
|
288
|
+
expect(acme.getAttribute("role")).toBe("radio");
|
|
289
|
+
expect(acme.getAttribute("aria-checked")).toBe("true");
|
|
290
|
+
expect(acme.getAttribute("aria-label")).toBe("Acme Studio, 3 new");
|
|
291
|
+
expect(screen.getByTestId("workspace-switcher-option-west").getAttribute("aria-checked")).toBe("false");
|
|
292
|
+
fireEvent.click(screen.getByTestId("workspace-switcher-option-west"));
|
|
293
|
+
expect(onSelect).toHaveBeenCalledWith(workspaces[2], "/o/west/classes");
|
|
294
|
+
});
|
|
295
|
+
});
|