@kahitsan/ksui 0.51.0-solid2.1 → 0.51.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 +0 -10
- package/package.json +6 -8
- package/src/components/base/AccountAvatar.tsx +1 -1
- package/src/components/base/ActionMenu.tsx +5 -7
- package/src/components/base/AddAttachmentTile.tsx +6 -6
- package/src/components/base/BadgeSelect.tsx +9 -11
- package/src/components/base/Button.tsx +41 -35
- package/src/components/base/CameraCapture.tsx +2 -5
- package/src/components/base/CopyButton.tsx +1 -2
- package/src/components/base/DataTable.tsx +112 -91
- package/src/components/base/DatePicker.tsx +17 -15
- package/src/components/base/DateTile.tsx +12 -14
- package/src/components/base/Dropdown.tsx +5 -6
- package/src/components/base/ExistingAttachmentTile.test.tsx +3 -3
- package/src/components/base/ExistingAttachmentTile.tsx +4 -6
- package/src/components/base/EyebrowBadge.tsx +1 -2
- package/src/components/base/FormErrorBanner.tsx +1 -2
- package/src/components/base/FormField.tsx +1 -1
- package/src/components/base/ImageCropper.tsx +3 -3
- package/src/components/base/ImageViewer.test.tsx +0 -2
- package/src/components/base/ImageViewer.tsx +3 -4
- package/src/components/base/KpiCard.tsx +2 -3
- package/src/components/base/Modal.test.tsx +2 -3
- package/src/components/base/Modal.tsx +12 -11
- package/src/components/base/ModalHeader.tsx +1 -2
- package/src/components/base/MonthCalendar.tsx +1 -2
- package/src/components/base/MultiSelectGroup.tsx +5 -7
- package/src/components/base/ProgressBar.tsx +17 -8
- package/src/components/base/RadioCardGroup.tsx +12 -14
- package/src/components/base/SectionHeading.tsx +1 -2
- package/src/components/base/SegmentedFilter.tsx +8 -10
- package/src/components/base/SocialLinksBar.tsx +1 -2
- package/src/components/base/StatusIndicator.tsx +1 -2
- package/src/components/base/StatusPill.tsx +1 -1
- package/src/components/base/TagPill.tsx +1 -1
- package/src/components/base/ThemeToggle.tsx +11 -5
- package/src/components/base/Tooltip.tsx +1 -2
- package/src/components/composite/AccountRadioPicker.tsx +11 -14
- package/src/components/composite/ComboBox.tsx +13 -18
- package/src/components/composite/CustomRenderer.tsx +1 -1
- package/src/components/composite/FileField.tsx +3 -6
- package/src/components/composite/FlowGraph.tsx +12 -15
- package/src/components/composite/FlowRunner.test.tsx +0 -2
- package/src/components/composite/FlowRunner.tsx +1 -2
- package/src/components/composite/FormActions.tsx +1 -1
- package/src/components/composite/FormAdvancedSection.tsx +13 -13
- package/src/components/composite/LiveTimer.tsx +14 -8
- package/src/components/composite/MarkdownNotes.tsx +1 -2
- package/src/components/composite/MentionTextarea.tsx +22 -31
- package/src/components/composite/MultiPeriodPicker.tsx +9 -11
- package/src/components/composite/NotFound.tsx +15 -4
- package/src/components/composite/PaymentAccountPicker.tsx +24 -19
- package/src/components/composite/SalesBodyEditor.tsx +7 -10
- package/src/components/composite/SearchableSelect.tsx +13 -14
- package/src/components/composite/SecretReveal.tsx +2 -2
- package/src/components/composite/TransactionForm.tsx +42 -52
- package/src/components/composite/TransferAccountsPicker.tsx +10 -11
- package/src/components/composite/TransferFeeChip.tsx +6 -7
- package/src/components/composite/VoucherPicker.test.tsx +48 -55
- package/src/components/composite/VoucherPicker.tsx +27 -36
- package/src/components/composite/picker-engine.ts +14 -20
- package/src/components/composite/resource/ResourcePage.test.tsx +1 -21
- package/src/components/composite/resource/ResourcePage.tsx +8 -23
- package/src/components/composite/resource/cells.tsx +1 -1
- package/src/icons/README.md +3 -1
- package/src/icons/artwork/bir-croc.ts +2 -0
- package/src/icons/bir-croc.tsx +4 -0
- package/src/icons/create-artwork-icon.test.tsx +1 -4
- package/src/icons/create-artwork-icon.tsx +24 -10
- package/src/icons/index.ts +1 -0
- package/src/icons/registry.ts +1 -0
- package/src/utils/account-icons.ts +1 -2
- package/src/utils/accounts-index.tsx +5 -8
- package/src/utils/confirm.tsx +1 -1
- package/src/utils/dom.ts +6 -7
- package/src/utils/highlight.tsx +1 -1
- package/src/utils/modal-layer.ts +3 -3
- package/src/utils/object-url-resource.ts +8 -11
- package/src/utils/top-layer.ts +8 -9
- package/src/components/base/Button.test.tsx +0 -23
- package/src/utils/aria.ts +0 -13
- package/src/utils/fetch-resource.ts +0 -59
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import X from "../../icons/x";
|
|
2
|
-
import { ariaTri } from "../../utils/aria";
|
|
3
2
|
|
|
4
3
|
export interface TransferFeeChipProps {
|
|
5
4
|
enabled: boolean;
|
|
@@ -12,20 +11,20 @@ export default function TransferFeeChip(props: TransferFeeChipProps) {
|
|
|
12
11
|
type="button"
|
|
13
12
|
data-testid="transactions-form-transfer-fee-toggle"
|
|
14
13
|
onClick={props.onToggle}
|
|
15
|
-
class=
|
|
14
|
+
class="flex items-center gap-1.5 self-center rounded-md border px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wider transition-colors cursor-pointer"
|
|
15
|
+
classList={{
|
|
16
16
|
"border-[color-mix(in_srgb,var(--ks-info,#38bdf8)_50%,transparent)] bg-[color-mix(in_srgb,var(--ks-info,#38bdf8)_15%,transparent)] text-[var(--ks-info-fg,#7dd3fc)] hover:bg-[color-mix(in_srgb,var(--ks-info,#38bdf8)_25%,transparent)]":
|
|
17
17
|
props.enabled,
|
|
18
18
|
"border-[var(--ks-input-border,#3f3f46)] bg-[color-mix(in_srgb,var(--ks-surface,#0f0f0f)_60%,transparent)] text-[var(--ks-fg-muted,#a1a1aa)] hover:border-[color-mix(in_srgb,var(--ks-info,#38bdf8)_40%,transparent)] hover:text-[var(--ks-info-fg,#7dd3fc)]":
|
|
19
19
|
!props.enabled,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
aria-pressed={ariaTri(props.enabled)}
|
|
20
|
+
}}
|
|
21
|
+
aria-pressed={props.enabled}
|
|
23
22
|
aria-label={props.enabled ? "Remove transfer fee" : "Add transfer fee"}
|
|
24
23
|
>
|
|
25
24
|
<span>Fees</span>
|
|
26
25
|
<span
|
|
27
|
-
class=
|
|
28
|
-
|
|
26
|
+
class="inline-flex items-center justify-center"
|
|
27
|
+
classList={{ hidden: !props.enabled }}
|
|
29
28
|
aria-hidden="true"
|
|
30
29
|
>
|
|
31
30
|
<X size={11} />
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
// The picker pages the list in from the server (page/limit) and delegates the
|
|
2
2
|
// search to it, so these assert the request contract as well as the rendering.
|
|
3
|
-
import { flush } from "solid-js";
|
|
4
3
|
import { describe, expect, it, vi } from "vitest";
|
|
5
4
|
import { createSignal } from "solid-js";
|
|
6
5
|
import { fireEvent, render, waitFor } from "@solidjs/testing-library";
|
|
7
6
|
import VoucherPicker, { type VoucherOption } from "./VoucherPicker";
|
|
8
7
|
|
|
9
|
-
// Solid 2 commits writes on a microtask; flush so the next assertion sees them.
|
|
10
|
-
const click = (el: Element) => {
|
|
11
|
-
fireEvent.click(el);
|
|
12
|
-
flush();
|
|
13
|
-
};
|
|
14
|
-
|
|
15
8
|
/** Captures every requested URL and serves pages out of `rows`. */
|
|
16
9
|
function mockPagedFetch(rows: VoucherOption[]) {
|
|
17
10
|
const calls: string[] = [];
|
|
@@ -66,7 +59,7 @@ describe("VoucherPicker fetchUrl", () => {
|
|
|
66
59
|
const { getByTestId } = render(() => (
|
|
67
60
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={100} packageIds={[]} />
|
|
68
61
|
));
|
|
69
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
62
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
70
63
|
|
|
71
64
|
await waitFor(() => expect(calls.length).toBeGreaterThan(0));
|
|
72
65
|
expect(calls[0]).toContain("/api/vouchers");
|
|
@@ -84,7 +77,7 @@ describe("VoucherPicker fetchUrl", () => {
|
|
|
84
77
|
fetchUrl="/api/counter/vouchers"
|
|
85
78
|
/>
|
|
86
79
|
));
|
|
87
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
80
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
88
81
|
|
|
89
82
|
await waitFor(() => expect(calls.length).toBeGreaterThan(0));
|
|
90
83
|
expect(calls[0]).toContain("/api/counter/vouchers");
|
|
@@ -95,7 +88,7 @@ describe("VoucherPicker fetchUrl", () => {
|
|
|
95
88
|
const { getByTestId, getAllByTestId } = render(() => (
|
|
96
89
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
97
90
|
));
|
|
98
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
91
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
99
92
|
|
|
100
93
|
await waitFor(() =>
|
|
101
94
|
expect(getAllByTestId(/^voucher-picker-result-/).length).toBeGreaterThan(0),
|
|
@@ -116,18 +109,18 @@ describe("VoucherPicker dialog", () => {
|
|
|
116
109
|
));
|
|
117
110
|
|
|
118
111
|
expect(queryByTestId("voucher-picker-popup")).toBeNull();
|
|
119
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
112
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
120
113
|
|
|
121
114
|
await waitFor(() => expect(getByTestId("voucher-picker-result-1")).toBeTruthy());
|
|
122
115
|
expect(getByTestId("voucher-picker-popup").closest("dialog")).not.toBeNull();
|
|
123
116
|
|
|
124
117
|
// Staging a row must not reach the consumer yet; the footer no longer
|
|
125
118
|
// repeats the code (it's in the listing), so the confirm enabling is the signal.
|
|
126
|
-
click(getByTestId("voucher-picker-result-1"));
|
|
119
|
+
fireEvent.click(getByTestId("voucher-picker-result-1"));
|
|
127
120
|
expect(onChange).not.toHaveBeenCalled();
|
|
128
121
|
expect(getByTestId("voucher-picker-confirm").hasAttribute("disabled")).toBe(false);
|
|
129
122
|
|
|
130
|
-
click(getByTestId("voucher-picker-confirm"));
|
|
123
|
+
fireEvent.click(getByTestId("voucher-picker-confirm"));
|
|
131
124
|
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ id: 1, code: "SAVE20" }));
|
|
132
125
|
await waitFor(() => expect(queryByTestId("voucher-picker-popup")).toBeNull());
|
|
133
126
|
});
|
|
@@ -138,11 +131,11 @@ describe("VoucherPicker dialog", () => {
|
|
|
138
131
|
const { getByTestId, queryByTestId } = render(() => (
|
|
139
132
|
<VoucherPicker selected={null} onChange={onChange} subtotal={1000} packageIds={[]} />
|
|
140
133
|
));
|
|
141
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
134
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
142
135
|
await waitFor(() => expect(getByTestId("voucher-picker-result-1")).toBeTruthy());
|
|
143
136
|
|
|
144
|
-
click(getByTestId("voucher-picker-result-1"));
|
|
145
|
-
click(getByTestId("voucher-picker-cancel"));
|
|
137
|
+
fireEvent.click(getByTestId("voucher-picker-result-1"));
|
|
138
|
+
fireEvent.click(getByTestId("voucher-picker-cancel"));
|
|
146
139
|
|
|
147
140
|
expect(onChange).not.toHaveBeenCalled();
|
|
148
141
|
await waitFor(() => expect(queryByTestId("voucher-picker-popup")).toBeNull());
|
|
@@ -153,13 +146,13 @@ describe("VoucherPicker dialog", () => {
|
|
|
153
146
|
const { getByTestId } = render(() => (
|
|
154
147
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
155
148
|
));
|
|
156
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
149
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
157
150
|
await waitFor(() => expect(getByTestId("voucher-picker-result-1")).toBeTruthy());
|
|
158
151
|
|
|
159
|
-
click(getByTestId("voucher-picker-result-1"));
|
|
152
|
+
fireEvent.click(getByTestId("voucher-picker-result-1"));
|
|
160
153
|
expect(getByTestId("voucher-picker-confirm").hasAttribute("disabled")).toBe(false);
|
|
161
154
|
|
|
162
|
-
click(getByTestId("voucher-picker-result-1"));
|
|
155
|
+
fireEvent.click(getByTestId("voucher-picker-result-1"));
|
|
163
156
|
expect(getByTestId("voucher-picker-confirm").hasAttribute("disabled")).toBe(true);
|
|
164
157
|
expect(getByTestId("voucher-picker-draft-summary").textContent).toContain("No voucher selected");
|
|
165
158
|
});
|
|
@@ -172,7 +165,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
172
165
|
const { getByTestId, queryByTestId } = render(() => (
|
|
173
166
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
174
167
|
));
|
|
175
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
168
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
176
169
|
await waitFor(() => expect(getByTestId("voucher-picker-result-1")).toBeTruthy());
|
|
177
170
|
|
|
178
171
|
fireEvent.input(getByTestId("voucher-picker-search"), { target: { value: "partner" } });
|
|
@@ -193,14 +186,14 @@ describe("VoucherPicker dialog", () => {
|
|
|
193
186
|
const { getByTestId } = render(() => (
|
|
194
187
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
195
188
|
));
|
|
196
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
189
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
197
190
|
|
|
198
191
|
await waitFor(() => expect(getByTestId("voucher-picker-result-50")).toBeTruthy());
|
|
199
192
|
expect(getByTestId("voucher-picker-result-50").textContent).toContain(
|
|
200
193
|
"BISCAST ACES outreach discount",
|
|
201
194
|
);
|
|
202
195
|
|
|
203
|
-
click(getByTestId("voucher-picker-result-50"));
|
|
196
|
+
fireEvent.click(getByTestId("voucher-picker-result-50"));
|
|
204
197
|
// The footer shows the description under the summary, beside the buttons.
|
|
205
198
|
expect(getByTestId("voucher-picker-draft-description").textContent).toContain(
|
|
206
199
|
"BISCAST ACES outreach discount",
|
|
@@ -215,7 +208,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
215
208
|
const { getByTestId, queryByTestId } = render(() => (
|
|
216
209
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
217
210
|
));
|
|
218
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
211
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
219
212
|
await waitFor(() => expect(getByTestId("voucher-picker-result-51")).toBeTruthy());
|
|
220
213
|
|
|
221
214
|
fireEvent.input(getByTestId("voucher-picker-search"), {
|
|
@@ -239,7 +232,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
239
232
|
const { getByTestId } = render(() => (
|
|
240
233
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
241
234
|
));
|
|
242
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
235
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
243
236
|
|
|
244
237
|
await waitFor(() => expect(getByTestId("voucher-picker-result-53")).toBeTruthy());
|
|
245
238
|
// Identical rows — a whitespace-only description must render nothing extra.
|
|
@@ -254,7 +247,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
254
247
|
const { getByTestId } = render(() => (
|
|
255
248
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
256
249
|
));
|
|
257
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
250
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
258
251
|
|
|
259
252
|
await waitFor(() => expect(getByTestId("voucher-picker-result-9")).toBeTruthy());
|
|
260
253
|
expect(getByTestId("voucher-picker-result-9").textContent).toContain("Expires in 3 days");
|
|
@@ -268,7 +261,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
268
261
|
const { getByTestId } = render(() => (
|
|
269
262
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
270
263
|
));
|
|
271
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
264
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
272
265
|
|
|
273
266
|
await waitFor(() => expect(getByTestId("voucher-picker-result-10")).toBeTruthy());
|
|
274
267
|
const text = getByTestId("voucher-picker-result-10").textContent ?? "";
|
|
@@ -283,7 +276,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
283
276
|
const { getByTestId } = render(() => (
|
|
284
277
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
285
278
|
));
|
|
286
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
279
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
287
280
|
|
|
288
281
|
await waitFor(() => expect(getByTestId("voucher-picker-result-20")).toBeTruthy());
|
|
289
282
|
expect(getByTestId("voucher-picker-result-20").textContent).toContain("3/10 used");
|
|
@@ -294,7 +287,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
294
287
|
const { getByTestId } = render(() => (
|
|
295
288
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
296
289
|
));
|
|
297
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
290
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
298
291
|
|
|
299
292
|
await waitFor(() => expect(getByTestId("voucher-picker-result-21")).toBeTruthy());
|
|
300
293
|
expect(getByTestId("voucher-picker-result-21").textContent).not.toContain("used");
|
|
@@ -307,7 +300,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
307
300
|
const { getByTestId, queryByTestId } = render(() => (
|
|
308
301
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
309
302
|
));
|
|
310
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
303
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
311
304
|
|
|
312
305
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-22")).toBeTruthy());
|
|
313
306
|
// Never selectable — it would be rejected at charge time.
|
|
@@ -320,7 +313,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
320
313
|
const { getByTestId } = render(() => (
|
|
321
314
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
322
315
|
));
|
|
323
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
316
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
324
317
|
|
|
325
318
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-7")).toBeTruthy());
|
|
326
319
|
expect(getByTestId("voucher-picker-inapplicable-7").textContent).toContain("minimum");
|
|
@@ -337,7 +330,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
337
330
|
packageIds={[]}
|
|
338
331
|
/>
|
|
339
332
|
));
|
|
340
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
333
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
341
334
|
|
|
342
335
|
await waitFor(() => expect(getByTestId("voucher-picker-result-3")).toBeTruthy());
|
|
343
336
|
// 20% of 99 and of 118, both rounded the same way the server rounds.
|
|
@@ -355,7 +348,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
355
348
|
packageIds={[]}
|
|
356
349
|
/>
|
|
357
350
|
));
|
|
358
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
351
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
359
352
|
|
|
360
353
|
await waitFor(() => expect(getByTestId("voucher-picker-result-4")).toBeTruthy());
|
|
361
354
|
const text = getByTestId("voucher-picker-result-4").textContent ?? "";
|
|
@@ -376,7 +369,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
376
369
|
const { getByTestId } = render(() => (
|
|
377
370
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[1]} />
|
|
378
371
|
));
|
|
379
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
372
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
380
373
|
|
|
381
374
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-30")).toBeTruthy());
|
|
382
375
|
expect(getByTestId("voucher-picker-inapplicable-30").textContent).toContain("minimum");
|
|
@@ -406,7 +399,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
406
399
|
packageLineages={["day-pass"]}
|
|
407
400
|
/>
|
|
408
401
|
));
|
|
409
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
402
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
410
403
|
await waitFor(() => expect(getByTestId("voucher-picker-result-35")).toBeTruthy());
|
|
411
404
|
});
|
|
412
405
|
|
|
@@ -427,7 +420,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
427
420
|
packageLineages={["day-pass", "single-use", "day-pass"]}
|
|
428
421
|
/>
|
|
429
422
|
));
|
|
430
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
423
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
431
424
|
await waitFor(() => expect(getByTestId("voucher-picker-result-55")).toBeTruthy());
|
|
432
425
|
});
|
|
433
426
|
|
|
@@ -449,7 +442,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
449
442
|
packageLineages={[null, "day-pass", "single-use"]}
|
|
450
443
|
/>
|
|
451
444
|
));
|
|
452
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
445
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
453
446
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-56")).toBeTruthy());
|
|
454
447
|
expect(queryByTestId("voucher-picker-result-56")).toBeNull();
|
|
455
448
|
expect(getByTestId("voucher-picker-inapplicable-56").textContent).toContain(
|
|
@@ -475,12 +468,12 @@ describe("VoucherPicker dialog", () => {
|
|
|
475
468
|
/>
|
|
476
469
|
));
|
|
477
470
|
|
|
478
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
471
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
479
472
|
await waitFor(() => expect(getByTestId("voucher-picker-result-57")).toBeTruthy());
|
|
480
|
-
click(getByTestId("voucher-picker-cancel"));
|
|
473
|
+
fireEvent.click(getByTestId("voucher-picker-cancel"));
|
|
481
474
|
|
|
482
475
|
setPackageLineage("single-use");
|
|
483
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
476
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
484
477
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-57")).toBeTruthy());
|
|
485
478
|
expect(queryByTestId("voucher-picker-result-57")).toBeNull();
|
|
486
479
|
expect(getByTestId("voucher-picker-confirm").hasAttribute("disabled")).toBe(true);
|
|
@@ -499,11 +492,11 @@ describe("VoucherPicker dialog", () => {
|
|
|
499
492
|
/>
|
|
500
493
|
));
|
|
501
494
|
|
|
502
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
495
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
503
496
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-59")).toBeTruthy());
|
|
504
497
|
expect(getByTestId("voucher-picker-confirm").hasAttribute("disabled")).toBe(true);
|
|
505
498
|
|
|
506
|
-
click(getByTestId("voucher-picker-confirm"));
|
|
499
|
+
fireEvent.click(getByTestId("voucher-picker-confirm"));
|
|
507
500
|
expect(onChange).not.toHaveBeenCalled();
|
|
508
501
|
});
|
|
509
502
|
|
|
@@ -521,7 +514,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
521
514
|
packageLineages={["day-pass"]}
|
|
522
515
|
/>
|
|
523
516
|
));
|
|
524
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
517
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
525
518
|
await waitFor(() => expect(getByTestId("voucher-picker-result-37")).toBeTruthy());
|
|
526
519
|
expect(queryByTestId("voucher-picker-inapplicable-37")).toBeNull();
|
|
527
520
|
expect(getByTestId("voucher-picker-result-37").textContent).toContain("ENABLED_LINEAGE");
|
|
@@ -543,7 +536,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
543
536
|
packageLineages={["single-use"]}
|
|
544
537
|
/>
|
|
545
538
|
));
|
|
546
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
539
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
547
540
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-39")).toBeTruthy());
|
|
548
541
|
expect(queryByTestId("voucher-picker-result-39")).toBeNull();
|
|
549
542
|
expect(getByTestId("voucher-picker-inapplicable-39").getAttribute("aria-disabled")).toBe("true");
|
|
@@ -569,7 +562,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
569
562
|
packageLineages={["single-use"]}
|
|
570
563
|
/>
|
|
571
564
|
));
|
|
572
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
565
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
573
566
|
await waitFor(() => expect(getByTestId("voucher-picker-inapplicable-36")).toBeTruthy());
|
|
574
567
|
expect(queryByTestId("voucher-picker-result-36")).toBeNull();
|
|
575
568
|
expect(getByTestId("voucher-picker-inapplicable-36").textContent).toContain(
|
|
@@ -638,7 +631,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
638
631
|
packageLineages={packageLineages}
|
|
639
632
|
/>
|
|
640
633
|
));
|
|
641
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
634
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
642
635
|
await waitFor(() =>
|
|
643
636
|
expect(
|
|
644
637
|
result
|
|
@@ -656,7 +649,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
656
649
|
const { getByTestId, queryByTestId } = render(() => (
|
|
657
650
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
658
651
|
));
|
|
659
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
652
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
660
653
|
|
|
661
654
|
await waitFor(() =>
|
|
662
655
|
expect(getByTestId("voucher-picker-popup").textContent).toContain("Permission denied"),
|
|
@@ -672,7 +665,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
672
665
|
const { getByTestId } = render(() => (
|
|
673
666
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
674
667
|
));
|
|
675
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
668
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
676
669
|
await waitFor(() =>
|
|
677
670
|
expect(getByTestId("voucher-picker-popup").textContent).toContain("network down"),
|
|
678
671
|
);
|
|
@@ -685,7 +678,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
685
678
|
const { getByTestId } = render(() => (
|
|
686
679
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={1000} packageIds={[]} />
|
|
687
680
|
));
|
|
688
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
681
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
689
682
|
await waitFor(() =>
|
|
690
683
|
expect(getByTestId("voucher-picker-popup").textContent).toContain(
|
|
691
684
|
"Vouchers module isn't available",
|
|
@@ -699,12 +692,12 @@ describe("VoucherPicker dialog", () => {
|
|
|
699
692
|
<VoucherPicker selected={null} onChange={onChange} subtotal={1000} packageIds={[]} />
|
|
700
693
|
));
|
|
701
694
|
|
|
702
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
695
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
703
696
|
await waitFor(() => expect(getByTestId("voucher-picker-result-40")).toBeTruthy());
|
|
704
|
-
click(getByTestId("voucher-picker-result-40"));
|
|
705
|
-
click(getByTestId("voucher-picker-cancel"));
|
|
697
|
+
fireEvent.click(getByTestId("voucher-picker-result-40"));
|
|
698
|
+
fireEvent.click(getByTestId("voucher-picker-cancel"));
|
|
706
699
|
|
|
707
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
700
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
708
701
|
await waitFor(() => expect(getByTestId("voucher-picker-result-40")).toBeTruthy());
|
|
709
702
|
expect(getByTestId("voucher-picker-draft-summary").textContent).toContain("No voucher selected");
|
|
710
703
|
expect(onChange).not.toHaveBeenCalled();
|
|
@@ -718,7 +711,7 @@ describe("VoucherPicker dialog", () => {
|
|
|
718
711
|
const { getByTestId } = render(() => (
|
|
719
712
|
<VoucherPicker selected={null} onChange={vi.fn()} subtotal={100} packageIds={[]} />
|
|
720
713
|
));
|
|
721
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
714
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
722
715
|
await waitFor(() => expect(getByTestId("voucher-picker-popup")).toBeTruthy());
|
|
723
716
|
|
|
724
717
|
fireEvent.keyDown(getByTestId("voucher-picker-search"), { key: "Escape" });
|
|
@@ -735,9 +728,9 @@ describe("VoucherPicker applyOnSelect", () => {
|
|
|
735
728
|
const { getByTestId, queryByTestId, findByTestId } = render(() => (
|
|
736
729
|
<VoucherPicker selected={null} onChange={onChange} subtotal={100} packageIds={[]} applyOnSelect />
|
|
737
730
|
));
|
|
738
|
-
click(getByTestId("voucher-picker-trigger"));
|
|
731
|
+
fireEvent.click(getByTestId("voucher-picker-trigger"));
|
|
739
732
|
expect(queryByTestId("voucher-picker-confirm")).toBeNull();
|
|
740
|
-
click(await findByTestId("voucher-picker-result-1"));
|
|
733
|
+
fireEvent.click(await findByTestId("voucher-picker-result-1"));
|
|
741
734
|
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ id: 1 }));
|
|
742
735
|
await waitFor(() => expect(queryByTestId("voucher-picker-popup")).toBeNull());
|
|
743
736
|
});
|
|
@@ -9,14 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
import { Modal } from "../base/Modal";
|
|
11
11
|
import { highlightMatch } from "../../utils/highlight";
|
|
12
|
-
import { createEffect, createMemo, createSignal, For, onCleanup, Show } from "solid-js";
|
|
13
|
-
import type { JSX } from "@solidjs/web";
|
|
12
|
+
import { createEffect, createMemo, createSignal, For, onCleanup, Show, type JSX } from "solid-js";
|
|
14
13
|
import Ticket from "../../icons/ticket";
|
|
15
14
|
import X from "../../icons/x";
|
|
16
15
|
import Search from "../../icons/search";
|
|
17
16
|
import Loader2 from "../../icons/loader-2";
|
|
18
17
|
import CalendarClock from "../../icons/calendar-clock";
|
|
19
|
-
import { ariaBool } from "../../utils/aria";
|
|
20
18
|
|
|
21
19
|
export interface VoucherOption {
|
|
22
20
|
id: number;
|
|
@@ -264,24 +262,20 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
264
262
|
|
|
265
263
|
// Debounce the keystrokes into a server-side search, so filtering spans the
|
|
266
264
|
// whole table rather than only the pages already pulled down.
|
|
267
|
-
createEffect(
|
|
268
|
-
|
|
269
|
-
(
|
|
270
|
-
if (!isOpen) return;
|
|
265
|
+
createEffect(() => {
|
|
266
|
+
const q = query();
|
|
267
|
+
if (!open()) return;
|
|
271
268
|
clearTimeout(debounceTimer);
|
|
272
269
|
debounceTimer = setTimeout(() => setDebouncedQuery(q.trim()), SEARCH_DEBOUNCE_MS);
|
|
273
|
-
}
|
|
274
|
-
);
|
|
270
|
+
});
|
|
275
271
|
onCleanup(() => clearTimeout(debounceTimer));
|
|
276
272
|
|
|
277
273
|
// Refetch from page 1 whenever the dialog opens or the search term settles.
|
|
278
|
-
createEffect(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
if (!isOpen) return;
|
|
274
|
+
createEffect(() => {
|
|
275
|
+
if (!open()) return;
|
|
276
|
+
const search = debouncedQuery();
|
|
282
277
|
loadPage(1, search, false);
|
|
283
|
-
}
|
|
284
|
-
);
|
|
278
|
+
});
|
|
285
279
|
|
|
286
280
|
const hasMore = createMemo(() => vouchers().length < total());
|
|
287
281
|
|
|
@@ -294,10 +288,10 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
294
288
|
// Re-created after every append — an observer only reports a CHANGE in
|
|
295
289
|
// intersection, so a sentinel that stays on screen (list still shorter than
|
|
296
290
|
// the viewport) would never fire again and paging would stall.
|
|
297
|
-
createEffect(
|
|
298
|
-
|
|
299
|
-
(
|
|
300
|
-
|
|
291
|
+
createEffect(() => {
|
|
292
|
+
const loadedCount = vouchers().length;
|
|
293
|
+
if (!open() || loadedCount === 0) return;
|
|
294
|
+
const el = sentinel();
|
|
301
295
|
if (!el || typeof IntersectionObserver === "undefined") return;
|
|
302
296
|
const io = new IntersectionObserver(
|
|
303
297
|
(entries) => {
|
|
@@ -306,9 +300,8 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
306
300
|
{ rootMargin: "120px" },
|
|
307
301
|
);
|
|
308
302
|
io.observe(el);
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
);
|
|
303
|
+
onCleanup(() => io.disconnect());
|
|
304
|
+
});
|
|
312
305
|
|
|
313
306
|
const today = () => new Date().toISOString().slice(0, 10);
|
|
314
307
|
|
|
@@ -393,10 +386,10 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
393
386
|
if (e.key === "Escape") e.stopPropagation();
|
|
394
387
|
};
|
|
395
388
|
|
|
396
|
-
createEffect(
|
|
397
|
-
if (!
|
|
389
|
+
createEffect(() => {
|
|
390
|
+
if (!open()) return;
|
|
398
391
|
document.addEventListener("keydown", swallowEscape, true);
|
|
399
|
-
|
|
392
|
+
onCleanup(() => document.removeEventListener("keydown", swallowEscape, true));
|
|
400
393
|
});
|
|
401
394
|
|
|
402
395
|
const metaLine = (v: VoucherOption): string =>
|
|
@@ -413,17 +406,15 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
413
406
|
|
|
414
407
|
// The footer clamps the description to two lines; offer "More" only when the
|
|
415
408
|
// text actually overflowed. Re-measured whenever the staged description changes.
|
|
416
|
-
createEffect(
|
|
417
|
-
|
|
418
|
-
(notes) => {
|
|
409
|
+
createEffect(() => {
|
|
410
|
+
const notes = draftNotes();
|
|
419
411
|
const el = descEl;
|
|
420
412
|
if (!notes || !el) {
|
|
421
413
|
setDescOverflowing(false);
|
|
422
414
|
return;
|
|
423
415
|
}
|
|
424
416
|
setDescOverflowing(el.scrollHeight > el.clientHeight);
|
|
425
|
-
}
|
|
426
|
-
);
|
|
417
|
+
});
|
|
427
418
|
|
|
428
419
|
const expiresSoon = (v: VoucherOption): boolean => {
|
|
429
420
|
if (!v.valid_until) return false;
|
|
@@ -445,7 +436,7 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
445
436
|
props.compact ? "px-2.5 py-2" : "px-3 py-2.5"
|
|
446
437
|
} rounded-lg bg-[color-mix(in_srgb,var(--ks-border,rgba(39,39,42,0.5))_30%,transparent)] border border-[color-mix(in_srgb,var(--ks-border-strong,#3f3f46)_50%,transparent)] hover:border-[color-mix(in_srgb,var(--ks-primary,#c9a961)_40%,transparent)] hover:bg-[color-mix(in_srgb,var(--ks-primary,#c9a961)_5%,transparent)] transition-colors text-sm text-left cursor-pointer disabled:cursor-not-allowed disabled:opacity-60`}
|
|
447
438
|
aria-haspopup="dialog"
|
|
448
|
-
aria-expanded={
|
|
439
|
+
aria-expanded={open()}
|
|
449
440
|
>
|
|
450
441
|
<Ticket size={16} class="shrink-0 text-[var(--ks-fg-muted,#a1a1aa)]" />
|
|
451
442
|
<Show when={props.selected} fallback={<span class="text-[var(--ks-fg-subtle,#71717a)] italic">No voucher</span>}>
|
|
@@ -547,16 +538,16 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
547
538
|
{(v) => {
|
|
548
539
|
const selected = () => draft()?.id === v.id;
|
|
549
540
|
return (
|
|
550
|
-
<li role="option" aria-selected={
|
|
541
|
+
<li role="option" aria-selected={selected()}>
|
|
551
542
|
<button
|
|
552
543
|
type="button"
|
|
553
544
|
data-testid={`voucher-picker-result-${v.id}`}
|
|
554
545
|
onClick={() => stage(v)}
|
|
555
|
-
class=
|
|
546
|
+
class="w-full text-left px-3 py-3 mb-1 rounded-lg border transition-colors flex items-center gap-3 cursor-pointer border-[color-mix(in_srgb,var(--ks-border-strong,#3f3f46)_40%,transparent)] hover:border-[color-mix(in_srgb,var(--ks-primary,#c9a961)_50%,transparent)] hover:bg-[color-mix(in_srgb,var(--ks-primary,#c9a961)_8%,transparent)]"
|
|
547
|
+
classList={{
|
|
556
548
|
"border-[color-mix(in_srgb,var(--ks-primary,#c9a961)_60%,transparent)] bg-[color-mix(in_srgb,var(--ks-primary,#c9a961)_12%,transparent)]":
|
|
557
549
|
selected(),
|
|
558
|
-
}
|
|
559
|
-
|
|
550
|
+
}}
|
|
560
551
|
>
|
|
561
552
|
<span class="flex flex-col items-center gap-1 shrink-0">
|
|
562
553
|
<Ticket size={18} class="text-[var(--ks-success-fg,#34d399)]" aria-hidden="true" />
|
|
@@ -576,7 +567,7 @@ export default function VoucherPicker(props: VoucherPickerProps): JSX.Element {
|
|
|
576
567
|
aria-hidden="true"
|
|
577
568
|
/>
|
|
578
569
|
</Show>
|
|
579
|
-
<span class=
|
|
570
|
+
<span class="truncate" classList={{ "text-[var(--ks-warning-fg,#fbbf24)]": runningOut(v) }}>
|
|
580
571
|
{metaLine(v)}
|
|
581
572
|
</span>
|
|
582
573
|
</span>
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
// single- and multi-select renders drive this one engine so there is exactly
|
|
4
4
|
// one copy of the mechanics.
|
|
5
5
|
|
|
6
|
-
import { createEffect, createSignal, onCleanup } from "solid-js";
|
|
7
|
-
import type { JSX } from "@solidjs/web";
|
|
6
|
+
import { createEffect, createSignal, onCleanup, type JSX } from "solid-js";
|
|
8
7
|
|
|
9
8
|
const POPUP_MAX_HEIGHT = 360;
|
|
10
9
|
const POPUP_MIN_WIDTH = 320;
|
|
@@ -36,22 +35,18 @@ export function createPickerPopup<T>(cfg: {
|
|
|
36
35
|
let debounceTimer: ReturnType<typeof setTimeout> | undefined;
|
|
37
36
|
let activeFetchToken = 0;
|
|
38
37
|
|
|
39
|
-
createEffect(
|
|
40
|
-
query
|
|
41
|
-
(q) => {
|
|
38
|
+
createEffect(() => {
|
|
39
|
+
const q = query();
|
|
42
40
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
43
41
|
debounceTimer = setTimeout(() => setDebouncedQuery(q), SEARCH_DEBOUNCE_MS);
|
|
44
|
-
|
|
42
|
+
onCleanup(() => {
|
|
45
43
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
49
46
|
|
|
50
|
-
createEffect(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!isOpen) return;
|
|
54
|
-
const q = debounced.trim();
|
|
47
|
+
createEffect(() => {
|
|
48
|
+
if (!open()) return;
|
|
49
|
+
const q = debouncedQuery().trim();
|
|
55
50
|
const token = ++activeFetchToken;
|
|
56
51
|
setLoading(true);
|
|
57
52
|
setError(null);
|
|
@@ -71,8 +66,7 @@ export function createPickerPopup<T>(cfg: {
|
|
|
71
66
|
if (token !== activeFetchToken) return;
|
|
72
67
|
setLoading(false);
|
|
73
68
|
});
|
|
74
|
-
}
|
|
75
|
-
);
|
|
69
|
+
});
|
|
76
70
|
|
|
77
71
|
const close = () => {
|
|
78
72
|
setOpen(false);
|
|
@@ -112,8 +106,8 @@ export function createPickerPopup<T>(cfg: {
|
|
|
112
106
|
});
|
|
113
107
|
};
|
|
114
108
|
|
|
115
|
-
createEffect(
|
|
116
|
-
if (!
|
|
109
|
+
createEffect(() => {
|
|
110
|
+
if (!open()) return;
|
|
117
111
|
updatePosition();
|
|
118
112
|
|
|
119
113
|
const onDocClick = (e: MouseEvent) => {
|
|
@@ -134,12 +128,12 @@ export function createPickerPopup<T>(cfg: {
|
|
|
134
128
|
document.addEventListener("keydown", onEsc, true);
|
|
135
129
|
window.addEventListener("resize", onReflow);
|
|
136
130
|
window.addEventListener("scroll", onReflow, true);
|
|
137
|
-
|
|
131
|
+
onCleanup(() => {
|
|
138
132
|
document.removeEventListener("mousedown", onDocClick);
|
|
139
133
|
document.removeEventListener("keydown", onEsc, true);
|
|
140
134
|
window.removeEventListener("resize", onReflow);
|
|
141
135
|
window.removeEventListener("scroll", onReflow, true);
|
|
142
|
-
};
|
|
136
|
+
});
|
|
143
137
|
});
|
|
144
138
|
|
|
145
139
|
const trimmedQuery = () => query().trim();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { fireEvent, render, screen } from "@solidjs/testing-library";
|
|
3
|
-
import type { JSX } from "
|
|
3
|
+
import type { JSX } from "solid-js";
|
|
4
4
|
import { ResourcePage } from "./ResourcePage";
|
|
5
5
|
import type { ResourceRow, ResourceUiSpec } from "./spec";
|
|
6
6
|
|
|
@@ -173,23 +173,3 @@ describe("ResourcePage permission gates and mutation failures", () => {
|
|
|
173
173
|
expect(await screen.findByText("PATCH failed visibly")).toBeTruthy();
|
|
174
174
|
});
|
|
175
175
|
});
|
|
176
|
-
|
|
177
|
-
describe("ResourcePage filters", () => {
|
|
178
|
-
// The table fetches untracked, so a filter change must refetch through the key.
|
|
179
|
-
it("refetches with the new value when a segmented filter changes", async () => {
|
|
180
|
-
const spec: ResourceUiSpec = {
|
|
181
|
-
...SPEC,
|
|
182
|
-
filters: [
|
|
183
|
-
{ type: "segmented", param: "state", options: ["active", "archived"], default: "active", testIdPrefix: "resources-state" },
|
|
184
|
-
],
|
|
185
|
-
};
|
|
186
|
-
const fetchImpl = fetchFor([ACTIVE]);
|
|
187
|
-
render(() => <ResourcePage spec={spec} host={host(() => true)} fetchImpl={fetchImpl} />);
|
|
188
|
-
await screen.findByText(ACTIVE.name as string);
|
|
189
|
-
expect(fetchImpl).toHaveBeenCalledWith(expect.stringContaining("state=active"), expect.anything());
|
|
190
|
-
fireEvent.click(screen.getByTestId("resources-state-archived"));
|
|
191
|
-
await vi.waitFor(() =>
|
|
192
|
-
expect(fetchImpl).toHaveBeenCalledWith(expect.stringContaining("state=archived"), expect.anything()),
|
|
193
|
-
);
|
|
194
|
-
});
|
|
195
|
-
});
|