@terreno/ui 57.20.0 → 58.0.0-beta.1
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/.ai/guidelines/core.md +1 -1
- package/CHANGELOG.md +93 -0
- package/dist/ActionSheet.d.ts +9 -9
- package/dist/ActionSheet.d.ts.map +1 -1
- package/dist/ActionSheet.js +11 -4
- package/dist/ActionSheet.js.map +1 -1
- package/dist/AnnouncementNavigator.d.ts +7 -1
- package/dist/AnnouncementNavigator.d.ts.map +1 -1
- package/dist/AnnouncementNavigator.js +15 -16
- package/dist/AnnouncementNavigator.js.map +1 -1
- package/dist/Avatar.d.ts.map +1 -1
- package/dist/Avatar.js +1 -1
- package/dist/Avatar.js.map +1 -1
- package/dist/Box.d.ts.map +1 -1
- package/dist/Box.js +3 -1
- package/dist/Box.js.map +1 -1
- package/dist/Common.d.ts +71 -39
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/ConsentFormScreen.d.ts.map +1 -1
- package/dist/ConsentFormScreen.js.map +1 -1
- package/dist/ConsentNavigator.d.ts +5 -3
- package/dist/ConsentNavigator.d.ts.map +1 -1
- package/dist/ConsentNavigator.js +4 -4
- package/dist/ConsentNavigator.js.map +1 -1
- package/dist/CustomSelectField.js.map +1 -1
- package/dist/DataTable.d.ts.map +1 -1
- package/dist/DataTable.js +37 -12
- package/dist/DataTable.js.map +1 -1
- package/dist/DateTimeField.js +6 -6
- package/dist/DateTimeField.js.map +1 -1
- package/dist/DropdownPanel.d.ts +0 -5
- package/dist/DropdownPanel.d.ts.map +1 -1
- package/dist/DropdownPanel.js +0 -5
- package/dist/DropdownPanel.js.map +1 -1
- package/dist/FilterAccordion.d.ts.map +1 -1
- package/dist/FilterAccordion.js.map +1 -1
- package/dist/FilterBoolean.d.ts.map +1 -1
- package/dist/FilterBoolean.js.map +1 -1
- package/dist/FilterSelectMenu.js +1 -1
- package/dist/FilterSelectMenu.js.map +1 -1
- package/dist/GPTChat.d.ts.map +1 -1
- package/dist/GPTChat.js.map +1 -1
- package/dist/Heading.d.ts.map +1 -1
- package/dist/Heading.js +6 -12
- package/dist/Heading.js.map +1 -1
- package/dist/HeightField.d.ts.map +1 -1
- package/dist/HeightField.js +9 -9
- package/dist/HeightField.js.map +1 -1
- package/dist/Hyperlink.d.ts.map +1 -1
- package/dist/Hyperlink.js +6 -1
- package/dist/Hyperlink.js.map +1 -1
- package/dist/Image.d.ts +1 -1
- package/dist/MarkdownEditorField.d.ts.map +1 -1
- package/dist/MarkdownEditorField.js +1 -1
- package/dist/MarkdownEditorField.js.map +1 -1
- package/dist/OfflineBanner.d.ts +3 -2
- package/dist/OfflineBanner.d.ts.map +1 -1
- package/dist/OfflineBanner.js +3 -2
- package/dist/OfflineBanner.js.map +1 -1
- package/dist/OtpField.d.ts.map +1 -1
- package/dist/OtpField.js +4 -4
- package/dist/OtpField.js.map +1 -1
- package/dist/PickerSelect.d.ts +4 -4
- package/dist/PickerSelect.d.ts.map +1 -1
- package/dist/PickerSelect.js +9 -9
- package/dist/PickerSelect.js.map +1 -1
- package/dist/ProvisionalConsentSigner.d.ts +3 -2
- package/dist/ProvisionalConsentSigner.d.ts.map +1 -1
- package/dist/ProvisionalConsentSigner.js +2 -2
- package/dist/ProvisionalConsentSigner.js.map +1 -1
- package/dist/SidebarNavigation.js +2 -2
- package/dist/SidebarNavigation.js.map +1 -1
- package/dist/SidebarNavigation.native.js +2 -2
- package/dist/SidebarNavigation.native.js.map +1 -1
- package/dist/Skeleton.js.map +1 -1
- package/dist/TapToEdit.d.ts +1 -1
- package/dist/TapToEdit.d.ts.map +1 -1
- package/dist/TapToEdit.js.map +1 -1
- package/dist/Text.d.ts.map +1 -1
- package/dist/Text.js +27 -50
- package/dist/Text.js.map +1 -1
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TextField.js +4 -4
- package/dist/TextField.js.map +1 -1
- package/dist/Theme.d.ts.map +1 -1
- package/dist/Theme.js +16 -0
- package/dist/Theme.js.map +1 -1
- package/dist/ThumbsUpDownFeedback.d.ts.map +1 -1
- package/dist/ThumbsUpDownFeedback.js.map +1 -1
- package/dist/ToastNotifications.d.ts.map +1 -1
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip.js.map +1 -1
- package/dist/Unifier.d.ts +1 -1
- package/dist/WebAddressAutocomplete.js.map +1 -1
- package/dist/WebDropdownMenu.d.ts +3 -3
- package/dist/WebDropdownMenu.d.ts.map +1 -1
- package/dist/WebDropdownMenu.js +1 -1
- package/dist/WebDropdownMenu.js.map +1 -1
- package/dist/announcementPlatform.d.ts +5 -0
- package/dist/announcementPlatform.d.ts.map +1 -1
- package/dist/announcementPlatform.js +9 -0
- package/dist/announcementPlatform.js.map +1 -1
- package/dist/asks/AskCard.d.ts +2 -2
- package/dist/asks/AskCard.d.ts.map +1 -1
- package/dist/dataTableColumnWidths.d.ts +76 -0
- package/dist/dataTableColumnWidths.d.ts.map +1 -0
- package/dist/dataTableColumnWidths.js +181 -0
- package/dist/dataTableColumnWidths.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/login/LoginScreen.js.map +1 -1
- package/dist/requestClient.d.ts +71 -0
- package/dist/requestClient.d.ts.map +1 -0
- package/dist/requestClient.js +139 -0
- package/dist/requestClient.js.map +1 -0
- package/dist/security/PasswordCard.d.ts.map +1 -1
- package/dist/security/PasswordCard.js.map +1 -1
- package/dist/security/TwoFactorSettingsCard.d.ts.map +1 -1
- package/dist/security/TwoFactorSettingsCard.js +1 -1
- package/dist/security/TwoFactorSettingsCard.js.map +1 -1
- package/dist/signUp/SignUpScreen.js.map +1 -1
- package/dist/table/Table.d.ts.map +1 -1
- package/dist/table/Table.js.map +1 -1
- package/dist/table/TableTitle.d.ts.map +1 -1
- package/dist/table/TableTitle.js +2 -1
- package/dist/table/TableTitle.js.map +1 -1
- package/dist/textFontSizes.d.ts +12 -0
- package/dist/textFontSizes.d.ts.map +1 -0
- package/dist/textFontSizes.js +21 -0
- package/dist/textFontSizes.js.map +1 -0
- package/dist/useAcknowledgeAnnouncement.d.ts +8 -63
- package/dist/useAcknowledgeAnnouncement.d.ts.map +1 -1
- package/dist/useAcknowledgeAnnouncement.js +31 -80
- package/dist/useAcknowledgeAnnouncement.js.map +1 -1
- package/dist/useAnnouncements.d.ts +14 -47
- package/dist/useAnnouncements.d.ts.map +1 -1
- package/dist/useAnnouncements.js +30 -57
- package/dist/useAnnouncements.js.map +1 -1
- package/dist/useConsentForms.d.ts +6 -38
- package/dist/useConsentForms.d.ts.map +1 -1
- package/dist/useConsentForms.js +25 -48
- package/dist/useConsentForms.js.map +1 -1
- package/dist/useProvisionalConsent.d.ts +7 -58
- package/dist/useProvisionalConsent.d.ts.map +1 -1
- package/dist/useProvisionalConsent.js +57 -67
- package/dist/useProvisionalConsent.js.map +1 -1
- package/dist/useSubmitConsent.d.ts +9 -39
- package/dist/useSubmitConsent.d.ts.map +1 -1
- package/dist/useSubmitConsent.js +10 -39
- package/dist/useSubmitConsent.js.map +1 -1
- package/package.json +40 -38
- package/src/ActionSheet.test.tsx +13 -13
- package/src/ActionSheet.tsx +18 -5
- package/src/AddressField.test.tsx +9 -3
- package/src/AnnouncementNavigator.test.tsx +219 -319
- package/src/AnnouncementNavigator.tsx +25 -20
- package/src/Avatar.tsx +2 -9
- package/src/Badge.test.tsx +1 -1
- package/src/Banner.test.tsx +0 -1
- package/src/Box.test.tsx +85 -77
- package/src/Box.tsx +4 -2
- package/src/Button.test.tsx +11 -6
- package/src/Card.test.tsx +2 -2
- package/src/Common.ts +79 -44
- package/src/ConflictSheet.test.tsx +5 -5
- package/src/ConsentFormScreen.test.tsx +3 -1
- package/src/ConsentFormScreen.tsx +2 -1
- package/src/ConsentNavigator.test.tsx +166 -243
- package/src/ConsentNavigator.tsx +9 -13
- package/src/CustomSelectField.test.tsx +16 -4
- package/src/CustomSelectField.tsx +3 -3
- package/src/DataTable.test.tsx +73 -5
- package/src/DataTable.tsx +72 -19
- package/src/DataTableVirtualizationRegression.test.tsx +1 -0
- package/src/DateTimeActionSheet.test.tsx +2 -0
- package/src/DateTimeField.test.tsx +3 -12
- package/src/DateTimeField.tsx +10 -10
- package/src/DismissButton.test.tsx +22 -4
- package/src/DropdownPanel.tsx +0 -6
- package/src/EmailField.test.tsx +13 -22
- package/src/EmojiSelector.test.tsx +2 -2
- package/src/ErrorBoundary.test.tsx +5 -3
- package/src/Field.test.tsx +20 -44
- package/src/FilterAccordion.tsx +3 -3
- package/src/FilterBoolean.tsx +3 -3
- package/src/FilterSelectMenu.tsx +1 -1
- package/src/GPTChat.test.tsx +24 -16
- package/src/GPTChat.tsx +10 -9
- package/src/Heading.test.tsx +1 -1
- package/src/Heading.tsx +7 -14
- package/src/HeightField.tsx +17 -10
- package/src/Hyperlink.tsx +6 -3
- package/src/Icon.test.tsx +2 -2
- package/src/Image.test.tsx +1 -1
- package/src/Link.test.tsx +13 -6
- package/src/MarkdownEditorField.tsx +10 -2
- package/src/MarkdownView.test.tsx +10 -6
- package/src/MobileAddressAutoComplete.test.tsx +2 -1
- package/src/Modal.test.tsx +10 -3
- package/src/ModalSheet.test.tsx +11 -10
- package/src/MultiselectField.test.tsx +17 -3
- package/src/NumberField.test.tsx +14 -14
- package/src/NumberPickerActionSheet.test.tsx +1 -1
- package/src/OfflineBanner.tsx +3 -2
- package/src/OpenAPIContext.test.tsx +4 -4
- package/src/OpenAPIRenderRegression.test.tsx +1 -1
- package/src/OtpField.tsx +6 -5
- package/src/P0RenderRegression.test.tsx +7 -1
- package/src/P1RenderRegression.test.tsx +1 -0
- package/src/P2ButtonRenderRegression.test.tsx +1 -0
- package/src/Page.test.tsx +1 -1
- package/src/PhoneNumberField.test.tsx +14 -38
- package/src/PickerSelect.tsx +12 -11
- package/src/Popover.test.tsx +2 -2
- package/src/ProvisionalConsentSigner.test.tsx +140 -113
- package/src/ProvisionalConsentSigner.tsx +5 -4
- package/src/RadioField.test.tsx +7 -2
- package/src/SegmentedControl.test.tsx +21 -12
- package/src/SidebarNavigation.native.tsx +2 -2
- package/src/SidebarNavigation.test.tsx +18 -6
- package/src/SidebarNavigation.tsx +2 -2
- package/src/Signature.test.tsx +20 -23
- package/src/Skeleton.tsx +1 -1
- package/src/Slider.test.tsx +1 -1
- package/src/SplitPage.test.tsx +15 -5
- package/src/TapToEdit.test.tsx +40 -17
- package/src/TapToEdit.tsx +1 -1
- package/src/TerrenoFontProvider.test.tsx +1 -1
- package/src/Text.test.tsx +4 -4
- package/src/Text.tsx +25 -51
- package/src/TextField.test.tsx +82 -9
- package/src/TextField.tsx +6 -5
- package/src/Theme.test.tsx +49 -0
- package/src/Theme.tsx +16 -0
- package/src/ThumbsUpDownFeedback.tsx +3 -3
- package/src/Toast.test.tsx +5 -5
- package/src/ToastNotifications.test.tsx +73 -70
- package/src/ToastNotifications.tsx +3 -2
- package/src/ToastNotifications.webModal.test.tsx +6 -3
- package/src/Tooltip.test.tsx +3 -3
- package/src/Tooltip.tsx +2 -1
- package/src/UnifiedAddressAutoComplete.test.tsx +1 -1
- package/src/UserInactivity.test.tsx +1 -0
- package/src/WebAddressAutocomplete.test.tsx +12 -12
- package/src/WebAddressAutocomplete.tsx +3 -3
- package/src/WebDropdownMenu.test.tsx +16 -15
- package/src/WebDropdownMenu.tsx +16 -5
- package/src/__snapshots__/Card.test.tsx.snap +1 -1
- package/src/__snapshots__/DataTable.test.tsx.snap +13 -0
- package/src/__snapshots__/DismissButton.test.tsx.snap +3 -3
- package/src/__snapshots__/Field.test.tsx.snap +4 -2
- package/src/__snapshots__/Heading.test.tsx.snap +1 -1
- package/src/__snapshots__/Image.test.tsx.snap +1 -1
- package/src/__snapshots__/Page.test.tsx.snap +2 -2
- package/src/__snapshots__/Text.test.tsx.snap +1 -1
- package/src/announcementPlatform.ts +10 -0
- package/src/asks/AskCard.test.tsx +20 -15
- package/src/asks/AskCard.tsx +2 -2
- package/src/asks/AskFiles.test.tsx +5 -1
- package/src/asks/askFileRefs.test.ts +1 -1
- package/src/asks/askSummary.test.ts +2 -2
- package/src/benchmarks/importTiming.ts +1 -1
- package/src/blocks/BlocksView.test.tsx +20 -11
- package/src/bunSetup.ts +43 -1
- package/src/dataTableColumnWidths.test.ts +266 -0
- package/src/dataTableColumnWidths.ts +272 -0
- package/src/dataTableFilters.test.tsx +1 -1
- package/src/index.tsx +9 -2
- package/src/isolated/ListDetailLayout.isolated.tsx +2 -4
- package/src/login/LoginScreen.test.tsx +6 -6
- package/src/login/LoginScreen.tsx +2 -2
- package/src/requestClient.test.ts +288 -0
- package/src/requestClient.ts +228 -0
- package/src/security/PasswordCard.test.tsx +3 -3
- package/src/security/PasswordCard.tsx +7 -5
- package/src/security/TwoFactorSettingsCard.tsx +10 -3
- package/src/signUp/SignUpScreen.test.tsx +4 -4
- package/src/signUp/SignUpScreen.tsx +2 -2
- package/src/table/Table.tsx +1 -2
- package/src/table/TableTitle.tsx +2 -1
- package/src/table/tableContext.test.tsx +5 -5
- package/src/test-utils.tsx +132 -1
- package/src/testing/reactDomServer.d.ts +7 -0
- package/src/textFontSizes.ts +31 -0
- package/src/useAcknowledgeAnnouncement.test.ts +101 -193
- package/src/useAcknowledgeAnnouncement.ts +69 -147
- package/src/useAnnouncements.test.ts +122 -186
- package/src/useAnnouncements.ts +49 -105
- package/src/useConsentForms.test.ts +59 -112
- package/src/useConsentForms.ts +37 -87
- package/src/useProvisionalConsent.test.ts +74 -150
- package/src/useProvisionalConsent.ts +79 -125
- package/src/useSubmitConsent.test.ts +59 -85
- package/src/useSubmitConsent.ts +22 -77
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {describe, expect, it, mock} from "bun:test";
|
|
2
|
-
import
|
|
2
|
+
import {act, fireEvent, waitFor} from "@testing-library/react-native";
|
|
3
|
+
import type React from "react";
|
|
3
4
|
import {Pressable} from "react-native";
|
|
4
5
|
import {Box} from "./Box";
|
|
5
6
|
import {ConsentNavigator} from "./ConsentNavigator";
|
|
6
7
|
import {Text} from "./Text";
|
|
7
|
-
import {renderWithTheme} from "./test-utils";
|
|
8
|
+
import {createFakeRequestClient, fakeHttpError, renderWithTheme} from "./test-utils";
|
|
8
9
|
import type {ConsentFormPublic} from "./useConsentForms";
|
|
9
10
|
|
|
10
11
|
const makeForm = (overrides: Partial<ConsentFormPublic> = {}): ConsentFormPublic => ({
|
|
@@ -27,50 +28,38 @@ const makeForm = (overrides: Partial<ConsentFormPublic> = {}): ConsentFormPublic
|
|
|
27
28
|
...overrides,
|
|
28
29
|
});
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
31
|
+
/** Fake client serving `forms` from GET /consents/pending; submissions remove the form. */
|
|
32
|
+
const createConsentClient = (
|
|
33
|
+
initialForms: ConsentFormPublic[],
|
|
34
|
+
{
|
|
35
|
+
pending,
|
|
36
|
+
respond,
|
|
37
|
+
}: {
|
|
38
|
+
pending?: () => unknown;
|
|
39
|
+
respond?: (body: Record<string, unknown>) => unknown;
|
|
40
|
+
} = {}
|
|
41
|
+
): ReturnType<typeof createFakeRequestClient> & {forms: () => ConsentFormPublic[]} => {
|
|
42
|
+
let forms = [...initialForms];
|
|
43
|
+
const fake = createFakeRequestClient({
|
|
44
|
+
"GET /consents/pending": () => (pending ? pending() : {data: forms}),
|
|
45
|
+
"POST /consents/respond": (args) => {
|
|
46
|
+
const body = (args.body ?? {}) as Record<string, unknown>;
|
|
47
|
+
if (respond) {
|
|
48
|
+
return respond(body);
|
|
49
|
+
}
|
|
50
|
+
forms = forms.filter((form) => form.id !== body.consentFormId);
|
|
51
|
+
return {agreed: body.agreed, id: "response-1"};
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
return {...fake, forms: () => forms};
|
|
53
55
|
};
|
|
54
56
|
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
isLoading: true,
|
|
62
|
-
refetch: mock(() => Promise.resolve()),
|
|
63
|
-
})),
|
|
64
|
-
useSubmitConsentResponseMutation: mock(() => [
|
|
65
|
-
mock(() => ({unwrap: mock(() => Promise.resolve({}))})),
|
|
66
|
-
{error: undefined, isLoading: false},
|
|
67
|
-
]),
|
|
68
|
-
})),
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
enhanceEndpoints: mock((_config: unknown) => innerApi),
|
|
73
|
-
};
|
|
57
|
+
const renderNavigator = async (
|
|
58
|
+
element: React.ReactElement
|
|
59
|
+
): Promise<ReturnType<typeof renderWithTheme>> => {
|
|
60
|
+
const result = renderWithTheme(element);
|
|
61
|
+
await waitFor(() => expect(result.queryByTestId("consent-navigator-loading")).toBeNull());
|
|
62
|
+
return result;
|
|
74
63
|
};
|
|
75
64
|
|
|
76
65
|
const ExtraScreen: React.FC<{onNext?: () => void}> = ({onNext}) => (
|
|
@@ -84,9 +73,9 @@ const ExtraScreen: React.FC<{onNext?: () => void}> = ({onNext}) => (
|
|
|
84
73
|
|
|
85
74
|
describe("ConsentNavigator", () => {
|
|
86
75
|
it("renders children when there are no pending consent forms", async () => {
|
|
87
|
-
const
|
|
88
|
-
const {getByText} =
|
|
89
|
-
<ConsentNavigator
|
|
76
|
+
const {client} = createConsentClient([]);
|
|
77
|
+
const {getByText} = await renderNavigator(
|
|
78
|
+
<ConsentNavigator client={client}>
|
|
90
79
|
<Text>App Content</Text>
|
|
91
80
|
</ConsentNavigator>
|
|
92
81
|
);
|
|
@@ -95,11 +84,10 @@ describe("ConsentNavigator", () => {
|
|
|
95
84
|
});
|
|
96
85
|
|
|
97
86
|
it("shows ConsentFormScreen when there are pending forms", async () => {
|
|
98
|
-
const
|
|
99
|
-
const api = createMockApi([form]);
|
|
87
|
+
const {client} = createConsentClient([makeForm()]);
|
|
100
88
|
|
|
101
|
-
const {getByTestId} =
|
|
102
|
-
<ConsentNavigator
|
|
89
|
+
const {getByTestId} = await renderNavigator(
|
|
90
|
+
<ConsentNavigator client={client}>
|
|
103
91
|
<Text>App Content</Text>
|
|
104
92
|
</ConsentNavigator>
|
|
105
93
|
);
|
|
@@ -108,11 +96,24 @@ describe("ConsentNavigator", () => {
|
|
|
108
96
|
expect(getByTestId("consent-form-agree-button")).toBeTruthy();
|
|
109
97
|
});
|
|
110
98
|
|
|
111
|
-
it("
|
|
112
|
-
const
|
|
99
|
+
it("requests pending consents under baseUrl", async () => {
|
|
100
|
+
const {client, calls} = createFakeRequestClient({
|
|
101
|
+
"GET /api/consents/pending": () => [],
|
|
102
|
+
});
|
|
103
|
+
const {getByText} = await renderNavigator(
|
|
104
|
+
<ConsentNavigator baseUrl="/api" client={client}>
|
|
105
|
+
<Text>App Content</Text>
|
|
106
|
+
</ConsentNavigator>
|
|
107
|
+
);
|
|
108
|
+
expect(getByText("App Content")).toBeTruthy();
|
|
109
|
+
expect(calls[0]?.url).toBe("/api/consents/pending");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("shows loading spinner while fetching consent forms", () => {
|
|
113
|
+
const {client} = createConsentClient([], {pending: () => new Promise(() => {})});
|
|
113
114
|
|
|
114
115
|
const {getByTestId} = renderWithTheme(
|
|
115
|
-
<ConsentNavigator
|
|
116
|
+
<ConsentNavigator client={client}>
|
|
116
117
|
<Text>App Content</Text>
|
|
117
118
|
</ConsentNavigator>
|
|
118
119
|
);
|
|
@@ -121,10 +122,10 @@ describe("ConsentNavigator", () => {
|
|
|
121
122
|
});
|
|
122
123
|
|
|
123
124
|
it("shows extra screens after consent forms are completed", async () => {
|
|
124
|
-
const
|
|
125
|
+
const {client} = createConsentClient([]);
|
|
125
126
|
|
|
126
|
-
const {getByTestId, queryByText} =
|
|
127
|
-
<ConsentNavigator
|
|
127
|
+
const {getByTestId, queryByText} = await renderNavigator(
|
|
128
|
+
<ConsentNavigator client={client} extraScreens={[<ExtraScreen key="extra" />]}>
|
|
128
129
|
<Text>App Content</Text>
|
|
129
130
|
</ConsentNavigator>
|
|
130
131
|
);
|
|
@@ -134,11 +135,10 @@ describe("ConsentNavigator", () => {
|
|
|
134
135
|
});
|
|
135
136
|
|
|
136
137
|
it("shows children after all extra screens are dismissed", async () => {
|
|
137
|
-
const
|
|
138
|
-
const {act, fireEvent, waitFor} = await import("@testing-library/react-native");
|
|
138
|
+
const {client} = createConsentClient([]);
|
|
139
139
|
|
|
140
|
-
const {getByTestId, getByText} =
|
|
141
|
-
<ConsentNavigator
|
|
140
|
+
const {getByTestId, getByText} = await renderNavigator(
|
|
141
|
+
<ConsentNavigator client={client} extraScreens={[<ExtraScreen key="extra" />]}>
|
|
142
142
|
<Text>App Content</Text>
|
|
143
143
|
</ConsentNavigator>
|
|
144
144
|
);
|
|
@@ -153,10 +153,10 @@ describe("ConsentNavigator", () => {
|
|
|
153
153
|
});
|
|
154
154
|
|
|
155
155
|
it("injects onNext prop into extra screen elements", async () => {
|
|
156
|
-
const
|
|
156
|
+
const {client} = createConsentClient([]);
|
|
157
157
|
|
|
158
|
-
const {getByTestId} =
|
|
159
|
-
<ConsentNavigator
|
|
158
|
+
const {getByTestId} = await renderNavigator(
|
|
159
|
+
<ConsentNavigator client={client} extraScreens={[<ExtraScreen key="extra" />]}>
|
|
160
160
|
<Text>App Content</Text>
|
|
161
161
|
</ConsentNavigator>
|
|
162
162
|
);
|
|
@@ -165,124 +165,96 @@ describe("ConsentNavigator", () => {
|
|
|
165
165
|
expect(getByTestId("extra-screen-next")).toBeTruthy();
|
|
166
166
|
});
|
|
167
167
|
|
|
168
|
-
it("renders children when error is auth (401)", () => {
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
useSubmitConsentResponseMutation: mock(() => [
|
|
179
|
-
mock(() => ({unwrap: mock(() => Promise.resolve({}))})),
|
|
180
|
-
{error: undefined, isLoading: false},
|
|
181
|
-
]),
|
|
182
|
-
})),
|
|
183
|
-
})),
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
const {getByText} = renderWithTheme(
|
|
187
|
-
<ConsentNavigator api={api}>
|
|
168
|
+
it("renders children when error is auth (401)", async () => {
|
|
169
|
+
const onError = mock(() => {});
|
|
170
|
+
const {client} = createConsentClient([], {
|
|
171
|
+
pending: () => {
|
|
172
|
+
throw fakeHttpError(401);
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const {getByText} = await renderNavigator(
|
|
177
|
+
<ConsentNavigator client={client} onError={onError}>
|
|
188
178
|
<Text>App Content</Text>
|
|
189
179
|
</ConsentNavigator>
|
|
190
180
|
);
|
|
191
|
-
expect(getByText("App Content")).toBeTruthy();
|
|
181
|
+
await waitFor(() => expect(getByText("App Content")).toBeTruthy());
|
|
182
|
+
expect(onError).not.toHaveBeenCalled();
|
|
192
183
|
});
|
|
193
184
|
|
|
194
|
-
it("renders children when error is auth (403)", () => {
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
})),
|
|
204
|
-
useSubmitConsentResponseMutation: mock(() => [
|
|
205
|
-
mock(() => ({unwrap: mock(() => Promise.resolve({}))})),
|
|
206
|
-
{error: undefined, isLoading: false},
|
|
207
|
-
]),
|
|
208
|
-
})),
|
|
209
|
-
})),
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
const {getByText} = renderWithTheme(
|
|
213
|
-
<ConsentNavigator api={api}>
|
|
185
|
+
it("renders children when error is auth (403 originalStatus)", async () => {
|
|
186
|
+
const {client} = createConsentClient([], {
|
|
187
|
+
pending: () => {
|
|
188
|
+
throw Object.assign(new Error("Forbidden"), {originalStatus: 403});
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const {getByText} = await renderNavigator(
|
|
193
|
+
<ConsentNavigator client={client}>
|
|
214
194
|
<Text>App Content</Text>
|
|
215
195
|
</ConsentNavigator>
|
|
216
196
|
);
|
|
217
|
-
expect(getByText("App Content")).toBeTruthy();
|
|
197
|
+
await waitFor(() => expect(getByText("App Content")).toBeTruthy());
|
|
218
198
|
});
|
|
219
199
|
|
|
220
|
-
it("renders error screen with retry button for non-auth errors", () => {
|
|
200
|
+
it("renders error screen with retry button for non-auth errors", async () => {
|
|
221
201
|
const onError = mock(() => {});
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
]),
|
|
235
|
-
})),
|
|
236
|
-
})),
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
const {getByTestId, getByText} = renderWithTheme(
|
|
240
|
-
<ConsentNavigator api={api} onError={onError}>
|
|
202
|
+
let shouldFail = true;
|
|
203
|
+
const {client, callsTo} = createConsentClient([], {
|
|
204
|
+
pending: () => {
|
|
205
|
+
if (shouldFail) {
|
|
206
|
+
throw fakeHttpError(500, "Server error");
|
|
207
|
+
}
|
|
208
|
+
return [];
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
const {getByTestId, getByText} = await renderNavigator(
|
|
213
|
+
<ConsentNavigator client={client} onError={onError}>
|
|
241
214
|
<Text>App Content</Text>
|
|
242
215
|
</ConsentNavigator>
|
|
243
216
|
);
|
|
244
|
-
expect(getByTestId("consent-navigator-error")).toBeTruthy();
|
|
217
|
+
await waitFor(() => expect(getByTestId("consent-navigator-error")).toBeTruthy());
|
|
245
218
|
expect(getByText("Failed to load consent forms")).toBeTruthy();
|
|
246
219
|
expect(onError).toHaveBeenCalled();
|
|
220
|
+
|
|
221
|
+
shouldFail = false;
|
|
222
|
+
await act(async () => {
|
|
223
|
+
fireEvent.press(getByText("Retry"));
|
|
224
|
+
});
|
|
225
|
+
await waitFor(() => expect(getByText("App Content")).toBeTruthy());
|
|
226
|
+
expect(callsTo("GET /consents/pending")).toHaveLength(2);
|
|
247
227
|
});
|
|
248
228
|
|
|
249
|
-
it("
|
|
250
|
-
const
|
|
229
|
+
it("submits and shows the app once the last form is agreed to", async () => {
|
|
230
|
+
const {client, callsTo} = createConsentClient([makeForm()]);
|
|
251
231
|
|
|
252
|
-
const {getByText} =
|
|
253
|
-
<ConsentNavigator
|
|
232
|
+
const {getByTestId, getByText} = await renderNavigator(
|
|
233
|
+
<ConsentNavigator client={client}>
|
|
254
234
|
<Text>App Content</Text>
|
|
255
235
|
</ConsentNavigator>
|
|
256
236
|
);
|
|
257
237
|
|
|
258
|
-
|
|
238
|
+
await act(async () => {
|
|
239
|
+
fireEvent.press(getByTestId("consent-form-agree-button"));
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
await waitFor(() => expect(getByText("App Content")).toBeTruthy());
|
|
243
|
+
const [submission] = callsTo("POST /consents/respond");
|
|
244
|
+
expect(submission?.body).toMatchObject({agreed: true, consentFormId: "form-1"});
|
|
245
|
+
// One initial load plus one refetch: the post-submit invalidation and the explicit
|
|
246
|
+
// refetch share a request.
|
|
247
|
+
expect(callsTo("GET /consents/pending")).toHaveLength(2);
|
|
259
248
|
});
|
|
260
249
|
|
|
261
|
-
it("
|
|
262
|
-
const {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const refetch = mock(() => Promise.resolve());
|
|
267
|
-
const api = {
|
|
268
|
-
enhanceEndpoints: mock(() => ({
|
|
269
|
-
injectEndpoints: mock(() => ({
|
|
270
|
-
useGetPendingConsentsQuery: mock(() => ({
|
|
271
|
-
data: {data: [form]},
|
|
272
|
-
error: undefined,
|
|
273
|
-
isLoading: false,
|
|
274
|
-
refetch,
|
|
275
|
-
})),
|
|
276
|
-
useSubmitConsentResponseMutation: mock(() => [
|
|
277
|
-
submitMutation,
|
|
278
|
-
{error: undefined, isLoading: false},
|
|
279
|
-
]),
|
|
280
|
-
})),
|
|
281
|
-
})),
|
|
282
|
-
};
|
|
250
|
+
it("advances to the next pending form after agreeing", async () => {
|
|
251
|
+
const {client} = createConsentClient([
|
|
252
|
+
makeForm(),
|
|
253
|
+
makeForm({id: "form-2", slug: "privacy", title: "Privacy Policy"}),
|
|
254
|
+
]);
|
|
283
255
|
|
|
284
|
-
const {getByTestId} =
|
|
285
|
-
<ConsentNavigator
|
|
256
|
+
const {getByTestId, findByText} = await renderNavigator(
|
|
257
|
+
<ConsentNavigator client={client}>
|
|
286
258
|
<Text>App Content</Text>
|
|
287
259
|
</ConsentNavigator>
|
|
288
260
|
);
|
|
@@ -291,35 +263,20 @@ describe("ConsentNavigator", () => {
|
|
|
291
263
|
fireEvent.press(getByTestId("consent-form-agree-button"));
|
|
292
264
|
});
|
|
293
265
|
|
|
294
|
-
expect(
|
|
266
|
+
expect(await findByText("Privacy Policy")).toBeTruthy();
|
|
295
267
|
});
|
|
296
268
|
|
|
297
269
|
it("invokes onError when consent submission fails on agree", async () => {
|
|
298
|
-
const {act, fireEvent} = await import("@testing-library/react-native");
|
|
299
|
-
const form = makeForm();
|
|
300
270
|
const onError = mock(() => {});
|
|
301
|
-
const
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
useGetPendingConsentsQuery: mock(() => ({
|
|
308
|
-
data: {data: [form]},
|
|
309
|
-
error: undefined,
|
|
310
|
-
isLoading: false,
|
|
311
|
-
refetch,
|
|
312
|
-
})),
|
|
313
|
-
useSubmitConsentResponseMutation: mock(() => [
|
|
314
|
-
submitMutation,
|
|
315
|
-
{error: undefined, isLoading: false},
|
|
316
|
-
]),
|
|
317
|
-
})),
|
|
318
|
-
})),
|
|
319
|
-
};
|
|
271
|
+
const submitError = fakeHttpError(500, "submit failed");
|
|
272
|
+
const {client, callsTo} = createConsentClient([makeForm()], {
|
|
273
|
+
respond: () => {
|
|
274
|
+
throw submitError;
|
|
275
|
+
},
|
|
276
|
+
});
|
|
320
277
|
|
|
321
|
-
const {getByTestId} =
|
|
322
|
-
<ConsentNavigator
|
|
278
|
+
const {getByTestId} = await renderNavigator(
|
|
279
|
+
<ConsentNavigator client={client} onError={onError}>
|
|
323
280
|
<Text>App Content</Text>
|
|
324
281
|
</ConsentNavigator>
|
|
325
282
|
);
|
|
@@ -328,76 +285,45 @@ describe("ConsentNavigator", () => {
|
|
|
328
285
|
fireEvent.press(getByTestId("consent-form-agree-button"));
|
|
329
286
|
});
|
|
330
287
|
|
|
331
|
-
await
|
|
332
|
-
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
expect(onError).toHaveBeenCalled();
|
|
288
|
+
await waitFor(() => expect(onError).toHaveBeenCalledWith(submitError));
|
|
289
|
+
expect(callsTo("GET /consents/pending")).toHaveLength(1);
|
|
336
290
|
});
|
|
337
291
|
|
|
338
292
|
it("calls submit with agreed=false when user declines an optional consent form", async () => {
|
|
339
|
-
const {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
const submitMutation = mock(() => ({unwrap}));
|
|
343
|
-
const refetch = mock(() => Promise.resolve());
|
|
344
|
-
const api = {
|
|
345
|
-
enhanceEndpoints: mock(() => ({
|
|
346
|
-
injectEndpoints: mock(() => ({
|
|
347
|
-
useGetPendingConsentsQuery: mock(() => ({
|
|
348
|
-
data: {data: [form]},
|
|
349
|
-
error: undefined,
|
|
350
|
-
isLoading: false,
|
|
351
|
-
refetch,
|
|
352
|
-
})),
|
|
353
|
-
useSubmitConsentResponseMutation: mock(() => [
|
|
354
|
-
submitMutation,
|
|
355
|
-
{error: undefined, isLoading: false},
|
|
356
|
-
]),
|
|
357
|
-
})),
|
|
358
|
-
})),
|
|
359
|
-
};
|
|
293
|
+
const {client, callsTo} = createConsentClient([
|
|
294
|
+
makeForm({allowDecline: true, required: false}),
|
|
295
|
+
]);
|
|
360
296
|
|
|
361
|
-
const {getByTestId} =
|
|
362
|
-
<ConsentNavigator
|
|
297
|
+
const {getByTestId, getByText} = await renderNavigator(
|
|
298
|
+
<ConsentNavigator client={client}>
|
|
363
299
|
<Text>App Content</Text>
|
|
364
300
|
</ConsentNavigator>
|
|
365
301
|
);
|
|
366
302
|
|
|
367
|
-
const declineBtn = getByTestId("consent-form-decline-button");
|
|
368
303
|
await act(async () => {
|
|
369
|
-
fireEvent.press(
|
|
304
|
+
fireEvent.press(getByTestId("consent-form-decline-button"));
|
|
305
|
+
});
|
|
306
|
+
await waitFor(() => expect(getByText("App Content")).toBeTruthy());
|
|
307
|
+
expect(callsTo("POST /consents/respond")[0]?.body).toMatchObject({
|
|
308
|
+
agreed: false,
|
|
309
|
+
consentFormId: "form-1",
|
|
370
310
|
});
|
|
371
|
-
expect(submitMutation).toHaveBeenCalled();
|
|
372
311
|
});
|
|
373
312
|
|
|
374
313
|
it("invokes onError when consent submission fails on decline", async () => {
|
|
375
|
-
const {act, fireEvent} = await import("@testing-library/react-native");
|
|
376
|
-
const form = makeForm({allowDecline: true, required: false});
|
|
377
314
|
const onError = mock(() => {});
|
|
378
|
-
const declineError =
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
error: undefined,
|
|
388
|
-
isLoading: false,
|
|
389
|
-
refetch,
|
|
390
|
-
})),
|
|
391
|
-
useSubmitConsentResponseMutation: mock(() => [
|
|
392
|
-
submitMutation,
|
|
393
|
-
{error: undefined, isLoading: false},
|
|
394
|
-
]),
|
|
395
|
-
})),
|
|
396
|
-
})),
|
|
397
|
-
};
|
|
315
|
+
const declineError = fakeHttpError(500, "decline failed");
|
|
316
|
+
const {client, callsTo} = createConsentClient(
|
|
317
|
+
[makeForm({allowDecline: true, required: false})],
|
|
318
|
+
{
|
|
319
|
+
respond: () => {
|
|
320
|
+
throw declineError;
|
|
321
|
+
},
|
|
322
|
+
}
|
|
323
|
+
);
|
|
398
324
|
|
|
399
|
-
const {getByTestId} =
|
|
400
|
-
<ConsentNavigator
|
|
325
|
+
const {getByTestId} = await renderNavigator(
|
|
326
|
+
<ConsentNavigator client={client} onError={onError}>
|
|
401
327
|
<Text>App Content</Text>
|
|
402
328
|
</ConsentNavigator>
|
|
403
329
|
);
|
|
@@ -405,19 +331,16 @@ describe("ConsentNavigator", () => {
|
|
|
405
331
|
await act(async () => {
|
|
406
332
|
fireEvent.press(getByTestId("consent-form-decline-button"));
|
|
407
333
|
});
|
|
408
|
-
await act(async () => {
|
|
409
|
-
await new Promise((r) => setTimeout(r, 0));
|
|
410
|
-
});
|
|
411
334
|
|
|
412
|
-
expect(onError).toHaveBeenCalledWith(declineError);
|
|
413
|
-
expect(
|
|
335
|
+
await waitFor(() => expect(onError).toHaveBeenCalledWith(declineError));
|
|
336
|
+
expect(callsTo("GET /consents/pending")).toHaveLength(1);
|
|
414
337
|
});
|
|
415
338
|
|
|
416
339
|
it("renders non-element extra screens as-is without injecting onNext", async () => {
|
|
417
|
-
const
|
|
340
|
+
const {client} = createConsentClient([]);
|
|
418
341
|
|
|
419
|
-
const {queryByText, toJSON} =
|
|
420
|
-
<ConsentNavigator
|
|
342
|
+
const {queryByText, toJSON} = await renderNavigator(
|
|
343
|
+
<ConsentNavigator client={client} extraScreens={[null]}>
|
|
421
344
|
<Text>App Content</Text>
|
|
422
345
|
</ConsentNavigator>
|
|
423
346
|
);
|
package/src/ConsentNavigator.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import React, {useState} from "react";
|
|
|
3
3
|
import {Box} from "./Box";
|
|
4
4
|
import {Button} from "./Button";
|
|
5
5
|
import {ConsentFormScreen} from "./ConsentFormScreen";
|
|
6
|
+
import type {TerrenoRequestClient} from "./requestClient";
|
|
6
7
|
import {Spinner} from "./Spinner";
|
|
7
8
|
import {Text} from "./Text";
|
|
8
9
|
import {detectLocale, useConsentForms} from "./useConsentForms";
|
|
@@ -11,10 +12,11 @@ import {useSubmitConsent} from "./useSubmitConsent";
|
|
|
11
12
|
|
|
12
13
|
interface ConsentNavigatorProps {
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
15
|
+
* Request client for the consent routes, usually the app's `@terreno/syncdb/api` client
|
|
16
|
+
* (`createApiClient(...)`). Any object with a matching `request` method works.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
client: TerrenoRequestClient;
|
|
19
|
+
/** Path prefixed to the consent routes (for example `/api`); defaults to none. */
|
|
18
20
|
baseUrl?: string;
|
|
19
21
|
children: React.ReactNode;
|
|
20
22
|
extraScreens?: React.ReactNode[];
|
|
@@ -23,7 +25,7 @@ interface ConsentNavigatorProps {
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export const ConsentNavigator: React.FC<ConsentNavigatorProps> = ({
|
|
26
|
-
|
|
28
|
+
client,
|
|
27
29
|
baseUrl,
|
|
28
30
|
children,
|
|
29
31
|
extraScreens,
|
|
@@ -32,14 +34,8 @@ export const ConsentNavigator: React.FC<ConsentNavigatorProps> = ({
|
|
|
32
34
|
}) => {
|
|
33
35
|
const [currentIndex, setCurrentIndex] = useState(0);
|
|
34
36
|
const [extraScreenIndex, setExtraScreenIndex] = useState(0);
|
|
35
|
-
const {forms, isLoading, error, refetch} = useConsentForms(
|
|
36
|
-
|
|
37
|
-
baseUrl
|
|
38
|
-
);
|
|
39
|
-
const {submit, isSubmitting} = useSubmitConsent(
|
|
40
|
-
api as Parameters<typeof useSubmitConsent>[0],
|
|
41
|
-
baseUrl
|
|
42
|
-
);
|
|
37
|
+
const {forms, isLoading, error, refetch} = useConsentForms(client, baseUrl);
|
|
38
|
+
const {submit, isSubmitting} = useSubmitConsent(client, baseUrl);
|
|
43
39
|
const locale = detectLocale();
|
|
44
40
|
const validExtraScreens = extraScreens ?? [];
|
|
45
41
|
|
|
@@ -122,7 +118,7 @@ export const ConsentNavigator: React.FC<ConsentNavigatorProps> = ({
|
|
|
122
118
|
try {
|
|
123
119
|
await submit(body);
|
|
124
120
|
// Always refetch and reset so we pick up the updated pending list.
|
|
125
|
-
// Advancing currentIndex is racy because
|
|
121
|
+
// Advancing currentIndex is racy because the submit invalidation shrinks
|
|
126
122
|
// the forms array in the background.
|
|
127
123
|
setCurrentIndex(0);
|
|
128
124
|
await refetch();
|
|
@@ -13,14 +13,19 @@ describe("CustomSelectField", () => {
|
|
|
13
13
|
|
|
14
14
|
it("renders correctly with default props", () => {
|
|
15
15
|
const {toJSON} = renderWithTheme(
|
|
16
|
-
<CustomSelectField onChange={() => {}} options={defaultOptions} />
|
|
16
|
+
<CustomSelectField onChange={() => {}} options={defaultOptions} value="" />
|
|
17
17
|
);
|
|
18
18
|
expect(toJSON()).toMatchSnapshot();
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
it("renders with title", () => {
|
|
22
22
|
const {getByText, toJSON} = renderWithTheme(
|
|
23
|
-
<CustomSelectField
|
|
23
|
+
<CustomSelectField
|
|
24
|
+
onChange={() => {}}
|
|
25
|
+
options={defaultOptions}
|
|
26
|
+
title="Select Option"
|
|
27
|
+
value=""
|
|
28
|
+
/>
|
|
24
29
|
);
|
|
25
30
|
expect(getByText("Select Option")).toBeTruthy();
|
|
26
31
|
expect(toJSON()).toMatchSnapshot();
|
|
@@ -28,7 +33,12 @@ describe("CustomSelectField", () => {
|
|
|
28
33
|
|
|
29
34
|
it("renders with placeholder", () => {
|
|
30
35
|
const {toJSON} = renderWithTheme(
|
|
31
|
-
<CustomSelectField
|
|
36
|
+
<CustomSelectField
|
|
37
|
+
onChange={() => {}}
|
|
38
|
+
options={defaultOptions}
|
|
39
|
+
placeholder="Choose one..."
|
|
40
|
+
value=""
|
|
41
|
+
/>
|
|
32
42
|
);
|
|
33
43
|
expect(toJSON()).toMatchSnapshot();
|
|
34
44
|
});
|
|
@@ -53,6 +63,7 @@ describe("CustomSelectField", () => {
|
|
|
53
63
|
errorText="Please select an option"
|
|
54
64
|
onChange={() => {}}
|
|
55
65
|
options={defaultOptions}
|
|
66
|
+
value=""
|
|
56
67
|
/>
|
|
57
68
|
);
|
|
58
69
|
expect(getByText("Please select an option")).toBeTruthy();
|
|
@@ -64,6 +75,7 @@ describe("CustomSelectField", () => {
|
|
|
64
75
|
helperText="Select or enter a custom value"
|
|
65
76
|
onChange={() => {}}
|
|
66
77
|
options={defaultOptions}
|
|
78
|
+
value=""
|
|
67
79
|
/>
|
|
68
80
|
);
|
|
69
81
|
expect(getByText("Select or enter a custom value")).toBeTruthy();
|
|
@@ -79,7 +91,7 @@ describe("CustomSelectField", () => {
|
|
|
79
91
|
it("includes custom option in dropdown", () => {
|
|
80
92
|
// The component automatically adds a "Custom" option to the options list
|
|
81
93
|
const {toJSON} = renderWithTheme(
|
|
82
|
-
<CustomSelectField onChange={() => {}} options={defaultOptions} />
|
|
94
|
+
<CustomSelectField onChange={() => {}} options={defaultOptions} value="" />
|
|
83
95
|
);
|
|
84
96
|
expect(toJSON()).toMatchSnapshot();
|
|
85
97
|
});
|