@tsed/react-formio 3.0.0-alpha.10 → 3.0.0-alpha.12
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/dist/atoms/icon/Icon.js.map +1 -1
- package/dist/chunks/index.js +33 -30
- package/dist/chunks/index.js.map +1 -1
- package/dist/chunks/index.module.js +16 -16
- package/dist/chunks/index.module.js.map +1 -1
- package/dist/chunks/react-select-animated.esm.js +1204 -1101
- package/dist/chunks/react-select-animated.esm.js.map +1 -1
- package/dist/hooks/keyboard.constants.d.ts +38 -0
- package/dist/hooks/keyboard.constants.js +7 -0
- package/dist/hooks/keyboard.constants.js.map +1 -0
- package/dist/hooks/useKeyboardControls.d.ts +12 -0
- package/dist/hooks/useKeyboardControls.js +35 -0
- package/dist/hooks/useKeyboardControls.js.map +1 -0
- package/dist/hooks/useTooltip.js.map +1 -1
- package/dist/interfaces/Operation.d.ts +12 -2
- package/dist/molecules/alert/Alert.js.map +1 -1
- package/dist/molecules/button/Button.d.ts +18 -5
- package/dist/molecules/button/Button.js +22 -26
- package/dist/molecules/button/Button.js.map +1 -1
- package/dist/molecules/card/Card.js +7 -5
- package/dist/molecules/card/Card.js.map +1 -1
- package/dist/molecules/forms/form-control/FormControl.js.map +1 -1
- package/dist/molecules/forms/input-tags/InputTags.js +14 -14
- package/dist/molecules/forms/input-tags/InputTags.js.map +1 -1
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js +26 -26
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js.map +1 -1
- package/dist/molecules/forms/input-tags/components/ReactTags.js +289 -300
- package/dist/molecules/forms/input-tags/components/ReactTags.js.map +1 -1
- package/dist/molecules/forms/input-text/InputText.js +3 -3
- package/dist/molecules/forms/input-text/InputText.js.map +1 -1
- package/dist/molecules/forms/select/Select.js.map +1 -1
- package/dist/molecules/forms/select/components/ChoicesSelect.js +71 -73
- package/dist/molecules/forms/select/components/ChoicesSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/HtmlSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/ReactSelect.js +13 -14
- package/dist/molecules/forms/select/components/ReactSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/choices.template.js +2340 -2257
- package/dist/molecules/forms/select/components/choices.template.js.map +1 -1
- package/dist/molecules/forms/select/hooks/useOptions.js.map +1 -1
- package/dist/molecules/loader/Loader.js.map +1 -1
- package/dist/molecules/modal/Modal.js +23 -24
- package/dist/molecules/modal/Modal.js.map +1 -1
- package/dist/molecules/pagination/Pagination.js +19 -19
- package/dist/molecules/pagination/Pagination.js.map +1 -1
- package/dist/molecules/pagination/PaginationButton.js.map +1 -1
- package/dist/molecules/pagination/utils/getPageNumbers.js.map +1 -1
- package/dist/molecules/table/Table.d.ts +11 -3
- package/dist/molecules/table/Table.js +31 -32
- package/dist/molecules/table/Table.js.map +1 -1
- package/dist/molecules/table/components/DefaultArrowSort.js.map +1 -1
- package/dist/molecules/table/components/DefaultCell.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellFooter.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellHeader.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellOperations.d.ts +12 -4
- package/dist/molecules/table/components/DefaultCellOperations.js +13 -7
- package/dist/molecules/table/components/DefaultCellOperations.js.map +1 -1
- package/dist/molecules/table/components/DefaultFilter.js.map +1 -1
- package/dist/molecules/table/components/DefaultOperationButton.d.ts +12 -4
- package/dist/molecules/table/components/DefaultOperationButton.js +1 -1
- package/dist/molecules/table/components/DefaultOperationButton.js.map +1 -1
- package/dist/molecules/table/filters/RangeFilter.js +23 -24
- package/dist/molecules/table/filters/RangeFilter.js.map +1 -1
- package/dist/molecules/table/filters/SelectFilter.js +11 -13
- package/dist/molecules/table/filters/SelectFilter.js.map +1 -1
- package/dist/molecules/table/filters/TextFieldFilter.js.map +1 -1
- package/dist/molecules/table/hooks/useTable.d.ts +12 -4
- package/dist/molecules/table/hooks/useTable.js +7 -7
- package/dist/molecules/table/hooks/useTable.js.map +1 -1
- package/dist/molecules/table/hooks/useUniqValues.js.map +1 -1
- package/dist/molecules/table/utils/mapFormToColumns.js +20 -21
- package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
- package/dist/molecules/tabs/Tab.d.ts +13 -0
- package/dist/molecules/tabs/Tab.js +66 -0
- package/dist/molecules/tabs/Tab.js.map +1 -0
- package/dist/molecules/tabs/TabList.d.ts +2 -0
- package/dist/molecules/tabs/TabList.js +23 -0
- package/dist/molecules/tabs/TabList.js.map +1 -0
- package/dist/molecules/tabs/TabPanel.d.ts +9 -0
- package/dist/molecules/tabs/TabPanel.js +27 -0
- package/dist/molecules/tabs/TabPanel.js.map +1 -0
- package/dist/molecules/tabs/Tabs.d.ts +4 -16
- package/dist/molecules/tabs/Tabs.js +7 -67
- package/dist/molecules/tabs/Tabs.js.map +1 -1
- package/dist/molecules/tabs/TabsBody.d.ts +1 -0
- package/dist/molecules/tabs/TabsBody.js +10 -0
- package/dist/molecules/tabs/TabsBody.js.map +1 -0
- package/dist/molecules/tabs/TabsLegacy.d.ts +17 -0
- package/dist/molecules/tabs/TabsLegacy.js +49 -0
- package/dist/molecules/tabs/TabsLegacy.js.map +1 -0
- package/dist/molecules/tabs/all.d.ts +5 -0
- package/dist/molecules/tabs/all.js +13 -0
- package/dist/molecules/tabs/all.js.map +1 -0
- package/dist/molecules/tabs/context/TabControl.d.ts +52 -0
- package/dist/molecules/tabs/context/TabControl.js +85 -0
- package/dist/molecules/tabs/context/TabControl.js.map +1 -0
- package/dist/molecules/tabs/hooks/tabControl.d.ts +44 -0
- package/dist/molecules/tabs/hooks/tabControl.js +34 -0
- package/dist/molecules/tabs/hooks/tabControl.js.map +1 -0
- package/dist/organisms/form/Form.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.js +41 -41
- package/dist/organisms/form/access/FormAccess.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.schema.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.utils.js +2 -2
- package/dist/organisms/form/access/FormAccess.utils.js.map +1 -1
- package/dist/organisms/form/{action → actions}/FormAction.js +7 -8
- package/dist/organisms/form/actions/FormAction.js.map +1 -0
- package/dist/organisms/form/builder/FormBuilder.js.map +1 -1
- package/dist/organisms/form/builder/FormEdit.d.ts +3 -1
- package/dist/organisms/form/builder/FormEdit.js +38 -35
- package/dist/organisms/form/builder/FormEdit.js.map +1 -1
- package/dist/organisms/form/builder/FormEdit.reducer.js.map +1 -1
- package/dist/organisms/form/builder/FormEditCtas.js +34 -34
- package/dist/organisms/form/builder/FormEditCtas.js.map +1 -1
- package/dist/organisms/form/builder/FormParameters.js.map +1 -1
- package/dist/organisms/form/builder/useFormBuilder.js +41 -38
- package/dist/organisms/form/builder/useFormBuilder.js.map +1 -1
- package/dist/organisms/form/builder/useFormEdit.js +1 -1
- package/dist/organisms/form/builder/useFormEdit.js.map +1 -1
- package/dist/organisms/form/exports/FormExport.d.ts +5 -0
- package/dist/organisms/form/exports/FormExport.js +55 -0
- package/dist/organisms/form/exports/FormExport.js.map +1 -0
- package/dist/organisms/form/preview/FormPreview.d.ts +6 -0
- package/dist/organisms/form/preview/FormPreview.js +11 -0
- package/dist/organisms/form/preview/FormPreview.js.map +1 -0
- package/dist/organisms/form/settings/FormSettings.js +24 -24
- package/dist/organisms/form/settings/FormSettings.js.map +1 -1
- package/dist/organisms/form/settings/FormSettings.schema.js.map +1 -1
- package/dist/organisms/form/settings/FormSettings.utils.js.map +1 -1
- package/dist/organisms/form/useForm.js +664 -661
- package/dist/organisms/form/useForm.js.map +1 -1
- package/dist/organisms/modal/RemoveModal.js +16 -17
- package/dist/organisms/modal/RemoveModal.js.map +1 -1
- package/dist/organisms/table/actions/ActionsTable.js.map +1 -1
- package/dist/organisms/table/forms/FormsTable.js.map +1 -1
- package/dist/organisms/table/forms/components/FormsCell.js.map +1 -1
- package/dist/organisms/table/submissions/SubmissionsTable.d.ts +11 -3
- package/dist/organisms/table/submissions/SubmissionsTable.js +4 -1
- package/dist/organisms/table/submissions/SubmissionsTable.js.map +1 -1
- package/dist/organisms/views/FormViews.d.ts +24 -0
- package/dist/organisms/views/FormViews.js +96 -0
- package/dist/organisms/views/FormViews.js.map +1 -0
- package/dist/registries/components.js.map +1 -1
- package/dist/utils/getEventValue.js.map +1 -1
- package/dist/utils/iconClass.js.map +1 -1
- package/dist/utils/mapPagination.js.map +1 -1
- package/dist/utils/stopPropagationWrapper.js.map +1 -1
- package/package.json +7 -7
- package/src/atoms/icon/Icon.stories.tsx +1 -1
- package/src/hooks/keyboard.constants.ts +40 -0
- package/src/hooks/useKeyboardControls.spec.tsx +208 -0
- package/src/hooks/useKeyboardControls.ts +84 -0
- package/src/interfaces/Operation.ts +9 -3
- package/src/molecules/button/Button.stories.tsx +1 -1
- package/src/molecules/button/Button.tsx +43 -24
- package/src/molecules/card/Card.tsx +4 -0
- package/src/molecules/forms/form-control/FormControl.stories.tsx +1 -1
- package/src/molecules/forms/input-tags/InputTags.tsx +1 -1
- package/src/molecules/forms/input-tags/components/ChoicesTags.stories.tsx +1 -1
- package/src/molecules/forms/input-tags/components/ReactTags.stories.tsx +1 -1
- package/src/molecules/forms/input-text/InputText.stories.tsx +2 -2
- package/src/molecules/forms/select/components/ChoicesSelect.stories.tsx +2 -2
- package/src/molecules/forms/select/components/HtmlSelect.stories.tsx +2 -2
- package/src/molecules/forms/select/components/ReactSelect.stories.tsx +2 -2
- package/src/molecules/loader/Loader.stories.tsx +1 -1
- package/src/molecules/modal/Modal.stories.tsx +1 -1
- package/src/molecules/pagination/Pagination.stories.tsx +1 -8
- package/src/molecules/pagination/Pagination.tsx +0 -1
- package/src/molecules/table/Table.stories.tsx +36 -3
- package/src/molecules/table/Table.tsx +12 -6
- package/src/molecules/table/components/DefaultCellOperations.tsx +13 -7
- package/src/molecules/table/components/DefaultOperationButton.tsx +5 -4
- package/src/molecules/table/filters/SelectFilter.tsx +1 -1
- package/src/molecules/table/hooks/useTable.tsx +5 -5
- package/src/molecules/tabs/Tab.tsx +106 -0
- package/src/molecules/tabs/TabList.tsx +37 -0
- package/src/molecules/tabs/TabPanel.tsx +37 -0
- package/src/molecules/tabs/Tabs.spec.tsx +126 -73
- package/src/molecules/tabs/Tabs.stories.tsx +298 -65
- package/src/molecules/tabs/Tabs.tsx +10 -81
- package/src/molecules/tabs/TabsBody.tsx +11 -0
- package/src/molecules/tabs/TabsLegacy.stories.tsx +103 -0
- package/src/molecules/tabs/TabsLegacy.tsx +84 -0
- package/src/molecules/tabs/all.ts +5 -0
- package/src/molecules/tabs/context/TabControl.tsx +166 -0
- package/src/molecules/tabs/hooks/tabControl.spec.tsx +388 -0
- package/src/molecules/tabs/hooks/tabControl.ts +52 -0
- package/src/organisms/__fixtures__/form-firstname.fixture.json +1 -0
- package/src/organisms/__fixtures__/form.fixture.json +1 -0
- package/src/organisms/form/Form.stories.tsx +94 -118
- package/src/organisms/form/access/FormAccess.stories.tsx +2 -2
- package/src/organisms/form/actions/FormAction.stories.tsx +422 -0
- package/src/organisms/form/builder/FormBuilder.stories.tsx +4 -1
- package/src/organisms/form/builder/FormEdit.stories.tsx +1 -1
- package/src/organisms/form/builder/FormEdit.tsx +7 -1
- package/src/organisms/form/builder/useFormBuilder.ts +5 -1
- package/src/organisms/form/builder/useFormEdit.ts +1 -1
- package/src/organisms/form/exports/FormExport.stories.tsx +71 -0
- package/src/organisms/form/exports/FormExport.tsx +58 -0
- package/src/organisms/form/preview/FormPreview.stories.tsx +61 -0
- package/src/organisms/form/preview/FormPreview.tsx +21 -0
- package/src/organisms/modal/RemoveModal.stories.tsx +1 -1
- package/src/organisms/table/actions/ActionsTable.stories.tsx +38 -36
- package/src/organisms/table/submissions/SubmissionsTable.stories.tsx +103 -57
- package/src/organisms/table/submissions/SubmissionsTable.tsx +10 -4
- package/src/organisms/views/FormViews.stories.tsx +224 -0
- package/src/organisms/views/FormViews.tsx +146 -0
- package/vite.config.mts +2 -2
- package/dist/organisms/form/action/FormAction.js.map +0 -1
- package/src/organisms/form/action/FormAction.stories.tsx +0 -364
- package/tsconfig.app.json +0 -11
- package/tsconfig.json +0 -21
- package/tsconfig.node.json +0 -13
- package/tsconfig.spec.json +0 -14
- /package/dist/organisms/form/{action → actions}/FormAction.d.ts +0 -0
- /package/src/organisms/form/{action → actions}/FormAction.tsx +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import {
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { delay, http, HttpResponse } from "msw";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
+
import { expect, fn, userEvent, waitFor, within } from "storybook/test";
|
|
4
5
|
|
|
5
6
|
import { SubmissionType } from "../../interfaces";
|
|
6
7
|
import { InputText } from "../../molecules/forms/input-text/InputText";
|
|
@@ -9,12 +10,6 @@ import formFirstname from "../__fixtures__/form-firstname.fixture.json";
|
|
|
9
10
|
import { useEditForm } from "../__fixtures__/useEditForm";
|
|
10
11
|
import { Form } from "./Form";
|
|
11
12
|
|
|
12
|
-
async function delay(number: number) {
|
|
13
|
-
return new Promise((resolve) => {
|
|
14
|
-
setTimeout(resolve, number);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
13
|
/**
|
|
19
14
|
* The form component is the primary component of the system. It is what takes the form definition (json) and renders the
|
|
20
15
|
* form into html. There are multiple ways to send the form to the Form component. The two main ways are to pass the `src`
|
|
@@ -332,15 +327,15 @@ export const WithOnSubmit: Story = {
|
|
|
332
327
|
expect(firstnameInput).toHaveValue("John");
|
|
333
328
|
expect(lastNameInput).toHaveValue("Doe");
|
|
334
329
|
|
|
335
|
-
userEvent.clear(firstnameInput);
|
|
336
|
-
userEvent.type(firstnameInput, "Jane", { delay: 100 });
|
|
330
|
+
await userEvent.clear(firstnameInput);
|
|
331
|
+
await userEvent.type(firstnameInput, "Jane", { delay: 100 });
|
|
337
332
|
|
|
338
333
|
await waitFor(() => {
|
|
339
334
|
expect(firstnameInput).toHaveValue("Jane");
|
|
340
335
|
});
|
|
341
336
|
|
|
342
|
-
userEvent.clear(lastNameInput);
|
|
343
|
-
userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
337
|
+
await userEvent.clear(lastNameInput);
|
|
338
|
+
await userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
344
339
|
|
|
345
340
|
await waitFor(() => {
|
|
346
341
|
expect(lastNameInput).toHaveValue("Smith");
|
|
@@ -397,42 +392,20 @@ export const WithOnSubmit: Story = {
|
|
|
397
392
|
* Form with custom validation hook
|
|
398
393
|
*/
|
|
399
394
|
export const CustomValidation: Story = {
|
|
400
|
-
parameters: {
|
|
401
|
-
mockData: [
|
|
402
|
-
{
|
|
403
|
-
url: "https://test.dev/todos/1",
|
|
404
|
-
method: "GET",
|
|
405
|
-
status: 500,
|
|
406
|
-
response: {
|
|
407
|
-
message: "My custom message about this field",
|
|
408
|
-
type: "custom",
|
|
409
|
-
path: ["firstName"],
|
|
410
|
-
level: "error"
|
|
411
|
-
},
|
|
412
|
-
delay: 800
|
|
413
|
-
}
|
|
414
|
-
]
|
|
415
|
-
},
|
|
395
|
+
parameters: {},
|
|
416
396
|
args: {
|
|
417
397
|
form: formFirstname as never,
|
|
418
398
|
options: {
|
|
419
399
|
hooks: {
|
|
420
400
|
async customValidation(submission: SubmissionType, callback: (error: any) => void) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
const responseData = await response.json();
|
|
430
|
-
|
|
431
|
-
if (response.ok) {
|
|
432
|
-
callback(null);
|
|
433
|
-
} else {
|
|
434
|
-
callback(responseData);
|
|
435
|
-
}
|
|
401
|
+
setTimeout(() => {
|
|
402
|
+
callback({
|
|
403
|
+
message: "My custom message about this field",
|
|
404
|
+
type: "custom",
|
|
405
|
+
path: ["firstName"],
|
|
406
|
+
level: "error"
|
|
407
|
+
});
|
|
408
|
+
}, 200);
|
|
436
409
|
}
|
|
437
410
|
}
|
|
438
411
|
}
|
|
@@ -451,15 +424,15 @@ export const CustomValidation: Story = {
|
|
|
451
424
|
let firstnameInput = canvas.getByRole("textbox", { name: "First name" });
|
|
452
425
|
let lastNameInput = canvas.getByRole("textbox", { name: "Last name" });
|
|
453
426
|
|
|
454
|
-
userEvent.clear(firstnameInput);
|
|
455
|
-
userEvent.type(firstnameInput, "Jane", { delay: 100 });
|
|
427
|
+
await userEvent.clear(firstnameInput);
|
|
428
|
+
await userEvent.type(firstnameInput, "Jane", { delay: 100 });
|
|
456
429
|
|
|
457
430
|
await waitFor(() => {
|
|
458
431
|
expect(firstnameInput).toHaveValue("Jane");
|
|
459
432
|
});
|
|
460
433
|
|
|
461
|
-
userEvent.clear(lastNameInput);
|
|
462
|
-
userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
434
|
+
await userEvent.clear(lastNameInput);
|
|
435
|
+
await userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
463
436
|
|
|
464
437
|
await waitFor(() => {
|
|
465
438
|
expect(lastNameInput).toHaveValue("Smith");
|
|
@@ -467,7 +440,7 @@ export const CustomValidation: Story = {
|
|
|
467
440
|
|
|
468
441
|
let submitButton = canvas.getByRole("button", { name: "Submit" });
|
|
469
442
|
|
|
470
|
-
userEvent.click(submitButton);
|
|
443
|
+
await userEvent.click(submitButton);
|
|
471
444
|
|
|
472
445
|
await waitFor(async () => {
|
|
473
446
|
expect(canvas.getByText("Please fix the following errors before submitting.")).toBeInTheDocument();
|
|
@@ -490,35 +463,29 @@ export const FetchSubmissionWithCustomAction: Story = {
|
|
|
490
463
|
}
|
|
491
464
|
},
|
|
492
465
|
parameters: {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
firstName: "John",
|
|
517
|
-
lastName: "Doe"
|
|
518
|
-
},
|
|
519
|
-
delay: 800
|
|
520
|
-
}
|
|
521
|
-
]
|
|
466
|
+
chromatic: { disableSnapshot: false },
|
|
467
|
+
msw: {
|
|
468
|
+
handlers: [
|
|
469
|
+
http.get("https://local.dev/form/Test", async () => {
|
|
470
|
+
await delay(200);
|
|
471
|
+
return HttpResponse.json(JSON.parse(JSON.stringify(formFirstname)));
|
|
472
|
+
}),
|
|
473
|
+
http.get("https://local.dev/form/Test/submissions/1", async () => {
|
|
474
|
+
await delay(300);
|
|
475
|
+
return HttpResponse.json({
|
|
476
|
+
firstName: "Jane",
|
|
477
|
+
lastName: "Doe"
|
|
478
|
+
});
|
|
479
|
+
}),
|
|
480
|
+
http.put("https://local.dev/form/Test/submissions/1", async () => {
|
|
481
|
+
await delay(800);
|
|
482
|
+
return HttpResponse.json({
|
|
483
|
+
firstName: "Jane",
|
|
484
|
+
lastName: "Doe"
|
|
485
|
+
});
|
|
486
|
+
})
|
|
487
|
+
]
|
|
488
|
+
}
|
|
522
489
|
},
|
|
523
490
|
render(args) {
|
|
524
491
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -562,15 +529,20 @@ export const FetchSubmissionWithCustomAction: Story = {
|
|
|
562
529
|
let firstnameInput = canvas.getByRole("textbox", { name: "First name" });
|
|
563
530
|
let lastNameInput = canvas.getByRole("textbox", { name: "Last name" });
|
|
564
531
|
|
|
565
|
-
userEvent.clear(firstnameInput);
|
|
566
|
-
|
|
532
|
+
await userEvent.clear(firstnameInput);
|
|
533
|
+
|
|
534
|
+
await waitFor(() => {
|
|
535
|
+
expect(firstnameInput).toHaveValue("");
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
await userEvent.type(firstnameInput, "Jane", { delay: 100 });
|
|
567
539
|
|
|
568
540
|
await waitFor(() => {
|
|
569
541
|
expect(firstnameInput).toHaveValue("Jane");
|
|
570
542
|
});
|
|
571
543
|
|
|
572
|
-
userEvent.clear(lastNameInput);
|
|
573
|
-
userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
544
|
+
await userEvent.clear(lastNameInput);
|
|
545
|
+
await userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
574
546
|
|
|
575
547
|
await waitFor(() => {
|
|
576
548
|
expect(lastNameInput).toHaveValue("Smith");
|
|
@@ -578,7 +550,7 @@ export const FetchSubmissionWithCustomAction: Story = {
|
|
|
578
550
|
|
|
579
551
|
let submitButton = canvas.getByRole("button", { name: "Submit" });
|
|
580
552
|
|
|
581
|
-
userEvent.click(submitButton);
|
|
553
|
+
await userEvent.click(submitButton);
|
|
582
554
|
|
|
583
555
|
await delay(1000);
|
|
584
556
|
|
|
@@ -597,37 +569,36 @@ export const ErrorOnSubmitServer: Story = {
|
|
|
597
569
|
}
|
|
598
570
|
},
|
|
599
571
|
parameters: {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
]
|
|
572
|
+
chromatic: { disableSnapshot: false },
|
|
573
|
+
msw: {
|
|
574
|
+
handlers: [
|
|
575
|
+
http.get("https://local.dev/form/Test2", async () => {
|
|
576
|
+
await delay(200);
|
|
577
|
+
return HttpResponse.json(JSON.parse(JSON.stringify(formFirstname)));
|
|
578
|
+
}),
|
|
579
|
+
http.get("https://local.dev/form/Test2/submissions/2", async () => {
|
|
580
|
+
await delay(300);
|
|
581
|
+
return HttpResponse.json({
|
|
582
|
+
firstName: "John",
|
|
583
|
+
lastName: "Doe"
|
|
584
|
+
});
|
|
585
|
+
}),
|
|
586
|
+
http.put("https://local.dev/form/Test2/submissions/2", async () => {
|
|
587
|
+
await delay(800);
|
|
588
|
+
return HttpResponse.json(
|
|
589
|
+
{
|
|
590
|
+
message: "My custom message about this field",
|
|
591
|
+
type: "custom",
|
|
592
|
+
path: ["firstName"],
|
|
593
|
+
level: "error"
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
status: 400
|
|
597
|
+
}
|
|
598
|
+
);
|
|
599
|
+
})
|
|
600
|
+
]
|
|
601
|
+
}
|
|
631
602
|
},
|
|
632
603
|
render(args) {
|
|
633
604
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -671,15 +642,20 @@ export const ErrorOnSubmitServer: Story = {
|
|
|
671
642
|
let firstnameInput = canvas.getByRole("textbox", { name: "First name" });
|
|
672
643
|
let lastNameInput = canvas.getByRole("textbox", { name: "Last name" });
|
|
673
644
|
|
|
674
|
-
userEvent.clear(firstnameInput);
|
|
675
|
-
|
|
645
|
+
await userEvent.clear(firstnameInput);
|
|
646
|
+
|
|
647
|
+
await waitFor(() => {
|
|
648
|
+
expect(firstnameInput).toHaveValue("");
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
await userEvent.type(firstnameInput, "Jane", { delay: 100 });
|
|
676
652
|
|
|
677
653
|
await waitFor(() => {
|
|
678
654
|
expect(firstnameInput).toHaveValue("Jane");
|
|
679
655
|
});
|
|
680
656
|
|
|
681
|
-
userEvent.clear(lastNameInput);
|
|
682
|
-
userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
657
|
+
await userEvent.clear(lastNameInput);
|
|
658
|
+
await userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
683
659
|
|
|
684
660
|
await waitFor(() => {
|
|
685
661
|
expect(lastNameInput).toHaveValue("Smith");
|
|
@@ -687,7 +663,7 @@ export const ErrorOnSubmitServer: Story = {
|
|
|
687
663
|
|
|
688
664
|
let submitButton = canvas.getByRole("button", { name: "Submit" });
|
|
689
665
|
|
|
690
|
-
userEvent.click(submitButton);
|
|
666
|
+
await userEvent.click(submitButton);
|
|
691
667
|
|
|
692
668
|
await delay(1000);
|
|
693
669
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { expect, fn, userEvent, within } from "
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { expect, fn, userEvent, within } from "storybook/test";
|
|
3
3
|
|
|
4
4
|
import { FormAccess } from "./FormAccess";
|
|
5
5
|
|